/* ============ Tokens ============ */
:root {
  --accent: #6d5dfc;
  --bg: #f6f6fa;
  --surface: #ffffff;
  --surface-2: #f1f1f7;
  --border: #e6e6ef;
  --grid: #ececf3;
  --text: #191927;
  --muted: #6b6b80;
  --faint: #9a9aae;
  --danger: #e5484d;
  --warn: #d97706;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgb(20 20 40 / .06), 0 4px 14px rgb(20 20 40 / .06);
  --shadow-lg: 0 20px 60px rgb(20 20 40 / .22);
  --radius: 10px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0f14;
  --surface: #16171f;
  --surface-2: #1d1e28;
  --border: #272938;
  --grid: #1f2130;
  --text: #ececf4;
  --muted: #9b9cb2;
  --faint: #6c6d84;
  --warn: #f59e0b;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 14px rgb(0 0 0 / .25);
  --shadow-lg: 0 24px 70px rgb(0 0 0 / .55);
  color-scheme: dark;
}
:root[data-density="compact"] { font-size: 13px; }
:root[data-density="cozy"] { font-size: 14px; }
:root[data-density="comfortable"] { font-size: 15px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.grow { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85em; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.warn { color: var(--warn); }
.ico { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
kbd { font: 600 10px var(--font); padding: 2px 5px; border-radius: 4px; background: rgb(255 255 255 / .18); margin-left: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); flex-shrink: 0; }
.dot.big { width: 14px; height: 14px; }

/* ============ Buttons & controls ============ */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px; font-weight: 550; border: 1px solid var(--border); background: var(--surface); transition: background .15s, transform .08s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.wide { width: 100%; justify-content: flex-start; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover, .icon-btn.on { background: var(--surface-2); color: var(--text); }
.icon-btn.tiny { width: 22px; height: 22px; }
.link { color: var(--accent); font-weight: 550; text-align: left; }
.link:hover { text-decoration: underline; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 7px; font-weight: 550; color: var(--muted); transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
:root[data-theme="dark"] .seg button.on { background: #30324a; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .06); }
.seg.small button { padding: 4px 9px; font-size: .88em; }

input:not([type=checkbox]):not([type=color]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input:disabled { opacity: .45; }
textarea { resize: vertical; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 34px; height: 20px; border-radius: 20px; background: var(--border); position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.chips, .day-picker { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip { padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border); font-size: .85em; color: var(--muted); font-weight: 550; }
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 24px; height: 24px; border-radius: 50%; background: var(--c); border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--surface); transition: transform .1s; }
.sw:hover { transform: scale(1.12); }
.sw.on { border-color: var(--c); }
.sw.auto { width: auto; padding: 0 9px; border-radius: 12px; border: 1px solid var(--border); font-size: .8em; color: var(--muted); box-shadow: none; }
.sw.auto.on { border-color: var(--accent); color: var(--accent); }
.sw-custom { width: 28px; height: 28px; border: 0; padding: 0; background: none; cursor: pointer; }

/* ============ Shell ============ */
.shell { display: grid; grid-template-columns: 240px 1fr 0; height: 100vh; height: 100dvh; overflow: hidden; transition: grid-template-columns .25s ease; }
.shell.panel-open { grid-template-columns: 240px 1fr 340px; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { flex: 1; min-height: 0; overflow: auto; }

.sidebar { display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2em; padding: 2px 6px 6px; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 550; text-align: left; width: 100%; }
.nav:hover { background: var(--surface-2); color: var(--text); }
.nav.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.side-section { display: flex; flex-direction: column; gap: 1px; }
.side-label { display: flex; align-items: center; justify-content: space-between; font-size: .75em; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 4px 10px; }
.side-proj { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 7px; text-align: left; color: var(--text); }
.side-proj:hover { background: var(--surface-2); }
.side-proj small { color: var(--faint); font-variant-numeric: tabular-nums; }

/* Cube preview */
.cube-card { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.cube-card .side-label { padding: 0 0 2px; }
.cube-msg { font-size: .82em; line-height: 1.35; }
.cube-msg small { color: var(--muted); display: block; margin-top: 2px; }
.cube { --glow: #94a3b8; --bright: .5; width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--glow) 40%, #fff), var(--glow)); opacity: var(--bright); box-shadow: 0 0 18px color-mix(in srgb, var(--glow) 70%, transparent), inset 0 -3px 6px rgb(0 0 0 / .15); transition: background .6s, box-shadow .6s; }
.cube.pulse { animation: pulse 1.8s ease-in-out infinite; }
.cube.big { width: 90px; height: 90px; border-radius: 20px; }
@keyframes pulse { 50% { opacity: calc(var(--bright) * .45); box-shadow: 0 0 6px color-mix(in srgb, var(--glow) 40%, transparent); } }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface); min-height: 60px; flex-wrap: wrap; }
.date-nav { display: flex; align-items: center; gap: 4px; }
.range { font-size: 1.15em; font-weight: 650; margin: 0 0 0 4px; letter-spacing: -.01em; white-space: nowrap; }
.only-mobile { display: none; }

/* ============ Calendar ============ */
.cal { display: flex; flex-direction: column; height: 100%; }
.cal-head, .cal-grid { display: grid; grid-template-columns: 58px repeat(var(--cols), minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--border); background: var(--surface); overflow: hidden; scrollbar-gutter: stable; flex-shrink: 0; }
.gutter-head { font-size: .68em; color: var(--faint); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; text-align: center; }
.day-head { display: flex; align-items: baseline; gap: 6px; padding: 10px 10px 8px; border-left: 1px solid var(--grid); flex-wrap: wrap; }
.day-head .dow { font-size: .78em; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.day-head .dnum { font-size: 1.35em; font-weight: 650; }
.day-head .load { margin-left: auto; font-size: .72em; color: var(--faint); font-weight: 550; }
.day-head.today .dnum { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 7px; }
.day-head.today .dow { color: var(--accent); }
.day-head.pastday { opacity: .6; }
.allday { flex-basis: 100%; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.allday:empty { display: none; }
.allday-chip { font-size: .72em; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 70%, var(--text)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-body { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; position: relative; }
.cal-grid { position: relative; }
.gutter { position: relative; }
.hour-label { position: absolute; right: 8px; transform: translateY(-50%); font-size: .7em; color: var(--faint); font-weight: 550; white-space: nowrap; }
.day-col {
  position: relative; border-left: 1px solid var(--grid);
  background-image:
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--grid) 55%, transparent) 1px, transparent 1px);
  background-size: 100% var(--hour-h), 100% calc(var(--hour-h) / 2);
}
.day-col.today { background-color: color-mix(in srgb, var(--accent) 3%, transparent); }
.band { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--accent) 4.5%, transparent); border-left: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: #ef4444; z-index: 5; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }

.item { position: absolute; display: flex; gap: 6px; padding: 4px 6px 4px 7px; border-radius: 7px; overflow: hidden; font-size: .82em; line-height: 1.25; cursor: pointer; z-index: 2; user-select: none; touch-action: none; transition: box-shadow .15s, opacity .2s; }
.item:hover { z-index: 4; box-shadow: var(--shadow); }
.item-main { min-width: 0; flex: 1; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.item.short .item-title { white-space: nowrap; display: block; }
.item.tiny { padding: 0 6px 0 7px; align-items: center; gap: 5px; }
.item.tiny .check { width: 13px; height: 13px; border-width: 1.5px; margin-top: 0; }
.item.tiny .check svg { width: 9px; height: 9px; }
.item.tiny .item-title { font-size: .95em; line-height: 1.1; }
.item.tiny .chunk-tag, .item.tiny .flex-tag { font-size: .85em; }
.item-meta { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: .92em; margin-top: 1px; white-space: nowrap; overflow: hidden; }
.item.task { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); border-left: 3px solid var(--c); }
.item.event { background: color-mix(in srgb, var(--c) 82%, #000 0%); color: #fff; border: 1px solid transparent; }
.item.event .item-meta { color: rgb(255 255 255 / .85); }
:root[data-theme="dark"] .item.event { background: color-mix(in srgb, var(--c) 62%, var(--surface)); }
.item.flex { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 12%, transparent) 0 6px, color-mix(in srgb, var(--c) 6%, transparent) 6px 12px); border: 1px dashed color-mix(in srgb, var(--c) 60%, transparent); }
.item.past { opacity: .5; }
.item.done .item-title { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--muted); }
.item.risk { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 60%, transparent); }
.item.dragging { opacity: .85; z-index: 20; box-shadow: var(--shadow-lg); cursor: grabbing; transition: none; }
.chunk { margin-left: 5px; font-size: .78em; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 0 5px; border-radius: 8px; }
.flex-tag { margin-left: 6px; font-size: .75em; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.risk-tag { display: inline-flex; align-items: center; gap: 2px; color: var(--warn); font-weight: 600; }

/* Checkbox */
.check { width: 17px; height: 17px; border-radius: 50%; border: 1.8px solid color-mix(in srgb, var(--c, var(--accent)) 80%, var(--muted)); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: transparent; transition: background .2s, transform .15s, color .2s; margin-top: 1px; }
.check:hover { background: color-mix(in srgb, var(--c, var(--accent)) 20%, transparent); color: color-mix(in srgb, var(--c, var(--accent)) 80%, var(--text)); transform: scale(1.1); }
.check.on { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); color: #fff; animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.3); } }

/* ============ Tasks panel ============ */
.panel { display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--surface); overflow: hidden; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.panel-head h2 { margin: 0; font-size: 1.05em; }
.panel-body { flex: 1; overflow-y: auto; padding: 0 12px 20px; display: flex; flex-direction: column; gap: 12px; }
.quick { padding: 6px 12px 12px; border-bottom: 1px solid var(--border); }
.quick-box { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; }
.quick-box:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.quick-box .ico { color: var(--accent); margin-top: 2px; }
.quick-input { border: 0 !important; box-shadow: none !important; padding: 0 !important; background: transparent !important; resize: none; line-height: 1.4; }
.quick-preview { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; min-height: 0; }
.pchip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: .78em; font-weight: 600; }
.pchip.strong { background: var(--accent); color: #fff; }
.quick-help { margin-top: 8px; font-size: .74em; color: var(--faint); line-height: 1.7; }
.quick-help code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--muted); }
.quick-help b { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 9px 10px; display: flex; flex-direction: column; }
.stat b { font-size: 1.2em; }
.stat span { font-size: .74em; color: var(--muted); }
.stat.warn b { color: var(--warn); }
.panel-list { display: flex; flex-direction: column; gap: 3px; }
.group-label { font-size: .72em; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 10px 4px 4px; }
.task-row { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px 8px 12px; border-radius: 9px; cursor: pointer; transition: background .12s; }
.task-row:hover { background: var(--surface-2); }
.tr-bar { position: absolute; left: 3px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--c); }
.tr-main { min-width: 0; flex: 1; }
.tr-title { font-weight: 550; display: flex; align-items: center; gap: 6px; }
.prio { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); flex-shrink: 0; }
.tr-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .78em; color: var(--muted); margin-top: 2px; }
.task-row.done .tr-title, .step.done .tr-title { text-decoration: line-through; color: var(--muted); }
.proj-tag { color: color-mix(in srgb, var(--c) 75%, var(--text)); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: .9em; }

/* ============ Agenda ============ */
.agenda { max-width: 860px; margin: 0 auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.ag-day { display: grid; grid-template-columns: 70px 1fr; gap: 14px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.ag-day.today { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.ag-date { display: flex; flex-direction: column; align-items: center; }
.ag-date b { font-size: 1.6em; line-height: 1.1; }
.ag-date span { font-weight: 650; color: var(--muted); font-size: .85em; }
.ag-date small { color: var(--faint); font-size: .75em; }
.ag-day.today .ag-date b { color: var(--accent); }
.ag-items { display: flex; flex-direction: column; gap: 2px; }
.ag-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.ag-item:hover { background: var(--surface-2); }
.ag-item.past { opacity: .55; }
.ag-item.done .ag-title { text-decoration: line-through; color: var(--muted); }
.ag-time { width: 128px; flex-shrink: 0; font-size: .8em; color: var(--muted); font-variant-numeric: tabular-nums; }
.ag-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex-shrink: 0; margin: 0 3px; }
.ag-item.flex .ag-dot { border-radius: 50%; }
.ag-title { font-weight: 550; }
.ag-empty { color: var(--faint); font-size: .85em; padding: 6px 8px; }

/* ============ Projects ============ */
.projects { padding: 20px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.proj-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); border-top: 4px solid var(--c); }
.proj-card header { display: flex; justify-content: space-between; gap: 10px; }
.proj-card h3 { margin: 0; font-size: 1.1em; }
.proj-card p { margin: 4px 0 0; font-size: .88em; }
.proj-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8em; color: var(--muted); }
.progress { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--c); border-radius: 6px; transition: width .5s ease; }
.card-actions { display: flex; gap: 2px; align-self: flex-start; }
.ai-cta { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, transparent); color: var(--accent); }
.ai-cta:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ai-cta span { display: flex; flex-direction: column; gap: 2px; }
.ai-cta small { color: var(--muted); font-size: .82em; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; counter-reset: step; }
.step { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; cursor: pointer; --c: var(--c); }
.step:hover { background: var(--surface-2); }
.step.risk .tr-title::after { content: "at risk"; color: var(--warn); margin-left: 6px; font-size: .75em; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.step-input { font-size: .9em; background: var(--surface-2) !important; border-style: dashed !important; }
.proj-card.new { align-items: center; justify-content: center; min-height: 180px; border: 2px dashed var(--border); border-top-width: 2px; box-shadow: none; background: transparent; color: var(--muted); font-weight: 600; gap: 6px; text-align: center; }
.proj-card.new:hover { border-color: var(--accent); color: var(--accent); }

/* ============ Modal ============ */
.modal-back { position: fixed; inset: 0; background: rgb(10 10 20 / .38); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 100; opacity: 0; transition: opacity .16s; overflow-y: auto; }
.modal-back.open { opacity: 1; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; display: flex; flex-direction: column; transform: translateY(8px) scale(.98); transition: transform .18s ease; max-height: 88vh; }
.modal.wide { max-width: 760px; }
.modal-back.open .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-head h2 { margin: 0; font-size: 1.05em; }
.modal-body { padding: 8px 18px 16px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.form { display: flex; flex-direction: column; gap: 14px; }
.title-input { font-size: 1.3em !important; font-weight: 650; border: 0 !important; box-shadow: none !important; padding: 4px 0 !important; background: transparent !important; }
.title-input.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: .78em; font-weight: 650; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.row.four { grid-template-columns: repeat(4, 1fr); }
.stack { display: flex; flex-direction: column; gap: 10px; padding-top: 22px; }
.status-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .86em; padding: 9px 12px; border-radius: 9px; background: var(--surface-2); color: var(--muted); }
.status-line.risk { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.status-line .link { margin-left: auto; }
.deps { display: flex; flex-direction: column; gap: 6px; }
.dep-list { display: flex; flex-direction: column; gap: 4px; max-height: 140px; overflow-y: auto; }
.dep { display: flex; gap: 8px; align-items: center; font-size: .9em; cursor: pointer; }
.dep.done span { text-decoration: line-through; color: var(--muted); }

/* AI breakdown */
.bd-out { display: flex; flex-direction: column; gap: 4px; }
.bd-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bd-summary { padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, transparent); margin-bottom: 6px; }
.bd-summary p { margin: 0 0 4px; }
.bd-head, .bd-step { display: grid; grid-template-columns: 22px 1fr 70px 136px 110px; gap: 8px; align-items: start; }
.bd-head { padding: 0 2px; font-weight: 600; }
.bd-head span:first-child { grid-column: 2; }
.bd-step { padding: 6px 2px; border-radius: 8px; }
.bd-step input[type=checkbox] { margin-top: 10px; }
.bd-step.off { opacity: .45; }
.bd-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bd-title { font-weight: 550; }
.bd-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
@media (max-width: 760px) {
  .bd-head { display: none; }
  .bd-step { grid-template-columns: 22px 1fr 1fr; }
  .bd-main { grid-column: 2 / -1; }
  .bd-dur { grid-column: 2; } .bd-due { grid-column: 3; } .bd-kind { grid-column: 2 / -1; }
}

/* Settings */
.settings { display: grid; grid-template-columns: 170px 1fr; gap: 18px; min-height: 420px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-tab { text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 550; }
.settings-tab:hover { background: var(--surface-2); color: var(--text); }
.settings-tab.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.settings-pane { min-width: 0; }
.set-section { display: flex; flex-direction: column; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.set-section:last-child { border-bottom: 0; }
.set-section h3 { margin: 0; font-size: .95em; }
.set-section h3:empty { display: none; }
.set-section p { margin: 0; font-size: .9em; }
.lead { color: var(--muted); font-size: .9em; margin: 0 0 4px; }
.profile-head { display: flex; align-items: center; gap: 12px; }
.inline-title { font-weight: 650; max-width: 260px; }
.week-grid { display: flex; flex-direction: column; gap: 6px; }
.wg-row { display: grid; grid-template-columns: 100px 1fr auto 1fr; gap: 10px; align-items: center; }
.wg-row.off .hint { opacity: .4; }
.type-row { display: grid; grid-template-columns: auto 160px 90px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.code { background: var(--surface-2); border: 1px solid var(--border); padding: 10px 12px; border-radius: 9px; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-all; margin: 0; }
.cube-demo { display: flex; align-items: center; gap: 18px; padding: 8px 0; }
.stack.tight { padding-top: 0; gap: 8px; }
.key-row { display: flex; gap: 8px; align-items: center; }
.howto { font-size: .9em; background: var(--surface-2); border-radius: 9px; padding: 10px 12px; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { margin: 8px 0 0; padding-left: 20px; line-height: 1.7; color: var(--muted); }
.roadmap { margin: 0; padding-left: 18px; color: var(--muted); font-size: .9em; line-height: 1.8; }

/* Toasts & confetti */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; width: min(560px, calc(100vw - 32px)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; background: #1c1c28; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .9em; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; max-width: 100%; }
.toast.in { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }
.toast-act { color: #b8b0ff; font-weight: 650; white-space: nowrap; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 300; }
.boot-error { max-width: 420px; margin: 20vh auto; text-align: center; padding: 16px; }

.scrim { display: none; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .shell, .shell.panel-open { grid-template-columns: 220px 1fr; }
  .panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 100vw); z-index: 50; transform: translateX(100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .shell.panel-open .panel { transform: none; }
  .shell.panel-open .scrim { display: block; position: fixed; inset: 0; background: rgb(10 10 20 / .3); z-index: 40; }
}
@media (max-width: 760px) {
  .shell, .shell.panel-open { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .shell.drawer-open .sidebar { transform: none; }
  .shell.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgb(10 10 20 / .3); z-index: 40; }
  .only-mobile { display: inline-flex; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .range { font-size: 1em; order: 10; width: 100%; margin: 0; }
  .views button { padding: 5px 8px; }
  .cal-head, .cal-grid { grid-template-columns: 44px repeat(var(--cols), minmax(0, 1fr)); }
  .day-head .load { display: none; }
  .row, .row.four { grid-template-columns: 1fr; }
  .settings { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; }
  .settings-tab { white-space: nowrap; }
  .wg-row { grid-template-columns: 90px 1fr auto 1fr; gap: 6px; }
  .type-row { grid-template-columns: auto 1fr auto; }
  .type-row .swatches, .type-row .hint { grid-column: 1 / -1; }
  .ag-day { grid-template-columns: 50px 1fr; padding: 10px; gap: 10px; }
  .ag-time { width: 96px; }
  .projects, .agenda { padding: 16px; }
  .proj-grid { grid-template-columns: 1fr; }
  .modal-back { padding: 16px; }
}

/* Falling behind */
.behind-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; font-weight: 600; font-size: .85em; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); white-space: nowrap; }
.behind-pill:hover { background: color-mix(in srgb, var(--warn) 20%, transparent); }
.behind { display: flex; flex-direction: column; gap: 8px; }
.behind-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--c); border-radius: 10px; }
.behind-row .dot { display: none; }
.behind-title { font-weight: 600; }
.behind-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn.sm { height: 28px; padding: 0 10px; font-size: .85em; }
.behind-clear { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 0; color: var(--muted); text-align: center; }
.behind-clear svg { color: var(--ok, #22c55e); }
.behind-clear strong { color: var(--text); }
@media (max-width: 760px) {
  .behind-row { flex-wrap: wrap; }
  .behind-acts { width: 100%; justify-content: flex-start; }
  .behind-pill .pill-long { display: none; }
}
@media (max-width: 1000px) { .behind-pill .pill-long { display: none; } .behind-pill { padding: 0 10px; } }

/* Sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.signin-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 26px 24px; box-shadow: var(--shadow-lg); }
.signin-card h1 { margin: 4px 0 0; font-size: 1.3em; }
.signin-card .brand { padding: 0; }
.signin-card .btn.wide { justify-content: center; height: 40px; margin-top: 4px; }
.signin-error { color: var(--danger, #dc2626); font-size: .9em; min-height: 1.2em; }
.signin-error:empty { display: none; }

/* Account & household */
.row.three { grid-template-columns: repeat(3, 1fr); }
.key-row.wrap { flex-wrap: wrap; }
.key-row input { flex: 1; min-width: 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.member .hint { margin: 0; }
.member details.reset { width: 100%; }
.member details.reset summary { cursor: pointer; color: var(--muted); font-size: .88em; }
.member details.reset .key-row { margin-top: 8px; }
h3.sub { margin: 16px 0 8px; font-size: .95em; }
@media (max-width: 760px) { .row.three { grid-template-columns: 1fr; } }

/* Calendars: "Google -> Tempo" direction and steps */
.flow { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.flow-box { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: .9em; }
.flow-arrow { color: var(--accent); display: inline-flex; }
.steps { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }
.steps h3 { margin: 0 0 6px; font-size: .95em; }
.steps ol { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 4px; }
.howto.live ol { padding-left: 20px; display: grid; gap: 6px; }
