:root {
  --bg: #f6f4ef; --panel: #ffffff; --ink: #1d1d1f; --muted: #7a7770; --line: #e6e2d9;
  --accent: #3b5bdb; --accent-soft: #e7ecff; --danger: #d9480f; --danger-soft: #fff0e6;
  --ok: #2f9e44; --hour: 52px;
  --life: #2f9e44; --study: #3b5bdb; --masters: #ae3ec9; --opps: #e8590c; --event: #868e96;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181b; --panel: #212226; --ink: #ececec; --muted: #8d8f96; --line: #2f3136;
    --accent: #7b93ff; --accent-soft: #283152; --danger: #ff8a5c; --danger-soft: #3a2519;
    --life: #69db7c; --study: #7b93ff; --masters: #da77f2; --opps: #ffa94d; --event: #adb5bd;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.shell { display: flex; min-height: 100vh; }
.side { width: 210px; flex: none; padding: 20px 12px; border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 700; font-size: 18px; padding: 0 10px 16px; }
.side a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px;
  color: var(--ink); text-decoration: none; cursor: pointer; }
.side a:hover { background: var(--line); }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ic { width: 20px; text-align: center; }

main { flex: 1; min-width: 0; padding: 16px 24px 80px; max-width: 1200px; }
.cmd { display: flex; gap: 8px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0 8px; }
.cmd input { flex: 1; min-width: 0; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.cmd input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.cmd select { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 0 8px; }
.cmd button { width: 44px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-size: 20px; cursor: pointer; }
.hint { min-height: 20px; font-size: 13px; color: var(--muted); padding: 0 4px 8px; }

h1 { font-size: 22px; margin: 6px 0 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1 .sub { font-size: 14px; color: var(--muted); font-weight: 400; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.navbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 2px 10px; cursor: pointer; font-size: 15px; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 0; }
.empty { color: var(--muted); padding: 10px 14px; font-size: 14px; }

/* task rows */
.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 14px; cursor: pointer; }
.task + .task { border-top: 1px solid var(--line); }
.task:hover { background: color-mix(in srgb, var(--line) 40%, transparent); }
.chk { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--muted); margin-top: 1px;
  display: grid; place-items: center; cursor: pointer; background: none; padding: 0; }
.chk:hover { border-color: var(--ok); }
.task.done .chk { background: var(--ok); border-color: var(--ok); }
.task.done .chk::after { content: "✓"; color: #fff; font-size: 13px; font-weight: 700; }
.task.done .ttl { text-decoration: line-through; color: var(--muted); }
.tbody { flex: 1; min-width: 0; }
.ttl { word-wrap: break-word; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.chip { padding: 1px 7px; border-radius: 99px; background: var(--line); white-space: nowrap; }
.chip.sec { color: #fff; }
.chip.dl { background: var(--danger-soft); color: var(--danger); }
.chip.dl.calm { background: var(--line); color: var(--muted); }
.sec-life { background: var(--life) !important; } .sec-study { background: var(--study) !important; }
.sec-masters { background: var(--masters) !important; } .sec-opps { background: var(--opps) !important; }
.task[draggable="true"] { cursor: grab; }

/* timeline */
.timeline { position: relative; margin: 6px 0; }
.hour { height: var(--hour); border-top: 1px solid var(--line); position: relative; }
.hour span { position: absolute; top: -9px; left: 8px; font-size: 11px; color: var(--muted); background: var(--panel); padding: 0 4px; }
.blk { position: absolute; left: 56px; right: 8px; border-radius: 8px; padding: 3px 8px; font-size: 13px;
  overflow: hidden; cursor: pointer; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.blk.ev { border-left-color: var(--event); background: color-mix(in srgb, var(--event) 18%, var(--panel)); cursor: default; }
.blk.done { opacity: .5; text-decoration: line-through; }
.blk b { font-weight: 600; margin-right: 4px; }
.nowline { position: absolute; left: 48px; right: 0; height: 2px; background: var(--danger); z-index: 2; }

/* week */
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-height: 160px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); }
.day.over { outline: 2px dashed var(--accent); }
.day-h { padding: 8px 10px 4px; font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; cursor: pointer; }
.day-h span { color: var(--muted); font-weight: 400; }
.day .task { padding: 5px 8px; font-size: 13px; gap: 6px; }
.day .chk { width: 16px; height: 16px; border-radius: 5px; }
.day .ev { padding: 4px 10px; font-size: 12px; color: var(--muted); }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 16px; }
.card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.card .task { padding: 5px 0; }
.card select { border: 1px solid var(--line); border-radius: 8px; padding: 2px 6px; background: var(--panel); }
.ck { display: flex; gap: 8px; align-items: center; font-size: 14px; padding: 2px 0; }
.ck input { width: 16px; height: 16px; }
.ck.done span { text-decoration: line-through; color: var(--muted); }
.inline-add { display: flex; gap: 6px; }
.inline-add input { flex: 1; min-width: 0; border: 1px dashed var(--line); background: transparent; border-radius: 8px; padding: 5px 8px; font-size: 13px; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
details pre { white-space: pre-wrap; font: inherit; font-size: 13px; margin: 6px 0 0; color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 7px 12px; cursor: pointer; }
.btn.primary, button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.newform { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-bottom: 14px; }
.newform input, .newform select { border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: var(--panel); }

/* dialog */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--panel); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.tf { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.tf-title { font-size: 18px; font-weight: 600; border: 0; border-bottom: 1px solid var(--line); padding: 4px 0 8px; background: transparent; }
.tf-title:focus { outline: none; border-color: var(--accent); }
.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.tf-grid .wide { grid-column: 1 / -1; }
.tf-grid input, .tf-grid select, .tf textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--bg); color: var(--ink); font-size: 14px; min-width: 0; }
.tf textarea { min-height: 70px; resize: vertical; }
.tf-actions { display: flex; gap: 8px; }
.tf-actions button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.tf-actions .danger { color: var(--danger); }
.grow { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; z-index: 50; display: flex; gap: 12px; align-items: center; }
.toast button { background: none; border: 0; color: var(--accent-soft); cursor: pointer; font-weight: 600; padding: 0; }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
}
@media (max-width: 700px) {
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: auto; height: auto; flex-direction: row;
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0;
    border-top: 1px solid var(--line); background: var(--bg); z-index: 10; }
  .brand { display: none; }
  .side a { flex-direction: column; gap: 1px; font-size: 10px; padding: 4px 2px; flex: 1; }
  .side a .ic { font-size: 17px; }
  main { padding: 10px 16px 90px; }
  .cmd select { width: 44px; }
  .cards { grid-template-columns: 1fr; }
  .tf-grid { grid-template-columns: 1fr; }
}
