/* ============ tokens ============ */
:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --paper: #fffdf9;
  --line: #e7e3da;
  --line-2: #d6d1c5;
  --ink: #1b1a17;
  --ink-2: #57544c;
  --ink-3: #8b877c;
  --hover: #f1ede4;
  --phd: #2a78d6;        /* domain accents = categorical slots 1, 7, 3 (fixed) */
  --out: #4a3aa7;
  --job: #1baf7a;
  --accent: var(--phd);
  /* status palette (never themed) */
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #0b6b0b; --crit-ink: #a92b2b;
  --serif: "Newsreader", "Iowan Old Style", Georgia, "DejaVu Serif", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgb(40 30 10 / .05);
  --lift: 0 12px 40px rgb(30 20 0 / .16);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #141412; --paper: #1b1b19; --line: #2c2b28; --line-2: #3b3a36;
    --ink: #f4f2ec; --ink-2: #c3c0b5; --ink-3: #8f8c82; --hover: #23221f;
    --phd: #3987e5; --out: #9085e9; --job: #199e70;
    --good-ink: #5fcf5f; --crit-ink: #ff8b8b;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --lift: 0 12px 40px rgb(0 0 0 / .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141412; --paper: #1b1b19; --line: #2c2b28; --line-2: #3b3a36;
  --ink: #f4f2ec; --ink-2: #c3c0b5; --ink-3: #8f8c82; --hover: #23221f;
  --phd: #3987e5; --out: #9085e9; --job: #199e70;
  --good-ink: #5fcf5f; --crit-ink: #ff8b8b;
  --shadow: 0 1px 2px rgb(0 0 0 / .4); --lift: 0 12px 40px rgb(0 0 0 / .5);
}
[data-domain="phd"] { --accent: var(--phd); }
[data-domain="out"] { --accent: var(--out); }
[data-domain="job"] { --accent: var(--job); }
[data-domain="later"], [data-domain="home"] { --accent: var(--ink-2); }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ============ header (fixed, does not scroll) ============ */
.hdr { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.hdr-in { max-width: 1180px; margin: 0 auto; padding: 0 28px; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; gap: 10px; align-items: center; flex: none; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font: 600 17px var(--serif); }
.brand b { display: block; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; }
.brand small { display: block; color: var(--ink-3); font-size: 11.5px; line-height: 1.2; }
#nav { display: flex; gap: 4px; align-items: stretch; height: 100%; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { display: flex; align-items: center; gap: 7px; padding: 0 12px; color: var(--ink-2); font-weight: 500; white-space: nowrap; position: relative; }
#nav a:hover { color: var(--ink); }
#nav a i { width: 7px; height: 7px; border-radius: 2px; background: var(--dc); }
#nav a.on { color: var(--ink); }
#nav a.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--dc); }
#nav a .n { font-size: 11.5px; font-weight: 600; color: var(--ink-3); background: var(--hover); border-radius: 999px; padding: 0 7px; line-height: 18px; }
#nav a .n.hot { color: #fff; background: var(--critical); }
.hdr-r { display: flex; align-items: center; gap: 14px; flex: none; }
.tgt { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.tgt b { font: 500 19px var(--serif); color: var(--ink); }
.live { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-3); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.live i.ok { background: var(--good); }
.live i.bad { background: var(--critical); }
.icon-btn { border: 1px solid var(--line); background: transparent; border-radius: 7px; width: 30px; height: 28px; cursor: pointer; color: var(--ink-2); }
.sub { border-top: 1px solid var(--line); }
.sub-in { max-width: 1180px; margin: 0 auto; padding: 0 28px; height: 42px; display: flex; align-items: center; gap: 6px; }
.sub-in a { padding: 5px 12px; border-radius: 7px; color: var(--ink-2); font-weight: 500; font-size: 13.5px; }
.sub-in a:hover { background: var(--hover); color: var(--ink); }
.sub-in a.on { background: color-mix(in srgb, var(--phd) 12%, var(--paper)); color: var(--ink); }
.sub-in a .n { font-size: 11.5px; color: var(--ink-3); margin-left: 4px; }
.sub[hidden] { display: none; }

.main { max-width: 1180px; margin: 0 auto; padding: 30px 28px 80px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.top h1 { font: 500 34px/1.1 var(--serif); letter-spacing: -.015em; margin: 0; }
.top .crumb { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; display: flex; gap: 7px; align-items: center; }
.top .crumb i { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.top .hint { color: var(--ink-3); font-size: 13px; margin-top: 6px; }
.top .acts { display: flex; gap: 8px; align-items: center; }

/* ============ controls ============ */
.btn { border: 1px solid var(--line-2); background: var(--paper); border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { filter: brightness(1.07); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--crit-ink); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 11px; background: var(--paper); width: 220px; }
.search svg { color: var(--ink-3); flex: none; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; padding: 0; }
.search:focus-within { border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--ink-2); font-weight: 500; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg button .c { opacity: .6; margin-left: 5px; font-size: 12px; }
.bar-ctl { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.in { border: 1px solid var(--line-2); background: var(--paper); border-radius: 8px; padding: 7px 10px; outline: 0; width: 100%; }
.in:focus { border-color: var(--accent); }
textarea.in { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ============ list rows (the core component) ============ */
.list { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--hover); }
.row.dim { opacity: .55; }
.row .t { font-weight: 600; font-size: 15px; letter-spacing: -.005em; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.row .typ { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.row .org { color: var(--ink-2); font-size: 13px; }
.row .focus { color: var(--ink-3); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .rt { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.lk { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--paper); color: var(--ink); white-space: nowrap; }
.lk:hover { border-color: var(--accent); color: var(--accent); }
.lk .ar { font-size: 11px; opacity: .7; }
select.stsel { border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 2px 6px; font-size: 12px; color: var(--ink-2); cursor: pointer; }

/* date block — the anchor of every row */
.date { width: 74px; text-align: center; border-radius: 10px; padding: 6px 4px 7px; background: var(--hover); border: 1px solid transparent; }
.date .d { font: 500 26px/1 var(--serif); }
.date .m { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-top: 1px; }
.date .r { font-size: 11px; font-weight: 600; margin-top: 4px; color: var(--ink-2); }
.date.crit { background: color-mix(in srgb, var(--critical) 13%, var(--paper)); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.date.crit .r { color: var(--crit-ink); }
.date.ser { background: color-mix(in srgb, var(--serious) 15%, var(--paper)); border-color: color-mix(in srgb, var(--serious) 40%, transparent); }
.date.warn { background: color-mix(in srgb, var(--warning) 16%, var(--paper)); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.date.done { background: color-mix(in srgb, var(--good) 11%, var(--paper)); }
.date.done .r { color: var(--good-ink); }
.date.past { background: transparent; border-color: var(--line); }
.date.past .d, .date.past .m { color: var(--ink-3); }
.date.none .d { font: 500 14px/1.2 var(--sans); padding: 5px 0 1px; color: var(--ink-2); }

.sec-h { display: flex; justify-content: space-between; align-items: baseline; margin: 30px 0 10px; }
.sec-h h2 { font: 500 21px var(--serif); margin: 0; letter-spacing: -.01em; }
.sec-h .m { color: var(--ink-3); font-size: 13px; }
.sec-h a.m:hover { color: var(--ink); }
.empty { padding: 26px; text-align: center; color: var(--ink-3); }

/* ============ overview ============ */
.hello { font: 400 17px var(--serif); color: var(--ink-2); margin: -6px 0 22px; }
.hello b { color: var(--ink); font-weight: 500; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; border-top: 3px solid var(--dc); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--line-2); border-top-color: var(--dc); }
.tile .k { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.tile .v { font: 500 30px/1.15 var(--serif); margin-top: 4px; }
.tile .s { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.todo { display: grid; grid-template-columns: 20px 92px minmax(0, 1fr); gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.todo:last-child { border-bottom: 0; }
.todo.clk { cursor: pointer; }
.todo.clk:hover { background: var(--hover); }
.todo .w { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.todo .w.late { color: var(--crit-ink); }
.todo .x { min-width: 0; }
.todo .x .a { font-weight: 500; }
.todo .x .b { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 3px; background: var(--dc, var(--ink-3)); justify-self: center; }
.chk { width: 18px; height: 18px; border: 1.5px solid var(--line-2); border-radius: 5px; cursor: pointer; display: grid; place-items: center; background: var(--paper); }
.chk:hover { border-color: var(--good); }
.chk.on { background: var(--good); border-color: var(--good); color: #fff; font-size: 12px; }
.addtask { display: flex; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--bg); }
.addtask input { flex: 1; }
.addtask input[type=date] { flex: none; width: 150px; }

/* ============ outreach ============ */
.orow { display: grid; grid-template-columns: 116px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.orow:last-child { border-bottom: 0; }
.orow:hover { background: var(--hover); }
.ost { font-size: 12.5px; font-weight: 600; display: grid; gap: 1px; }
.ost .l { display: inline-flex; gap: 6px; align-items: center; }
.ost .l i { width: 8px; height: 8px; border-radius: 50%; background: var(--sc); }
.ost .w { font-weight: 500; color: var(--ink-3); font-size: 11.5px; }
.ask { font-size: 11px; font-weight: 600; letter-spacing: .03em; color: var(--accent); }
.wave-h { display: flex; gap: 12px; align-items: baseline; margin: 26px 0 10px; }
.wave-h:first-of-type { margin-top: 0; }
.wave-h h2 { font: 500 20px var(--serif); margin: 0; }
.wave-h .m { color: var(--ink-3); font-size: 13px; }

/* ============ calendar ============ */
.cal-h { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.cal-h h2 { font: 500 22px var(--serif); margin: 0 6px; min-width: 180px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal .dw { background: var(--paper); padding: 8px 10px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.cal .c { background: var(--paper); min-height: 104px; padding: 7px 8px; display: flex; flex-direction: column; gap: 4px; }
.cal .c.out { background: var(--bg); }
.cal .c .n { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.cal .c.out .n { color: var(--ink-3); }
.cal .c.today .n { color: #fff; background: var(--accent); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.ev { font-size: 12px; padding: 2px 7px; border-radius: 5px; background: color-mix(in srgb, var(--dc) 13%, var(--paper)); border-left: 3px solid var(--dc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ev.alt { background: transparent; border: 1px dashed var(--dc); border-left: 3px solid var(--dc); }

/* ============ letters ============ */
.mx { width: 100%; border-collapse: collapse; background: var(--paper); }
.mx th, .mx td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.mx tr:last-child td { border-bottom: 0; }
.mx thead th { vertical-align: bottom; background: var(--bg); font-weight: 600; }
.mx .rn b { display: block; font-size: 14px; }
.mx .rn span { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.mx td.c, .mx th.c { text-align: center; }
.mx .ap { font-weight: 600; cursor: pointer; }
.mx .ap:hover { color: var(--accent); }
.mx .sub { font-size: 12px; color: var(--ink-3); }
.lc { min-width: 104px; border-radius: 7px; padding: 4px 9px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px dashed var(--line-2); background: transparent; color: var(--ink-3); }
.lc.to-ask { border-style: solid; color: var(--ink); background: color-mix(in srgb, var(--warning) 16%, var(--paper)); border-color: color-mix(in srgb, var(--warning) 50%, transparent); }
.lc.asked { border-style: solid; color: var(--ink); background: color-mix(in srgb, var(--serious) 14%, var(--paper)); border-color: color-mix(in srgb, var(--serious) 45%, transparent); }
.lc.agreed { border-style: solid; color: var(--ink); background: color-mix(in srgb, var(--phd) 12%, var(--paper)); border-color: color-mix(in srgb, var(--phd) 40%, transparent); }
.lc.submitted { border-style: solid; color: var(--good-ink); background: color-mix(in srgb, var(--good) 12%, var(--paper)); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-top: 12px; align-items: center; }

/* ============ saved links ============ */
.paste { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.paste textarea { min-height: 96px; font-size: 13.5px; }
.paste .f { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 12px; flex-wrap: wrap; }
.paste .f p { margin: 0; color: var(--ink-3); font-size: 12.5px; max-width: 640px; }
.lrow { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.fav { width: 34px; height: 34px; border-radius: 8px; background: var(--hover); display: grid; place-items: center; font: 600 15px var(--serif); color: var(--ink-2); text-transform: uppercase; }
.lrow .h { font-weight: 600; }
.lrow .p { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .nt { font-size: 13px; color: var(--ink-2); }
.lrow .acts { display: flex; gap: 6px; align-items: center; }
.pill { font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.new { border-color: var(--ink-2); color: var(--ink); }
.pill.ok { border-color: color-mix(in srgb, var(--good) 50%, transparent); color: var(--good-ink); }

/* ============ drawer ============ */
.scrim { position: fixed; inset: 0; background: rgb(20 15 5 / .3); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(600px, 100vw); background: var(--paper); border-left: 1px solid var(--line); box-shadow: var(--lift); transform: translateX(102%); transition: transform .22s ease; z-index: 40; overflow-y: auto; }
.drawer.on { transform: none; }
.dh { padding: 22px 26px 18px; border-bottom: 1px solid var(--line); position: relative; }
.dh .x { position: absolute; top: 16px; right: 16px; }
.dh .kick { font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); display: flex; gap: 7px; align-items: center; }
.dh .kick i { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.dh h2 { font: 500 25px/1.2 var(--serif); margin: 8px 40px 4px 0; letter-spacing: -.01em; }
.dh .org { color: var(--ink-2); }
.dh .focus { color: var(--ink-2); margin-top: 10px; font-size: 14px; }
.dh .links { justify-content: flex-start; margin-top: 14px; }
.dh .links .lk { font-size: 13px; padding: 5px 11px; }
.dl { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.dl .tx b { display: block; }
.dl .tx span { font-size: 12.5px; color: var(--ink-3); }
.vf { color: var(--good-ink); font-weight: 600; }
.vf.no { color: var(--ink-3); font-weight: 500; }
.db { padding: 18px 26px 40px; display: grid; gap: 22px; }
.blk h3 { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; }
.blk p { margin: 0; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 6px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.na { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; }
.doc { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.doc:last-child { border-bottom: 0; }
.doc .nm { font-weight: 500; }
.doc .fp { font-size: 12px; color: var(--ink-3); font-family: ui-monospace, Menlo, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc .fp.y { color: var(--good-ink); }
.let { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; }
.dfoot { display: flex; gap: 8px; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 16px; }

/* ============ modal ============ */
.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgb(20 15 5 / .35); padding: 16px; }
.modal.on { display: grid; }
.mb { width: min(600px, 100%); max-height: 92vh; overflow-y: auto; background: var(--paper); border-radius: 14px; box-shadow: var(--lift); border: 1px solid var(--line); }
.mb .h { padding: 20px 22px 6px; }
.mb .h h3 { font: 500 22px var(--serif); margin: 0; }
.mb .h p { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }
.mb .b { padding: 12px 22px; display: grid; gap: 12px; }
.mb .f { padding: 12px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.fl { display: grid; gap: 5px; }
.fl label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.fl small { color: var(--ink-3); font-size: 11.5px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details.more summary { cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 13px; padding: 4px 0; }
details.more[open] summary { margin-bottom: 10px; }
details.more > div { display: grid; gap: 12px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--paper); padding: 9px 14px; border-radius: 9px; font-size: 13px; box-shadow: var(--lift); animation: tin .18s ease; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }

/* ============ responsive ============ */
@media (max-width: 1000px) { .tiles { grid-template-columns: 1fr 1fr; } .tgt span { display: none; } }
/* ============ phone-only chrome ============
   #dock, the app-bar overflow (#more / #barTitle / #moreBtn) and the calendar
   agenda exist only on phones: base rule hides them, every layout rule for them
   lives inside the @media (max-width: 820px) block below. */
#dock, #more, #barTitle, #moreBtn, .agenda { display: none; }

@media (max-width: 820px) {
  /* ---- app shell: last-row padding, tap behaviour, safe areas ---- */
  html, body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
  body { touch-action: manipulation; }
  .hdr-in { height: auto; min-height: 48px; flex-wrap: nowrap; padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; gap: 10px; }
  .brand, #nav, #target, #liveTxt, #lockBtn, #themeBtn { display: none; }
  #barTitle { display: block; flex: 1; min-width: 0; font-weight: 600; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hdr-r { margin-left: auto; gap: 10px; }
  #moreBtn { display: grid; place-items: center; width: 40px; height: 40px; font-size: 18px; line-height: 1; }
  #more { display: none; position: absolute; top: calc(env(safe-area-inset-top) + 52px); right: 12px; z-index: 26; min-width: 236px; padding: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--lift); }
  #more.on { display: grid; gap: 4px; }
  #more .mt { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: var(--ink-2); padding: 2px 4px 9px; border-bottom: 1px solid var(--line); }
  #more .mt b { font: 500 17px var(--serif); color: var(--ink); }
  #more .btn { min-height: 44px; justify-content: flex-start; text-align: left; }
  /* ---- PhD sub-views as a segmented control (the .hdr row is already sticky) ---- */
  .sub { border-top: 1px solid var(--line); padding: 8px 14px 10px; }
  .sub-in { height: auto; max-width: none; padding: 3px; gap: 3px; background: var(--hover); border-radius: 10px; }
  .sub-in a { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 38px; }
  .sub-in a.on { background: var(--paper); box-shadow: var(--shadow); }
  /* ---- content ---- */
  .main { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .top { margin-bottom: 12px; }
  .top > div:first-child { display: none; }   /* page title moved into the app bar */
  .top .acts { width: 100%; }
  .search { width: 100%; min-height: 44px; }
  .bar-ctl { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .bar-ctl::-webkit-scrollbar { display: none; }
  .seg { flex: none; }
  .seg button { min-height: 40px; }
  .row { grid-template-columns: 62px minmax(0, 1fr); min-height: 44px; }
  .row .rt { grid-column: 1 / -1; align-items: flex-start; }
  .links { justify-content: flex-start; }
  .orow { grid-template-columns: 1fr; gap: 8px; min-height: 44px; }
  .todo { grid-template-columns: 24px 78px minmax(0, 1fr); min-height: 44px; }
  .chk { width: 24px; height: 24px; }
  .lrow { min-height: 44px; }
  .btn, .lk, .stsel, .lc { min-height: 44px; }
  .icon-btn { width: 40px; height: 40px; }
  .ev { font-size: 11px; }
  .g2 { grid-template-columns: 1fr; }
  .brand small { display: none; }
  /* ---- calendar: vertical agenda instead of the 7-column grid ---- */
  .cal { display: none; }
  .agenda { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
  .agenda .ag { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 14px; min-height: 44px; border-bottom: 1px solid var(--line); border-left: 3px solid var(--dc); cursor: pointer; }
  .agenda .ag:last-child { border-bottom: 0; }
  .agenda .ad { text-align: center; }
  .agenda .ad b { display: block; font: 500 20px/1.1 var(--serif); }
  .agenda .ad span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
  .agenda .at { min-width: 0; font-weight: 600; }
  .agenda .am { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* ---- referee letters: matrix scrolls sideways, first column pinned ---- */
  .mx { min-width: 560px; }
  .mx td:first-child, .mx th:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 1px 0 0 var(--line); }
  .mx thead th:first-child { background: var(--bg); }
  /* ---- detail view as a bottom sheet ---- */
  .drawer { top: auto; bottom: 0; width: 100%; height: auto; max-height: 92dvh; display: flex; flex-direction: column; overflow: hidden; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); transform: translateY(102%); }
  .drawer.on { transform: none; }
  .drawer.dragging { transition: none; }
  .drawer::before { content: ""; flex: none; width: 42px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 8px auto 2px; }
  .drawer .dh { flex: none; padding: 12px 18px 14px; touch-action: none; }
  .drawer .dh h2 { font-size: 22px; }
  .drawer .db { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 18px calc(20px + env(safe-area-inset-bottom)); }
  .drawer input, .drawer textarea, .drawer select { font-size: 16px; }
  .drawer .kv { grid-template-columns: 96px minmax(0, 1fr); }
  /* ---- add / edit modal: full-screen sheet ---- */
  .modal { padding: 0; align-items: stretch; }
  .mb { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; display: flex; flex-direction: column; border: 0; border-radius: 0; }
  .mb .h { flex: none; padding: calc(env(safe-area-inset-top) + 18px) 18px 6px; }
  .mb .b { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 18px; }
  .mb .f { flex: none; padding: 12px 18px calc(env(safe-area-inset-bottom) + 14px); }
  .mb .in, .mb select, .mb textarea { font-size: 16px; }
  /* ---- floating add button (the visible label moves to aria-label) ---- */
  .top [data-add] { position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 24; width: 56px; height: 56px; min-height: 56px; padding: 0; display: grid; place-items: center; border-radius: 50%; font-size: 0; box-shadow: 0 8px 22px rgb(20 15 5 / .32); }
  .top [data-add]::before { content: "+"; font-size: 28px; font-weight: 500; line-height: 1; }
  /* ---- bottom tab dock ---- */
  #dock { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: saturate(1.5) blur(12px); -webkit-backdrop-filter: saturate(1.5) blur(12px); border-top: 1px solid var(--line); }
  #dock a { flex: 1; display: grid; place-items: center; gap: 2px; min-height: 56px; padding: 6px 2px; border-radius: 10px; color: var(--ink-3); position: relative; }
  #dock a svg { width: 24px; height: 24px; }
  #dock a.on { color: var(--dc); }
  #dock a .lb { font-size: 10.5px; font-weight: 600; letter-spacing: .01em; }
  #dock a .n { position: absolute; top: 3px; left: 50%; margin-left: 3px; font-size: 10px; font-weight: 700; line-height: 15px; padding: 0 5px; border-radius: 999px; background: var(--hover); color: var(--ink-2); }
  #dock a .n.hot { background: var(--critical); color: #fff; }
  /* ---- toasts clear the dock ---- */
  .toasts { left: 14px; right: 14px; bottom: calc(72px + env(safe-area-inset-bottom)); justify-items: center; }
}

/* read-only mode: hide/disable everything that edits */
body.ro [data-add], body.ro [data-sent], body.ro [data-replied], body.ro [data-followed], body.ro [data-edit], body.ro [data-del],
body.ro [data-file], body.ro [data-dismiss], body.ro [data-restore], body.ro #addTask, body.ro #pasteForm, body.ro [data-addref], body.ro #addRef { display: none !important; }
body.ro select, body.ro .drawer input, body.ro .drawer textarea, body.ro .chk, body.ro .lc { pointer-events: none; }
body.ro select { appearance: none; -webkit-appearance: none; border-color: transparent; background: transparent; padding-right: 0; }
#lockBtn { font-size: 12.5px; }
