/* Windsor OS — design tokens ------------------------------------------- */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --border: #e2ded6;
  --border-strong: #cfc9bd;
  --text: #1c1b18;
  --text-dim: #6b665d;
  --text-faint: #9a948a;
  --accent: #7a5cff;
  --accent-soft: #efeaff;
  --danger: #c0392b;
  --danger-soft: #fbeae8;
  --ok: #2e7d5b;
  --warn: #b06d10;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 27, 24, .06), 0 8px 24px rgba(28, 27, 24, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  --c-slate: #64748b;  --c-red: #d4483b;   --c-amber: #c98a12;  --c-green: #3f8f4f;
  --c-teal: #2b8a86;   --c-blue: #3b74d4;  --c-violet: #7a5cff; --c-pink: #c2427f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1e1e23;
    --surface-2: #26262c;
    --border: #32323a;
    --border-strong: #45454f;
    --text: #ececf0;
    --text-dim: #a3a3ad;
    --text-faint: #74747f;
    --accent: #9d85ff;
    --accent-soft: #2a2440;
    --danger: #ff6b5b;
    --danger-soft: #3a2320;
    --ok: #5cc48f;
    --warn: #e0a340;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);

    --c-slate: #94a3b8;  --c-red: #ff7a6b;   --c-amber: #e6b040;  --c-green: #64bb77;
    --c-teal: #4fbcb6;   --c-blue: #6fa2f0;  --c-violet: #9d85ff; --c-pink: #ec74aa;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -.01em; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---- login ------------------------------------------------------------ */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .mark { font-size: 28px; margin-bottom: 12px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.login-card input { text-align: center; }
.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin-top: 10px;
}

/* ---- shell ------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100dvh; }

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 18px;
  font-weight: 650; letter-spacing: -.02em; font-size: 16px;
}
.brand .dot {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--c-pink));
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
}
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  background: none; border: 0; border-radius: var(--radius-sm);
  text-align: left; cursor: pointer; color: var(--text-dim);
  font-weight: 500;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-btn .icon { width: 18px; text-align: center; font-size: 14px; }
.nav-btn .count {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--text-dim);
  padding: 1px 6px; border-radius: 20px;
}
.nav-btn.active .count { background: var(--surface); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

.main { padding: 28px 32px 80px; max-width: 1000px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h2 { font-size: 22px; }
.page-head .sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

/* ---- controls --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 550; font-size: 14px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

input[type=text], input[type=password], input[type=datetime-local],
input[type=date], select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 72px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .04em;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- cards / lists ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card > h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); margin-bottom: 12px;
}

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat .n { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.stat.alert .n { color: var(--danger); }
.stat.soon .n { color: var(--warn); }

.task {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}
.task:last-child { border-bottom: 0; }
.task .check {
  flex: none; width: 19px; height: 19px; margin-top: 2px;
  border: 1.5px solid var(--border-strong); border-radius: 6px;
  background: none; cursor: pointer; display: grid; place-items: center;
  color: transparent; font-size: 12px; line-height: 1;
}
.task .check:hover { border-color: var(--accent); color: var(--text-faint); }
.task.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task .title { font-weight: 520; word-break: break-word; }
.task.done .title { text-decoration: line-through; color: var(--text-faint); }
.task .meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim); margin-top: 3px;
}
.task .due.overdue { color: var(--danger); font-weight: 600; }
.task .due.today { color: var(--warn); font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-dim); white-space: nowrap;
}
.pill .swatch { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.kind { text-transform: capitalize; }
.prio { font-size: 11px; letter-spacing: .5px; }
.prio-2 { color: var(--danger); font-weight: 700; }
.prio-0 { color: var(--text-faint); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  padding: 5px 12px; border-radius: 20px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.empty { color: var(--text-faint); font-size: 14px; padding: 22px 4px; text-align: center; }

/* ---- week view -------------------------------------------------------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; min-height: 130px;
}
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); margin: 0 0 8px; display: flex; justify-content: space-between;
}
.day.today h4 { color: var(--accent); }
.day .n { font-weight: 700; color: var(--text); }
.chip-item {
  font-size: 12px; padding: 4px 7px; border-radius: 6px;
  background: var(--surface-2); margin-bottom: 5px; cursor: pointer;
  border-left: 3px solid var(--c-slate); word-break: break-word;
}
.chip-item .t { font-variant-numeric: tabular-nums; color: var(--text-dim); font-size: 11px; }

/* ---- courses ---------------------------------------------------------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.course-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--c-slate); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
}
.course-card h4 { margin: 0 0 3px; font-size: 15px; }
.course-card .det { font-size: 12px; color: var(--text-dim); }
.course-card.archived { opacity: .55; }

/* ---- modal ------------------------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 19, 17, .45);
  display: grid; place-items: center; padding: 16px; z-index: 40;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 440px; max-height: 88dvh; overflow-y: auto;
  padding: 22px;
}
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}
.modal-actions .left { margin-right: auto; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 20px; font-size: 13px;
  z-index: 60; box-shadow: var(--shadow);
}

/* ---- mobile ----------------------------------------------------------- */
.mobile-nav { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 18px 16px 92px; }
  .row-2 { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: auto; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav button {
    background: none; border: 0; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10px; color: var(--text-dim); padding: 4px;
  }
  .mobile-nav button .icon { font-size: 17px; }
  .mobile-nav button.active { color: var(--accent); }
  .fab {
    position: fixed; right: 18px; bottom: calc(70px + env(safe-area-inset-bottom));
    width: 52px; height: 52px; border-radius: 50%; z-index: 31;
    background: var(--accent); color: #fff; border: 0; font-size: 26px;
    box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center;
  }
}
@media (min-width: 761px) { .fab { display: none; } }
