/* ============================================================
   MOMENTUM — Soft Metro Theme (V8 Global Fill)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 13px; line-height: 1.5; color: var(--text-main);
  background-color: var(--bg-app); -webkit-font-smoothing: antialiased;
  min-height: 100dvh; overflow: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: var(--r); }

/* --- TOKENS --- */
:root {
  color-scheme: dark;
  --bg-app: #1F1E1D;
  --bg-panel: #2A2927;
  --bg-surface: #343230;
  --bg-hover: #3F3C39;
  --text-main: #F2EEE8;
  --text-soft: #CFC8BF;
  --text-faint: #A39B90;
  --border-color: #3D3A37;
  --border-bright: #5A5651;

  --accent: #357FA3; --accent-hover: #2D6E8F; --accent-text: #7CC0E0;
  --danger: #D2574A; --success: #6B9A4A; --warning: #D6A33C;

  --f-display: 'Segoe UI Light', 'Segoe UI', 'Inter', system-ui, sans-serif;
  --f-body: 'Segoe UI', 'Inter', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;
  
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r: 6px; --r-lg: 12px; --r-pill: 999px;
  --topbar-h: 48px; --sidebar-w: 240px; --bottom-nav-h: 56px;
  --nav-total: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  
  --shadow-sm: none; 
  --shadow-md: 0 4px 14px rgba(0,0,0,.25); 
  --shadow-lg: 0 12px 32px rgba(0,0,0,.35);
  
  --accent-wash: color-mix(in srgb, var(--accent) 24%, transparent);
  --tint: color-mix(in srgb, var(--accent) 30%, var(--bg-panel));
}

/* Page colour based on active page */
:root:has(.sidebar-nav a.active[href="index.html"]) { --accent: #357FA3; --accent-hover: #2D6E8F; --accent-text: #7CC0E0; }
:root:has(.sidebar-nav a.active[href="work.html"])  { --accent: #C26A30; --accent-hover: #A95A27; --accent-text: #EDA16C; }
:root:has(.sidebar-nav a.active[href="study.html"]) { --accent: #7B5CA8; --accent-hover: #6A4E93; --accent-text: #B9A0DD; }

/* Utility */
.display { font-family: var(--f-display); font-weight: 300; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.empty { color: var(--text-soft); text-align: center; padding: var(--s5); border: 1px dashed var(--border-bright); border-radius: var(--r); font-size: 13px; background: var(--bg-panel); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* --- GLOBAL HORIZONTAL FILL ANIMATION --- */
.has-fill { position: relative !important; overflow: hidden !important; }
.has-fill > *:not(.fill) { position: relative; z-index: 1; }
.fill {
  position: absolute; inset: 0 auto 0 0; width: 0; z-index: 0; pointer-events: none;
  background: rgba(255, 255, 255, 0.15);
  transition: width 0.8s cubic-bezier(0.35,.1,.25,1);
}
.fill.on { width: 100%; }

/* Old neon hex overrides for Metro */
html body .space-dot[style*="#F0883E" i], html body .sc-icon[style*="#F0883E" i] { background: #B8923A !important; }
html body .dense-row[style*="#F0883E" i], html body .cal-item[style*="#F0883E" i], html body .ag-row[style*="#F0883E" i] { border-left-color: #B8923A !important; }
html body .space-dot[style*="#388BFD" i], html body .sc-icon[style*="#388BFD" i] { background: #4F73B8 !important; }
html body .dense-row[style*="#388BFD" i], html body .cal-item[style*="#388BFD" i], html body .ag-row[style*="#388BFD" i] { border-left-color: #4F73B8 !important; }
html body .space-dot[style*="#DB61A2" i], html body .sc-icon[style*="#DB61A2" i] { background: #B5607F !important; }
html body .dense-row[style*="#DB61A2" i], html body .cal-item[style*="#DB61A2" i], html body .ag-row[style*="#DB61A2" i] { border-left-color: #B5607F !important; }
html body .space-dot[style*="#3FB950" i], html body .sc-icon[style*="#3FB950" i] { background: #5C8A3F !important; }
html body .dense-row[style*="#3FB950" i], html body .cal-item[style*="#3FB950" i], html body .ag-row[style*="#3FB950" i] { border-left-color: #5C8A3F !important; }
html body .space-dot[style*="#A371F7" i], html body .sc-icon[style*="#A371F7" i] { background: #35807E !important; }
html body .dense-row[style*="#A371F7" i], html body .cal-item[style*="#A371F7" i], html body .ag-row[style*="#A371F7" i] { border-left-color: #35807E !important; }

/* APP SHELL */
.app { display: flex; height: 100dvh; overflow: hidden; }
.sidebar { width: var(--sidebar-w); flex: none; background: #171615; border-right: 0; display: flex; flex-direction: column; padding: var(--s3); overflow-y: auto; transition: transform 0.2s; }
.sidebar-logo { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s2) var(--s3); margin-bottom: var(--s3); border-bottom: 0; }
.sidebar-logo-mark { width: 24px; height: 24px; background: var(--accent); color: #fff; display: grid; place-items: center; border-radius: var(--r); font-weight: 700; font-size: 14px; }
.sidebar-logo-text { font-weight: 300; font-size: 20px; letter-spacing: -0.02em; color: var(--text-main); }
.sidebar-section { margin-bottom: var(--s4); }
.sidebar-section-label { font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); padding: 0 var(--s2); margin-bottom: var(--s2); }
.sidebar-nav, .sidebar-spaces { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a { display: flex; align-items: center; gap: var(--s2); padding: 11px 12px; border-radius: var(--r); font-size: 13px; font-weight: 500; color: #fff; opacity: .72; transition: opacity .15s; }
.sidebar-nav a:nth-child(1) { background: #357FA3; }
.sidebar-nav a:nth-child(2) { background: #C26A30; }
.sidebar-nav a:nth-child(3) { background: #7B5CA8; }
.sidebar-nav a:hover { opacity: .9; }
.sidebar-nav a.active { opacity: 1; }
.sidebar-nav a.active svg { color: #fff; }
.sidebar-space { display: flex; align-items: center; gap: var(--s2); padding: 9px 12px; border-radius: var(--r); font-size: 13px; color: #fff !important; opacity: .72; transition: opacity .15s; width: 100%; text-align: left; }
.sidebar-space:nth-child(1) { background: #5E6B76; }
.sidebar-space:nth-child(2) { background: #B8923A; color: #1c1608 !important; }
.sidebar-space:nth-child(3) { background: #4F73B8; }
.sidebar-space:nth-child(4) { background: #B5607F; }
.sidebar-space:nth-child(5) { background: #5C8A3F; }
.sidebar-space:nth-child(6) { background: #35807E; }
.sidebar-space:hover { opacity: .9; }
.sidebar-space .space-dot { display: none; }
.space-count { margin-left: auto; font-family: var(--f-mono); font-size: 11px; background: rgba(0,0,0,.25); color: inherit; padding: 2px 6px; border-radius: var(--r-pill); }
.sidebar-foot { margin-top: auto; padding-top: var(--s4); border-top: 0; }
.sidebar-foot button { width: 100%; text-align: left; padding: 6px var(--s2); color: var(--text-faint); font-size: 11px; font-family: var(--f-mono); border-radius: var(--r); transition: color .1s; }
.sidebar-foot button:hover { color: #fff; background: rgba(210,87,74,.35); }
.sidebar-clock { padding: 8px 12px; margin-bottom: var(--s2); border-radius: var(--r); background: #1F1E1D; border: 0; display: flex; justify-content: space-between; align-items: baseline; }
.clock-date { font-size: 12px; color: var(--text-faint); margin: 0; }
.clock-time { font-size: 16px; font-family: var(--f-mono); font-weight: 600; color: var(--accent-text); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; backdrop-filter: blur(2px); }

.main-col { display: flex; flex-direction: column; flex: 1; min-width: 0; height: 100dvh; background: var(--bg-app); }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s5); background: var(--bg-panel); border-bottom: 3px solid var(--accent); flex: none; }
.crumb { font-size: 13px; font-weight: 500; color: var(--text-main); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-menu-btn { display: none; color: var(--text-main); }
.mobile-bottom-nav { display: none; }
.main { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.main-inner { width: 100%; height: 100%; display: flex; flex-direction: column; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px; height: 34px; border-radius: var(--r); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .15s; border: 1px solid transparent; }
.btn:active { transform: scale(0.98); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: none; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border-bright); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-surface); border-color: var(--text-faint); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.detail-title-input::placeholder, .quick-capture input::placeholder { color: var(--text-faint); }

/* MODALS & DRAWERS */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); z-index: 1000; display: none; align-items: center; justify-content: center; padding: var(--s3); opacity: 0; transition: opacity 0.2s; }
.modal-overlay.on { display: flex; opacity: 1; }
.modal-content { background: var(--bg-panel); border: 0; border-top: 4px solid var(--accent); border-radius: var(--r-lg); width: 100%; max-width: 480px; padding: var(--s5); box-shadow: var(--shadow-lg); transform: scale(0.95); transition: transform 0.2s; }
.modal-overlay.on .modal-content { transform: scale(1); }

.detail-pane { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 90vw; background: var(--bg-panel); border-left: 0; transform: translateX(100%); transition: transform 0.3s var(--smooth); z-index: 1000; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,0.4); visibility: hidden; }
.detail-pane.open { transform: translateX(0); visibility: visible; }
.detail-head { display: flex; align-items: flex-start; gap: 12px; padding: var(--s5) var(--s5) var(--s4); border-bottom: 0; background: var(--tint); }
.detail-title-input { flex: 1; min-width: 0; width: 100%; font-size: 18px; font-weight: 600; line-height: 1.3; padding: 0; border: 0; background: transparent; color: var(--text-main); outline: none; resize: none; }
.detail-close { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r); color: var(--text-main); flex: none; }
.detail-close:hover { background: rgba(0,0,0,.25); }
.detail-body { flex: 1; padding: var(--s5); overflow-y: auto; }
.detail-field { margin-bottom: var(--s4); }
.detail-field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-soft); margin-bottom: 6px; }
.detail-field select, .detail-field input, .detail-field textarea { width: 100%; height: 36px; padding: 0 8px; border: 1px solid var(--border-bright); border-radius: var(--r); background: var(--bg-app); font-size: 13px; color: var(--text-main); transition: border-color .15s; }
.detail-field textarea { height: auto; padding: 10px; min-height: 120px; resize: vertical; }
.detail-field select:focus, .detail-field input:focus, .detail-field textarea:focus { outline: none; border-color: var(--accent-text); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px); background: var(--bg-hover); color: var(--text-main); padding: 10px 16px; border-radius: var(--r-pill); font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 2000; box-shadow: var(--shadow-md); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* CHECKBOX */
.check { width: 18px; height: 18px; flex: none; border: 2px solid var(--border-bright); border-radius: 4px; background: transparent; display: grid; place-items: center; color: transparent; cursor: pointer; transition: all 0.2s; }
.check:active { transform: scale(0.9); }
.check.doing { border-color: var(--warning); }
.check.on { background: var(--success); border-color: var(--success); color: #fff; animation: popCheck 0.4s; }
@keyframes popCheck { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.check svg { width: 60%; height: 60%; stroke-width: 3; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

.confetti-piece { position: fixed; top: -10px; z-index: 9999; width: 8px; height: 8px; pointer-events: none; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }

/* WORK PAGE */
.work-page { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.crumb-pre { color: var(--text-faint); }
.view-toggle { display: inline-flex; background: var(--bg-app); border: 0; padding: 2px; border-radius: var(--r); }
.view-toggle button { padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--text-soft); transition: background .1s; }
.view-toggle button.active { background: var(--accent); color: #fff; }

.workbench { position: relative; display: flex; align-items: center; padding: var(--s5) var(--s6); border-bottom: 3px solid var(--accent); flex: none; overflow: hidden; background: var(--bg-panel); min-height: 200px; }
.workbench-cover { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; }
.workbench-overlay { position: absolute; inset: 0; background: linear-gradient(to right, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0.1) 100%); z-index: 1; }
.workbench-content { position: relative; z-index: 2; width: 100%; display: flex; flex-direction: column; gap: var(--s4); color: #fff; }
.wb-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); width: 100%; }
.wb-title { font-family: var(--f-display); font-size: 42px; font-weight: 300; line-height: 1.1; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.wb-desc { width: 100%; max-width: 600px; background: rgba(255,255,255,0.1); border: 1px solid transparent; padding: 10px 14px; border-radius: var(--r); font-size: 14px; color: rgba(255,255,255,0.9); outline: none; backdrop-filter: blur(4px); }
.wb-desc:focus { border-color: #fff; background: rgba(0,0,0,0.3); color: #fff; }
.wb-desc::placeholder { color: rgba(255,255,255,0.5); }
.wb-resources { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); }
.resource-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); border-radius: var(--r); font-size: 12px; color: #fff; white-space: nowrap; backdrop-filter: blur(4px); transition: background .15s; }
.resource-btn:hover { background: rgba(255,255,255,0.2); }

.work-bottom { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.panel-backlog { width: 280px; flex: none; background: #1A1918; border-right: 0; display: flex; flex-direction: column; }
.backlog-head { padding: var(--s3) var(--s4); border-bottom: 0; background: var(--tint); }
.backlog-head h2 { color: var(--text-main); }
.quick-capture { padding: var(--s3); border-bottom: 0; }
.quick-capture input { width: 100%; height: 36px; background: var(--bg-app); border: 1px solid var(--border-bright); border-radius: var(--r); padding: 0 10px; font-size: 13px; }
.backlog-list { flex: 1; overflow-y: auto; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }

.drag-card { background: var(--bg-surface); border: 0; border-left: 4px solid var(--accent); border-radius: var(--r); padding: var(--s3); cursor: grab; transition: background .1s; }
.drag-card:hover { background: var(--bg-hover); }
.drag-card-title { font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-main); }
.drag-card-meta { font-size: 12px; color: var(--text-faint); display: flex; gap: var(--s2); align-items: center; }

.output-area { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-app); }
.output-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s5); }
.rich-list { display: flex; flex-direction: column; gap: 6px; max-width: 1000px; margin: 0 auto; width: 100%; }
.section-head { display: flex; align-items: center; gap: var(--s2); margin: var(--s4) 0 var(--s2); padding-bottom: var(--s2); border-bottom: 1px solid var(--border-color); }
.section-head:first-child { margin-top: 0; }
.section-head h2 { font-size: 18px; font-weight: 300; text-transform: none; letter-spacing: 0; color: var(--accent-text); font-family: var(--f-display); }
.section-head .count { font-size: 12px; font-family: var(--f-mono); color: var(--text-faint); }

.dense-row { display: flex; align-items: center; gap: var(--s3); padding: 8px var(--s3); background: var(--bg-panel); border: 0; border-left: 5px solid var(--border-bright); border-radius: var(--r); cursor: pointer; min-height: 42px; transition: background .1s; }
.dense-row:hover { background: var(--bg-surface); }
.dense-row.done { opacity: 0.5; filter: none; }
.dense-row.done .dense-title { text-decoration: line-through; color: var(--text-faint); }
.dense-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
.dense-meta { display: flex; align-items: center; gap: var(--s2); flex: none; font-size: 13px; color: var(--text-faint); }
.dense-meta .late { color: var(--danger); }
.priority { font-size: 0; width: 9px; height: 9px; padding: 0; border: 0 !important; background: none !important; border-radius: 50%; }
.priority.high { background: var(--danger) !important; }
.priority.medium { background: var(--warning) !important; }
.priority.low { display: none; }

.cal-wrap { border: 0; background: var(--bg-panel); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.cal-bar { padding: 8px 12px; border-bottom: 0; display: flex; justify-content: space-between; align-items: center; flex: none; }
.cal-bar .btn { height: 26px; padding: 0 8px; }
.cal-nav { display: flex; gap: 4px; }
.cal-nav .btn { width: 28px; padding: 0; }
.cal-header { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 0; background: var(--tint); }
.cal-header div { padding: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-main); }
.cal-header .today { color: var(--accent-text); font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, minmax(96px, 1fr)); }
.cal-cell { border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: 6px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.cal-cell::-webkit-scrollbar { display: none; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.empty { background: #1A1918; opacity: 1; }
.cal-cell.today { background: var(--accent-wash); }
.cal-date { font-size: 12px; font-weight: 600; color: var(--text-faint); padding-left: 2px; }
.cal-cell.today .cal-date { color: var(--accent-text); font-weight: 700; }
.cal-item { font-size: 12px; padding: 4px 6px; border-radius: 4px; cursor: pointer; border: 0; border-left: 3px solid var(--border-bright); transition: background .1s; }
.cal-item:hover { background: var(--bg-hover); }
.cal-item.event { background: var(--tint) !important; color: var(--text-main); }
.cal-item.task { background: var(--bg-surface); }
.cal-item.task.done { text-decoration: line-through; opacity: .5; }
.cal-item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
.cal-item-row { display: flex; align-items: center; gap: 4px; }
.cal-item .check { width: 14px; height: 14px; }
.drop-highlight { background: var(--accent-wash)!important; outline: 2px dashed var(--accent-text); outline-offset: -2px; }

.grip { display: grid; place-items: center; width: 34px; flex: none; align-self: stretch; touch-action: none; color: var(--text-faint); background: rgba(0,0,0,.2); cursor: grab; -webkit-user-select: none; user-select: none; }
.touch-ghost { position: fixed; z-index: 3000; pointer-events: none; transform: translate(-50%, -140%); max-width: 220px; padding: 8px 12px; background: var(--bg-panel); border: 1px solid var(--accent); border-radius: var(--r); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); overflow-wrap: anywhere; }
.drag-src { opacity: .35; }
.wk-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--border-color); flex: none; }
.wk-day { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; min-width: 0; border-radius: var(--r); border: 1px solid transparent; }
.wk-name { font-size: 12px; color: var(--text-faint); line-height: 1.2; }
.wk-num { font-size: 15px; font-weight: 600; line-height: 1.2; }
.wk-day.today .wk-num { color: var(--accent-text); }
.wk-day.sel { background: var(--accent); border-color: var(--accent); }
.wk-day.sel .wk-num, .wk-day.sel .wk-name { color: #fff; }
.wk-dots { display: flex; gap: 3px; height: 5px; }
.wk-dots i { width: 5px; height: 5px; border-radius: 50%; }
.agenda { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s2) var(--s3); display: flex; flex-direction: column; gap: 6px; }
.ag-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; flex: none; }
.ag-head .btn { height: 30px; }
.ag-row { display: flex; align-items: center; gap: 10px; padding: 8px 0 8px 10px; flex: none; background: var(--bg-surface); border: 0; border-left: 5px solid var(--border-bright); border-radius: var(--r); overflow: hidden; }
.ag-row .grip { margin: -8px 0; }
.ag-row.done { opacity: .5; }
.ag-row.done .ag-title { text-decoration: line-through; }
.ag-ev { width: 24px; height: 24px; display: grid; place-items: center; color: var(--text-soft); flex: none; }
.ag-main { flex: 1; min-width: 0; }
.ag-title { font-size: 14px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; color: var(--text-main); }
.ag-sub { font-size: 13px; color: var(--text-faint); }
.dc-body { flex: 1; min-width: 0; }
body.is-dragging .wk-day, body.is-dragging .agenda, body.is-dragging .panel-backlog { outline: 1px dashed var(--border-bright); outline-offset: -2px; }
body.is-dragging .drop-highlight { outline: 2px solid var(--accent); }

/* STUDY PAGE */
.study-layout { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.mode-toggle { display: flex; background: var(--bg-app); border: 0; border-radius: var(--r); padding: 2px; }
.mode-toggle button { padding: 6px 16px; border-radius: 4px; font-size: 13px; font-weight: 600; color: var(--text-soft); transition: background .1s; border: none; background: transparent; cursor: pointer; }
.mode-toggle button.active { background: var(--accent); color: #fff; }

.study-header { padding: var(--s5) var(--s5) var(--s3); background: var(--bg-panel); border-bottom: 3px solid var(--accent); flex: none; display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; }
.search-bar { position: relative; flex: 1; max-width: 600px; }
.search-bar input { width: 100%; height: 44px; background: var(--bg-app); border: 1px solid var(--border-bright); border-radius: var(--r); padding: 0 16px 0 44px; font-size: 16px; color: var(--text-main); }
.search-bar input:focus { outline: none; border-color: var(--accent-text); }
.search-bar svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.study-scroll { flex: 1; overflow-y: auto; padding: var(--s5); background: var(--bg-app); }

.continue-card { background: var(--accent); border: 0; border-radius: var(--r-lg); padding: var(--s5); display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: filter .2s; margin-bottom: var(--s6); box-shadow: none; }
.continue-card:hover { filter: brightness(1.08); }
.cc-content { flex: 1; }
.cc-label { font-size: 12px; font-weight: 600; text-transform: uppercase; color: #fff; letter-spacing: 0.06em; margin-bottom: 6px; }
.cc-title { font-family: var(--f-display); font-size: 26px; font-weight: 300; color: #fff; line-height: 1.1; margin-bottom: 6px; }
.cc-meta { font-size: 13px; color: rgba(255,255,255,.85); display: flex; align-items: center; gap: 8px; }
.cc-btn { width: 56px; height: 56px; border-radius: 50%; background: #fff; color: var(--accent); display: grid; place-items: center; flex: none; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s4); }
.subject-card { position: relative; height: 200px; border-radius: var(--r-lg); overflow: hidden; cursor: pointer; transition: filter .2s; background: var(--bg-surface); }
.subject-card:hover { filter: brightness(1.1); }
.skill-cover { position: absolute; inset: 0; background-size: cover; background-position: center; background-color: var(--tile, #4F73B8); }
.skill-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.3) 60%, transparent 100%); }
.skill-content { position: absolute; inset: 0; padding: var(--s4); display: flex; flex-direction: column; justify-content: flex-end; }
.sc-title { font-size: 20px; font-weight: 600; color: #fff; line-height: 1.1; margin-bottom: 4px; }
.sc-meta { font-size: 13px; color: rgba(255,255,255,.75); margin-bottom: 12px; }
.sc-progress { height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; overflow: hidden; width: 100%; }
.sc-progress i { display: block; height: 100%; background: #fff; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s5); }
.book-card { display: flex; flex-direction: column; cursor: pointer; text-decoration: none; color: inherit; position: relative; }
.book-cover { aspect-ratio: 2/3; background: var(--tile, #4F73B8); border: 0; border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; font-family: var(--f-display); font-weight: 300; font-size: 64px; color: rgba(255,255,255,.85); box-shadow: none; position: relative; overflow: hidden; transition: filter .2s; }
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.book-cover span { z-index: 0; }
.book-card:hover .book-cover { filter: brightness(1.1); }
.book-title { font-family: var(--f-display); font-size: 18px; font-weight: 300; color: var(--text-main); line-height: 1.2; margin-top: 12px; }
.book-author { font-family: var(--f-mono); font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.book-progress { height: 3px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.book-progress i { display: block; height: 100%; background: var(--accent-text); }

.subject-grid > :nth-child(6n+1), .book-grid > :nth-child(6n+1) { --tile: #4F73B8; }
.subject-grid > :nth-child(6n+2), .book-grid > :nth-child(6n+2) { --tile: #7B5CA8; }
.subject-grid > :nth-child(6n+3), .book-grid > :nth-child(6n+3) { --tile: #B5607F; }
.subject-grid > :nth-child(6n+4), .book-grid > :nth-child(6n+4) { --tile: #35807E; }
.subject-grid > :nth-child(6n+5), .book-grid > :nth-child(6n+5) { --tile: #5C8A3F; }
.subject-grid > :nth-child(6n+6), .book-grid > :nth-child(6n+6) { --tile: #C26A30; }

.subject-header { background: var(--tint); border-bottom: 0; padding: var(--s5); }
.subject-top { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s4); }
.subject-title { font-family: var(--f-display); font-size: 36px; font-weight: 300; color: var(--text-main); line-height: 1; }
.subject-desc { font-size: 14px; color: var(--text-soft); max-width: 600px; margin-bottom: var(--s4); }
.sub-resources { display: flex; gap: var(--s2); flex-wrap: wrap; }
.res-pill { display: flex; align-items: center; gap: 6px; padding: 4px 12px; background: var(--bg-app); border: 0; border-radius: var(--r-pill); font-size: 12px; color: var(--text-main); text-decoration: none; }
.chapter-list { display: flex; flex-direction: column; gap: var(--s3); }
details.chapter { background: var(--bg-panel); border: 0; border-radius: var(--r-lg); overflow: hidden; }
details.chapter[open] { border-color: transparent; }
summary.chapter-head { padding: var(--s4); font-size: 15px; font-weight: 500; color: var(--text-main); cursor: pointer; display: flex; align-items: center; justify-content: space-between; list-style: none; background: var(--bg-surface); border-left: 5px solid var(--accent); }
summary.chapter-head::-webkit-details-marker { display: none; }
details.chapter[open] summary.chapter-head { background: var(--tint); }
.chapter-meta { font-size: 12px; font-weight: 400; color: var(--text-faint); font-family: var(--f-mono); }
.lesson-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--border-color); cursor: pointer; transition: background .1s; }
.lesson-row:hover { background: var(--bg-surface); }
.lesson-row.done { opacity: 0.6; }
.lesson-row.done .lesson-title { text-decoration: line-through; color: var(--text-faint); }
.lesson-title { flex: 1; font-size: 14px; font-weight: 500; color: var(--text-main); }
.lesson-dur { font-size: 12px; color: var(--text-faint); }

.split-view { display: flex; height: 100%; width: 100%; overflow: hidden; background: #000; }
.video-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.video-header { padding: var(--s3) var(--s4); background: var(--tint); border-bottom: 0; display: flex; align-items: center; gap: var(--s3); }
.video-container { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #000; }
.video-container iframe { width: 100%; height: 100%; border: none; }
.notes-pane { width: 400px; flex: none; background: var(--bg-panel); border-left: 1px solid var(--border-color); display: flex; flex-direction: column; }
.notes-header { padding: var(--s3) var(--s4); border-bottom: 0; display: flex; justify-content: space-between; align-items: center; background: var(--tint); }
.player-notes-list { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.note-card { background: #DCCB8A; border: 0; border-left: 4px solid #8F7A2E; border-radius: 2px 8px 8px 2px; padding: var(--s3) var(--s4); }
.note-meta { font-size: 11px; color: #5F5122; margin-bottom: 6px; font-family: var(--f-mono); display: flex; justify-content: space-between; }
.note-text { font-size: 13.5px; line-height: 1.6; color: #2E2710; white-space: pre-wrap; }
.note-composer { padding: var(--s4); border-top: 1px solid var(--border-color); background: var(--bg-panel); }
.note-composer textarea { width: 100%; height: 120px; background: #DCCB8A; border: 0; border-radius: 2px 8px 8px 2px; padding: var(--s3); font-size: 16px; color: #2E2710; resize: none; font-family: var(--f-body); line-height: 1.5; }
.note-composer .btn { margin-top: var(--s3); width: 100%; }

.shelf-tabs { display: flex; gap: var(--s2); margin-bottom: var(--s5); border-bottom: 0; padding-bottom: var(--s3); width: 100%; }
.shelf-tab { padding: 6px 12px; font-size: 14px; font-weight: 500; color: var(--text-soft); cursor: pointer; border-radius: var(--r); transition: background .1s; }
.shelf-tab:hover { color: var(--text-main); }
.shelf-tab.active { background: var(--accent); color: #fff; }
.action-icon { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.35); border: 0; color: #fff; border-radius: 4px; width: 24px; height: 24px; display: grid; place-items: center; opacity: 0; transition: opacity 0.1s; z-index: 10; }
.subject-card:hover .action-icon, .book-card:hover .action-icon { opacity: 1; }

.obsidian-layout { display: flex; height: 100%; background: var(--bg-panel); border: 0; border-radius: var(--r-lg); overflow: hidden; position: relative; }
.ob-sidebar { width: 280px; flex: none; border-right: 0; background: #1A1918; display: flex; flex-direction: column; transition: width 0.2s; }
.ob-sidebar.hidden { width: 0; border: none; overflow: hidden; }
.ob-header { padding: var(--s3); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.ob-tree { flex: 1; overflow-y: auto; padding: var(--s2); }
details.ob-folder { margin-bottom: 2px; border-radius: var(--r); transition: background 0.2s; }
details.ob-folder.drag-over { background: var(--accent-wash); outline: 2px dashed var(--accent); outline-offset: -2px; }
details.ob-folder > summary { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: 13px; font-weight: 600; color: var(--text-main); cursor: pointer; border-radius: var(--r); list-style: none; transition: all 0.15s; }
details.ob-folder > summary::-webkit-details-marker { display: none; }
details.ob-folder > summary:hover { background: var(--bg-hover); }
details.ob-folder[open] > summary { color: var(--text-main); }
details.ob-folder > summary::before { content: '▶'; font-size: 8px; color: var(--text-faint); display: inline-block; transition: transform 0.1s; }
details.ob-folder[open] > summary::before { transform: rotate(90deg); }
.ob-notes-list { padding-left: 16px; margin-left: 8px; border-left: 1px solid var(--border-color); }
.ob-note-link { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: 13px; color: var(--text-faint); cursor: grab; border-radius: var(--r); transition: all 0.15s; }
.ob-note-link:active { cursor: grabbing; }
.ob-note-link:hover { background: var(--bg-hover); color: var(--text-main); }
.ob-note-link.active { background: var(--accent); color: #fff; }
.ob-editor { flex: 1; display: flex; flex-direction: column; background: var(--bg-panel); position: relative; }
.ob-editor-head { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 12px; }
.ob-editor-title { flex: 1; background: transparent; border: none; font-size: 24px; font-family: var(--f-display); color: var(--text-main); outline: none; }
.ob-editor-body { flex: 1; padding: var(--s4); }
.ob-editor-body textarea { width: 100%; height: 100%; background: transparent; border: none; font-size: 16px; line-height: 1.6; color: var(--text-main); outline: none; resize: none; font-family: var(--f-body); transition: padding 0.3s; }
.ob-editor-body textarea:focus { padding-left: 20px; border-left: 2px solid var(--accent); }
.ob-folder-select { background: var(--bg-surface); border: 0; color: var(--text-main); padding: 6px; border-radius: 4px; font-size: 12px; outline: none; }
.ob-empty { flex: 1; display: grid; place-items: center; color: var(--text-faint); padding: var(--s5); text-align: center; }

/* MOBILE */
@media (max-width: 800px) {
  .app { flex-direction: column; height: 100dvh; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transform: translateX(-100%); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.on { display: block; }
  .mobile-bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-total); background: #171615; border-top: 0; z-index: 50; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .mobile-bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #fff; font-size: 12px; font-weight: 500; opacity: .6; transition: opacity 0.1s; }
  .mobile-bottom-nav a:nth-child(1) { background: #357FA3; }
  .mobile-bottom-nav a:nth-child(2) { background: #C26A30; }
  .mobile-bottom-nav a:nth-child(3) { background: #7B5CA8; }
  .mobile-bottom-nav a.active { color: #fff; opacity: 1; }
  .main-col { height: calc(100dvh - var(--nav-total)); flex: 1; }
  .toast { bottom: calc(var(--nav-total) + 16px); }
  .topbar { padding: 0 var(--s3); gap: var(--s2); }
  .mobile-menu-btn { display: grid; place-items: center; width: 32px; height: 32px; }
  .crumb { flex: 1; font-size: 14px; font-weight: 600; }
  .crumb-pre, .btn-event, .topbar .lbl { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar .btn { height: 34px; padding: 0 10px; }
  .topbar .btn-primary { width: 36px; padding: 0; }
  .view-toggle button { padding: 6px 10px; }
  .detail-pane { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%; height: 85dvh; border-left: none; border-top: 1px solid var(--border-bright); border-radius: 16px 16px 0 0; transform: translateY(100%); box-shadow: 0 -10px 40px rgba(0,0,0,0.5); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .detail-pane.open { transform: translateY(0); }
  .detail-body { padding: var(--s4); }
  .detail-head { padding: var(--s4); }
  .detail-field select, .detail-field input { height: 44px; font-size: 16px; }
  .btn { height: 40px; }
  .check { width: 24px; height: 24px; }
  .workbench { display: none !important; }
  .work-page { height: 100%; width: 100%; }
  .work-bottom { flex-direction: column; width: 100%; height: 100%; }
  .output-area { flex: 1; min-height: 0; }
  .output-scroll { display: flex; flex-direction: column; padding: var(--s2); }
  .rich-list { flex: none; }
  .cal-wrap { flex: 1; min-height: 0; height: auto; border-radius: var(--r); }
  .cal-bar { padding: 4px 10px; }
  .cal-bar .btn { height: 32px; }
  .cal-nav .btn { width: 36px; }
  .panel-backlog { width: 100%; height: auto; max-height: 28dvh; flex: none; border-top: 3px solid var(--accent); border-right: none; box-shadow: 0 -10px 30px rgba(0,0,0,0.1); }
  .backlog-head { display: none; }
  .quick-capture { padding: 6px 10px; }
  .quick-capture input { height: 36px; font-size: 16px; }
  .backlog-list { flex: none; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 2px 10px 10px; gap: 8px; -webkit-overflow-scrolling: touch; }
  .backlog-list::-webkit-scrollbar { display: none; }
  .backlog-list .empty { width: 100%; padding: 10px; }
  .drag-card { display: flex; align-items: stretch; width: 176px; flex: none; padding: 0; overflow: hidden; background: var(--bg-panel); touch-action: none; }
  .drag-card .dc-body { padding: 6px 10px; }
  .drag-card-title { font-size: 13px; line-height: 1.25; margin-bottom: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .drag-card-meta span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-list-view .panel-backlog { display: none !important; }
  .dense-row { flex-wrap: wrap; align-items: flex-start; min-height: 44px; }
  .dense-title { white-space: normal; overflow-wrap: anywhere; }
  .dense-meta { flex-basis: 100%; margin-left: 36px; flex-wrap: wrap; }
  .study-header { padding: var(--s4) var(--s3); flex-direction: column; align-items: stretch; }
  .study-scroll { padding: var(--s3); }
  .cc-title { font-size: 20px; }
  .cc-btn { width: 44px; height: 44px; }
  .split-view { flex-direction: column; overflow-y: auto; }
  .video-pane { min-height: 35dvh; flex: none; }
  .notes-pane { width: 100%; flex: 1; border-left: none; border-top: 1px solid var(--border-color); }
  .subject-grid { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .obsidian-layout { flex-direction: column; }
  .ob-sidebar { width: 100%; height: 35dvh; border-right: none; border-bottom: 1px solid var(--border-color); }
  .ob-sidebar.hidden { height: 0; }
}