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

:root {
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --primary-dark: #1d4ed8;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);

    --not-yet-color: #94a3b8;
    --not-yet-bg: #f1f5f9;
    --not-yet-border: #cbd5e1;
    --not-yet-text: #475569;

    --developing-color: #f59e0b;
    --developing-bg: #fffbeb;
    --developing-border: #fcd34d;
    --developing-text: #92400e;

    --got-it-color: #3b82f6;
    --got-it-bg: #eff6ff;
    --got-it-border: #93c5fd;
    --got-it-text: #1d4ed8;

    --strong-color: #10b981;
    --strong-bg: #ecfdf5;
    --strong-border: #6ee7b7;
    --strong-text: #065f46;
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-light: #1e3a5f;
    --primary-dark: #60a5fa;
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #cbd5e1;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);

    --not-yet-bg: #1e293b;
    --not-yet-border: #475569;
    --not-yet-text: #94a3b8;

    --developing-bg: #451a03;
    --developing-border: #b45309;
    --developing-text: #fcd34d;

    --got-it-bg: #172554;
    --got-it-border: #2563eb;
    --got-it-text: #93c5fd;

    --strong-bg: #064e3b;
    --strong-border: #10b981;
    --strong-text: #6ee7b7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

/* ── Header ─────────────────────────────────────────── */
#header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 16px;
    box-shadow: var(--shadow);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon { font-size: 1.4rem; }

#header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-right label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

/* ── Layout ──────────────────────────────────────────── */
#content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────── */
#sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

#sidebar.hidden { display: none !important; }

.sidebar-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.sidebar-section { }

.select-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.select-group select { flex: 1; min-width: 0; }

/* ── Main Content ────────────────────────────────────── */
#main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ── Welcome ─────────────────────────────────────────── */
.welcome-message {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
}

.welcome-icon { font-size: 3rem; margin-bottom: 16px; }
.welcome-message h2 { font-size: 1.4rem; margin-bottom: 10px; color: var(--text); }
.welcome-message p { line-height: 1.7; font-size: 0.95rem; }

/* ── Progress Summary (sidebar) ──────────────────────── */
.progress-summary {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 4px;
}

.progress-summary.hidden { display: none !important; }

.summary-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.pill {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 600;
}

.pill-not-yet    { background: var(--not-yet-bg);    color: var(--not-yet-text);    border: 1px solid var(--not-yet-border); }
.pill-developing { background: var(--developing-bg); color: var(--developing-text); border: 1px solid var(--developing-border); }
.pill-got-it     { background: var(--got-it-bg);     color: var(--got-it-text);     border: 1px solid var(--got-it-border); }
.pill-strong     { background: var(--strong-bg);     color: var(--strong-text);     border: 1px solid var(--strong-border); }

.progress-bar-wrap {
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--got-it-color), var(--strong-color));
    border-radius: 999px;
    transition: width 0.4s ease;
    min-width: 0;
}

.summary-pct {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
}

/* ── Subject Header ──────────────────────────────────── */
.subject-header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--border);
}

.subject-header h2 { font-size: 1.4rem; font-weight: 700; }
.subject-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.subject-desc { color: var(--text-muted); margin-top: 4px; font-size: 0.88rem; line-height: 1.5; }

/* ── Section Card ────────────────────────────────────── */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.section-header:hover { background: var(--bg); }

.section-toggle {
    font-size: 0.65rem;
    color: var(--text-muted);
    width: 12px;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.section-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

.section-badge {
    font-size: 0.72rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    flex-shrink: 0;
}

.section-body.collapsed { display: none; }

/* ── Task Row ────────────────────────────────────────── */
.task-row {
    border-bottom: 1px solid #f1f5f9;
}

.task-row:last-of-type { border-bottom: none; }

.task-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 14px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.status-dot.s-not_yet    { background: var(--not-yet-color); }
.status-dot.s-developing { background: var(--developing-color); }
.status-dot.s-got_it     { background: var(--got-it-color); }
.status-dot.s-strong     { background: var(--strong-color); }

.task-text {
    flex: 1;
    font-size: 0.855rem;
    line-height: 1.55;
    color: var(--text);
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: 6px;
}

/* ── Status Select ───────────────────────────────────── */
.status-sel {
    font-size: 0.73rem;
    padding: 3px 5px;
    border-radius: 5px;
    border: 1px solid;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
    appearance: none;
    -webkit-appearance: none;
    min-width: 84px;
    text-align: center;
}

.status-sel:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.status-sel.s-not_yet    { background: var(--not-yet-bg);    color: var(--not-yet-text);    border-color: var(--not-yet-border); }
.status-sel.s-developing { background: var(--developing-bg); color: var(--developing-text); border-color: var(--developing-border); }
.status-sel.s-got_it     { background: var(--got-it-bg);     color: var(--got-it-text);     border-color: var(--got-it-border); }
.status-sel.s-strong     { background: var(--strong-bg);     color: var(--strong-text);     border-color: var(--strong-border); }

/* ── Notes Toggle Button ─────────────────────────────── */
.notes-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 3px 7px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: all 0.15s;
    line-height: 1;
}

.notes-btn:hover { background: var(--bg); border-color: var(--text-muted); }
.notes-btn.has-notes { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── Notes Row ───────────────────────────────────────── */
.notes-row {
    display: none;
    padding: 0 14px 10px 33px;
    background: var(--bg);
    border-top: 1px dashed var(--border);
}

.notes-row.open { display: block; }

.notes-input {
    width: 100%;
    min-height: 66px;
    padding: 7px 9px;
    font-size: 0.83rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    margin-top: 8px;
    transition: border-color 0.15s;
}

.notes-input:focus { outline: none; border-color: var(--primary); }

.notes-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    min-height: 16px;
}

.save-ok { color: var(--strong-text); font-weight: 500; }

/* ── Add bars ────────────────────────────────────────── */
.add-task-bar {
    padding: 6px 14px 8px;
    border-top: 1px dashed var(--border);
    background: var(--bg);
}

.add-section-bar {
    padding: 14px 0;
    text-align: center;
}

.empty-tasks {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 10px 14px;
    font-style: italic;
}

.empty-tasks a { color: var(--primary); text-decoration: none; }
.empty-tasks a:hover { text-decoration: underline; }

/* ── Heading dividers within sections ───────────────── */
.heading-divider {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 12px 14px 6px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.heading-divider:first-child {
    border-top: none;
    margin-top: 0;
}

/* ── Manage list in modal ────────────────────────────── */
.manage-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.manage-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.88rem;
}
.manage-list .del-btn {
    background: none;
    border: 1px solid #fca5a5;
    color: #ef4444;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
}
.manage-list .del-btn:hover { background: #fee2e2; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    padding: 7px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}

.btn-primary  { background: var(--primary); color: white; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { background: var(--bg); color: var(--text); border-color: #94a3b8; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 5px 8px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-del { background: transparent; border: 1px solid #fca5a5; color: #ef4444; padding: 5px 7px; }
.btn-del:hover { background: #fee2e2; border-color: #ef4444; }
.btn-sm  { padding: 5px 10px; font-size: 0.78rem; }
.btn-xs  { padding: 3px 8px;  font-size: 0.73rem; }

/* ── Selects ─────────────────────────────────────────── */
select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.83rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
select:focus { outline: none; border-color: var(--primary); }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { display: block; font-size: 0.83rem; font-weight: 600; margin-bottom: 5px; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 5px; line-height: 1.4; }

.form-control {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
    line-height: 1.4;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
[data-theme="dark"] .form-control:focus { box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.form-control.error { border-color: #ef4444; }
textarea.form-control { resize: vertical; }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none !important; }

.modal {
    background: var(--surface);
    border-radius: 12px;
    width: 92%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
    animation: modalIn 0.18s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(.96) translateY(-6px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Misc ────────────────────────────────────────────── */
.hidden { display: none !important; }
.loading { text-align: center; color: var(--text-muted); padding: 40px; font-size: 0.9rem; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px; font-size: 0.9rem; }
.empty-state a { color: var(--primary); text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }
.error-msg { color: #dc2626; font-size: 0.83rem; margin-top: 4px; }

/* Task list scrolling */
#task-list {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-right: 8px;
}

#task-list::-webkit-scrollbar {
    width: 8px;
}

#task-list::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

#task-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

#task-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Section blocks in Add Subject modal */
.section-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}
.section-header-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.section-header-row .sec-name {
    flex: 1;
    font-weight: 500;
}
.headings-container {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}
.heading-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
}
.heading-block .hdg-name {
    margin-bottom: 6px;
    font-size: 0.95em;
}
.heading-block .hdg-tasks {
    margin-bottom: 6px;
    min-height: 60px;
}
