/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff;
    --bg-sidebar: #f8f9fa;
    --bg-hover: #f1f3f5;
    --bg-active: #eef2ff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-muted: #9ca3af;
    --text-sidebar: #4b5563;
    --accent: #6366f1;
    --accent-light: #eef2ff;
    --danger: #ef4444;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.06);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

html { font-size: 16px; }
body {
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

input, button, textarea { font-family: inherit; font-size: inherit; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }

.hidden { display: none !important; }

/* ── Buttons ── */
.btn-primary {
    background: var(--accent); color: #fff; border: none; padding: 6px 16px;
    border-radius: var(--radius); cursor: pointer; font-weight: 500; transition: background .15s;
}
.btn-primary:hover { background: #4f46e5; }
.btn-sm { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.btn-sm:hover { background: var(--bg-hover); }
.chip {
    display: inline-block; padding: 2px 10px; border: 1px solid var(--border); border-radius: 100px;
    font-size: 11px; color: var(--text-muted); cursor: pointer; background: var(--bg); transition: all .15s;
}
.chip:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn { background: none; border: 1px solid var(--border); padding: 4px 10px; border-radius: var(--radius); cursor: pointer; font-size: 13px; color: var(--text-muted); }
.nav-btn:hover { background: var(--bg-hover); }
.input { border: 1px solid var(--border); padding: 6px 10px; border-radius: var(--radius); width: 100%; }
.input-sm { width: 80px; flex-shrink: 0; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-sidebar); }
.login-card {
    background: #fff; padding: 40px; border-radius: 12px; box-shadow: var(--shadow);
    width: 360px; max-width: 90vw; text-align: center;
}
.login-logo { margin-bottom: 24px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-logo-icon { width: 32px; height: 32px; background: var(--accent); color: #fff; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.login-logo-text { font-size: 20px; font-weight: 700; color: var(--text); }
.login-input { width: 100%; border: 1px solid var(--border); padding: 10px 14px; border-radius: var(--radius); font-size: 15px; text-align: center; }
.login-btn { width: 100%; margin-top: 12px; padding: 10px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-weight: 600; cursor: pointer; font-size: 14px; }
.login-btn:hover { background: #4f46e5; }
.login-error { margin-top: 8px; color: var(--danger); font-size: 12px; min-height: 18px; }

/* ── App Layout ── */
.app-body { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: 240px; min-width: 240px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
.sidebar-brand { padding: 14px 16px; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--border); }
.brand-icon { width: 44px; height: 26px; background: #16a34a; color: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.sidebar-search { padding: 8px 12px; }
.search-input { width: 100%; border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; font-size: 12px; background: #fff; }
.sidebar-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.sb-section-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; padding: 8px 8px 4px; }
.sb-item {
    display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer;
    font-size: 13px; color: var(--text-sidebar); transition: background .1s; user-select: none;
}
.sb-item:hover { background: var(--bg-hover); }
.sb-item.active { background: var(--bg-active); color: var(--accent); font-weight: 500; }
.sb-item-icon { font-size: 16px; flex-shrink: 0; }
.sb-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 4px; }
.sb-btn { padding: 3px 10px; border: 1px solid var(--border); border-radius: 4px; background: #fff; font-size: 11px; cursor: pointer; color: var(--text-muted); transition: all .1s; }
.sb-btn:hover { background: var(--bg-hover); color: var(--text); }
.sb-btn-accent { color: var(--accent); border-color: var(--accent-light); }
.sb-btn-logout { color: var(--danger); border-color: #fecaca; }

.sb-context { position: fixed; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 1000; min-width: 120px; padding: 4px; }
.sb-context div { padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.sb-context div:hover { background: var(--bg-hover); }
.sb-context div.danger { color: var(--danger); }

/* ── Main Content ── */
.main-content { flex: 1; overflow-y: auto; position: relative; }
.view { max-width: 65%; margin: 0 auto; padding: 24px 40px 40px; }

/* ── Doc View ── */
/* ── Cover ── */
.cover-bar { border-radius: var(--radius); margin-bottom: 0; display: none; }
.cover-bar.has-cover { display: block; position: relative; overflow: hidden; min-height: 180px; }
.cover-img { width: 100%; height: 180px; object-fit: cover; display: block; border-radius: var(--radius); }
.cover-remove-btn {
    position: absolute; top: 10px; right: 14px; background: rgba(0,0,0,.45); color: #fff;
    border: none; padding: 4px 12px; border-radius: 4px; font-size: 0.6875rem; cursor: pointer;
    opacity: 0; transition: opacity .2s; z-index: 5;
}
.cover-bar:hover .cover-remove-btn { opacity: 1; }

/* ── Doc Header ── */
.doc-header { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 20px; margin-top: 8px; }
.page-icon { font-size: 52px; cursor: pointer; user-select: none; padding: 6px; border-radius: 14px; transition: background .15s; line-height: 1; flex-shrink: 0; }
.page-icon:hover { background: var(--bg-hover); }
.page-title-input { flex: 1; border: none; font-size: 2rem; font-weight: 700; color: var(--text); background: transparent; padding: 10px 0; min-width: 0; }
.page-title-input:focus { box-shadow: none; }

.doc-toolbar { display: flex; gap: 8px; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.tool-btn { padding: 5px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; font-size: 0.8125rem; cursor: pointer; color: var(--text-muted); }
.tool-btn:hover { background: var(--bg-hover); color: var(--text); }

.doc-preview { min-height: 400px; line-height: 1.85; font-size: 0.9375rem; }
.doc-editor { width: 100%; min-height: 400px; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.7; resize: vertical; }

/* ── Nation Syntax Styles ── */
.wiki-link { color: var(--accent); font-weight: 500; }
.wiki-link-new { color: var(--text-muted); border-bottom: 1px dashed var(--text-muted); }
.tag-badge { display: inline-block; background: var(--bg-hover); color: var(--text-muted); padding: 0 6px; border-radius: 4px; font-size: 12px; margin: 0 2px; }

.comp { margin: 8px 0; }
.comp-notice { background: #fef3c7; border-left: 3px solid #f59e0b; padding: 8px 12px; border-radius: 0 var(--radius) var(--radius) 0; font-size: 13px; }
.comp-label { font-weight: 700; font-size: 10px; color: #92400e; margin-right: 8px; }
.comp-cond { font-size: 10px; color: var(--text-muted); margin-left: 8px; }
.comp-calc { background: var(--accent-light); padding: 2px 8px; border-radius: 4px; font-size: 12px; color: var(--accent); font-family: var(--font-mono); }
.comp-image { max-width: 100%; border-radius: var(--radius); }
.comp-video { max-width: 100%; border-radius: var(--radius); }
.comp-list { padding-left: 20px; }
.comp-embed { border: 1px solid var(--border); padding: 8px 12px; border-radius: var(--radius); background: var(--bg-sidebar); font-size: 13px; }
.cal-event-inline { background: #ede9fe; color: #6d28d9; padding: 1px 6px; border-radius: 4px; font-size: 0.75rem; }

/* TODO Block */
.todo-block { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.todo-header { font-size: 0.6875rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.todo-item { display: flex; align-items: center; gap: 8px; padding: 5px 4px; cursor: pointer; font-size: 0.875rem; border-radius: 4px; transition: background .1s; user-select: none; }
.todo-item:hover { background: var(--bg-sidebar); }
.todo-mark { width: 18px; height: 18px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; border: 1.5px solid var(--border); color: var(--text-muted); }
.todo-mark.todo-done { background: #d1fae5; border-color: #6ee7b7; color: #059669; }
.todo-mark.todo-fail { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.todo-text { flex: 1; }
.todo-text.todo-done { text-decoration: line-through; color: #059669; }
.todo-text.todo-fail { text-decoration: line-through; color: #dc2626; }

/* Upload Placeholder */
.upload-placeholder {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px;
    text-align: center; cursor: pointer; color: var(--text-muted); font-size: 0.875rem;
    transition: all .2s; margin: 12px 0;
}
.upload-placeholder:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Notice Builder */
.notice-builder {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
    margin: 12px 0; background: var(--bg-sidebar);
}
.notice-builder-title { font-size: 0.6875rem; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; }
.notice-builder-select, .notice-builder-input {
    width: 100%; border: 1px solid var(--border); padding: 6px 8px; border-radius: 4px;
    font-size: 0.8125rem; margin-bottom: 6px; background: #fff;
}
.notice-builder-btn {
    width: 100%; background: var(--accent); color: #fff; border: none; padding: 6px;
    border-radius: 4px; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
}
.notice-builder-btn:hover { background: #4f46e5; }

/* Tag Filter */
.tag-filter { padding: 4px 12px 6px; display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); }
.tag-filter-chip { padding: 1px 8px; border: 1px solid var(--border); border-radius: 100px; font-size: 0.6875rem; cursor: pointer; color: var(--text-muted); background: #fff; transition: all .1s; white-space: nowrap; }
.tag-filter-chip:hover, .tag-filter-chip.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.tag-filter-chip.active { font-weight: 600; }
.tag-filter-all { font-weight: 500; }

/* ── Markdown Overrides ── */
.doc-preview h1 { font-size: 1.75rem; font-weight: 700; margin: 20px 0 10px; }
.doc-preview h2 { font-size: 1.3rem; font-weight: 600; margin: 18px 0 8px; }
.doc-preview h3 { font-size: 1.05rem; font-weight: 600; margin: 14px 0 6px; }
.doc-preview p { margin: 8px 0; }
.doc-preview ul, .doc-preview ol { padding-left: 22px; margin: 8px 0; }
.doc-preview li { margin: 3px 0; }
.doc-preview code { background: var(--bg-sidebar); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.8125rem; }
.doc-preview pre { background: var(--bg-sidebar); padding: 14px 18px; border-radius: var(--radius); overflow-x: auto; margin: 10px 0; }
.doc-preview pre code { background: none; padding: 0; }
.doc-preview blockquote { border-left: 3px solid var(--border); padding-left: 14px; color: var(--text-muted); margin: 10px 0; }
.doc-preview hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.doc-preview table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.doc-preview th, .doc-preview td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 0.875rem; }
.doc-preview th { background: var(--bg-sidebar); font-weight: 600; }
.doc-preview input[type="checkbox"] { margin-right: 8px; }

/* ── Tracker ── */
.tracker-header { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.tracker-date-box { display: flex; flex-direction: column; align-items: center; }
.tracker-date-box span { font-size: 18px; font-weight: 700; }
.tracker-date-box input { border: none; background: var(--bg-sidebar); padding: 2px 6px; border-radius: 4px; font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 2px; }

.tracker-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
.section-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.time-form { display: flex; gap: 6px; margin-bottom: 10px; }
.time-list { display: flex; flex-direction: column; gap: 4px; }
.time-entry { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; background: var(--bg-sidebar); border-radius: 4px; font-size: 13px; }
.time-totals { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.time-totals strong { color: var(--text); }

.tracker-diary { border-top: 1px solid var(--border); padding-top: 16px; }
.diary-templates { display: flex; gap: 6px; margin-bottom: 10px; }
.diary-editor { min-height: 160px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: text; line-height: 1.8; }
.diary-editor:empty::before { content: 'Double click to edit...'; color: var(--text-muted); }
.diary-editor-raw { width: 100%; min-height: 160px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font-family: var(--font-mono); font-size: 13px; resize: vertical; }
.save-status { font-size: 10px; color: var(--text-muted); }

.tracker-planner { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.tracker-planner .nav-btn { font-size: 10px; padding: 2px 8px; vertical-align: middle; }
.tracker-planner .section-title { display: flex; align-items: center; gap: 6px; }

/* Planner Layout: grid + floating sidebar */
.planner-layout { display: flex; gap: 12px; align-items: flex-start; }
#planner-grid { flex: 1; min-width: 0; overflow-x: auto; }
.planner-sidebar {
    width: 140px; flex-shrink: 0;
    position: sticky; top: 12px;
    background: var(--bg-sidebar); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px; max-height: calc(100vh - 40px); overflow-y: auto;
}
.planner-sidebar-title { font-size: 0.6875rem; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }

.task-pool { display: flex; flex-direction: column; gap: 4px; min-height: 20px; }
.task-chip {
    padding: 4px 12px; border-radius: 6px; font-size: 0.75rem; font-weight: 500; cursor: grab; user-select: none;
    transition: transform .1s, box-shadow .1s; white-space: nowrap;
}
.task-chip:active { cursor: grabbing; transform: scale(1.05); box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.task-chip-dur { font-size: 0.625rem; opacity: 0.7; margin-left: 4px; }

/* Planner Table */
#planner-grid { flex: 1; min-width: 0; overflow-x: auto; }
.planner-table { width: 100%; border-collapse: collapse; font-size: 0.6875rem; table-layout: fixed; min-width: 700px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.planner-table thead { background: var(--bg-sidebar); }
.planner-table th, .planner-table td { border: 1px solid #f3f4f6; }
.planner-time-col { width: 52px; text-align: right; padding: 3px 6px; font-size: 0.625rem; color: var(--text-muted); vertical-align: top; }
.planner-day-col { text-align: center; padding: 6px 4px; font-weight: 600; line-height: 1.3; vertical-align: middle; }
.planner-today { background: var(--accent-light); color: var(--accent); }
.planner-date-sub { font-size: 0.625rem; opacity: 0.6; }
.planner-cell { height: 18px; vertical-align: top; }
.empty-cell { cursor: pointer; }
.empty-cell:hover { background: var(--bg-hover); }
.planner-cell-over { background: var(--accent-light) !important; }
.planner-event {
    padding: 3px 6px; font-size: 0.625rem; cursor: pointer; line-height: 1.3; height: 100%; min-height: 18px;
    transition: opacity .1s;
}
.planner-event:hover { opacity: 0.8; }
.planner-event-conflict { border-left-style: dashed !important; position: relative; }
.planner-event-conflict::after { content: '⚠'; position: absolute; top: 2px; right: 4px; font-size: 0.5625rem; }
.planner-event-time { display: block; font-size: 0.5625rem; opacity: 0.6; }
.planner-drag-indicator {
    display: none; position: fixed; z-index: 100; pointer-events: none;
    background: #1f2937; color: #fff; font-size: 0.75rem; font-weight: 600;
    padding: 2px 8px; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.planner-now-row .planner-time-col {
    color: var(--accent); font-weight: 700;
}
.planner-now-badge {
    position: absolute; right: 2px; top: 0; z-index: 2;
    font-size: 0.5rem; font-weight: 700; color: #fff; background: var(--accent);
    padding: 0 3px; border-radius: 2px; line-height: 16px;
}
.planner-now-cell { position: relative; background: var(--accent-light) !important; }

/* Export Dropdown */
#tracker-export-area { position: relative; }
.export-dropdown {
    position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 50; min-width: 180px; padding: 4px;
}
.export-item { display: block; width: 100%; text-align: left; padding: 6px 12px; border: none; background: none; font-size: 0.8125rem; cursor: pointer; border-radius: 4px; color: var(--text); }
.export-item:hover { background: var(--bg-hover); }
.export-divider { border-top: 1px solid var(--border); margin: 4px 0; }
.export-range { padding: 4px 8px; }

/* ── Calendar ── */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-actions { display: flex; gap: 6px; }
.cal-month-label { font-size: 16px; font-weight: 600; margin: 0 12px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 10px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.cal-grid-month { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(90px, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-cell { background: #fff; padding: 4px 6px; min-height: 90px; font-size: 12px; }
.cal-cell-other { background: var(--bg-sidebar); }
.cal-cell-today { background: var(--accent-light); }
.cal-day-num { font-weight: 600; font-size: 12px; }
.cal-dot { font-size: 9px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; margin-top: 1px; }
.cal-more { font-size: 9px; color: var(--text-muted); }
.cal-grid-week { display: flex; gap: 4px; }
.cal-day-col { flex: 1; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-height: 400px; }
.cal-day-today { background: var(--accent-light); }
.cal-day-head { font-size: 11px; font-weight: 600; margin-bottom: 6px; }
.cal-day-event { font-size: 11px; padding: 2px 4px; margin: 2px 0; background: #ede9fe; border-radius: 3px; }
.cal-event-time { color: var(--text-muted); margin-right: 4px; }

/* ── Graph ── */
#view-graph.view { max-width: none; padding: 0; display: flex; height: calc(100vh - 0px); }
#graph-network { flex: 1; height: 100%; }
.cabinet { width: 200px; background: var(--bg-sidebar); border-left: 1px solid var(--border); padding: 12px; overflow-y: auto; font-size: 12px; }
.cabinet h4 { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.cabinet-item { padding: 4px 8px; border-radius: 4px; cursor: grab; margin: 2px 0; font-size: 12px; }
.cabinet-item:hover { background: var(--bg-hover); }

/* Graph Context Menu */
#graph-context-menu {
    display: none; position: absolute; z-index: 1000; width: 180px;
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1); padding: 4px 0; overflow: hidden;
}
.context-menu-item {
    padding: 8px 16px; font-size: 0.8125rem; color: var(--text); cursor: pointer;
    display: flex; align-items: center; transition: background .1s;
}
.context-menu-item:hover { background: #f3f4f6; color: var(--accent); }
.context-menu-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* Cabinet Tags */
.cabinet-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.cabinet-tag {
    padding: 1px 8px; border: 1px solid var(--border); border-radius: 100px;
    font-size: 0.625rem; cursor: pointer; color: var(--text-muted); background: #fff;
}
.cabinet-tag:hover, .cabinet-tag.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* Graph Context Menu */
.graph-context {
    position: fixed; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 1000; min-width: 160px; padding: 4px;
}
.graph-context div {
    padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 0.8125rem;
}
.graph-context div:hover { background: var(--bg-hover); }
.graph-ctx-sep { border-top: 1px solid var(--border); margin: 4px 0; padding: 0 !important; cursor: default !important; }

/* ── Analytics Panel ── */
.analytics-panel { position: fixed; right: 0; top: 0; width: 360px; height: 100vh; background: #fff; border-left: 1px solid var(--border); box-shadow: -4px 0 12px rgba(0,0,0,.04); z-index: 100; display: flex; flex-direction: column; }
.analytics-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.analytics-header h3 { font-size: 14px; }
.analytics-body { flex: 1; overflow-y: auto; padding: 16px; }
.var-list { margin-bottom: 12px; }
.var-item { padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 13px; display: flex; justify-content: space-between; }
.var-item:hover { background: var(--bg-hover); }
.var-unit { font-size: 11px; color: var(--text-muted); }
.var-create { display: flex; gap: 6px; margin-bottom: 16px; }
.analytics-chart-area { margin-top: 12px; }
.chart-wrap { height: 200px; margin-bottom: 16px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #c4c9d0; }

/* ── Muted ── */
.muted { color: var(--text-muted); font-style: italic; }

/* Bottom tab bar (mobile) */
.mobile-topbar { display: none; }
.mobile-tabs { display: none; }
.mobile-menu-btn { display: none; }
.sidebar-backdrop { display: none; }

/* ── Mobile (<768px) ── */
@media (max-width: 768px) {
    body { font-size: 15px; }

    /* Top bar */
    .mobile-topbar {
        display: flex; align-items: center; justify-content: space-between;
        position: fixed; top: 0; left: 0; right: 0; z-index: 110;
        background: #fff; border-bottom: 1px solid var(--border); padding: 8px 14px;
        height: 48px;
    }
    .mobile-topbar-brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; }
    .mobile-topbar-brand .brand-icon { width: 44px; height: 26px; background: #16a34a; color: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
    .mobile-topbar-brand .brand-green { color: #16a34a; }
    .mobile-topbar-toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
    .mobile-topbar-toggle button {
        padding: 4px 14px; border: none; background: #fff; font-size: 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all .1s;
    }
    .mobile-topbar-toggle button.active { background: var(--accent); color: #fff; }

    /* Sidebar */
    .sidebar {
        position: fixed; left: 0; top: 48px; bottom: 0; width: 100%; z-index: 100;
        display: none; overflow-y: auto;
    }
    .sidebar.mobile-show { display: flex; }
    .sidebar-brand { display: none; }
    .sidebar-search { padding: 12px 16px; }
    .search-input { padding: 10px 14px; font-size: 14px; }
    .sb-item { padding: 10px 16px; font-size: 15px; }
    .sb-item-icon { font-size: 20px; }
    .sb-section-label { font-size: 11px; padding: 12px 16px 4px; }
    .sidebar-footer { padding: 12px 16px; }
    .sb-btn { padding: 6px 14px; font-size: 13px; }
    .tag-filter { padding: 8px 16px; }
    .tag-filter-chip { padding: 4px 10px; font-size: 12px; }

    /* Main */
    .main-content {
        margin-left: 0; margin-top: 48px;
        display: none;
    }
    .main-content.mobile-show { display: block; }
    .view { max-width: 100%; padding: 12px 14px 30px; }

    /* Doc */
    .page-icon { font-size: 38px; }
    .page-title-input { font-size: 1.4rem; }
    .cover-bar.has-cover { height: 100px; }
    .doc-toolbar { flex-wrap: wrap; }

    /* Tracker */
    .tracker-grid { grid-template-columns: 1fr; }
    .tracker-chart { max-width: 180px; margin: 0 auto; }

    /* Planner */
    .planner-layout { flex-direction: column; }
    .planner-sidebar { width: 100%; position: static; max-height: none; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; padding: 8px; }
    .planner-sidebar-title { display: none; }
    .planner-sidebar .task-pool { flex-direction: row; flex-wrap: wrap; }
    .planner-table { min-width: 100%; font-size: 0.5625rem; }
    .planner-time-col { width: 32px; font-size: 0.5rem; padding: 2px; }
    .planner-day-col { padding: 4px 2px; font-size: 0.5625rem; }
    .planner-cell { height: 14px; }
    .planner-event { font-size: 0.5rem; padding: 1px 3px; }

    /* Calendar */
    .cal-grid-month { grid-auto-rows: minmax(56px, 1fr); }
    .cal-cell { min-height: 56px; padding: 2px 3px; font-size: 10px; }
    .cal-dot { font-size: 7px; }
    .cal-grid-week { flex-direction: column; gap: 8px; }
    .cal-day-col { min-height: auto; }
    .cal-weekdays, #cal-weekdays { font-size: 9px; }

    /* Graph */
    #view-graph.view { flex-direction: column; padding: 0; }
    #graph-network { height: 55vh; }
    .cabinet { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 30vh; }

    /* Analytics */
    .analytics-panel { width: 100%; }

    /* Export */
    .export-dropdown { right: auto; left: 0; }

    .doc-editor { min-height: 55vh; }
}

