:root {
    --bg-main: #1e1e1e;
    --bg-panel: #252526;
    --bg-activity: #2c2c2c;
    --border: #2d2d2d;
    --text: #cccccc;
    --text-strong: #ffffff;
    --text-muted: #999999;
    --accent: #4fc1ff;
    --accent-blue: #007acc;
}

body[data-theme="light"] {
    --bg-main: #ffffff;
    --bg-panel: #f3f3f3;
    --bg-activity: #e0e0e0;
    --border: #ccc;
    --text: #222222;
    --text-strong: #000000;
    --text-muted: #555555;
    --accent: #007acc;
    --accent-blue: #1182d3;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.monaco-editor *,
.monaco-editor-overflowing-widgets *,
.monaco-editor-overflowing-widgets {
    box-sizing: revert;
    margin: revert;
    padding: revert;
    color: revert;
    font-size: revert;
    line-height: revert;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.activity-bar {
    width: 52px;
    background: var(--bg-activity);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
}

.activity-icon {
    width: 100%;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.activity-icon i {
    font-size: 24px;
    color: var(--text-muted);
    transition: color 0.2s;
}

.activity-icon:hover i {
    color: var(--text-strong);
}

.activity-icon.active i {
    color: var(--accent-blue);
}

.activity-icon.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    background: var(--accent-blue);
}

.sidebar {
    display: flex;
    height: 100%;
    transition: width 0.15s ease;
}

.sidebar-panel {
    transition: opacity 0.1s;
}

.sidebar-panel {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-actions {
    display: flex;
    gap: 8px;
    padding: 8px 14px;
}

.sidebar-actions button {
    background: var(--bg-activity);
    color: var(--text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    padding: 6px 12px;
    font-size: 14px;
}

.sidebar-actions button:hover {
    background: var(--border);
}

#addTaskBtn {
    padding: 8px 16px;
    font-size: 15px;
    color: var(--text-strong);
}

.sidebar-content {
    flex: 1;
    padding: 10px 14px;
    overflow-y: auto;
}

.file-tree,
.task-list {
    list-style: none;
}

.file {
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
}

.file:hover {
    background: rgba(255,255,255,0.08);
}

.file.active {
    background: rgba(255,255,255,0.12);
}

.file.folder-entry {
    color: var(--text);
    cursor: pointer;
    gap: 6px;
}

.file.folder-entry i {
    font-size: 15px;
    color: var(--accent);
    flex-shrink: 0;
}

.file-tree-nested {
    padding-left: 16px;
    border-left: 1px solid var(--border);
    margin-left: 10px;
    list-style: none;
}

.file.dragging {
    opacity: 0.4;
}

.file.drag-over {
    background: rgba(79, 193, 255, 0.15);
    outline: 1px dashed var(--accent);
}

.file-tree.drag-over-root {
    outline: 1px dashed var(--accent);
    outline-offset: -2px;
    background: rgba(79, 193, 255, 0.05);
    border-radius: 4px;
}

.context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    font-size: 13px;
}

.context-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
}

.context-item i {
    font-size: 15px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.context-item:hover {
    background: rgba(255,255,255,0.08);
}

.context-item:hover i {
    color: var(--text);
}

.context-item.danger {
    color: #f87171;
}

.context-item.danger i {
    color: #f87171;
}

.context-item.danger:hover {
    background: rgba(248,113,113,0.1);
}

.context-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: default;
    position: relative;
}

.task-item:hover {
    background: rgba(255,255,255,0.08);
}

.task-item:hover .task-actions {
    opacity: 1;
}

.task-item:hover .task-preview {
    display: flex;
}

.task-done .task-title {
    text-decoration: line-through;
    opacity: 0.5;
}

.task-color {
    width: 6px;
    border-radius: 2px;
    align-self: stretch;
    flex-shrink: 0;
    margin-top: 2px;
    min-height: 20px;
}

.task-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.task-title {
    font-size: 14px;
    color: var(--text-strong);
    font-weight: 500;
}

.task-preview {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

.task-desc {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-word;
}

.task-date {
    font-size: 11px;
    color: var(--accent);
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    margin-top: 1px;
}

.task-btn {
    background: none;
    border: none;
    padding: 3px 4px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-btn i {
    font-size: 14px;
    color: var(--text-muted);
    transition: color 0.15s;
}

.task-btn:hover {
    background: rgba(255,255,255,0.1);
}

.task-btn-done:hover i {
    color: #22c55e;
}

.task-btn-edit:hover i {
    color: var(--accent);
}

.task-btn-delete:hover i {
    color: #f87171;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-bar {
    display: flex;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
    height: 36px;
}

.tab-bar::-webkit-scrollbar {
    height: 3px;
}

.tab-bar::-webkit-scrollbar-thumb {
    background: var(--border);
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    height: 36px;
    border-right: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-panel);
    flex-shrink: 0;
}

.tab:hover {
    background: var(--bg-main);
    color: var(--text);
}

.tab.active {
    background: var(--bg-main);
    color: var(--text-strong);
    border-top: 1px solid var(--accent-blue);
}

.tab-label {
    flex: 1;
}

.tab-close {
    display: flex;
    align-items: center;
    border-radius: 3px;
    padding: 1px 2px;
}

.tab-close:hover {
    background: rgba(255,255,255,0.15);
}

.tab-close i {
    font-size: 14px;
}

#editor-container {
    flex: 1;
    width: 100%;
    display: none;
}

.editor-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    user-select: none;
}

.home-container {
    padding: 80px;
    max-width: 520px;
}

.home-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-strong);
}

.home-section {
    margin-bottom: 32px;
}

.home-section h2 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--accent);
    text-transform: uppercase;
}

.home-links {
    list-style: none;
}

.home-links li {
    padding: 6px 0;
    color: var(--accent);
    font-size: 15px;
    cursor: pointer;
}

.home-links li:hover {
    text-decoration: underline;
}

.muted {
    color: var(--text-muted);
    cursor: default;
}

.task-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.task-modal-content {
    background: var(--bg-panel);
    width: 420px;
    border-radius: 8px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.task-modal-content h3 {
    font-size: 18px;
    color: var(--text-strong);
}

.task-modal label {
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-modal input,
.task-modal textarea,
.task-modal select {
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.task-modal textarea {
    resize: none;
}

.task-modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

.task-modal-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background: var(--bg-activity);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}


#ac {
    display: none;
    position: fixed;
    z-index: 99999;
    background: #252526;
    border: 1px solid #454545;
    border-radius: 3px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    width: 480px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #424242 #252526;
}
#ac::-webkit-scrollbar { width: 8px; }
#ac::-webkit-scrollbar-thumb { background: #424242; border-radius: 4px; }
#ac::-webkit-scrollbar-track { background: #252526; }

.ac-row {
    display: flex;
    align-items: center;
    height: 22px;
    cursor: pointer;
    overflow: hidden;
}
.ac-row:hover { background: #2a2d2e; }
.ac-row.active { background: #04395e; }

.ac-icon {
    width: 26px;
    min-width: 26px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ac-label {
    min-width: 100px;
    width: 130px;
    flex-shrink: 0;
    color: #cccccc;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-row.active .ac-label { color: #ffffff; }

.ac-detail {
    flex: 1;
    color: #9e9e9e;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
    font-style: italic;
}
.ac-row.active .ac-detail { color: #cccccc; }

.ac-type {
    min-width: 64px;
    text-align: right;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 11px;
    color: #606060;
    white-space: nowrap;
    padding-right: 10px;
    flex-shrink: 0;
}
.ac-row.active .ac-type { color: #9e9e9e; }

body[data-theme="light"] #ac { background: #f8f8f8; border-color: #c8c8c8; box-shadow: 0 4px 16px rgba(0,0,0,0.15); scrollbar-color: #c0c0c0 #f3f3f3; }
body[data-theme="light"] #ac::-webkit-scrollbar-thumb { background: #c0c0c0; }
body[data-theme="light"] #ac::-webkit-scrollbar-track { background: #f3f3f3; }
body[data-theme="light"] .ac-row:hover { background: #e8e8e8; }
body[data-theme="light"] .ac-row.active { background: #0066bf; }
body[data-theme="light"] .ac-label { color: #1f1f1f; }
body[data-theme="light"] .ac-row.active .ac-label { color: #ffffff; }
body[data-theme="light"] .ac-detail { color: #666666; }
body[data-theme="light"] .ac-row.active .ac-detail { color: #dddddd; }
body[data-theme="light"] .ac-type { color: #999999; }
body[data-theme="light"] .ac-row.active .ac-type { color: #dddddd; }

/* ── preview ─────────────────────────────────────────────────────────────── */

.editor-preview-split {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

.editor-pane {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.editor-pane #editor-container {
    width: 100%;
    height: 100%;
}

.preview-resizer {
    width: 5px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
}

.preview-resizer::after {
    content: '';
    position: absolute;
    inset: 0 -3px;
}

.preview-resizer:hover { background: var(--accent); }
.preview-resizer.dragging { background: var(--accent); }

.preview-pane {
    display: flex;
    flex-direction: column;
    width: 42%;
    min-width: 220px;
    max-width: 80%;
    background: var(--bg-main);
    overflow: hidden;
}

.preview-topbar {
    height: 36px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 6px 0 12px;
    flex-shrink: 0;
    gap: 4px;
}

.preview-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.preview-title i {
    font-size: 14px;
    color: var(--accent);
}

.preview-topbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.preview-topbar-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.preview-topbar-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-strong);
}
body[data-theme="light"] .preview-topbar-btn:hover {
    background: rgba(0,0,0,0.06);
}

#preview-frame {
    flex: 1;
    border: none;
    background: #fff;
    width: 100%;
}

.preview-placeholder {
    flex: 1;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    gap: 10px;
    background: var(--bg-main);
}

.preview-placeholder i {
    font-size: 36px;
    opacity: 0.25;
}

.preview-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0 10px;
    height: 100%;
    font-size: 13px;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border-radius: 0;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.preview-toggle-btn i { font-size: 15px; }
.preview-toggle-label { font-size: 12px; font-weight: 500; }
.preview-toggle-btn:hover {
    color: var(--text-strong);
    background: rgba(255,255,255,0.05);
}
body[data-theme="light"] .preview-toggle-btn:hover {
    background: rgba(0,0,0,0.04);
}
.preview-toggle-btn.active { color: var(--accent); }

/* ── viewport presets ───────────────────────────────────────────────────── */

.preview-viewport-btns {
    display: flex;
    align-items: center;
    gap: 1px;
    margin: 0 6px;
}

.preview-vp-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.preview-vp-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-strong); }
.preview-vp-btn.active { color: var(--accent); }
body[data-theme="light"] .preview-vp-btn:hover { background: rgba(0,0,0,0.06); }

.preview-frame-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #c8c8c8;
    overflow: auto;
    position: relative;
    transition: background 0.2s;
}

.preview-frame-wrap.vp-full {
    background: transparent;
}

.preview-frame-wrap.vp-full #preview-frame {
    width: 100%;
    height: 100%;
    box-shadow: none;
    border-radius: 0;
}

#preview-frame {
    border: none;
    background: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 16px rgba(0,0,0,0.3);
    border-radius: 4px;
}

/* ── console ─────────────────────────────────────────────────────────────── */

.preview-console {
    height: 160px;
    min-height: 80px;
    background: #0d0d0d;
    border-top: 1px solid #2d2d2d;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
}

body[data-theme="light"] .preview-console {
    background: #1e1e1e;
    border-top-color: #ccc;
}

.preview-console-toolbar {
    height: 28px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    background: #161616;
    border-bottom: 1px solid #2a2a2a;
    flex-shrink: 0;
    gap: 6px;
}

body[data-theme="light"] .preview-console-toolbar {
    background: #252526;
    border-bottom-color: #3a3a3a;
}

.preview-console-title {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex: 1;
}

.preview-console-output {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}
.preview-console-output::-webkit-scrollbar { width: 6px; }
.preview-console-output::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.console-line {
    padding: 2px 10px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    display: flex;
    gap: 8px;
    align-items: baseline;
    border-bottom: 1px solid transparent;
}
.console-line:hover { background: rgba(255,255,255,0.04); }

.console-line.log   { color: #cccccc; }
.console-line.info  { color: #4fc1ff; background: rgba(79,193,255,0.05); }
.console-line.warn  { color: #e5c07b; background: rgba(229,192,123,0.07); border-bottom-color: rgba(229,192,123,0.1); }
.console-line.error { color: #f87171; background: rgba(248,113,113,0.07); border-bottom-color: rgba(248,113,113,0.15); }

.console-line-icon {
    flex-shrink: 0;
    font-size: 12px;
    opacity: 0.7;
}
.console-line-text { flex: 1; }

.console-empty {
    padding: 16px 10px;
    color: #444;
    font-style: italic;
}
