/* Agenda — Dark Matter Labs
   Leather-bound sidebar, quiet Apple-style surfaces everywhere else. */

:root {
  --font: "Helvetica Neue", Helvetica, "Inter Tight", Arial, sans-serif;

  --bg: #F1F1EF;
  --surface: #FFFFFF;
  --surface-2: #F8F8F7;
  --surface-3: #EDEDEB;
  --ink: #1C1B1A;
  --ink-2: #5F5C58;
  --ink-3: #9A9792;
  --hair: rgba(28, 27, 26, .085);
  --hair-2: rgba(28, 27, 26, .14);

  --accent: #A2522A;
  --accent-hover: #8E4622;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(162, 82, 42, .11);
  --accent-ring: rgba(162, 82, 42, .35);

  --leather-1: #6E3B24;
  --leather-2: #4A2818;
  --leather-hi: rgba(255, 214, 178, .16);
  --stitch: rgba(246, 224, 198, .44);
  --on-leather: #F6EADD;
  --on-leather-2: rgba(246, 234, 221, .64);
  --on-leather-3: rgba(246, 234, 221, .52);

  --danger: #CF4339;
  --warn: #D2962A;
  --info: #4A7BD4;

  --r-sm: 7px;
  --r: 11px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .05), 0 0 0 .5px rgba(0, 0, 0, .07);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, .07), 0 0 0 .5px rgba(0, 0, 0, .07);
  --shadow-pop: 0 18px 50px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .1);

  --hour: 52px;
  --sidebar: 268px;
  --inspector: 372px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141312;
  --surface: #1D1C1B;
  --surface-2: #232220;
  --surface-3: #2C2A28;
  --ink: #F3F1EE;
  --ink-2: #ABA6A0;
  --ink-3: #6F6B66;
  --hair: rgba(255, 255, 255, .075);
  --hair-2: rgba(255, 255, 255, .13);
  --accent: #D27F50;
  --accent-hover: #E08E5F;
  --accent-ink: #1A0F09;
  --accent-soft: rgba(210, 127, 80, .15);
  --accent-ring: rgba(210, 127, 80, .4);
  --leather-1: #3B2216;
  --leather-2: #22140C;
  --leather-hi: rgba(255, 200, 160, .09);
  --stitch: rgba(232, 200, 168, .3);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 .5px rgba(255, 255, 255, .06);
  --shadow-2: 0 6px 18px rgba(0, 0, 0, .4), 0 0 0 .5px rgba(255, 255, 255, .07);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .1);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312;
    --surface: #1D1C1B;
    --surface-2: #232220;
    --surface-3: #2C2A28;
    --ink: #F3F1EE;
    --ink-2: #ABA6A0;
    --ink-3: #6F6B66;
    --hair: rgba(255, 255, 255, .075);
    --hair-2: rgba(255, 255, 255, .13);
    --accent: #D27F50;
    --accent-hover: #E08E5F;
    --accent-ink: #1A0F09;
    --accent-soft: rgba(210, 127, 80, .15);
    --accent-ring: rgba(210, 127, 80, .4);
    --leather-1: #3B2216;
    --leather-2: #22140C;
    --leather-hi: rgba(255, 200, 160, .09);
    --stitch: rgba(232, 200, 168, .3);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 .5px rgba(255, 255, 255, .06);
    --shadow-2: 0 6px 18px rgba(0, 0, 0, .4), 0 0 0 .5px rgba(255, 255, 255, .07);
    --shadow-pop: 0 20px 60px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .1);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: .003em;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }

/* ───────── App frame ───────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

/* ───────── Leather ───────── */
.leather {
  position: relative;
  color: var(--on-leather);
  background-color: var(--leather-2);
  background-image:
    var(--grain-coarse, none),
    var(--grain-fine, none),
    radial-gradient(120% 60% at 20% 0%, var(--leather-hi), transparent 60%),
    linear-gradient(178deg, var(--leather-1), var(--leather-2));
  background-blend-mode: soft-light, overlay, normal, normal;
  background-size: 260px 260px, 140px 140px, 100% 100%, 100% 100%;
}
.leather::before {            /* stitched inset edge */
  content: "";
  position: absolute;
  inset: 9px;
  border: 1.5px dashed var(--stitch);
  border-radius: 12px;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .45));
}
.leather::after {             /* spine shading against the page */
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 14px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .28));
  pointer-events: none;
}

/* ───────── Sidebar ───────── */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 18px 16px 20px;
  overflow: hidden;
  z-index: 30;
}
.sidebar-scroll { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: none; position: relative; z-index: 1; }
.sidebar-scroll::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; position: relative; z-index: 1; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #F9EBDD, #D9B58F 60%, #A5774F);
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, .35), 0 1px 0 rgba(255, 255, 255, .12), 0 2px 4px rgba(0, 0, 0, .4);
  display: grid; place-items: center;
}
.brand-mark::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--leather-2); box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; text-shadow: 0 -1px 0 rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .06); }
.brand-sub { font-size: 11px; color: var(--on-leather-3); margin-top: -1px; }

.mini { padding: 4px 4px 14px; }
.mini-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px; }
.mini-title { font-weight: 600; font-size: 13px; text-shadow: 0 -1px 0 rgba(0, 0, 0, .4); }
.mini-nav { display: flex; gap: 2px; }
.mini-nav button { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--on-leather-2); }
.mini-nav button:hover { background: rgba(255, 255, 255, .08); color: var(--on-leather); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.mini-dow { font-size: 10.5px; color: var(--on-leather-3); font-weight: 500; padding: 2px 0 4px; }
.mini-day {
  position: relative; height: 28px; border-radius: 50%;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--on-leather);
  aspect-ratio: 1; width: 28px; justify-self: center;
}
.mini-day.out { color: var(--on-leather-3); }
.mini-day:hover { background: rgba(255, 255, 255, .09); }
.mini-day.sel { box-shadow: inset 0 0 0 1.5px var(--on-leather-2); }
.mini-day.today { background: #F4E4D2; color: #4A2717; font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, .45), inset 0 -1px 0 rgba(0, 0, 0, .15); }
.mini-day.has::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: currentColor; opacity: .7; }

.nav-section { margin-top: 10px; }
.nav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 4px; font-size: 11.5px; font-weight: 600; color: var(--on-leather-3);
}
.nav-head button { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: var(--on-leather-2); }
.nav-head button:hover { background: rgba(255, 255, 255, .08); color: var(--on-leather); }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 9px; border-radius: 9px; text-align: left;
  color: var(--on-leather); font-weight: 500; font-size: 13.5px;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .4);
  transition: background .15s;
}
.nav-item svg.i { color: var(--on-leather-2); }
.nav-item:hover { background: rgba(255, 255, 255, .065); }
.nav-item.active {
  background: rgba(0, 0, 0, .24);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45), inset 0 0 0 .5px rgba(0, 0, 0, .3), 0 1px 0 rgba(255, 255, 255, .07);
}
.nav-item.active svg.i { color: var(--on-leather); }
.nav-item.drop { background: rgba(255, 255, 255, .14); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 12px; color: var(--on-leather-2); font-variant-numeric: tabular-nums; }
.nav-item .count.alert { color: #FFC9A8; font-weight: 600; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin: 0 3px; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .5); flex: none; }
.nav-item .edit { opacity: 0; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px; color: var(--on-leather-2); }
.nav-item:hover .edit, .nav-item:focus-within .edit { opacity: 1; }
.nav-item .edit:hover { background: rgba(255, 255, 255, .1); }
.nav-item:hover .count + .edit { margin-left: -4px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 6px; }
.tag-pill {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, .2); color: var(--on-leather-2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35), 0 1px 0 rgba(255, 255, 255, .06);
}
.tag-pill:hover, .tag-pill.active { color: var(--on-leather); background: rgba(0, 0, 0, .32); }
.sidebar-foot { display: flex; align-items: center; gap: 6px; padding: 10px 4px 2px; position: relative; z-index: 1; border-top: 1px solid rgba(0, 0, 0, .25); box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset; margin-top: 8px; }
.sidebar-foot .nav-item { width: auto; flex: 1; }

/* ───────── Toolbar ───────── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px 10px;
  min-height: 64px;
}
.tb-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.tb-title h1 { margin: 0; font-size: 25px; line-height: 1.15; font-weight: 300; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title h1 strong { font-weight: 700; }
.tb-title .sub { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.menu-btn { display: none; }
.navgroup { display: flex; align-items: center; background: var(--surface); border-radius: 9px; box-shadow: var(--shadow-1); height: 32px; }
.navgroup button { height: 32px; padding: 0 10px; display: grid; place-items: center; color: var(--ink-2); font-weight: 500; font-size: 13px; }
.navgroup button:hover { color: var(--ink); }
.navgroup .today-btn { border-left: 1px solid var(--hair); border-right: 1px solid var(--hair); padding: 0 13px; color: var(--ink); }
.seg {
  display: inline-flex; padding: 2px; border-radius: 9px; background: var(--surface-3);
  height: 32px; position: relative;
}
.seg button {
  padding: 0 13px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--ink-2);
  position: relative; z-index: 1; transition: color .2s;
}
.seg button.on { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .06); }
.search {
  position: relative; display: flex; align-items: center; width: 200px;
}
.search svg.i { position: absolute; left: 10px; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 32px; padding: 0 10px 0 32px; border-radius: 9px; border: 0;
  background: var(--surface-3); outline: none; transition: background .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }

/* ───────── Quick add ───────── */
.quick { padding: 0 24px 14px; }
.quick-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-1);
  padding: 0 8px 0 14px; height: 44px; transition: box-shadow .2s;
}
.quick-box:focus-within { box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-2); }
.quick-box > svg.i { color: var(--accent); width: 18px; height: 18px; }
.quick-box input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 14.5px; }
.quick-box input::placeholder { color: var(--ink-3); }
.quick-box kbd { font-family: var(--font); font-size: 11px; color: var(--ink-3); background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }
.btn {
  height: 32px; padding: 0 14px; border-radius: 8px; font-weight: 500; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .15), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-plain { background: var(--surface-3); color: var(--ink); }
.btn-plain:hover { background: var(--hair-2); }
.btn-ghost { color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.quick-preview { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 4px 0; min-height: 0; }
.quick-preview:empty { display: none; }
.token {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  padding: 3px 9px 3px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.token svg.i { width: 13px; height: 13px; }

/* ───────── View area ───────── */
.view { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 0 24px 20px; }
.scroll { overflow-y: auto; min-height: 0; flex: 1; }
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }

/* ───────── List mode ───────── */
.listview { max-width: 820px; width: 100%; margin: 0 auto; padding-bottom: 80px; }
.hero {
  display: flex; align-items: center; gap: 18px; padding: 6px 4px 18px;
}
.ring { width: 46px; height: 46px; flex: none; }
.ring circle { fill: none; stroke-width: 4.5; }
.ring .track { stroke: var(--hair-2); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .6s var(--ease); }
.hero-text strong { display: block; font-size: 15px; font-weight: 600; }
.hero-text span { color: var(--ink-3); font-size: 13px; }
.group { margin-bottom: 18px; }
.group-head {
  display: flex; align-items: baseline; gap: 10px; padding: 0 6px 8px;
}
.group-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.group-head h2.overdue { color: var(--danger); }
.group-head .sub { color: var(--ink-3); font-size: 12.5px; flex: 1; }
.rows { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.rows.drop { box-shadow: 0 0 0 2px var(--accent-ring), var(--shadow-1); }
.row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 14px 11px 14px; position: relative; cursor: default;
  transition: background .12s, opacity .35s, transform .35s var(--ease);
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 46px; right: 0; border-top: 1px solid var(--hair); }
.row:hover { background: var(--surface-2); }
.row.sel { background: var(--accent-soft); }
.row.sel + .row::before, .row.sel::before { opacity: 0; }
.row.leaving { opacity: 0; transform: translateX(14px); }
.row.dragging { opacity: .4; }
.row-main { flex: 1; min-width: 0; padding-top: 1px; }
.row-title { font-size: 14.5px; font-weight: 400; overflow-wrap: anywhere; }
.row.done .row-title { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 3px; font-size: 12.5px; color: var(--ink-3); }
.row-meta span { display: inline-flex; align-items: center; gap: 4px; }
.row-meta svg.i { width: 13px; height: 13px; }
.row-meta .late { color: var(--danger); }
.row-meta .listname::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.row-meta .tag { color: var(--accent); }
.row-actions { display: flex; gap: 6px; align-items: center; align-self: center; }
.flag { align-self: center; display: inline-flex; gap: 1px; font-weight: 800; font-size: 13px; letter-spacing: -.05em; }
.flag.p1 { color: var(--info); }
.flag.p2 { color: var(--warn); }
.flag.p3 { color: var(--danger); }

.check {
  --c: var(--accent);
  width: 21px; height: 21px; border-radius: 50%; flex: none; margin-top: 0;
  box-shadow: inset 0 0 0 1.6px color-mix(in srgb, var(--c) 70%, var(--ink-3));
  display: grid; place-items: center; position: relative;
  transition: background .2s, box-shadow .2s, transform .15s;
}
.check:hover { background: color-mix(in srgb, var(--c) 12%, transparent); }
.check:active { transform: scale(.88); }
.check svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset .3s .05s var(--ease); }
.check.on { background: var(--c); box-shadow: inset 0 0 0 1.6px var(--c); }
.check.on svg { stroke-dashoffset: 0; }
.check.sm { width: 15px; height: 15px; }
.check.sm svg { width: 9px; height: 9px; }

.empty {
  text-align: center; padding: 56px 20px; color: var(--ink-3);
}
.empty h3 { margin: 12px 0 4px; color: var(--ink-2); font-size: 15px; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 34ch; font-size: 13px; }
.empty .stamp {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; color: var(--on-leather);
}
.empty .stamp svg.i { width: 28px; height: 28px; }

/* ───────── Time grid (day/week) ───────── */
.cal { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.cal-card { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: hidden; }
.cal-head { display: flex; border-bottom: 1px solid var(--hair); background: var(--surface); position: relative; z-index: 3; }
.gutter { width: 58px; flex: none; }
.dayhead {
  flex: 1; min-width: 0; padding: 10px 8px 8px; display: flex; align-items: baseline; gap: 6px; justify-content: center;
  color: var(--ink-2); font-size: 12.5px; font-weight: 500; border-left: 1px solid var(--hair);
}
.dayhead:hover { color: var(--ink); }
.dayhead .d { font-size: 20px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.dayhead.today .d { color: var(--accent-ink); background: var(--accent); border-radius: 999px; min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 6px; font-weight: 600; }
.dayhead.weekend { color: var(--ink-3); }
.allday { display: flex; border-bottom: 1px solid var(--hair-2); background: var(--surface); position: relative; z-index: 2; }
.allday .gutter { font-size: 10.5px; color: var(--ink-3); text-align: right; padding: 8px 8px 0 0; }
.allday-col { flex: 1; min-width: 0; border-left: 1px solid var(--hair); padding: 4px; display: flex; flex-direction: column; gap: 3px; min-height: 36px; max-height: 118px; overflow-y: auto; }
.allday-col.drop, .mcell.drop { background: var(--accent-soft); }
.grid-scroll { flex: 1; overflow-y: auto; position: relative; min-height: 0; }
.grid { display: flex; position: relative; }
.hours { width: 58px; flex: none; position: relative; height: calc(var(--hour) * 24); }
.hours span { position: absolute; right: 9px; transform: translateY(-50%); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col {
  flex: 1; min-width: 0; position: relative; height: calc(var(--hour) * 24);
  border-left: 1px solid var(--hair);
  background-image:
    linear-gradient(to bottom, var(--hair) 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(var(--hour) / 2), color-mix(in srgb, var(--hair) 55%, transparent) calc(var(--hour) / 2), color-mix(in srgb, var(--hair) 55%, transparent) calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px));
  background-size: 100% var(--hour);
}
.col.today { background-color: color-mix(in srgb, var(--accent) 3.5%, transparent); }
.col.drop { background-color: var(--accent-soft); }
.drop-ghost { position: absolute; left: 3px; right: 3px; border-radius: 6px; border: 1.5px dashed var(--accent); background: var(--accent-soft); pointer-events: none; z-index: 5; font-size: 11px; color: var(--accent); padding: 2px 6px; font-weight: 600; }
.ev {
  --c: var(--accent);
  position: absolute; border-radius: 6px; padding: 3px 6px 3px 8px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 15%, var(--surface));
  color: color-mix(in srgb, var(--c) 72%, var(--ink));
  box-shadow: inset 3px 0 0 var(--c), 0 0 0 .5px color-mix(in srgb, var(--c) 30%, transparent);
  font-size: 12px; line-height: 1.3; cursor: default; z-index: 2;
  display: flex; gap: 6px; align-items: flex-start;
  transition: box-shadow .15s;
}
.ev:hover { box-shadow: inset 3px 0 0 var(--c), 0 0 0 .5px color-mix(in srgb, var(--c) 50%, transparent), var(--shadow-2); z-index: 4; }
.ev.sel { background: var(--c); color: #fff; box-shadow: var(--shadow-2); z-index: 4; }
.ev.sel .check { box-shadow: inset 0 0 0 1.4px rgba(255,255,255,.8); }
.ev .ev-body { min-width: 0; flex: 1; }
.ev .ev-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.ev .ev-time { opacity: .75; font-variant-numeric: tabular-nums; font-size: 11px; }
.ev.short { align-items: center; padding-top: 1px; padding-bottom: 1px; }
.ev.short .ev-body { display: flex; gap: 6px; white-space: nowrap; }
.ev.short .ev-title { -webkit-line-clamp: 1; }
.ev.done { opacity: .55; }
.ev.done .ev-title { text-decoration: line-through; }
.ev .check { margin-top: 1px; }
.ev.ghost, .chip.ghost {
  background: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent);
  opacity: .7;
}
.ev.ghost { border-left: 3px dashed color-mix(in srgb, var(--c) 60%, transparent); }
.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--danger); z-index: 6; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.now-label { position: absolute; right: 6px; transform: translateY(-50%); font-size: 10.5px; font-weight: 700; color: var(--danger); background: var(--surface); padding: 0 2px; z-index: 6; font-variant-numeric: tabular-nums; }

.chip {
  --c: var(--accent);
  display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 2px 6px; border-radius: 5px; font-size: 12px; line-height: 1.35;
  background: color-mix(in srgb, var(--c) 13%, var(--surface));
  color: color-mix(in srgb, var(--c) 70%, var(--ink));
  cursor: default; flex: none;
}
.chip.timed { background: transparent; }
.chip.timed::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; }
.chip:hover { filter: brightness(.97); background: color-mix(in srgb, var(--c) 20%, var(--surface)); }
.chip.sel { background: var(--c); color: #fff; }
.chip.sel::before { background: #fff; }
.chip .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; flex: 1; min-width: 0; }
.chip .tm { font-variant-numeric: tabular-nums; opacity: .7; font-size: 11px; flex: none; }
.chip.done { opacity: .5; }
.chip.done .t { text-decoration: line-through; }
.chip .check { margin: 0; }

/* Day view */
.dayview { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; flex: 1; min-height: 0; }
.daystrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 0 0 12px; }
.daystrip button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 7px; border-radius: 10px;
  color: var(--ink-3); font-size: 11.5px; font-weight: 500; position: relative;
}
.daystrip button:hover { background: var(--surface-3); }
.daystrip button b { font-size: 17px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.daystrip button.today b { color: var(--accent); font-weight: 700; }
.daystrip button.sel b { background: var(--ink); color: var(--bg); }
.daystrip button.sel.today b { background: var(--accent); color: var(--accent-ink); }
.daystrip button i { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); opacity: 0; }
.daystrip button.has i { opacity: .7; }
.side-panel { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; padding-bottom: 20px; }
.side-panel .group { margin: 0; }
.side-panel .row { padding: 9px 12px; }
.side-panel .row + .row::before { left: 42px; }
.side-panel .row-title { font-size: 13.5px; }
.slot-hint { padding: 14px; color: var(--ink-3); font-size: 12.5px; text-align: center; }

/* Month view */
.month { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mhead { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--hair); }
.mhead div { padding: 10px 10px 8px; font-size: 12px; font-weight: 500; color: var(--ink-3); text-align: right; }
.mgrid { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); min-height: 0; }
.mcell { border-left: 1px solid var(--hair); border-top: 1px solid var(--hair); padding: 5px 5px 4px; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; }
.mcell:nth-child(7n+1) { border-left: 0; }
.mcell:nth-child(-n+7) { border-top: 0; }
.mcell.out { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.mcell.out .mnum { color: var(--ink-3); }
.mcell.weekend:not(.out) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.mnum { align-self: flex-end; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; padding: 0 5px; margin-bottom: 1px; }
.mnum:hover { background: var(--surface-3); }
.mcell.today .mnum { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.mcell .more { font-size: 11.5px; color: var(--ink-3); font-weight: 500; text-align: left; padding: 0 6px; }
.mcell .more:hover { color: var(--ink); }

/* ───────── Inspector ───────── */
.inspector {
  position: fixed; top: 10px; right: 10px; bottom: 10px; width: var(--inspector);
  background: var(--surface-2); border-radius: 18px; box-shadow: var(--shadow-pop);
  transform: translateX(calc(100% + 24px)); transition: transform .42s var(--ease);
  display: flex; flex-direction: column; z-index: 40; overflow: hidden;
}
.inspector.open { transform: none; }
.insp-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 16px; }
.insp-head .crumb { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.insp-head .crumb i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.insp-body { flex: 1; overflow-y: auto; padding: 4px 16px 20px; }
.insp-title {
  width: 100%; border: 0; outline: none; background: none; resize: none;
  font-size: 22px; font-weight: 700; letter-spacing: -.025em; line-height: 1.25; padding: 4px 0; overflow: hidden;
}
.insp-title::placeholder { color: var(--ink-3); }
.insp-notes {
  width: 100%; border: 0; outline: none; background: none; resize: none; min-height: 52px;
  color: var(--ink-2); font-size: 13.5px; padding: 4px 0 10px; line-height: 1.5;
}
.insp-notes::placeholder { color: var(--ink-3); }
.igroup { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-1); margin: 0 0 14px; }
.igroup-label { font-size: 12px; color: var(--ink-3); padding: 0 4px 6px; font-weight: 500; }
.irow { display: flex; align-items: center; gap: 10px; padding: 0 12px; min-height: 44px; position: relative; }
.irow + .irow::before { content: ""; position: absolute; top: 0; left: 42px; right: 0; border-top: 1px solid var(--hair); }
.irow > svg.i { color: var(--ink-3); }
.irow .ilabel { flex: 1; font-size: 13.5px; }
.irow .ilabel.muted { color: var(--ink-3); }
.irow input[type="date"], .irow input[type="time"], .irow select, .irow input[type="number"] {
  border: 0; background: var(--surface-3); border-radius: 7px; height: 30px; padding: 0 8px; outline: none; font-size: 13px;
  font-variant-numeric: tabular-nums; max-width: 170px;
}
.irow select { appearance: none; -webkit-appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: right 12px center, right 8px center; background-size: 4px 4px; background-repeat: no-repeat; }
.irow input:focus, .irow select:focus { box-shadow: 0 0 0 3px var(--accent-ring); }
.irow .clear { color: var(--ink-3); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; }
.irow .clear:hover { color: var(--ink); background: var(--surface-3); }
.pseg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; }
.pseg button { height: 26px; min-width: 36px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.pseg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.pseg button.on.p1 { color: var(--info); }
.pseg button.on.p2 { color: var(--warn); }
.pseg button.on.p3 { color: var(--danger); }
.subtasks .irow { min-height: 40px; }
.subtasks .irow + .irow::before { left: 38px; }
.subtasks input[type="text"] { flex: 1; border: 0; outline: none; background: none; font-size: 13.5px; min-width: 0; height: 36px; }
.subtasks .irow.done input[type="text"] { color: var(--ink-3); text-decoration: line-through; }
.subtasks .irow .clear { opacity: 0; }
.subtasks .irow:hover .clear, .subtasks .irow:focus-within .clear { opacity: 1; }
.tagbox { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px 12px; align-items: center; min-height: 44px; }
.tagbox > svg.i { color: var(--ink-3); margin-right: 4px; }
.tagbox .tok { display: inline-flex; align-items: center; gap: 3px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 4px 2px 9px; font-size: 12.5px; font-weight: 500; }
.tagbox .tok button { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
.tagbox .tok button:hover { background: var(--accent-soft); }
.tagbox .tok svg.i { width: 11px; height: 11px; }
.tagbox input { flex: 1; min-width: 80px; border: 0; outline: none; background: none; font-size: 13.5px; height: 26px; }
.insp-foot { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--hair); background: var(--surface-2); }
.insp-foot .btn { flex: 1; justify-content: center; height: 36px; }
.insp-foot .btn-danger { flex: none; width: 44px; padding: 0; }
.insp-meta { color: var(--ink-3); font-size: 11.5px; text-align: center; padding: 2px 0 6px; }

/* ───────── Toasts, dialogs ───────── */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px;
  background: #2A2725; color: #F3EEE9; padding: 9px 9px 9px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-size: 13.5px; font-weight: 500;
  animation: toast-in .35s var(--ease);
  max-width: min(92vw, 460px);
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button { color: #F2B48E; font-weight: 700; padding: 5px 10px; border-radius: 7px; }
.toast button:hover { background: rgba(255, 255, 255, .08); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

dialog {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface-2); color: var(--ink);
  box-shadow: var(--shadow-pop); width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
}
dialog[open] { animation: dlg-in .3s var(--ease); }
dialog::backdrop { background: rgba(20, 14, 10, .32); backdrop-filter: blur(3px); }
@keyframes dlg-in { from { opacity: 0; transform: scale(.97) translateY(6px); } }
.dlg { padding: 20px 20px 18px; }
.dlg h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.dlg p { margin: 0 0 14px; color: var(--ink-2); font-size: 13.5px; }
.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg .field { width: 100%; height: 38px; border: 0; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-1); padding: 0 12px; outline: none; font-size: 14px; }
.dlg .field:focus { box-shadow: 0 0 0 3px var(--accent-ring); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatch.on { box-shadow: 0 0 0 2.5px var(--surface-2), 0 0 0 4.5px var(--c); }
.dlg .igroup { margin-bottom: 12px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13.5px; align-items: center; }
.keys kbd { font-family: var(--font); font-size: 12px; font-weight: 600; background: var(--surface); box-shadow: var(--shadow-1); border-radius: 6px; padding: 3px 7px; justify-self: start; min-width: 24px; text-align: center; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.tabbar, .m-only, .insp-head .grab { display: none; }
.scrim { display: none; }

/* ───────── Responsive ───────── */
@media (max-width: 1180px) {
  .dayview { grid-template-columns: minmax(0, 1fr) 270px; }
  .search { width: 160px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw);
    transform: translateX(-104%); transition: transform .4s var(--ease); box-shadow: var(--shadow-pop);
  }
  .app.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 14, 10, .35); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 25; }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: grid; }
  .dayview { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .dayview .side-panel { order: -1; max-height: 34vh; }
  .inspector { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 88dvh; border-radius: 20px 20px 0 0; transform: translateY(104%); }
  .inspector.open { transform: none; }
}
/* ───────── Sync pill, form bits (all sizes) ───────── */
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: rgba(0, 0, 0, .22); color: var(--on-leather-2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .4), 0 1px 0 rgba(255, 255, 255, .06);
}
.sync-pill:hover { color: var(--on-leather); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--on-leather-3); flex: none; }
.sync-pill[data-state="synced"] .sync-dot { background: #8FD18A; box-shadow: 0 0 6px rgba(143, 209, 138, .7); }
.sync-pill[data-state="syncing"] .sync-dot { background: #F2C46D; animation: pulse 1s ease-in-out infinite; }
.sync-pill[data-state="offline"] .sync-dot, .sync-pill[data-state="signedout"] .sync-dot { background: #E7B48C; }
.sync-pill[data-state="error"] .sync-dot { background: #F08A7E; }
@keyframes pulse { 50% { opacity: .35; } }
.dlg .sync-pill, .igroup .sync-pill { background: var(--surface-3); color: var(--ink-2); box-shadow: none; }
.dlg .sync-pill:hover, .igroup .sync-pill:hover { color: var(--ink); }
.dlg .sync-pill .sync-dot, .igroup .sync-pill .sync-dot { background: var(--ink-3); }
.dlg .sync-pill[data-state="synced"] .sync-dot, .igroup .sync-pill[data-state="synced"] .sync-dot { background: #3FA34D; box-shadow: none; }
.dlg .sync-pill[data-state="syncing"] .sync-dot, .igroup .sync-pill[data-state="syncing"] .sync-dot { background: var(--warn); }
.dlg .sync-pill[data-state="error"] .sync-dot, .igroup .sync-pill[data-state="error"] .sync-dot { background: var(--danger); }
.sidebar-foot .sync-pill { flex: none; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.form-msg { min-height: 1.2em; margin: 12px 2px 0 !important; font-size: 13px !important; color: var(--ink-2); }
.form-msg.err { color: var(--danger); }
.muted-val { color: var(--ink-3); font-size: 13.5px; }

/* Composer sheet (used on phones) */
dialog.sheet { width: min(520px, calc(100vw - 32px)); padding: 0; overflow: hidden; }
.comp-head {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 16px; position: relative;
  color: var(--on-leather); background-color: var(--leather-2);
  background-image: var(--grain-coarse, none), var(--grain-fine, none), linear-gradient(180deg, var(--leather-1), var(--leather-2));
  background-blend-mode: soft-light, overlay, normal; background-size: 260px 260px, 140px 140px, 100% 100%;
}
.comp-head::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 6px; border-bottom: 1.5px dashed var(--stitch); pointer-events: none; }
.comp-head strong { font-size: 16px; font-weight: 700; text-shadow: 0 -1px 0 rgba(0, 0, 0, .45); }
.comp-btn { font-size: 15px; color: var(--on-leather-2); padding: 6px 8px; border-radius: 8px; text-shadow: 0 -1px 0 rgba(0, 0, 0, .35); }
.comp-btn.comp-add { color: #4A2717; background: #F4E4D2; font-weight: 700; padding: 6px 16px; border-radius: 999px; text-shadow: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .45), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.comp-body { padding: 16px 16px 18px; }
.comp-body input {
  width: 100%; border: 0; outline: none; background: none; font-size: 21px; font-weight: 500; letter-spacing: -.015em; padding: 4px 0 6px;
}
.comp-body input::placeholder { color: var(--ink-3); font-weight: 400; }
.comp-body .quick-preview { padding: 2px 0 4px; }
.comp-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 0 2px; }
.cchip {
  height: 32px; padding: 0 13px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-1);
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s;
}
.cchip.list::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.cchip.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.cchip.on.list::before { background: var(--accent-ink); }
.comp-body .hint { margin: 12px 2px 0; }

/* Phone month: compact grid + selected-day agenda */
.mmonth { padding: 4px 6px 10px; }
.mm-head { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11.5px; font-weight: 500; color: var(--ink-3); padding: 8px 0 4px; }
.mm-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.mday { height: 50px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 3px; border-radius: 10px; }
.mday .n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; font-variant-numeric: tabular-nums; }
.mday.out .n { color: var(--ink-3); }
.mday.today .n { color: var(--accent); font-weight: 700; }
.mday.sel .n { background: var(--ink); color: var(--bg); font-weight: 500; }
.mday.sel.today .n { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.mday.drop { background: var(--accent-soft); }
.mday .dots { display: flex; gap: 3px; height: 5px; }
.mday .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.mlist { padding: 16px 0 0; }

/* Swipe actions */
.rows { position: relative; }
.rows > .row { background: var(--surface); z-index: 1; }
.rows > .row:hover { background: var(--surface-2); }
.rows > .row.sel { background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.swipe-bg {
  position: absolute; left: 0; right: 0; z-index: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; color: #fff; font-weight: 600; font-size: 14px; background: var(--ink-3); transition: background .15s;
}
.swipe-bg span { display: inline-flex; align-items: center; gap: 8px; opacity: 0; transition: opacity .15s, transform .15s; }
.swipe-bg svg.i { width: 19px; height: 19px; stroke-width: 2.2; }
.swipe-bg.right .sw-l, .swipe-bg.left .sw-r { opacity: .8; }
.swipe-bg.right.armed { background: #3F9B54; }
.swipe-bg.left.armed { background: var(--danger); }
.swipe-bg.armed span { opacity: 1; transform: scale(1.06); }

/* ───────── Phone ───────── */
@media (max-width: 700px) {
  :root { --hour: 56px; }
  .m-only { display: grid; }
  .menu-btn { display: none !important; }
  .quick { display: none; }

  /* Leather header — a planner cover, stitched along the bottom edge */
  .toolbar {
    flex-wrap: wrap; align-items: center; gap: 12px 8px; min-height: 0;
    padding: calc(env(safe-area-inset-top) + 14px) 16px 22px;
    margin-bottom: 12px; position: relative; z-index: 10; color: var(--on-leather);
    border-radius: 0 0 22px 22px;
    background-color: var(--leather-2);
    background-image: var(--grain-coarse, none), var(--grain-fine, none), radial-gradient(120% 100% at 12% 0%, var(--leather-hi), transparent 62%), linear-gradient(180deg, var(--leather-1), var(--leather-2));
    background-blend-mode: soft-light, overlay, normal, normal;
    background-size: 260px 260px, 140px 140px, 100% 100%, 100% 100%;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .4), 0 8px 22px rgba(40, 20, 10, .22);
  }
  .toolbar::after {
    content: ""; position: absolute; left: 12px; right: 12px; bottom: 8px; height: 0;
    border-bottom: 1.5px dashed var(--stitch); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .5)); pointer-events: none;
  }
  .tb-title { order: 0; flex: 1 1 calc(100% - 60px); flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; }
  .tb-title h1 { font-size: 30px; line-height: 1.1; letter-spacing: -.03em; text-shadow: 0 -1px 0 rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 255, 255, .05); }
  .tb-title .sub { display: block; font-size: 13.5px; color: var(--on-leather-2); text-shadow: 0 -1px 0 rgba(0, 0, 0, .35); margin-top: 2px; }
  .toolbar .icon-btn {
    order: 1; width: 38px; height: 38px; border-radius: 50%; color: var(--on-leather);
    background: rgba(0, 0, 0, .2); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .07);
  }
  .toolbar .icon-btn svg.i { width: 18px; height: 18px; }
  .toolbar.mode-list .seg, .toolbar.mode-list .navgroup { display: none; }
  .seg {
    order: 2; flex: 1 1 0; height: 36px; border-radius: 11px; padding: 3px;
    background: rgba(0, 0, 0, .26); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 255, 255, .07);
  }
  .seg button { flex: 1; padding: 0 4px; border-radius: 8px; font-size: 13.5px; color: var(--on-leather-2); text-shadow: 0 -1px 0 rgba(0, 0, 0, .4); }
  .seg button.on { background: #F4E4D2; color: #4A2717; text-shadow: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .45), inset 0 -1px 0 rgba(0, 0, 0, .1); }
  .navgroup {
    order: 3; height: 36px; border-radius: 11px;
    background: rgba(0, 0, 0, .26); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 255, 255, .07);
  }
  .navgroup button { height: 36px; color: var(--on-leather); text-shadow: 0 -1px 0 rgba(0, 0, 0, .4); }
  .navgroup .today-btn { border-color: rgba(0, 0, 0, .3); color: var(--on-leather); padding: 0 12px; }
  .search { order: 4; flex: 1 1 100%; display: none; width: auto; }
  .toolbar.searching .search { display: flex; }
  .search input { height: 40px; border-radius: 11px; font-size: 16px; color: var(--on-leather); background: rgba(0, 0, 0, .26); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5); }
  .search input::placeholder { color: var(--on-leather-3); }
  .search svg.i { color: var(--on-leather-2); }
  .search input:focus { background: rgba(0, 0, 0, .32); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5), 0 0 0 2px rgba(244, 228, 210, .35); }

  .view { padding: 0 12px calc(96px + env(safe-area-inset-bottom)); }
  .listview { padding-bottom: 24px; }
  .hero { padding: 2px 6px 16px; }
  .group-head { padding: 0 8px 8px; }
  .group-head h2 { font-size: 17px; }
  .rows { border-radius: 14px; }
  .row { padding: 13px 14px; gap: 13px; min-height: 54px; }
  .row-title { font-size: 16px; }
  .row-meta { font-size: 13px; }
  .check { width: 24px; height: 24px; }
  .check svg { width: 13px; height: 13px; }
  .row + .row::before { left: 51px; }
  .row-actions .lbl { display: none; }
  .row-actions [data-action="delete"] { display: none; }
  .row-actions .btn { padding: 0 8px; }
  .row-actions { gap: 0; }
  .flag { font-size: 14px; }
  .empty { padding: 48px 16px; }

  /* Calendar on a phone */
  .cal-card { border-radius: 16px; }
  .gutter, .hours { width: 46px; }
  .hours span { font-size: 10.5px; right: 7px; }
  .dayhead { flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px 8px; font-size: 11.5px; }
  .dayhead .d { font-size: 18px; }
  .dayhead.today .d { min-width: 30px; height: 30px; }
  .allday-col { min-height: 34px; }
  .chip { font-size: 12.5px; padding: 3px 7px; }
  .ev { font-size: 12.5px; }
  .daystrip { gap: 2px; padding: 0 2px 10px; }
  .daystrip button b { width: 36px; height: 36px; font-size: 18px; }

  /* Leather tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    height: calc(66px + env(safe-area-inset-bottom)); padding: 9px 8px env(safe-area-inset-bottom);
    align-items: flex-start; justify-content: space-around;
    color: var(--on-leather); border-radius: 22px 22px 0 0;
    background-color: var(--leather-2);
    background-image: var(--grain-coarse, none), var(--grain-fine, none), linear-gradient(180deg, var(--leather-1), var(--leather-2));
    background-blend-mode: soft-light, overlay, normal;
    background-size: 260px 260px, 140px 140px, 100% 100%;
    box-shadow: 0 -1px 0 rgba(0, 0, 0, .35), 0 -8px 24px rgba(40, 20, 10, .2);
  }
  .tabbar::before {
    content: ""; position: absolute; left: 12px; right: 12px; top: 6px; height: 0;
    border-top: 1.5px dashed var(--stitch); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .5)); pointer-events: none;
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 6px;
    font-size: 10.5px; font-weight: 500; letter-spacing: .01em; color: var(--on-leather-3);
    text-shadow: 0 -1px 0 rgba(0, 0, 0, .45); transition: color .2s;
  }
  .tab svg.i { width: 24px; height: 24px; stroke-width: 1.6; filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .4)); }
  .tab.on { color: #F7E8D7; }
  .tab.on svg.i { filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .4)) drop-shadow(0 0 6px rgba(255, 220, 190, .25)); }
  .tab-add {
    position: relative; z-index: 1; flex: none; width: 60px; height: 60px; margin-top: -24px; border-radius: 50%; display: grid; place-items: center;
    color: #4A2717;
    background: radial-gradient(circle at 36% 28%, #FCF1E6, #E4C3A0 55%, #A97A50);
    box-shadow: 0 0 0 5px rgba(0, 0, 0, .18), 0 8px 18px rgba(0, 0, 0, .38), inset 0 -2px 4px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .7);
    transition: transform .15s;
  }
  .tab-add:active { transform: scale(.93); }
  .tab-add svg.i { width: 26px; height: 26px; stroke-width: 2.6; }

  .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); }

  /* Drawer above the tab bar */
  .sidebar { z-index: 50; padding-top: calc(env(safe-area-inset-top) + 22px); padding-bottom: calc(env(safe-area-inset-bottom) + 14px); }
  .scrim { z-index: 45; }

  /* Detail sheet: leather header with a grab handle */
  .inspector { height: 90dvh; z-index: 60; background: var(--bg); }
  .insp-head {
    position: relative; padding: 18px 14px 18px 18px; color: var(--on-leather);
    background-color: var(--leather-2);
    background-image: var(--grain-coarse, none), var(--grain-fine, none), linear-gradient(180deg, var(--leather-1), var(--leather-2));
    background-blend-mode: soft-light, overlay, normal;
    background-size: 260px 260px, 140px 140px, 100% 100%;
    touch-action: none;
  }
  .insp-head::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 6px; border-bottom: 1.5px dashed var(--stitch); pointer-events: none; }
  .insp-head .grab { display: block; position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: rgba(0, 0, 0, .35); box-shadow: 0 1px 0 rgba(255, 255, 255, .08); }
  .insp-head .crumb { color: var(--on-leather); font-size: 13px; font-weight: 500; text-shadow: 0 -1px 0 rgba(0, 0, 0, .4); }
  .insp-head .crumb i { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .3); }
  .insp-head .icon-btn { color: var(--on-leather); background: rgba(0, 0, 0, .2); border-radius: 50%; }
  .insp-body { padding-top: 14px; }
  .insp-title { font-size: 24px; }
  .irow { min-height: 48px; }
  .irow input[type="date"], .irow input[type="time"], .irow select { font-size: 15px; height: 34px; }
  .subtasks input[type="text"], .tagbox input { font-size: 16px; }
  .insp-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .insp-foot .btn { height: 44px; font-size: 15px; border-radius: 12px; }
  .insp-foot .btn-danger { width: 50px; }

  /* Composer as a bottom sheet */
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; max-height: 92dvh; }
  dialog.sheet[open] { animation: sheet-in .38s var(--ease); }
  .comp-head { padding-top: 16px; }
  .comp-body { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }

  .dlg .field, .dlg input { font-size: 16px; }
}
@keyframes sheet-in { from { transform: translateY(100%); } }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
