/* mailmill web client. Tokens: flour ground, ink text, mill-race accent, grain-gold unread. */
:root {
  --ground: #EDF0F3;
  --surface: #FFFFFF;
  --sunken: #E3E7EC;
  --ink: #1B2430;
  --muted: #5D6876;
  --line: #D5DBE2;
  --accent: #0B6E69;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEFED;
  --grain: #C8961A;
  --danger: #B42318;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  --rail: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #11151B; --surface: #192029; --sunken: #0D1116; --ink: #E3E7ED; --muted: #94A0AE;
    --line: #29323D; --accent: #3DB5AB; --accent-ink: #062523; --accent-soft: #163632; --grain: #E2B341; --danger: #F97066;
  }
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background: var(--ground); color: var(--ink); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- buttons and fields ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { padding: 0; width: 36px; }
.btn svg, .rail svg, .tabbar svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=time], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); font-size: 16px; /* 16px stops iOS zoom-on-focus */
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .field { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }

/* ---- login ---- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); }
.login .mark { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 18px; }
.login h1 { font: 700 30px/1.1 var(--font-title); margin: 0 0 6px; letter-spacing: -0.01em; }
.login p { margin: 0 0 24px; color: var(--muted); }
.login .btn { width: 100%; min-height: 44px; }
.error { color: var(--danger); min-height: 1.4em; margin: 0 0 10px; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; height: 100%; }
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0;
  border-right: 1px solid var(--line); background: var(--surface);
}
.rail a, .tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted);
  font-size: 11px; border-radius: var(--radius-m);
}
.rail a { width: 66px; padding: 8px 0; }
.rail a span, .tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
.rail a[aria-current=page], .tabbar a[aria-current=page] { color: var(--accent); }
.rail a[aria-current=page] { background: var(--accent-soft); }
.rail .spacer { flex: 1; }
.rail .mark { width: 34px; height: 34px; border-radius: 9px; margin-bottom: 10px; }
.main { min-width: 0; height: 100%; overflow: hidden; }
.tabbar { display: none; }

/* ---- panes ---- */
.panes { display: grid; height: 100%; }
.panes.mail { grid-template-columns: 220px minmax(300px, 380px) 1fr; }
.panes.two { grid-template-columns: minmax(280px, 360px) 1fr; }
.pane { min-width: 0; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; border-right: 1px solid var(--line); }
.pane:last-child { border-right: 0; }
.pane.side { background: var(--ground); padding: 10px 8px; }
.pane.list { background: var(--surface); display: flex; flex-direction: column; }
.pane.detail { background: var(--surface); display: flex; flex-direction: column; }
.pane-head {
  position: sticky; top: 0; z-index: 2; background: inherit; padding: calc(12px + var(--safe-t)) 16px 10px;
  display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line);
}
.pane-head h2 { font: 700 22px/1.2 var(--font-title); margin: 0; flex: 1; min-width: 0; letter-spacing: -0.01em; }
.pane-head .back { display: none; }
.search { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* mailbox list */
.folders a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-s);
  text-decoration: none; color: var(--ink);
}
.folders a[aria-current=true] { background: var(--sunken); font-weight: 600; }
.folders .count { margin-left: auto; font-size: 13px; color: var(--muted); }
.folders .count.unread { color: var(--ink); font-weight: 600; }
.folders .compose { width: 100%; margin-bottom: 12px; min-height: 40px; }
.folders .sub { padding-left: 26px; }

/* message list */
.msgs { list-style: none; margin: 0; padding: 0; }
.msgs li { border-bottom: 1px solid var(--line); }
.msgs a { display: grid; grid-template-columns: 14px 1fr auto; gap: 2px 8px; padding: 11px 16px 11px 8px; text-decoration: none; color: inherit; }
.msgs a[aria-current=true] { background: var(--accent-soft); }
.msgs .dot { grid-row: 1; align-self: center; width: 8px; height: 8px; border-radius: 50%; }
.msgs .unread .dot { background: var(--grain); }
.msgs .from { font-weight: 500; }
.msgs .unread .from, .msgs .unread .subj { font-weight: 650; }
.msgs .date { font-size: 13px; color: var(--muted); }
.msgs .subj, .msgs .prev { grid-column: 2 / 4; }
.msgs .prev { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msgs .flag { color: var(--grain); }
.more { margin: 14px auto; display: flex; }

/* reader */
.reader-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.reader-head h1 { font: 700 21px/1.25 var(--font-title); margin: 0 0 12px; overflow-wrap: anywhere; }
.reader-meta { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.reader-meta .who { font-weight: 600; }
.reader-meta .to { font-size: 13px; color: var(--muted); }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.attachments a { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); text-decoration: none; font-size: 14px; }
.attachments svg { width: 16px; height: 16px; vertical-align: -3px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notice { padding: 8px 20px; font-size: 14px; background: var(--sunken); display: flex; gap: 10px; align-items: center; }
.notice.warn { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); font-weight: 600; }
.notice.warn svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.notice.info { color: var(--muted); }
.mailframe { flex: 1; width: 100%; min-height: 300px; border: 0; background: #fff; }

/* ---- sheets (modals) ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(10 14 20 / 45%); z-index: 50; display: grid; place-items: center; padding: 16px; }
.sheet {
  width: min(640px, 100%); max-height: calc(100% - 32px); overflow: auto; background: var(--surface);
  border-radius: var(--radius-l); box-shadow: 0 24px 60px rgb(0 0 0 / 25%);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: inherit; z-index: 1; }
.sheet-head h2 { font: 700 18px/1.2 var(--font-title); margin: 0; flex: 1; }
.sheet-body { padding: 16px; }
.compose .addr { display: grid; grid-template-columns: 56px 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.compose .addr label { color: var(--muted); font-size: 14px; padding-left: 16px; }
.compose .addr input { border: 0; border-radius: 0; background: transparent; }
.compose textarea { border: 0; border-radius: 0; min-height: 260px; padding: 14px 16px; }
.compose .files { padding: 8px 16px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--sunken); font-size: 13px; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; color: var(--muted); }

/* ---- calendar ---- */
.cal { display: flex; height: 100%; background: var(--surface); }
.cal-main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; background: var(--surface); }
.cal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; min-height: 0; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-dow div { padding: 6px 8px; font-size: 12px; color: var(--muted); }
.day { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; min-height: 0; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.day:nth-child(7n) { border-right: 0; }
.day .n, .mday .n { font-size: 13px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.day.other .n, .mday.other .n { color: var(--muted); opacity: .6; }
.day.today .n, .mday.today .n { background: var(--accent); color: var(--accent-ink); font-weight: 700; opacity: 1; }
.day.selected { background: var(--accent-soft); }
.ev { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--accent); }
.ev.allday { background: var(--accent); color: var(--accent-ink); border-left: 0; }
button.ev { display: block; min-width: 0; margin: 1px 3px; border: 0; border-left: 3px solid var(--accent); font: inherit; font-size: 12px; line-height: 17px; text-align: left; cursor: pointer; }
button.ev.allday { border-left: 0; font-weight: 600; }
button.ev:hover { background: color-mix(in srgb, var(--accent) 26%, var(--surface)); }
button.ev.allday:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
.ev .tm { margin-right: 4px; color: var(--muted); }
.ev.cl { margin-left: 0; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.ev.cr { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li { border-bottom: 1px solid var(--line); }
.agenda button { width: 100%; display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 10px 16px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.agenda .when { font-size: 13px; color: var(--muted); white-space: pre-line; }
.agenda .t { display: block; font-weight: 600; overflow-wrap: anywhere; }
.agenda .muted { display: block; }
.agenda-title { font: 650 14px/1.2 var(--font-title); margin: 0; padding: 14px 16px 6px; color: var(--muted); }

/* view switcher */
.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.seg button { min-height: 34px; padding: 0 14px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg button:focus-visible { outline-offset: -2px; }
.cal-bar { display: flex; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.cal-bar .seg { flex: 1; }
.cal-bar .seg button { flex: 1; }

/* month view: one grid per week row, events laid out in lanes so multi-day bars stay continuous */
.cal-month { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(6, minmax(0, 1fr)); }
.wk { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 0; overflow: hidden; border-bottom: 1px solid var(--line); }
.wk:last-child { border-bottom: 0; }
.mday { grid-row: 1 / -1; min-width: 0; padding: 4px; border-right: 1px solid var(--line); cursor: pointer; }
.mday:nth-child(7) { border-right: 0; }
.mday.today { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.mday .n { cursor: pointer; }
.mday .n:hover { background: var(--sunken); }
.mday.today .n:hover { background: var(--accent); }
.wk .ev, .wk .ev-more { align-self: center; }
.ev-more { min-width: 0; padding: 0 8px; border: 0; background: none; font: inherit; font-size: 12px; color: var(--muted); text-align: left; cursor: pointer; white-space: nowrap; }
.ev-more:hover { color: var(--ink); text-decoration: underline; }

/* week and day views: hour grid with an all-day row on top */
.tg { --gut: 56px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tg-head, .tg-allday, .tg-body { display: grid; grid-template-columns: var(--gut) repeat(var(--n), minmax(0, 1fr)); }
.tg-head, .tg-allday { overflow-y: hidden; padding-right: var(--sbw, 0px); }
.tg-head { border-bottom: 1px solid var(--line); }
.tg-allday { max-height: 30vh; overflow-y: auto; padding-bottom: 3px; border-bottom: 1px solid var(--line); box-shadow: 0 2px 4px rgb(0 0 0 / 6%); position: relative; z-index: 2; background: var(--surface); }
.v-day .tg-head { display: none; }
.tg-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 8px; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; min-width: 0; }
.tg-day .dow { font-size: 12px; }
.tg-day .dn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); font: 600 19px/1 var(--font-title); }
.tg-day:hover .dn { background: var(--sunken); }
.tg-day.today .dow { color: var(--accent); font-weight: 600; }
.tg-day.today .dn, .tg-day.today:hover .dn { background: var(--accent); color: var(--accent-ink); }
.ad-label { grid-row: 1 / -1; grid-column: 1; padding: 6px 6px 0 0; font-size: 11px; line-height: 1.2; color: var(--muted); text-align: right; hyphens: auto; }
.ad-cell { grid-row: 1 / -1; border-left: 1px solid var(--line); cursor: pointer; }
.ad-cell:hover { background: var(--ground); }
.tg-allday .ev { align-self: center; margin-top: 2px; margin-bottom: 0; }
.tg-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.tg-body { height: calc(24 * var(--hour)); }
.tg-hours { position: relative; }
.tg-hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); }
.tg-col {
  position: relative; min-width: 0; container-type: inline-size; border-left: 1px solid var(--line); cursor: default; touch-action: pan-y; user-select: none;
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px); background-size: 100% var(--hour);
}
.v-week .tg-col.today { background-color: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.tev {
  position: absolute; z-index: 1; display: flex; flex-direction: column; overflow: hidden; padding: 3px 6px; border: 0; border-left: 3px solid var(--accent);
  border-radius: 4px; background: var(--accent-soft); color: var(--ink); font: inherit; font-size: 12px; line-height: 1.3;
  text-align: left; cursor: pointer; box-shadow: 0 0 0 1px var(--surface);
}
.tev:hover { background: color-mix(in srgb, var(--accent) 26%, var(--surface)); z-index: 2; }
.tev .tt { display: block; font-weight: 600; overflow-wrap: break-word; hyphens: auto; }
.tev .tm, .tev .tl { display: block; color: var(--muted); overflow-wrap: break-word; }
.tev.short { display: block; padding-top: 1px; padding-bottom: 1px; white-space: nowrap; text-overflow: ellipsis; }
.tev.short .tt, .tev.short .tm { display: inline; }
/* Wide columns keep text clear of later overlapping blocks; narrow ones need the full width for words. */
@container (min-width: 280px) { .tev.covered { padding-right: calc(var(--cover) + 6px); } }
.tg-sel {
  position: absolute; left: 2px; right: 3px; z-index: 3; padding: 2px 6px; border-radius: 4px; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 22%, transparent); border: 1px solid var(--accent); font-size: 12px; font-weight: 600; color: var(--ink);
}
.now { position: absolute; left: -1px; right: 0; z-index: 0; height: 2px; margin-top: -1px; background: var(--danger); pointer-events: none; }
.now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* mini month sidebar (wide screens) */
.cal-side { display: none; }
.mini-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.mini-head h3 { flex: 1; margin: 0 0 0 6px; font: 650 15px/1.2 var(--font-title); }
.mini-head .btn.icon { width: 30px; min-height: 30px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; text-align: center; }
.mini-grid .mw { padding: 2px 0 4px; font-size: 11px; color: var(--muted); }
.md { height: 30px; padding: 0; display: grid; place-items: center; border: 0; background: none; font: inherit; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.md span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.md:hover span { background: var(--sunken); }
.md.other { color: var(--muted); }
.md.inview { background: var(--accent-soft); }
.mini-grid .md.inview:nth-child(7n+1) { border-top-left-radius: 15px; border-bottom-left-radius: 15px; }
.mini-grid .md.inview:nth-child(7n) { border-top-right-radius: 15px; border-bottom-right-radius: 15px; }
.md.sel span { color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--accent); }
.md.today span, .md.today:hover span { background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: none; }
@media (min-width: 1100px) {
  .cal-side { display: block; flex: none; width: 244px; padding: calc(14px + var(--safe-t)) 12px 14px; border-right: 1px solid var(--line); background: var(--ground); overflow-y: auto; }
}
@media (max-width: 760px) {
  .cal-bar { padding: 6px 12px; }
  .v-month .cal-grid { flex: 1 1 0; min-height: 210px; }
  .agenda-wrap { flex: 0 1 auto; max-height: 42%; overflow-y: auto; border-top: 1px solid var(--line); }
  .tg { --gut: 56px; }
  .ad-label { font-size: 10px; padding-right: 4px; }
  .tev { font-size: 13px; }
}

/* ---- contacts and notes ---- */
.people { list-style: none; margin: 0; padding: 0; }
.people a { display: flex; gap: 12px; align-items: center; padding: 10px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.people a[aria-current=true] { background: var(--accent-soft); }
.people .letter { padding: 6px 16px; font-size: 13px; font-weight: 700; color: var(--muted); background: var(--ground); }
.card-view { padding: 24px 20px; max-width: 640px; }
.card-view h1 { font: 700 26px/1.2 var(--font-title); margin: 12px 0 2px; }
.card-view dl { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; margin: 22px 0; }
.card-view dt { color: var(--muted); font-size: 14px; }
.card-view dd { margin: 0; overflow-wrap: anywhere; }
.big-avatar { width: 72px; height: 72px; font-size: 26px; }
.multi .row { margin-bottom: 8px; }
.multi .row select { width: 110px; flex: none; }

.notes-list .note-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.notes-list .note-item[aria-current=true] { background: var(--accent-soft); }
.notes-list .note-item strong { display: block; }
.notes-list .pin { color: var(--grain); margin-right: 4px; }
.note-edit { display: flex; flex-direction: column; flex: 1; }
.note-edit input { border: 0; font: 700 24px/1.2 var(--font-title); padding: 18px 20px 6px; background: transparent; }
.note-edit textarea { flex: 1; border: 0; padding: 8px 20px 20px; font-size: 16px; background: transparent; resize: none; }
.saved { font-size: 13px; color: var(--muted); }

/* ---- tasks ---- */
.lists a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.lists a[aria-current=true] { background: var(--accent-soft); }
.swatch { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.lists .count { color: var(--muted); font-size: 14px; }
.task-add { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.task-add input[type=text] { flex: 1 1 100%; }
.task-add input[type=date], .task-add input[type=time] { flex: 1 1 0; width: auto; min-width: 0; }
.task-add .btn { flex: none; width: 38px; min-height: 38px; }
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li { display: flex; align-items: flex-start; gap: 4px; padding: 4px 16px 4px 6px; border-bottom: 1px solid var(--line); }
.tick { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; padding: 0; cursor: pointer; }
.tick .circle {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center;
  color: var(--accent-ink); transition: background .12s, border-color .12s;
}
.tick:hover .circle { border-color: var(--accent); }
.tick[aria-checked=true] .circle { background: var(--accent); border-color: var(--accent); }
.tick svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.tick[aria-checked=true] svg { opacity: 1; }
.task-body { flex: 1; min-width: 0; padding: 9px 0; border: 0; background: none; text-align: left; cursor: pointer; }
.task-body .t { display: block; overflow-wrap: anywhere; }
.task-body .meta { display: block; margin-top: 1px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-body .meta.overdue { color: var(--danger); }
.task-body .prio { color: var(--grain); font-weight: 700; margin-right: 6px; }
.tasks .done .t { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.done-toggle { align-self: flex-start; margin: 8px 6px; color: var(--muted); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px var(--surface); }
.swatches button[aria-checked=true] { border-color: var(--ink); }
@media (min-width: 761px) {
  .task-add input[type=text] { flex-basis: 200px; }
  .task-add input[type=date] { flex: 0 1 150px; }
  .task-add input[type=time] { flex: 0 1 110px; }
}

/* settings */
.settings { padding: 8px 20px 40px; max-width: 720px; }
.settings section { margin: 22px 0; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.settings h3 { font: 700 17px/1.2 var(--font-title); margin: 0 0 6px; }
.settings p { margin: 0 0 12px; color: var(--muted); }
.tokens { list-style: none; padding: 0; margin: 0 0 12px; }
.tokens li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tokens li.device { flex-wrap: wrap; }
.device-actions { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.device-state { color: var(--danger); }
.secret { font-family: ui-monospace, Menlo, monospace; background: var(--sunken); padding: 10px 12px; border-radius: var(--radius-s); user-select: all; overflow-wrap: anywhere; }
.qr { display: block; max-width: 100%; margin: 0 0 12px; border-radius: var(--radius-s); image-rendering: pixelated; }
.codes { list-style: none; padding: 12px; margin: 0 0 12px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; font-family: ui-monospace, Menlo, monospace; background: var(--sunken); border-radius: var(--radius-s); user-select: all; }
.twofa-confirm { margin-top: 16px; }
.login small { font-size: 13px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: var(--radius-m); z-index: 100;
  transition: opacity .18s, transform .18s; pointer-events: none; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- phone layout: stack navigation + bottom tab bar ---- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 0 calc(6px + var(--safe-b));
  }
  .tabbar a { padding: 4px 0; min-width: 0; }
  .panes.mail, .panes.two { grid-template-columns: 1fr; }
  .pane { border-right: 0; }
  .panes > .pane { display: none; }
  .panes[data-level="0"] > .pane:nth-child(1),
  .panes[data-level="1"] > .pane:nth-child(2),
  .panes[data-level="2"] > .pane:nth-child(3) { display: flex; flex-direction: column; }
  .panes.two[data-level="1"] > .pane:nth-child(2) { display: flex; }
  .pane.side { padding-top: calc(10px + var(--safe-t)); }
  .pane-head .back { display: inline-flex; }
  .sheet-backdrop { padding: 0; place-items: end stretch; }
  .sheet { width: 100%; max-height: calc(100% - var(--safe-t) - 12px); border-radius: var(--radius-l) var(--radius-l) 0 0; padding-bottom: var(--safe-b); }
  .cal-grid .ev { display: none; }
  .day { align-items: center; }
  .cal .pane-head h2 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cal .pane-head .label { display: none; }
  .cal .pane-head .btn.primary { width: 36px; padding: 0; }
  .sheet-head .btn.iconic .label { display: none; }
  .sheet-head .btn.iconic { width: 36px; padding: 0; }
  .day.has-ev::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
  .card-view dl { grid-template-columns: 1fr; gap: 2px; }
  .card-view dd { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- filters and spam (settings) ---- */
.row.wrap { flex-wrap: wrap; }
.settings h4 { font: 650 14px/1.2 var(--font); margin: 16px 0 4px; }
.settings .filter-note { background: var(--sunken); color: var(--ink); padding: 10px 12px; border-radius: var(--radius-s); }
.rules { list-style: none; padding: 0; margin: 0 0 14px; }
.rule { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rule-name { font-weight: 600; overflow-wrap: anywhere; }
.rule-sum { font-size: 14px; overflow-wrap: anywhere; }
.rule.off .rule-name, .rule.off .rule-sum { color: var(--muted); }
.rule-tools { display: flex; gap: 2px; }
.rule-tools .btn:disabled { opacity: .3; cursor: default; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 42px; height: 26px; margin: 0;
  border-radius: 13px; background: var(--line); cursor: pointer; transition: background .15s;
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 30%); transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(16px); }
.group { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 8px 14px 14px; margin: 0 0 14px; min-width: 0; }
.group legend { padding: 0 6px; font-weight: 650; font-size: 14px; }
.group .check:last-child { margin-bottom: 0; }
.check:has(input:disabled) { color: var(--muted); }
.match-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.match-row select { width: auto; }
.conds { list-style: none; padding: 0; margin: 0 0 10px; }
.cond { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; }
.cond + .cond { border-top: 1px solid var(--line); }
.cond > * { min-width: 0; }
.cond .c-field { flex: 0 1 9.5em; }
.cond .c-header { flex: 1 1 8em; }
.cond .c-op { flex: 0 1 10.5em; }
.cond .c-value { flex: 1 1 9em; }
.cond > .btn { flex: none; }
.sieve {
  font: 13px/1.5 ui-monospace, Menlo, monospace; min-height: 280px; white-space: pre; overflow-wrap: normal; overflow-x: auto; tab-size: 4;
}
.senders .addr { overflow-wrap: anywhere; }
.sender-add .grow { flex: 1 1 200px; }
.sender-add select { width: auto; flex: none; }
@media (max-width: 760px) {
  .rule { grid-template-columns: auto 1fr; }
  .rule-tools { grid-column: 2; margin-left: -8px; }
  .cond { display: grid; grid-template-columns: 1fr 1fr auto; }
  .cond .c-field { grid-area: 1 / 1; }
  .cond .c-op { grid-area: 1 / 2; }
  .cond > .btn { grid-area: 1 / 3; }
  .cond .c-header, .cond .c-value { grid-column: 1 / 3; }
  .sieve { font-size: 16px; }
}

/* ---- invitations ---- */
.invite { display: grid; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--accent-soft); }
.sheet .invite { border: 0; border-radius: var(--radius-m); padding: 12px; margin-bottom: 12px; }
.invite p { margin: 0; }
.invite-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.invite > .btn.ghost { justify-self: start; }
.answers { display: flex; flex-wrap: wrap; gap: 8px; }
.answers .btn { min-width: 96px; }
.guests { list-style: none; margin: 4px 0 12px; padding: 0; display: grid; gap: 2px; font-size: 14px; }
.guests li { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.guests li:last-child { border-bottom: 0; }
.guest-accepted { color: var(--accent); }
.guest-declined { color: var(--danger); }
.share-add .row { margin-top: 8px; }
.share-add .grow > select, .share-add .grow > input { width: 100%; }
.share-add .row > select { width: auto; flex: 0 0 auto; }

/* ---- mail: selection, conversation, compose (v2) ---- */
.msgs .unread .from, .msgs .unread .subj { font-weight: 700; }
.msgs .from { font-weight: 500; }
.msgs li { position: relative; }
.msgs li.selected a { background: var(--accent-soft); }
.msgs .pick { position: absolute; left: 6px; top: 12px; width: 16px; height: 16px; margin: 0; opacity: 0; z-index: 1; accent-color: var(--accent); }
.msgs li:hover .pick, .msgs .pick:focus-visible, .list.selecting .msgs .pick { opacity: 1; }
.msgs li:hover .dot, .list.selecting .msgs .dot { visibility: hidden; }
.list.selecting .msgs a { padding-left: 30px; }
.msgs .tcount { color: var(--muted); font-weight: 500; font-size: 13px; }
.pane-head.bulk { gap: 2px; }
.pane-head.bulk h2 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-head .select-btn { display: none; }
.reader-bar { gap: 2px; padding-top: calc(8px + var(--safe-t)); padding-bottom: 8px; }
.reader-head .small, .muted.small { font-size: 13px; }
.reader-head h1 { margin-bottom: 4px; }
.thread { display: flex; flex-direction: column; flex: 1; }
.thread.single .msg.open { flex: 1; display: flex; flex-direction: column; }
.msg { border-bottom: 1px solid var(--line); }
.msg.open { display: flex; flex-direction: column; }
.msg-head { display: flex; gap: 8px; align-items: flex-start; padding: 14px 16px 10px 20px; }
.msg-head .reader-meta { flex: 1; min-width: 0; }
.thread.multi .mailframe { flex: none; height: 60vh; min-height: 260px; }
.msg-line {
  display: grid; grid-template-columns: 28px minmax(80px, 180px) 1fr auto; gap: 10px; align-items: center; width: 100%;
  padding: 10px 16px 10px 20px; border: 0; background: none; text-align: left; cursor: pointer; color: inherit;
}
.msg-line:hover { background: var(--ground); }
.msg-line .who { font-weight: 600; }
.msg-line .prev { color: var(--muted); font-size: 14px; }
.msg-line .date { color: var(--muted); font-size: 13px; }
.avatar.small { width: 28px; height: 28px; font-size: 11px; }
.tag { margin-left: 6px; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--sunken); color: var(--muted); }
.empty-state { margin: auto; text-align: center; color: var(--muted); padding: 32px; }
.empty-state svg { width: 44px; height: 44px; stroke: currentColor; fill: none; stroke-width: 1.4; opacity: .5; }
.empty-state p { margin: 8px 0 0; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.shortcuts dd { margin: 0; }
kbd { font: 600 12px/1 ui-monospace, monospace; padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--ground); }
.compose .addr { grid-template-columns: 64px 1fr auto; }
.compose .addr-field { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 40px; padding: 4px 0; }
.addr-field .chips { display: contents; }
.addr-field input { flex: 1; min-width: 140px; border: 0 !important; background: transparent; padding: 6px 4px; }
.addr-chip { padding: 2px 4px 2px 10px; }
.addr-chip .chip-text { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-chip.bad { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.suggest {
  position: absolute; top: 100%; left: 0; z-index: 5; min-width: 280px; max-width: 100%; margin: 2px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: 0 8px 24px rgb(0 0 0 / 14%);
}
.suggest li { display: flex; flex-direction: column; padding: 6px 10px; border-radius: var(--radius-s); cursor: pointer; }
.suggest li .muted { font-size: 13px; }
.suggest li[aria-selected=true] { background: var(--accent-soft); }
.cc-toggle { margin-right: 10px; font-size: 13px; }
.btn.small { min-height: 28px; padding: 0 8px; }
.fmtbar { display: flex; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.fmtbar .btn.icon { width: 32px; height: 32px; }
.fmtbar .fmt { font-weight: 700; font-family: Georgia, serif; }
.fmtbar .btn:nth-child(2) .fmt { font-style: italic; font-weight: 400; }
.editor { min-height: 240px; padding: 14px 16px; outline: none; overflow-wrap: anywhere; }
.editor blockquote { margin: 6px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.editor ul, .editor ol { padding-left: 24px; }
.compose-sheet { position: relative; }
.drop-hint {
  display: none; position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: var(--radius-l);
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent); color: var(--accent); font-weight: 700;
  place-items: center; z-index: 10; pointer-events: none;
}
.compose-sheet.dropping .drop-hint { display: grid; }
@media (max-width: 760px) {
  .pane-head .select-btn { display: inline-flex; }
  .msgs .pick { left: 8px; }
  .msg-line { grid-template-columns: 28px 1fr auto; }
  .msg-line .prev { display: none; }
  .reader-bar .btn.icon { width: 36px; }
  .thread.multi .mailframe { height: 55vh; }
}

/* ---- polish ---- */
.settings-toc { display: none; }
@media (min-width: 1100px) {
  .settings-wrap { display: grid; grid-template-columns: minmax(0, 720px) 220px; gap: 32px; align-items: start; }
  .settings-toc { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 72px; padding: 22px 0; }
  .settings-toc a { color: var(--muted); text-decoration: none; padding: 5px 10px; border-radius: var(--radius-s); font-size: 14px; }
  .settings-toc a:hover { background: var(--ground); color: var(--ink); }
}
.settings section { scroll-margin-top: 64px; }
.pane > .empty:only-child { margin: auto; }
