:root {
  --bg: #f6f6f4; --panel: #ffffff; --text: #1b1b19; --muted: #6d6c66; --faint: #9a9993; --line: #e6e5e0;
  --asap: #c0392b; --asap-bg: #fdf2f0; --soon: #9a5b00; --skim: #4d6b57; --accent: #0f6e5b; --hover: #f0efea; --btn-line: #c9c8c1;
  --demo-bg: #fff6d9; --demo-line: #8a6d00; --demo-text: #6b5400;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514; --panel: #1e1e1c; --text: #ecebe6; --muted: #a3a29b; --faint: #7a7973; --line: #32312d;
    --asap: #ff7a63; --asap-bg: #2a1c19; --soon: #f0b45a; --skim: #8fbf9c; --accent: #4fc2a7; color-scheme: dark; --hover: #262624; --btn-line: #4a4944;
    --demo-bg: #2b2610; --demo-line: #c9a227; --demo-text: #e2c35a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
button, input { font: inherit; }

/* header */
header { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.sub { margin: 1px 0 0; color: var(--muted); font-size: 13px; }
.time { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.time span { color: var(--muted); font-size: 13px; margin-right: 4px; }
/* every action is a real button, big enough for a finger (44×44 px), with a clear border and a visible focus */
button, a.act { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 8px 14px;
  border: 1px solid var(--btn-line); background: var(--panel); color: var(--text); border-radius: 9px; cursor: pointer; font-size: 14px;
  text-decoration: none; white-space: nowrap; }
button:hover, a.act:hover { border-color: var(--text); }
button:focus-visible, a.act:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .6; cursor: default; }
button[aria-pressed="true"], button.primary, a.act.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); gap: 2px 24px; margin: 6px 0 0; font-size: 13px; }
.fact { display: flex; gap: 6px; align-items: center; min-width: 0; flex-wrap: wrap; }
.fact dt { font-weight: 700; } .fact dt::after { content: ":"; }
.fact dd { margin: 0; color: var(--muted); max-width: 60ch; overflow-wrap: anywhere; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.fact button.small { min-height: 44px; padding: 4px 12px; font-size: 13px; }
.head-acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* prototype demo controls: a strip at the very top, above the app header, visibly not part of the app */
.demo-strip { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: center;
  padding: 8px 16px; background: var(--demo-bg); border-bottom: 2px dashed var(--demo-line); font-size: 13px; }
.demo-label { font-weight: 700; color: var(--demo-text); text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
.pretend { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--demo-line); color: #fff; font-size: 17px; font-weight: 700; }
.real-date { color: var(--demo-text); font-size: 12px; }
.demo-strip .time { display: flex; gap: 6px; }
.demo-strip button { background: transparent; border-style: dashed; border-color: var(--demo-line); }
.demo-strip button[aria-pressed="true"] { background: var(--demo-line); color: #fff; border-color: var(--demo-line); border-style: solid; }
#status { max-width: 1000px; margin: 0 auto; padding: 10px 16px 0; color: var(--muted); font-size: 13px; min-height: 1.4em; }

/* sections */
main { max-width: 1000px; margin: 0 auto; padding: 4px 16px 24px; }
section { margin-top: 20px; }
h2 { font-size: 15px; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; letter-spacing: .01em; }
.count { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 0 8px; line-height: 20px; background: var(--line); color: var(--muted); }
#asap h2 { color: var(--asap); } #asap .count { background: var(--asap); color: #fff; }
#soon h2 { color: var(--soon); } #skim h2 { color: var(--skim); }
ul { list-style: none; padding: 0; margin: 0; }


/* one light row per email: a round Done checkbox, then the email (one big button that opens the details) */
.item { display: flex; align-items: stretch; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; }
.item:hover { border-color: var(--faint); background: var(--hover); }
.item.asap { border-left: 4px solid var(--asap); background: linear-gradient(90deg, var(--asap-bg), var(--panel) 40%); }
.item.asap:hover { background: var(--hover); }
.item.soon { border-left: 4px solid var(--soon); }
.row-done { flex: none; align-self: center; min-height: 44px; padding: 6px 12px; margin: 0 2px 0 6px; font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--btn-line); border-radius: 9px; }
.row-done:hover { color: var(--accent); border-color: var(--accent); }
.email { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; justify-content: space-between; text-align: left; white-space: normal;
  padding: 12px; border: none; border-radius: 10px 0 0 10px; background: transparent; color: var(--text); font-size: 15px; min-height: 44px; }
.email:hover { border: none; }
.email-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chev { flex: none; align-self: center; padding: 0 12px 0 6px; font-size: 26px; line-height: 1; color: var(--faint); }
.item:hover .chev { color: var(--text); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 5; display: flex; gap: 8px; align-items: center; padding: 6px 8px 6px 16px;
  border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: 0 4px 16px rgb(0 0 0 / .2); }
.toast button { background: transparent; color: var(--bg); border-color: var(--faint); }
.when { font-size: 14px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.seen-marker { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.due { font-weight: 650; color: var(--asap); }
.item.soon .due { color: var(--soon); }
.received { color: var(--faint); }
.line2 { min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.from { font-weight: 650; }
.reason { color: var(--text); }
.v-why { background: var(--bg); border-radius: 10px; padding: 10px 14px; margin: 14px 0 4px; }
.v-why h3 { margin: 0 0 6px; }
#viewer { max-width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding-top: 0; }
.v-head { position: sticky; top: 0; z-index: 1; display: flex; gap: 8px; align-items: center; justify-content: space-between;
  background: var(--panel); padding: 12px 0; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.v-head .close { float: none; }
.v-acts { display: flex; gap: 8px; flex-wrap: wrap; }
#viewer pre.v-text { max-height: none; }
.v-subject { margin-top: 4px; }
.w-email { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.w-facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 8px; font-size: 14px; }
.w-facts dt { color: var(--muted); } .w-facts dd { margin: 0; font-weight: 600; }
.v-why h4 { margin: 12px 0 4px; font-size: 14px; }
.v-why p { margin: 4px 0; font-size: 14px; }
.w-cond { color: var(--muted); }
.w-answers { margin: 4px 0; font-size: 14px; }
.w-answers li { padding: 1px 0; }
.yn { display: inline-block; min-width: 30px; text-align: center; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 0 4px; }
.yn.yes { background: var(--accent); color: #fff; } .yn.no { background: var(--line); color: var(--muted); }
.tip-wrap { position: relative; display: inline-block; margin-top: 6px; }
.tip { position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%); white-space: nowrap; background: var(--text); color: var(--bg);
  font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.tip[hidden] { display: none; }
.tag { flex: none; font-size: 11px; color: var(--faint); white-space: nowrap; }
.tag.learned { color: var(--accent); }
a.act.primary { color: #fff; }
.item.read .email { opacity: .55; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }

/* section widgets, used as tabs */
.widgets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.widget { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; text-align: left; white-space: normal; min-width: 0; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); min-height: 92px; }
.widget .w-title { font-size: 13px; font-weight: 650; color: var(--muted); }
.widget .w-total { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.widget .w-sub { font-size: 12px; color: var(--muted); }
.widget.asap .w-title, .widget.asap .w-total { color: var(--asap); }
.widget.soon .w-title, .widget.soon .w-total { color: var(--soon); }
.widget.skim .w-title, .widget.skim .w-total { color: var(--skim); }
.widget[aria-selected="true"] { border: 2px solid var(--text); padding: 9px 11px; box-shadow: 0 2px 8px rgb(0 0 0 / .12); }
.widget[aria-selected="true"].asap { border-color: var(--asap); background: var(--asap-bg); }
.widget[aria-selected="true"].soon { border-color: var(--soon); }
.widget[aria-selected="true"].skim { border-color: var(--skim); }
.panel { margin-top: 14px; }
.group-note { color: var(--muted); font-size: 12px; }

/* skim groups */
.group { margin-bottom: 10px; }
.group-head { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 6px; font-weight: 600; }
.group-head button { font-size: 12px; padding: 2px 8px; }

.settings { max-width: 1000px; margin: 0 auto; padding: 4px 16px; color: var(--muted); font-size: 13px; }
footer { max-width: 1000px; margin: 0 auto 24px; padding: 10px 16px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
#calibrate-hint { max-width: 968px; margin: 10px auto 0; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
#calibrate-hint[hidden] { display: none; }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); max-width: min(720px, calc(100vw - 32px)); width: 100%; padding: 18px; }
dialog::backdrop { background: rgb(0 0 0 / .35); }
#first-run progress { width: 100%; height: 10px; margin: 6px 0; }
#first-run .fr-state { font-weight: 600; margin: 4px 0; }
#first-run .fr-help { font-size: 13px; }
dialog h3 { margin: 0 0 6px; font-size: 16px; }
.close { float: right; font-size: 22px; line-height: 1; }
pre.v-text { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 var(--font); background: var(--bg); padding: 12px; border-radius: 8px; max-height: 60vh; overflow: auto; }
.v-meta, .v-note, .c-email, .p-match, .p-outcome, .c-help { color: var(--muted); font-size: 13px; }
.v-warn { color: var(--asap); font-size: 13px; font-weight: 600; }
fieldset { border: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
label.block { display: block; margin: 8px 0; }
label.block input { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); }
.proposal { margin-top: 10px; padding-top: 6px; border-top: 1px solid var(--line); }
.proposal h4 { margin: 4px 0; font-size: 14px; }
.actions { display: flex; gap: 8px; }
.sync { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.mb-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.mb-row .grow { flex: 1 1 240px; } .mb-row .port { flex: 0 0 100px; }
.mb-row .check { margin: 8px 0 16px; white-space: nowrap; }
.mb-result { min-height: 1.3em; font-size: 14px; font-weight: 600; }
.pw-saved { font-size: 14px; }
/* mocked parts: the same dashed look as the demo controls */
.mocked-btn { border-style: dashed; border-color: var(--demo-line); background: var(--demo-bg); }
.mock-badge { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--demo-text); font-weight: 700; }
dialog.mocked { border: 2px dashed var(--demo-line); }
.mock-note { margin: 0 0 6px; padding: 4px 8px; background: var(--demo-bg); color: var(--demo-text); border-radius: 6px; font-size: 12px; font-weight: 650; display: inline-block; }
#feedback textarea { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; }
#feedback select { display: block; margin-top: 4px; padding: 5px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.fb-which { color: var(--muted); }
.fb-anon { display: block; margin: 6px 0; font-size: 14px; }
.fb-sent { color: var(--demo-text); background: var(--demo-bg); padding: 8px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.mocked-act { flex-direction: column; gap: 0; line-height: 1.15; border-style: dashed; }
.act.primary.mocked-act { background: var(--accent); }
.mocked-act .mock-badge { font-size: 9px; }
.act.primary.mocked-act .mock-badge { color: #fff; opacity: .85; }
.v-mail-acts { display: contents; }
.note { position: fixed; inset: auto 16px 20px auto; margin: 0; max-width: 420px; padding: 10px 14px; border-radius: 10px; border: 2px dashed var(--demo-line);
  background: var(--demo-bg); color: var(--demo-text); font-size: 14px; font-weight: 600; box-shadow: 0 4px 16px rgb(0 0 0 / .15); }
.c-places label:has(input:disabled) { color: var(--faint); }
.c-feedback { margin: 10px 0; padding: 8px 10px; border: 2px dashed var(--demo-line); border-radius: 8px; background: var(--demo-bg); font-size: 14px; }
.c-feedback label { display: block; margin: 4px 0; }
.c-feedback textarea { width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: var(--panel); color: var(--text); }
.dh-list { max-height: 60vh; overflow: auto; }
.dh-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: center; }
.dh-when { color: var(--muted); font-size: 12px; }
.cal-list { max-height: 60vh; overflow: auto; }
.cal-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: center; }
.cal-list .cal-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.cal-list .cal-acts button { font-size: 12px; padding: 2px 8px; }
.cal-list .done { color: var(--accent); font-size: 12px; }

@media (max-width: 600px) {
  .facts { grid-template-columns: minmax(0, 1fr); }
  .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  header, .demo-strip { padding-left: 12px; padding-right: 12px; }
  main { padding-left: 12px; padding-right: 12px; }
}
