/* ==========================================================
   Planner — stylesheet
   Light + dark themes driven by [data-theme] on <html>.
   ========================================================== */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --accent:        #6366f1;
  --accent-2:      #8b5cf6;
  --accent-soft:   rgba(99, 102, 241, .12);
  --accent-text:   #ffffff;

  --bg:            #f5f6fb;
  --bg-grad:       radial-gradient(1200px 600px at 15% -10%, rgba(99,102,241,.10), transparent 60%),
                   radial-gradient(900px 500px at 100% 0%, rgba(139,92,246,.08), transparent 55%);
  --surface:       #ffffff;
  --surface-2:     #f1f3f9;
  --surface-3:     #e8ebf4;
  --border:        #e2e6f0;
  --border-strong: #cfd5e6;

  --text:          #141724;
  --text-2:        #4b5163;
  --muted:         #7a8194;

  --green:  #16a34a;
  --amber:  #d97706;
  --red:    #dc2626;
  --blue:   #0284c7;
  --pink:   #db2777;

  --shadow-1: 0 1px 2px rgba(20, 23, 36, .05), 0 1px 3px rgba(20, 23, 36, .04);
  --shadow-2: 0 4px 14px rgba(20, 23, 36, .07), 0 1px 3px rgba(20, 23, 36, .04);
  --shadow-3: 0 18px 50px rgba(20, 23, 36, .18);

  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 9px;

  --side-w: 258px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --accent:        #818cf8;
  --accent-2:      #a78bfa;
  --accent-soft:   rgba(129, 140, 248, .16);
  --accent-text:   #0b0d13;

  --bg:            #0e1016;
  --bg-grad:       radial-gradient(1100px 600px at 12% -12%, rgba(99,102,241,.16), transparent 60%),
                   radial-gradient(900px 500px at 100% 0%, rgba(167,139,250,.10), transparent 55%);
  --surface:       #161a23;
  --surface-2:     #1c2130;
  --surface-3:     #232838;
  --border:        #262b3a;
  --border-strong: #333a4e;

  --text:          #edeff5;
  --text-2:        #c2c8d8;
  --muted:         #99a0b3;

  --green:  #34d399;
  --amber:  #fbbf24;
  --red:    #f87171;
  --blue:   #38bdf8;
  --pink:   #f472b6;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  /* No -webkit-font-smoothing: antialiased here on purpose — on macOS it
     thins light-on-dark text and makes it look washed out. */
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; }

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

::selection { background: var(--accent-soft); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ── Buttons, fields ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 570; line-height: 1;
  padding: 10px 15px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, .3);
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--red); border-color: transparent; background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 12%, transparent); }
.btn-block { width: 100%; padding: 13px 15px; font-size: 15px; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: var(--r-sm); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 auto;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font-size: 16px; cursor: pointer; transition: background .15s, color .15s;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn.tiny { width: 24px; height: 24px; font-size: 14px; border-radius: 7px; }

input, textarea, select {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 34px;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
input[type="checkbox"] { width: auto; }
input[type="color"] { padding: 3px; height: 42px; cursor: pointer; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--muted); margin-bottom: 6px; text-transform: uppercase;
}
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

.alert {
  border-radius: var(--r-md); padding: 10px 13px; margin-bottom: 14px;
  font-size: 14px; border: 1px solid transparent;
}
.alert-error {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--red);
}
.alert-info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent);
}

/* ==========================================================
   Auth screen
   ========================================================== */
.auth-body { min-height: 100dvh; }
.auth-shell { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100dvh; }

.auth-art {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, #4f46e5, #7c3aed 55%, #c026d3);
  display: flex; align-items: center; justify-content: center; padding: 60px;
}
.auth-art-inner { position: relative; z-index: 2; max-width: 420px; color: #fff; }
.auth-art h2 { font-size: 40px; line-height: 1.1; margin: 22px 0 14px; letter-spacing: -.03em; }
.auth-art p { color: rgba(255, 255, 255, .9); font-size: 17px; margin: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.b1 { width: 420px; height: 420px; background: #22d3ee; top: -110px; left: -90px; }
.b2 { width: 360px; height: 360px; background: #f472b6; bottom: -120px; right: -70px; }
.b3 { width: 300px; height: 300px; background: #fbbf24; bottom: 30%; left: 40%; opacity: .3; }

.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; border-radius: 16px; font-size: 30px;
  background: rgba(255, 255, 255, .18); backdrop-filter: blur(6px); color: #fff;
}
.brand-mark.small {
  width: 30px; height: 30px; font-size: 18px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 27px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); margin: 0 0 24px; }
.auth-switch { text-align: center; color: var(--muted); margin: 18px 0 0; font-size: 14px; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}

/* ==========================================================
   App layout
   ========================================================== */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--side-w); flex: 0 0 var(--side-w);
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px 12px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; height: 100dvh;
}

.side-head { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-name { font-weight: 680; font-size: 16.5px; letter-spacing: -.02em; }
.side-close { display: none; margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 11px;
  color: var(--text-2); font-weight: 530; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
.nav-item .ni { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.side-section { margin-top: 18px; overflow-y: auto; flex: 1 1 auto; min-height: 40px; }
.side-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 11px 6px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.project-list { display: flex; flex-direction: column; gap: 1px; }
.project-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-size: 14px; border: 0; background: transparent;
  width: 100%; text-align: left; font-family: inherit;
}
.project-item:hover { background: var(--surface-2); color: var(--text); }
.project-item.active { background: var(--accent-soft); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.project-item .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .count { margin-left: auto; font-size: 12px; color: var(--muted); }

.side-foot { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 8px 2px; }
.avatar {
  width: 33px; height: 33px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.user-meta { min-width: 0; line-height: 1.25; }
.user-meta strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { display: block; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}
.menu-btn { display: none; }

.search-wrap { position: relative; flex: 1 1 auto; max-width: 460px; }
.search-wrap input {
  padding-left: 36px; border-radius: 999px; background: var(--surface-2);
  border-color: transparent;
}
.search-wrap input:focus { background: var(--surface); }
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 16px; pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-3);
  max-height: 60vh; overflow-y: auto; padding: 6px;
}
.sr-item {
  display: flex; gap: 10px; align-items: baseline;
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
}
.sr-item:hover, .sr-item.sel { background: var(--surface-2); }
.sr-kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; color: var(--accent); flex: 0 0 44px;
}
.sr-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-meta { color: var(--muted); font-size: 12px; flex: 0 0 auto; max-width: 40%;
           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 14px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.plus { font-size: 15px; }

.view { padding: 26px 22px 90px; max-width: 1220px; width: 100%; }

/* ── Page furniture ─────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 27px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.page-head .spacer { flex: 1 1 auto; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; }
.card-head .spacer { flex: 1 1 auto; }
.card-head .tag {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); padding: 2px 8px; border-radius: 999px;
}

.grid { display: grid; gap: 16px; }
.grid-dash { grid-template-columns: 1.15fr .85fr; align-items: start; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }

.empty { padding: 30px 18px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; opacity: .5; }

.loading { display: grid; place-items: center; padding: 80px 0; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 550;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--accent); border-color: transparent; color: #fff; }

/* ── Hero (Today) ──────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg); padding: 24px 26px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff; margin-bottom: 20px; box-shadow: var(--shadow-2);
}
.hero h1 { font-size: 30px; letter-spacing: -.03em; }
.hero .hero-date { opacity: .95; font-size: 14.5px; margin-top: 2px; }
.hero-stats { display: flex; gap: 26px; margin-top: 20px; flex-wrap: wrap; }
.hstat strong { display: block; font-size: 25px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hstat span { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; opacity: .92; font-weight: 600; }
.hero .hero-blob {
  position: absolute; right: -60px; top: -70px; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(255, 255, 255, .14);
}
.hero .hero-blob.two { right: 90px; bottom: -130px; top: auto; width: 180px; height: 180px; opacity: .5; }

/* ── Task list ─────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; }
.task {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 18px; border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--surface-2); }
.task.done .t-title { color: var(--muted); text-decoration: line-through; }

.check {
  width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px;
  border-radius: 50%; border: 2px solid var(--border-strong);
  background: transparent; cursor: pointer; padding: 0;
  display: grid; place-items: center;
  transition: border-color .15s, background .15s;
}
.check:hover { border-color: var(--accent); }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on::after { content: "✓"; color: #fff; font-size: 12px; line-height: 1; font-weight: 700; }
.check.p1 { border-color: var(--red); }
.check.p1.on { background: var(--red); border-color: var(--red); }

.t-body { flex: 1 1 auto; min-width: 0; }
.t-title { font-size: 14.5px; word-break: break-word; }
.t-notes { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: pre-wrap;
           display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-meta { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 5px; }
.t-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.task:hover .t-actions, .task:focus-within .t-actions { opacity: 1; }
@media (hover: none) { .t-actions { opacity: 1; } }

.pill {
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.pill.due-today { background: var(--accent-soft); color: var(--accent); }
.pill.overdue { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.pill.p1 { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.pill.p2 { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.pill.proj { background: var(--surface-3); color: var(--text-2); }
.pill.repeat { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }

/* quick inline add row */
.add-row { display: flex; gap: 9px; padding: 12px 18px; border-top: 1px solid var(--border); }
.add-row input { border-radius: 999px; background: var(--surface-2); border-color: transparent; }

/* ── Timeline (day) ────────────────────────────────────── */
.timeline {
  position: relative; display: grid;
  grid-template-columns: 58px 1fr;
  max-height: 620px; overflow-y: auto;
}
.tl-hours { position: relative; }
.tl-hour {
  height: 52px; border-bottom: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted); padding: 2px 8px 0 0; text-align: right;
}
.tl-track { position: relative; border-left: 1px solid var(--border); }
.tl-slot { height: 52px; border-bottom: 1px solid var(--border); cursor: pointer; }
.tl-slot:hover { background: var(--surface-2); }
.tl-event {
  position: absolute; left: 6px; right: 8px; z-index: 2;
  border-radius: 9px; padding: 5px 9px; overflow: hidden; cursor: pointer;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-left: 3px solid var(--accent);
  font-size: 12.5px; line-height: 1.35;
  box-shadow: var(--shadow-1);
}
.tl-event:hover { filter: brightness(1.05); }
.tl-event strong { display: block; font-weight: 620; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-event span { color: var(--text-2); font-size: 11.5px; }
.tl-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 5; }
.tl-now::before {
  content: ""; position: absolute; left: -5px; top: -4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--red);
}
.allday-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px; border-bottom: 1px solid var(--border); }

/* ── Month grid ────────────────────────────────────────── */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-title { font-size: 19px; font-weight: 650; min-width: 190px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 570;
  color: var(--text-2); padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.month {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; background: var(--surface); box-shadow: var(--shadow-1);
}
.month .dow {
  padding: 9px 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: center;
}
.mday {
  min-height: 104px; padding: 7px 8px; border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); cursor: pointer; position: relative;
  display: flex; flex-direction: column; gap: 3px;
}
.mday:nth-child(7n) { border-right: 0; }
.mday:hover { background: var(--surface-2); }
.mday.other { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.mday.other .mnum { color: var(--muted); opacity: .6; }
.mnum {
  font-size: 12.5px; font-weight: 620; color: var(--text-2);
  width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%;
}
.mday.today .mnum { background: var(--accent); color: #fff; }
.mev {
  font-size: 11.5px; padding: 2px 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 2.5px solid var(--accent);
}
.mev.task { background: var(--surface-2); border-left-color: var(--green); }
.mmore { font-size: 11px; color: var(--muted); padding-left: 4px; }

/* week view */
.week { display: grid; grid-template-columns: 58px repeat(7, 1fr); }
.week-head {
  display: grid; grid-template-columns: 58px repeat(7, 1fr);
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--surface); z-index: 3;
}
.wh { padding: 8px 6px; text-align: center; font-size: 12px; color: var(--muted); }
.wh strong { display: block; font-size: 16px; color: var(--text); }
.wh.today strong { color: var(--accent); }
.wcol { position: relative; border-left: 1px solid var(--border); }

/* ── Notes ─────────────────────────────────────────────── */
.note-card {
  display: flex; flex-direction: column; gap: 7px; padding: 16px 17px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform .12s, box-shadow .15s, border-color .15s;
  min-height: 138px;
}
.note-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.note-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--stripe, var(--accent)); opacity: .9;
}
.note-card h4 { font-size: 15.5px; padding-right: 22px; }
.note-card .n-body {
  color: var(--text-2); font-size: 13.5px; white-space: pre-wrap; flex: 1 1 auto;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.note-card .n-foot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }
.pin { position: absolute; top: 11px; right: 11px; font-size: 13px; color: var(--muted); }
.pin.on { color: var(--amber); }

/* ── Links ─────────────────────────────────────────────── */
.link-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; }
.favicon {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  background: var(--surface-2); display: grid; place-items: center; overflow: hidden;
}
.favicon img { width: 20px; height: 20px; }
.link-main { flex: 1 1 auto; min-width: 0; }
.link-main a { font-weight: 570; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-main .lurl { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-main .lnote { color: var(--text-2); font-size: 13px; margin-top: 4px; }

/* ── Settings ──────────────────────────────────────────── */
.settings-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.theme-picker { display: flex; gap: 10px; }
.theme-opt {
  flex: 1; border: 1.5px solid var(--border); border-radius: var(--r-md);
  padding: 12px 10px; text-align: center; cursor: pointer; background: var(--surface);
  font-size: 13px; font-weight: 570; color: var(--text-2); font-family: inherit;
}
.theme-opt.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.theme-swatch { height: 34px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--border); }
.sw-light { background: linear-gradient(135deg, #ffffff 50%, #eef0f7 50%); }
.sw-dark { background: linear-gradient(135deg, #1c2130 50%, #0e1016 50%); }
.sw-system { background: linear-gradient(135deg, #ffffff 50%, #0e1016 50%); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }

/* ── Modal ─────────────────────────────────────────────── */
/* The [hidden] attribute only works through the browser's default stylesheet,
   which ANY author `display` rule overrides. Without the :not([hidden])
   guard below, the backdrop covers the whole page permanently — dimming it,
   blurring it and eating every click. */
.modal-host { display: none; }
.modal-host:not([hidden]) {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 18, .55); backdrop-filter: blur(3px); }
.modal {
  position: relative; z-index: 2; width: 100%; max-width: 520px;
  max-height: calc(100dvh - 40px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 17px 20px 0; }
.modal-head h3 { font-size: 18px; flex: 1 1 auto; }
.modal-body { padding: 16px 20px; }
.modal-foot {
  display: flex; gap: 9px; justify-content: flex-end; padding: 0 20px 18px;
  flex-wrap: wrap;
}
.modal-foot .left { margin-right: auto; }

/* ── Toasts ────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 550;
  box-shadow: var(--shadow-3); animation: rise .2s ease-out;
  display: flex; align-items: center; gap: 10px; pointer-events: auto;
}
.toast.bad { background: var(--red); color: #fff; }
.toast button { background: none; border: 0; color: inherit; font: inherit;
  text-decoration: underline; cursor: pointer; padding: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ── Responsive ────────────────────────────────────────── */
.scrim { display: none; }

@media (max-width: 1080px) {
  .grid-dash { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    background: var(--surface); box-shadow: var(--shadow-3);
  }
  body.side-open .sidebar { transform: none; }
  body.side-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(10, 12, 18, .5);
  }
  .side-close { display: inline-flex; }
  .menu-btn { display: inline-flex; }
  .view { padding: 18px 14px 100px; }
  .topbar { padding: 10px 14px; }
  .qa-label { display: none; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 25px; }
  .mday { min-height: 74px; padding: 5px; }
  .mev { font-size: 10.5px; }
  .month .dow { padding: 7px 2px; font-size: 10px; }
  .week, .week-head { grid-template-columns: 42px repeat(7, 1fr); }
  .timeline { grid-template-columns: 46px 1fr; }
  .page-head h1 { font-size: 23px; }
  .field-row { flex-direction: column; gap: 0; }
}

@media print {
  .sidebar, .topbar, .toasts { display: none; }
}
