:root {
    --bg: #f5f7f2;
    --bg-2: #eef3ef;
    --card: #ffffff;
    --card-soft: #f9faf8;
    --text: #1f2933;
    --muted: #667085;
    --line: #d8e0df;
    --line-strong: #9fb2b1;
    --accent: #0f766e;
    --accent-soft: #e4f4f1;
    --red: #d9534f;
    --red-soft: #fff1f1;
    --blue: #2563eb;
    --blue-soft: #eef4ff;
    --green: #16a34a;
    --green-soft: #eefaf2;
    --shadow: 0 16px 42px rgba(31, 41, 51, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% -10%, rgba(15, 118, 110, .10), transparent 34%),
        radial-gradient(circle at 100% 0%, rgba(37, 99, 235, .07), transparent 30%),
        var(--bg);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.app-shell { width: min(100% - 32px, 1480px); margin: 0 auto; padding: 22px 0 42px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 900; color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 5vw, 42px); letter-spacing: -.05em; }
h2 { letter-spacing: -.035em; }
.topbar-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

.hero-panel, .panel, .map-panel, .drawer, .setup-card, .modal-card {
    background: rgba(255,255,255,.86);
    border: 1px solid rgba(159,178,177,.38);
    box-shadow: var(--shadow);
}
.hero-panel { border-radius: 24px; padding: 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.hero-panel h2 { margin: 8px 0 8px; font-size: clamp(25px, 4vw, 40px); }
.hero-panel p { color: var(--muted); line-height: 1.6; max-width: 860px; margin-bottom: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 10px; background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(15,118,110,.18); font-size: 12px; font-weight: 850; }
.hero-stats { width: 116px; height: 116px; flex: 0 0 116px; border-radius: 50%; display: grid; place-items: center; align-content: center; background: radial-gradient(circle, #fff 56%, var(--accent-soft) 58%); border: 8px solid #d7ebe7; color: var(--accent); }
.hero-stats strong { font-size: 30px; line-height: 1; }
.hero-stats span { display: block; font-size: 12px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.sidebar { display: grid; gap: 14px; position: sticky; top: 14px; }
.panel { border-radius: var(--radius); padding: 16px; }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.quiet { color: var(--muted); font-size: 13px; }
.primary-panel { border-color: rgba(15,118,110,.22); background: linear-gradient(180deg, #fff, #f7fbfa); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-card { border: 1px solid var(--line); border-radius: 14px; padding: 11px; background: var(--card-soft); }
.stat-card strong { display: block; font-size: 24px; letter-spacing: -.04em; }
.stat-card span { display: block; color: var(--muted); font-size: 12px; }
.stat-card.red { border-color: rgba(217,83,79,.25); }
.stat-card.blue { border-color: rgba(37,99,235,.24); }
.stat-card.green { border-color: rgba(22,163,74,.24); }
.bar { height: 9px; border-radius: 999px; background: #e7eceb; overflow: hidden; margin-top: 12px; }
.bar span { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width .25s ease; }

.input-label, .drawer-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
input[type="text"], input[type="password"], input[type="search"], input[type="file"], select, textarea { width: 100%; }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 12px;
    padding: 11px 12px;
    outline: none;
}
input[type="file"] { background: var(--card-soft); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 10px; }
input:focus, select:focus, textarea:focus { border-color: rgba(15,118,110,.55); box-shadow: 0 0 0 3px rgba(15,118,110,.08); }
textarea { resize: vertical; }
.checkbox-row { display: flex !important; gap: 10px; align-items: center; color: var(--muted); }
.checkbox-row input { width: auto; }

.mini-list { display: grid; gap: 8px; }
.mini-list.empty { color: var(--muted); font-size: 13px; }
.mini-item { display: block; border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 10px; color: var(--text); text-decoration: none; }
.mini-item:hover { border-color: rgba(15,118,110,.35); }
.mini-item strong { display: block; font-size: 13px; }
.mini-item small { color: var(--muted); display: block; margin-top: 4px; line-height: 1.4; }

.map-panel { border-radius: var(--radius); padding: 18px; min-width: 0; background: rgba(255,255,255,.9); }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.map-toolbar h2 { margin-bottom: 4px; }
.map-toolbar p { margin: 0; color: var(--muted); font-size: 13px; }
.tree-root { overflow-x: auto; padding: 6px 6px 40px; min-height: 560px; }
.tree-root.loading { color: var(--muted); }
.tree { min-width: 820px; }
.tree ul { list-style: none; margin: 0; padding-left: 34px; position: relative; }
.tree ul::before { content: ""; position: absolute; top: 0; bottom: 12px; left: 13px; width: 2px; background: var(--line-strong); opacity: .55; border-radius: 999px; }
.tree > ul { padding-left: 0; }
.tree > ul::before { display: none; }
.tree li { position: relative; margin: 12px 0; }
.tree li::before { content: ""; position: absolute; top: 26px; left: -21px; width: 21px; height: 2px; background: var(--line-strong); opacity: .65; border-radius: 999px; }
.tree > ul > li::before { display: none; }
.tree li.active-path::before, .tree ul.active-path-line::before { background: var(--accent); opacity: 1; }
.children.collapsed { display: none; }

.node-card {
    width: min(100%, 770px);
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: start;
    border: 1px solid var(--line);
    border-left: 6px solid var(--red);
    border-radius: 15px;
    background: #fff;
    padding: 12px;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.node-card:hover { transform: translateY(-1px); border-color: rgba(15,118,110,.32); box-shadow: 0 10px 28px rgba(31,41,51,.08); }
.node-card.highlighted { outline: 3px solid rgba(15,118,110,.18); border-color: rgba(15,118,110,.55); }
.node-card.active-path-card { box-shadow: 0 0 0 3px rgba(15,118,110,.10); }
.node-card.related-highlight { box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.node-card.status-learning { border-left-color: var(--blue); background: linear-gradient(90deg, var(--blue-soft), #fff 22%); }
.node-card.status-learned { border-left-color: var(--green); background: linear-gradient(90deg, var(--green-soft), #fff 22%); }
.node-card.status-todo { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-soft), #fff 22%); }
.toggle-button { width: 28px; height: 28px; border-radius: 10px; border: 1px solid var(--line); color: var(--text); background: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.toggle-button.no-children { opacity: .35; pointer-events: none; }
.node-main { min-width: 0; }
.node-title-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.node-title { font-weight: 850; letter-spacing: -.025em; }
.node-description { color: var(--muted); margin-top: 5px; font-size: 13px; line-height: 1.45; max-width: 630px; }
.node-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.badge { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: rgba(255,255,255,.78); border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: 11px; font-weight: 750; }
.badge.focus { color: #8a5a00; border-color: rgba(245,158,11,.35); background: #fff8e5; }
.badge.count { background: var(--accent-soft); color: var(--accent); border-color: rgba(15,118,110,.18); }
.node-side { display: grid; gap: 8px; justify-items: end; min-width: 118px; }
.quick-status { display: flex; gap: 5px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); border: 2px solid rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.status-dot.learning { background: var(--blue); }
.status-dot.learned { background: var(--green); }
.status-dot-button { border: 1px solid transparent; background: transparent; padding: 3px; border-radius: 8px; display: grid; place-items: center; }
.status-dot-button:hover { border-color: var(--line); background: #fff; }
.card-progress { width: 88px; height: 7px; background: #e6eceb; border-radius: 999px; overflow: hidden; }
.card-progress span { display: block; height: 100%; width: 0%; border-radius: inherit; background: currentColor; }

.primary-button, .ghost-button, .button-link, .status-choice, .icon-button {
    border: 1px solid var(--line);
    color: var(--text);
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.primary-button { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 850; }
.ghost-button:hover, .button-link:hover, .status-choice:hover, .icon-button:hover { transform: translateY(-1px); border-color: rgba(15,118,110,.4); background: #fbfffe; }
.primary-button:hover { transform: translateY(-1px); background: #0b5f59; }
.danger-link { color: #b42318; }
.icon-button { width: 40px; height: 40px; font-size: 25px; padding: 0; }
.status-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-choice { font-weight: 780; }
.status-choice.red { background: var(--red-soft); border-color: rgba(217,83,79,.25); }
.status-choice.blue { background: var(--blue-soft); border-color: rgba(37,99,235,.25); }
.status-choice.green { background: var(--green-soft); border-color: rgba(22,163,74,.25); }
.status-choice.active { outline: 3px solid rgba(15,118,110,.14); border-color: var(--accent); }

.drawer { position: fixed; inset: 0 0 0 auto; width: min(500px, calc(100vw - 18px)); padding: 18px; z-index: 20; transform: translateX(110%); transition: transform .22s ease; overflow-y: auto; border-radius: 22px 0 0 22px; }
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.drawer-header h2 { margin: 0; letter-spacing: -.035em; }
.breadcrumb { color: var(--muted); font-size: 12px; line-height: 1.5; background: var(--card-soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 14px; }
.drawer-form { display: grid; gap: 4px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 6px; }
.related-section { margin-top: 20px; }
.related-section h3 { margin: 0 0 10px; }
.related-links { display: flex; flex-wrap: wrap; gap: 8px; }
.related-links.empty { color: var(--muted); font-size: 13px; }
.related-chip { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 10px; border-radius: 999px; }
.advanced-details { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--card-soft); }
.advanced-details summary { cursor: pointer; font-weight: 800; color: var(--muted); }
.advanced-details[open] summary { margin-bottom: 10px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; border: 1px solid rgba(15,118,110,.22); background: #12201f; color: #fff; padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); max-width: min(520px, calc(100vw - 24px)); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 18px; background: rgba(31,41,51,.34); }
.modal[hidden] { display: none; }
.modal-card { width: min(620px, 100%); border-radius: 22px; padding: 18px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.modal-header h2 { margin-bottom: 0; }
code { background: var(--card-soft); border: 1px solid var(--line); border-radius: 7px; padding: 2px 5px; }

.setup-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.setup-card { width: min(520px, 100%); border-radius: 24px; padding: 28px; }
.setup-logo { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); border: 1px solid rgba(15,118,110,.18); color: var(--accent); font-size: 30px; font-weight: 900; margin-bottom: 14px; }
.setup-card h1 { margin: 0 0 10px; letter-spacing: -.04em; }
.setup-card p { color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 14px; margin-top: 18px; }
.login-form label { display: grid; gap: 8px; color: var(--muted); }
.login-form button { border: 0; border-radius: 14px; padding: 12px 14px; background: var(--accent); color: #fff; font-weight: 900; }
.notice { border-radius: 14px; padding: 12px; margin: 12px 0; font-size: 13px; line-height: 1.45; }
.notice.error { background: var(--red-soft); border: 1px solid rgba(217,83,79,.28); color: #8a1f1b; }
.notice.success { background: var(--green-soft); border: 1px solid rgba(22,163,74,.28); color: #14532d; }
.notice.warning { background: #fff8e5; border: 1px solid rgba(245,158,11,.28); color: #7a4d00; }
.notice.subtle { background: var(--accent-soft); border: 1px solid rgba(15,118,110,.16); color: #285451; margin-top: -2px; }
.small-warning { font-size: 13px; }
.danger-row { color: #b42318 !important; }

@media (max-width: 1100px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .app-shell { width: min(100% - 18px, 1520px); padding-top: 12px; }
    .topbar, .hero-panel, .map-toolbar { align-items: stretch; flex-direction: column; }
    .topbar-actions { justify-content: flex-start; }
    .hero-stats { width: auto; height: auto; flex-basis: auto; border-radius: 16px; border-width: 1px; padding: 14px; display: block; }
    .sidebar { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr; }
    .node-card { grid-template-columns: auto 1fr; }
    .node-side { grid-column: 2; justify-items: start; display: flex; align-items: center; }
    .status-buttons { grid-template-columns: 1fr; }
    .tree { min-width: 720px; }
}

/* v1.1 additions: maps, focus fade, task progress */
.small-button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 7px 9px;
    font-size: 12px;
    font-weight: 850;
    color: var(--accent);
}
.map-list { display: grid; gap: 8px; }
.map-list.empty { color: var(--muted); font-size: 13px; }
.map-button {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 14px;
    padding: 11px;
    color: var(--text);
}
.map-button:hover { border-color: rgba(15,118,110,.36); background: #fbfffe; }
.map-button.active { border-color: rgba(15,118,110,.55); background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.map-button strong { display: block; font-size: 13px; }
.map-button small { display: block; color: var(--muted); margin-top: 4px; line-height: 1.35; }

.tree-root.focus-mode-on .dimmed-branch { opacity: .28; filter: saturate(.65); transition: opacity .16s ease, filter .16s ease; }
.tree-root.focus-mode-on .dimmed-branch:hover { opacity: .72; filter: saturate(.9); }
.tree-root.focus-mode-on .dimmed-branch::before { opacity: .22; }
.tree-root.focus-mode-on .dimmed-branch > ul::before { opacity: .22; }
.depth-warning[hidden] { display: none; }

.task-section {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 16px;
    padding: 12px;
    margin: 2px 0 12px;
}
.task-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 10px; }
.task-header h3 { margin: 0 0 4px; font-size: 15px; }
.task-header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.task-progress-pill {
    flex: 0 0 auto;
    border: 1px solid rgba(15,118,110,.2);
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 900;
}
.task-list { display: grid; gap: 7px; margin-bottom: 10px; }
.task-list.empty { color: var(--muted); font-size: 13px; }
.task-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--card-soft);
    border-radius: 12px;
    padding: 8px;
}
.task-row.done { background: var(--green-soft); border-color: rgba(22,163,74,.22); }
.task-check { display: flex !important; gap: 8px !important; align-items: center; margin: 0 !important; color: var(--text) !important; font-size: 13px !important; }
.task-check input { width: auto; }
.task-row.done .task-check span { text-decoration: line-through; color: var(--muted); }
.task-edit, .task-delete {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    color: var(--muted);
    padding: 5px 7px;
    font-size: 12px;
}
.task-delete { color: #b42318; font-weight: 900; }
.add-task-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.add-task-row input { margin: 0; }
input:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 720px) {
    .task-row { grid-template-columns: 1fr auto; }
    .task-edit { grid-column: 1; justify-self: start; }
    .task-delete { grid-column: 2; }
}
