/* OVXMAIL · "paper & ink" */

@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/instrument-sans-wght.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-opsz.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --accent: #0F6B57;
  --bg: #F4F4F1;
  --panel: #FFFFFF;
  --ink: #16181C;
  --ink2: #3D4148;
  --muted: #62666E;
  --line: #E6E5E0;
  --hover: #ECECE8;
  --soft: #EDEDE9;
  --star: #B57A06;
  --danger: #B42318;
  --av1: #E7E1D4; --av2: #D9E5DF; --av3: #E0DFEA; --av4: #EADCDA;
  --shadow: 0 1px 2px rgb(22 24 28 / 4%), 0 2px 8px rgb(22 24 28 / 4%);
  --shadow-pop: 0 8px 28px rgb(22 24 28 / 14%), 0 1px 3px rgb(22 24 28 / 8%);
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1012;
    --panel: #17181B;
    --ink: #ECEDEE;
    --ink2: #C9CBCF;
    --muted: #9A9EA6;
    --line: #26282C;
    --hover: #1E2023;
    --soft: #202226;
    --star: #E2B23A;
    --danger: #F97066;
    --av1: #3A342A; --av2: #26352F; --av3: #2D2C3A; --av4: #3A2B2A;
    --shadow: none;
    --shadow-pop: 0 10px 30px rgb(0 0 0 / 50%);
    --mark-flap: #4CC29C;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Scrollbars: one thin, quiet style everywhere. Thumb in a soft ink tint, no track. */
:root { --scroll: #D6D5CF; }
@media (prefers-color-scheme: dark) { :root { --scroll: #34373D; } }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
@supports not (scrollbar-color: red blue) {
  /* Safari: no standard properties yet, so the same look via the WebKit pseudo-elements. */
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
}
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.muted { color: var(--muted); }
.spacer { flex: 1 1 auto; }
.ic { flex: 0 0 auto; display: block; }
kbd {
  font: 500 11px/1.4 var(--sans); padding: 0 5px; border-radius: 5px;
  border: 1px solid var(--line); color: var(--muted);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent;
  font-weight: 500; white-space: nowrap; color: var(--ink2);
}
.btn:hover { background: var(--hover); color: var(--ink); }
.btn-ink { background: var(--ink); color: var(--bg); font-weight: 600; }
.btn-ink:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); color: var(--bg); }
.btn-ink kbd { color: inherit; border-color: currentColor; opacity: .6; }
.btn-lg { height: 44px; padding: 0 18px; border-radius: 12px; }
.btn-quiet { color: var(--ink2); }
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 auto; display: inline-grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink2); padding: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn-outline { width: 34px; height: 34px; border: 1px solid var(--line); }
.icon-btn-lg { width: 44px; height: 44px; border-radius: 12px; }
.link-btn { border: 0; background: none; padding: 4px 0; font-weight: 600; color: var(--ink); }
.link-btn.quiet { font-weight: 400; font-size: 13px; color: var(--muted); }
.link-btn:hover { color: var(--accent); }
.htmx-request.btn-ink, .htmx-request [data-send] { opacity: .65; }

.seg { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--soft); }
.seg > a, .seg > button {
  border: 0; background: transparent; border-radius: 7px; padding: 4px 10px;
  font-size: 12px; color: var(--muted);
}
.seg > a:hover, .seg > button:hover { color: var(--ink); }
.seg > .on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.seg-tools > button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 9px; color: var(--ink2); }
.seg-tools > button:hover { background: var(--panel); }

/* ---------- avatars, swatches, chips ---------- */
.avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; position: relative;
  display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--ink2); background: var(--av1);
}
.avatar-sm { width: 30px; height: 30px; flex-basis: 30px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; flex-basis: 40px; font-size: 15px; }
.avatar.tone-1 { background: var(--av1); } .avatar.tone-2 { background: var(--av2); }
.avatar.tone-3 { background: var(--av3); } .avatar.tone-4 { background: var(--av4); }
.avatar.avatar-ink { background: var(--ink); color: var(--bg); }
.swatch { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 8px; background: #C9A227; }
.swatch.tone-1 { background: #C9A227; } .swatch.tone-2 { background: #5B8DB8; } .swatch.tone-3 { background: #B86B5B; }
.swatch.tone-4 { background: #6E9B6B; } .swatch.tone-5 { background: #8B6FB0; } .swatch.tone-6 { background: #B0866F; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  background: var(--soft); color: var(--ink2); font-weight: 500;
}
.pill { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; line-height: 16px; }

/* ---------- app shell ---------- */
.app {
  height: 100vh; height: 100dvh; display: grid;
  grid-template-columns: 236px minmax(320px, 404px) minmax(0, 1fr);
}
.wordmark { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.wordmark img { height: 24px; }
.mark-flap { stroke: var(--mark-flap, var(--accent)); }

.sidebar { grid-column: 1; grid-row: 1; }
.list { grid-column: 2; grid-row: 1; }
.reader { grid-column: 3; grid-row: 1; }

/* sidebar */
.sidebar { padding: 20px 14px 14px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; min-height: 0; }
.compose-btn { justify-content: flex-start; height: 44px; border-radius: 12px; padding: 0 14px; gap: 10px; }
.compose-btn > span.label { flex: 1; text-align: left; }
.compose-btn > kbd { flex: 0 0 auto; }
.nav-body { display: flex; flex-direction: column; gap: 18px; flex: 1 1 auto; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; border-radius: 10px; color: var(--ink2);
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--panel); box-shadow: var(--shadow); color: var(--ink); font-weight: 600; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .swatch { margin: 0 5px; }
.nav-item.depth-1 { padding-left: 34px; } .nav-item.depth-2, .nav-item.depth-3 { padding-left: 54px; }
.install-btn { border: 0; background: transparent; width: 100%; text-align: left; flex: 0 0 auto; }
.install-btn .label { color: var(--ink2); }
.offline-card .btn-lg { width: 100%; }
.count { font-size: 12px; color: var(--muted); }
.count.unread { color: var(--accent); font-weight: 600; }
.nav-section { padding: 0 10px; margin-bottom: -12px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.account { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account form { margin: 0; }
.live {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 2px var(--bg);
}
.live.on { background: #12A150; }

/* list */
.list { overflow-y: auto; min-height: 0; padding-bottom: 12px; overscroll-behavior: contain; }
.list-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 20px 12px 8px; display: flex; flex-direction: column; gap: 14px; }
.list-top { display: flex; align-items: center; gap: 6px; }
.search { flex: 1; margin: 0; }
.search-box {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); color: var(--muted);
  border: 1px solid transparent;
}
.search-box:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::-webkit-search-cancel-button { display: none; }
.list-title { display: flex; align-items: baseline; gap: 10px; padding: 0 4px; min-height: 34px; }
.list-title h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.list-title .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-title .seg { align-self: center; }
.bulk-bar { display: none; align-items: center; gap: 2px; padding: 0 4px; min-height: 34px; margin: 0; }
.list-inner.selecting .bulk-bar { display: flex; }
.list-inner.selecting .list-title { display: none; }
.bulk-count { font-weight: 600; margin-left: 8px; }
.check-all { display: grid; place-items: center; width: 34px; }

.rows { list-style: none; margin: 0; padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }
.group-label { padding: 12px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.row { position: relative; display: flex; gap: 12px; padding: 12px; border-radius: 14px; }
.row:hover { background: var(--hover); }
.row.active, .row.active:hover { background: var(--panel); box-shadow: var(--shadow); }
.row.cursor { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 50%, transparent); }
.row-link { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; color: var(--ink); }
.row-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--accent); }
.row-from { font-weight: 500; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-subject { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 22px; }
.row-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row-clip { color: var(--muted); }
.row.unread .row-from, .row.unread .row-subject { font-weight: 600; color: var(--ink); }
.row.unread .row-time { color: var(--accent); font-weight: 600; }

.row .avatar { cursor: pointer; }
.row .avatar input {
  position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; opacity: 0;
  cursor: pointer;
}
.row:hover .avatar input, .list-inner.selecting .avatar input, .row .avatar input:focus-visible { opacity: 1; }
.row:hover .avatar-letter, .list-inner.selecting .avatar-letter { visibility: hidden; }
.row:hover .avatar, .list-inner.selecting .row .avatar { background: var(--soft); }

/* Checkboxes: rounded square in the app's ink, jade with a white tick when checked. */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; margin: 0;
  width: 18px; height: 18px; border-radius: 6px; cursor: pointer;
  border: 1.5px solid color-mix(in srgb, var(--ink) 32%, transparent); background: var(--panel) center / 12px no-repeat;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
input[type="checkbox"]:hover { border-color: color-mix(in srgb, var(--ink) 55%, transparent); }
input[type="checkbox"]:checked {
  border-color: var(--accent); background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.row-star {
  position: absolute; right: 10px; bottom: 10px; width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); opacity: 0; padding: 0;
}
.row:hover .row-star, .row-star:focus-visible { opacity: 1; }
.row-star:hover { color: var(--star); background: var(--soft); }
.row-star.on { opacity: 1; color: var(--star); }
.row-star.on .ic, .star-btn.on .ic { fill: currentColor; }
.star-btn.on { color: var(--star); }

.pager { display: flex; align-items: center; gap: 4px; padding: 12px 20px 4px; color: var(--muted); font-size: 12px; }
.pager span { flex: 1; }
.list-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.list-empty p { margin: 0 0 4px; color: var(--ink); font-weight: 600; font-size: 15px; }

/* reader card */
.reader { min-height: 0; min-width: 0; padding: 12px 12px 12px 4px; }
.reader > .thread, .reader > .compose, .reader > .empty {
  height: 100%; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.empty { align-items: center; justify-content: center; text-align: center; gap: 4px; color: var(--muted); padding: 24px; }
.empty p { margin: 12px 0 0; color: var(--ink); font-weight: 600; font-size: 16px; }
.empty-mark { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); color: var(--muted); }
.notice-done .empty-mark { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--line); margin: 0; }
.toolbar .icon-btn-outline + .icon-btn-outline { margin-left: 4px; }
.divider { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--hover); color: var(--ink); }
.menu-pop {
  position: absolute; top: 44px; left: 0; z-index: 20; min-width: 220px; max-height: 360px; overflow-y: auto;
  padding: 6px; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-pop); border: 1px solid var(--line);
}
.menu-label { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink2); text-align: left;
}
.menu-item:hover { background: var(--hover); color: var(--ink); }
.menu-item .swatch { margin: 0 4px; }

.reader-scroll { flex: 1; overflow-y: auto; padding: 30px 48px 24px; }
.reader-col { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.thread-head { display: flex; flex-direction: column; gap: 10px; }
.thread-subject { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 32px; line-height: 1.15; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.thread-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.thread-meta .chip .swatch { width: 6px; height: 6px; flex-basis: 6px; border-radius: 2px; }

.msg > summary { list-style: none; cursor: pointer; }
.msg > summary::-webkit-details-marker { display: none; }
.mail-view > * + * { margin-top: 24px; }
.stack { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.msg-folded + .msg-folded { border-top: 1px solid var(--line); }
.msg-folded > summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.msg-folded > summary:hover { background: var(--hover); }
.msg-folded strong { flex: 0 0 auto; }
.msg-folded .snippet { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-folded[open] .snippet { visibility: hidden; }
.msg-folded > .msg-body { padding: 4px 16px 16px 58px; }
.msg-date { color: var(--muted); font-size: 13px; white-space: nowrap; flex: 0 0 auto; }
.msg-open { display: flex; flex-direction: column; }
.msg-open > summary { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.who { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; font-size: 13px; }
.who-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.who-line strong { font-size: 15px; }
.msg-open > .msg-body { padding-left: 52px; }
.msg-body { display: flex; flex-direction: column; gap: 16px; }
.notice {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px;
  background: var(--soft); color: var(--muted); font-size: 13px;
}
.notice span { flex: 1; }
.frame-wrap { border-radius: 12px; }
.body-frame { display: block; width: 100%; height: 40px; border: 0; background: transparent; border-radius: 12px; }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.file {
  display: flex; align-items: center; gap: 12px; width: 240px; max-width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--panel);
}
a.file:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.file-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-text strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-text span { font-size: 12px; color: var(--muted); }
.file-badge {
  width: 36px; height: 40px; flex: 0 0 36px; border-radius: 6px; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: .04em; background: var(--soft); color: var(--ink2);
}
.kind-pdf { background: #F3E1DC; color: #8C3B28; }
.kind-img { background: #DCE8F1; color: #2D5878; }
.kind-sheet { background: #DDEBDF; color: #2F6B3B; }
.kind-doc { background: #E1E4F2; color: #3B4A86; }
.kind-zip { background: #ECE6D8; color: #6B5A2E; }
.file-x { width: 30px; height: 30px; margin-right: -4px; color: var(--muted); }
.file.uploading { border-style: dashed; color: var(--muted); }
.progress { height: 4px; border-radius: 2px; background: var(--soft); overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 4px; width: 0; background: var(--accent); transition: width .15s; }
.msg-actions { display: flex; gap: 4px; }

.reply-bar { padding: 14px 48px 20px; }
.reply-inner {
  max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 6px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow);
}
.reply-field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left;
}
.reply-field:hover { background: var(--hover); color: var(--ink2); }
.reply-field span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* helpdesk: ticket numbers and statuses */
.ticket-code { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.ticket-code-lg { font-size: 13px; color: var(--ink2); }
.status-chip { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.st-open { --st: var(--accent); }
.st-pending { --st: #B57A06; }
.st-solved { --st: #5B6B7A; }
.st-closed { --st: var(--muted); }
.status-chip { color: var(--st); background: color-mix(in srgb, var(--st) 13%, transparent); }
.ticket-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.status-pick { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--soft); margin: 0; }
.status-opt { border: 0; background: transparent; border-radius: 7px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.status-opt:hover { color: var(--ink); }
.status-opt.on { background: var(--panel); color: var(--st); font-weight: 700; box-shadow: var(--shadow); }
.send-solve { border: 1px solid var(--line); margin-right: 8px; }

/* helpdesk workspace: desk switcher, ticket views, assignment, responses */
.desk-badge { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); border: 1px solid currentColor; border-radius: 6px; padding: 1px 6px; }
.accounts form { margin: 0; }
.account-item { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
.nav-rule { height: 1px; background: var(--line); margin: 5px 10px; }
.nav-quiet .nav-item { height: 34px; font-size: 13px; color: var(--muted); }
.nav-quiet .nav-item.active { color: var(--ink); }
.count.warn { color: var(--danger); font-weight: 600; }
.view-open .ic { color: var(--accent); }
.view-pending .ic { color: #B57A06; }
.view-unassigned .ic { color: var(--muted); }
.spam-hint { display: flex; align-items: center; gap: 10px; margin: 0 12px 10px; padding: 9px 12px; border: 1px dashed var(--line);
  border-radius: 12px; color: var(--ink2); font-size: 13px; }
.spam-hint .ic { color: var(--danger); flex: 0 0 auto; }
.spam-hint span { flex: 1; }
.spam-hint:hover { background: var(--hover); }
.assignee { width: 20px; height: 20px; flex: 0 0 20px; box-sizing: border-box; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 700; background: var(--av3); color: var(--ink2); }
.assignee.me { background: var(--ink); color: var(--bg); }
.assignee.none { background: transparent; border: 1.5px dashed var(--muted); }
.row-time.waited { font-variant-numeric: tabular-nums; }
.ticket-wait { font-size: 12px; }
.assign-pick { margin: 0; }
.assign-select { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 5px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel); }
.assign-select .assignee { width: 22px; height: 22px; flex-basis: 22px; }
.assign-select select { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 12px; padding: 0 2px; max-width: 170px; cursor: pointer; }
.ticket-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; }
.chain { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chain-person { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 3px; border-radius: 999px; background: var(--soft); color: var(--ink2); }
.avatar-xs { width: 20px; height: 20px; flex-basis: 20px; font-size: 10px; }
.chain .link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--accent); padding: 2px 4px; }
.respond-row { max-width: 760px; margin: 0 auto 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.respond-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 2px; }
.respond-btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.respond-btn:hover { border-color: var(--st); }
.respond-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st); }
/* phone-only desk pieces: status tabs, bottom bar, chain summary, chat view */
.desk-tabs, .desk-bar, .chain-count, .as-email-toggle, .chat, .chat-back { display: none; }
@media (max-width: 760px) {
  .thread:has(.chat) .mail-view { display: none; }
  .chat { display: flex; flex-direction: column; gap: 12px; margin: 6px -20px 0; padding: 18px 14px 14px; background: var(--bg); }
  .as-email-toggle:checked ~ .chat { display: none; }
  .as-email-toggle:checked ~ .mail-view { display: block; }
  .as-email-toggle:checked ~ .chat-back { display: inline-block; margin: 8px 0 4px; }
  .bubble { max-width: 84%; align-self: flex-start; padding: 10px 14px; border-radius: 18px 18px 18px 6px;
    background: var(--panel); box-shadow: var(--shadow); }
  .bubble.mine { align-self: flex-end; border-radius: 18px 18px 6px 18px; background: var(--ink); color: var(--bg); }
  .bubble-head { display: flex; align-items: baseline; gap: 8px; font-size: 12px; margin-bottom: 3px; }
  .bubble-head span { opacity: .7; }
  .bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }
  .bubble-files a { display: inline-flex; align-items: center; gap: 5px; margin: 8px 10px 0 0; font-size: 12px; color: inherit; text-decoration: underline; }
  .chat-event { align-self: center; font-size: 12px; font-weight: 600; color: var(--accent); }
  .chat-switch { align-self: center; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
}
@media (max-width: 760px) and (prefers-color-scheme: dark) {
  /* Dark mode: the desk's side is raised graphite, a shade above the customer's, with a hairline edge. */
  .bubble.mine { background: #2E3137; color: #ECEDEE; box-shadow: inset 0 0 0 1px #3B3F46; }
  .bubble.mine .bubble-head span { color: #A3A7AE; opacity: 1; }
}
.desk-head, .desk-search-toggle, .card, .ticket-back, .status-select, .ticket-sub, .assign-mobile, .send-dot { display: none; }
@media (max-width: 760px) {
  /* queue, as in the mobile mockup */
  .list-head:has(.desk-head) { padding: 18px 16px 6px; }
  .desk-head { display: flex; align-items: center; gap: 10px; }
  .desk-head h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
  .list-head:has(.desk-head) .list-title { display: none; }
  .list-head:has(.desk-head) .list-top { display: none; margin-top: 10px; }
  .list-head:has(.desk-search-toggle:checked) .list-top { display: flex; }
  .list-head:has(.desk-head) [data-toggle-nav] { display: none; }
  .desk-tabs { display: flex; gap: 4px; margin-top: 14px; padding: 4px; border-radius: 12px; background: var(--soft);
    overflow-x: auto; scrollbar-width: none; }
  .desk-tabs a { flex: 0 0 calc((100% - 8px) / 3); display: grid; place-items: center; height: 38px; border-radius: 9px;
    font-size: 13px; color: var(--muted); white-space: nowrap; }
  .desk-tabs a.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
  .app.desk .rows:has(.card) { display: flex; flex-direction: column; gap: 10px; padding: 4px 12px 12px; }
  .app.desk .rows:has(.card) .group-label { display: none; }
  .row:has(.card) { padding: 0; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
  .row:has(.card) > .avatar, .row:has(.card) .row-star,
  .row:has(.card) .row-line, .row:has(.card) .row-subject, .row:has(.card) .row-preview { display: none; }
  .card { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 12px 14px; }
  .card-top { display: flex; align-items: center; gap: 8px; }
  .card-top .ticket-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; }
  .card-badge { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; color: #1F4E8C; background: #E3EAF4; }
  .card-wait { font-size: 12px; color: var(--muted); white-space: nowrap; }
  .card-wait.late { color: var(--danger); font-weight: 600; }
  .card-subject { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app.desk .spam-hint { margin: 2px 12px 10px; }
  .app.desk .fab { width: 56px; padding: 0; gap: 0; justify-content: center; font-size: 0; border-radius: 18px; }

  /* ticket, as in the mobile mockup */
  .thread.is-ticket .toolbar { display: none; }
  .thread.is-ticket .reader-scroll { padding-top: 10px; }
  .ticket-back { display: inline-grid; width: 40px; height: 40px; margin-left: -10px; }
  .thread.is-ticket .ticket-bar { flex-wrap: nowrap; gap: 6px; }
  .thread.is-ticket .ticket-bar .ticket-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
  .thread.is-ticket .ticket-bar .ticket-wait, .thread.is-ticket .ticket-bar .assign-pick,
  .thread.is-ticket .ticket-bar .status-pick { display: none; }
  .status-select { display: block; margin: 0; }
  .status-pill { display: inline-flex; align-items: center; height: 34px; padding: 0 6px 0 8px; border-radius: 10px;
    background: color-mix(in srgb, var(--st) 14%, transparent); }
  .status-pill select { border: 0; background: transparent; color: var(--st); font: inherit; font-size: 13px; font-weight: 600; }
  .thread.is-ticket .thread-subject { font-size: 24px; line-height: 1.2; }
  .ticket-sub { display: block; margin-top: -6px; font-size: 12px; color: var(--muted); }
  .thread.is-ticket .from-line, .thread.is-ticket .thread-meta { display: none; }
  .assign-mobile { display: block; }
  .ticket-facts { gap: 8px; }
  .ticket-facts .assign-select { height: 34px; }
  .chain { height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; gap: 8px; font-size: 13px; }
  .chain .link-btn { padding: 0; font-size: 13px; }
  .chain-person { display: none; }
  .chain-count { display: inline; color: var(--ink2); }
  .thread.is-ticket .chat { margin-top: 14px; flex: 1 0 auto; }
  .thread.is-ticket .reader-col { min-height: 100%; display: flex; flex-direction: column; }
  .ticket-facts select, .status-pill select { field-sizing: content; }

  .respond-row { flex-wrap: nowrap; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
  .respond-btn { flex: 0 0 auto; height: 34px; border-radius: 999px; }
  .respond-label, .respond-dot { display: none; }
  .respond-btn.st-solved { color: var(--accent); font-weight: 600; }
  .thread.is-ticket .reply-inner .btn { display: none; }
  .thread.is-ticket .reply-field { height: 50px; padding: 0 5px 0 16px; justify-content: space-between; border: 1px solid var(--line);
    border-radius: 25px; background: var(--panel); color: var(--muted); font-weight: 400; }
  .thread.is-ticket .reply-field:hover { background: var(--panel); color: var(--muted); }
  .thread.is-ticket .reply-field > .ic { display: none; }
  .send-dot { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
    background: var(--ink); color: var(--bg); }

  .desk-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; display: flex; background: var(--panel);
    border-top: 1px solid var(--line); padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  .desk-bar > a, .desk-bar > form { flex: 1; margin: 0; }
  .desk-bar a, .desk-bar button { width: 100%; height: 52px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; border: 0; background: transparent; font: inherit; font-size: 11px; color: var(--muted); }
  .desk-bar .on { color: var(--ink); font-weight: 600; }
  .app.has-reader .desk-bar { display: none; }
  .app.desk .list { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .app.desk .fab { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .app.desk .list-title .muted { display: none; }
  /* mail-first agents: the Mail / Tickets bar shows on their own mail too */
  .app.mail-user .list { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .app.mail-user .fab { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .desk-switch { position: relative; }
  .desk-switch > summary { list-style: none; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-weight: 600; cursor: pointer; }
  .desk-switch > summary::-webkit-details-marker { display: none; }
  .desk-switch[open] > summary { border-color: var(--accent); }
  .desk-switch .menu-pop { right: 0; left: auto; min-width: 220px; }
}
/* the desk's view tabs on a wide screen, for mail-first agents (desk agents have them in the sidebar) */
@media (min-width: 761px) {
  .app.mail-user.desk .desk-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--soft);
    align-self: flex-start; flex-wrap: wrap; }
  .app.mail-user.desk .desk-tabs a { padding: 4px 10px; border-radius: 7px; font-size: 12px; color: var(--muted); }
  .app.mail-user.desk .desk-tabs a:hover { color: var(--ink); }
  .app.mail-user.desk .desk-tabs a.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
}
.nav-sub { padding-left: 40px; }

/* internal notes: warm paper, so they never read as something the customer saw */
:root { --note: #FBF5E6; --note-line: #EFE2BF; --note-ink: #8A5D05; }
@media (prefers-color-scheme: dark) { :root { --note: #2A2418; --note-line: #4A3E22; --note-ink: #E2B23A; } }
.note-tag { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--note-ink); }
.msg-note { background: var(--note); box-shadow: inset 0 0 0 1px var(--note-line); }
.bubble.note { align-self: stretch; max-width: none; background: var(--note); box-shadow: inset 0 0 0 1px var(--note-line); border-radius: 14px; }
.bubble.note .bubble-head span { opacity: 1; }
.note-box { margin: 0 0 10px; }
.note-box > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--note-ink); }
.note-box > summary::-webkit-details-marker { display: none; }
.note-form { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 0; padding: 10px 12px 12px; border-radius: 14px;
  background: var(--note); border: 1px solid var(--note-line); }
.note-hint { font-size: 12px; color: var(--note-ink); }
.note-field { position: relative; }
.note-field textarea { width: 100%; min-height: 64px; resize: vertical; border: 1px solid var(--note-line); border-radius: 10px;
  padding: 8px 10px; background: var(--panel); color: var(--ink); outline: 0; }
.note-field textarea:focus { border-color: var(--note-ink); }
.note-actions { display: flex; justify-content: flex-end; }

/* people suggestions (To / Cc / Bcc and @mentions) */
.recips { position: relative; }
.suggest { position: absolute; z-index: 30; left: 0; top: calc(100% + 4px); width: min(420px, 100%); margin: 0; padding: 6px;
  list-style: none; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-pop); }
.suggest li { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border-radius: 10px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--soft); }
.suggest .avatar { width: 28px; height: 28px; flex-basis: 28px; font-size: 12px; }
.suggest-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.suggest-text strong { font-size: 13px; }
.suggest-text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-kind { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }

/* People card: hover (or long-press) anyone shown in the app. */
[data-person] { cursor: default; }
.person-card { position: fixed; z-index: 60; width: min(320px, calc(100vw - 16px)); padding: 14px; border-radius: 14px;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-pop); font-size: 13px; }
.person-card[hidden] { display: none; }
.pc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pc-head .avatar { width: 40px; height: 40px; flex-basis: 40px; font-size: 16px; }
.pc-head strong { display: block; font-size: 15px; }
.pc-head span { color: var(--muted); }
.pc-row { display: flex; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); }
.pc-row > span:first-child { flex: 0 0 88px; color: var(--muted); }
.pc-row > :last-child { min-width: 0; overflow-wrap: anywhere; }
.person-card { --pc-link: var(--accent); }
@media (prefers-color-scheme: dark) { .person-card { --pc-link: #4CC29C; } } /* the green messages use in dark */
.pc-row a { color: var(--pc-link); text-decoration: none; }
.pc-row .link-btn { padding: 0; color: var(--pc-link); font-size: 13px; }
.pc-note { margin: 6px 0 0; color: var(--muted); }
.pc-actions { display: flex; gap: 8px; margin-top: 12px; }
.pc-actions .btn { min-height: 36px; padding: 0 14px; font-size: 13px; }
.note-field .suggest { top: auto; bottom: calc(100% + 4px); }
.compose-scroll .compose-col { position: relative; } /* @mention list sits under the caret */

/* live ticket notices */
.notices { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 32px)); }
.ticket-notice { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow-pop); }
.ticket-notice .ic { color: #4CC29C; }
.ticket-notice-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ticket-notice-text span { font-size: 12px; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-notice a { color: #4CC29C; font-weight: 600; font-size: 13px; padding: 8px 2px; }
.ticket-notice button { border: 0; background: transparent; color: inherit; opacity: .6; padding: 6px; }
@media (max-width: 760px) { .notices { left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top)); bottom: auto; width: auto; } }
.new-reply { font-size: 11px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.card-badge.new { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
@media (prefers-color-scheme: dark) { .st-pending { --st: #E2B23A; } .st-solved { --st: #9AA8B6; } }

/* compose */
.compose { position: relative; margin: 0; }
.compose-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--line); min-height: 59px; }
.save-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.compose-scroll { flex: 1; overflow-y: auto; padding: 20px 48px 24px; }
.compose-col { max-width: 760px; margin: 0 auto; }
.field { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.field > label { width: 56px; flex: 0 0 56px; color: var(--muted); }
.field select, .field > input {
  flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: transparent; color: var(--ink);
}
.recips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1; min-width: 0; padding: 8px 0; }
.recips > input { flex: 1 1 140px; min-width: 120px; height: 30px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.recip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; max-width: 100%; padding: 0 4px 0 3px;
  border-radius: 999px; background: var(--soft); font-weight: 500;
}
.recip .avatar { width: 24px; height: 24px; flex-basis: 24px; font-size: 11px; }
.recip > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recip.bad { background: color-mix(in srgb, var(--danger) 14%, var(--panel)); color: var(--danger); }
.recip button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); display: grid; place-items: center; padding: 0; }
.recip button:hover { background: var(--hover); color: var(--ink); }
.subject-input {
  display: block; width: 100%; margin-top: 26px; padding: 0; border: 0; outline: 0; background: transparent;
  font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: -0.01em; color: var(--ink);
}
.subject-input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.editor { margin-top: 16px; min-height: 280px; font-size: 15px; line-height: 1.7; outline: none; overflow-wrap: anywhere; }
.editor p { margin: 0 0 .9em; }
.editor ol, .editor ul { margin: 0 0 .9em; padding-left: 22px; }
.editor blockquote { margin: 0 0 .9em; padding-left: 1em; border-left: 2px solid var(--line); color: var(--muted); }
.editor a { color: var(--accent); }
.editor a.mention { font-weight: 600; text-decoration: none; cursor: default; user-select: all; }
.compose .files { margin-top: 18px; }
.compose .file { width: 260px; }
.compose-foot { padding: 14px 48px 20px; border-top: 1px solid var(--line); }
.compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.compose-actions [data-send] { margin-right: 10px; }
.dropzone {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border-radius: 18px; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent);
}

/* focus mode while composing: rail + full-width editor */
.app.composing { grid-template-columns: 72px 0 minmax(0, 1fr); }
.app.composing .list { display: none; }

/* icon rail (composing, and narrow desktops) */
.app.composing .sidebar { padding: 20px 0 14px; align-items: center; }
.app.composing .label, .app.composing .nav-section, .app.composing .wordmark .label { display: none; }
.app.composing .compose-btn { width: 44px; padding: 0; justify-content: center; }
.app.composing .nav-item { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 12px; position: relative; }
.app.composing .nav-item .count.unread { position: absolute; top: 4px; right: 3px; font-size: 10px; }
.app.composing .account { padding: 0; }
.app.composing .install-btn { width: 44px; }
.app.composing .nav-body { align-items: center; }

@media (max-width: 1180px) and (min-width: 761px) {
  .app { grid-template-columns: 72px minmax(300px, 380px) minmax(0, 1fr); }
  .sidebar { padding: 20px 0 14px; align-items: center; }
  .sidebar .label, .sidebar .nav-section { display: none; }
  .compose-btn { width: 44px; padding: 0; justify-content: center; }
  .nav-body { align-items: center; }
  .nav-item { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 12px; position: relative; }
  .nav-item.depth-1, .nav-item.depth-2, .nav-item.depth-3 { padding: 0; }
  .nav-item .count.unread { position: absolute; top: 4px; right: 3px; font-size: 10px; }
  .account { padding: 0; }
  .install-btn { width: 44px; }
  .reader-scroll, .compose-scroll { padding-left: 32px; padding-right: 32px; }
  .reply-bar, .compose-foot { padding-left: 32px; padding-right: 32px; }
}

/* installed app: keep content clear of notches and the home indicator */
@media (display-mode: standalone) {
  .sidebar { padding-top: max(20px, env(safe-area-inset-top)); }
  .list-head { padding-top: max(20px, env(safe-area-inset-top)); }
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px);
  padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop); font-weight: 500;
}
.toast.error { background: var(--danger); color: #fff; }

.only-mobile, .fab, .scrim { display: none; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; padding: 36px 32px 32px;
  border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); margin: 0;
}
.login-card .wordmark { padding: 0; margin-bottom: 10px; }
.login-head h1 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: -0.01em; }
.login-head p { margin: 4px 0 0; color: var(--muted); }
.login-field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--ink2); }
.login-field input {
  height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); outline: 0;
}
.login-field input:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--panel); }
.login-card .btn-lg { margin-top: 6px; width: 100%; }
.login-form { display: flex; flex-direction: column; gap: 18px; margin: 0; }
.login-alt > summary {
  list-style: none; cursor: pointer; text-align: center; font-size: 13px; color: var(--muted); padding: 4px 0;
}
.login-alt > summary::-webkit-details-marker { display: none; }
.login-alt > summary:hover { color: var(--ink); }
.login-alt[open] > summary { margin-bottom: 14px; }
.login-secondary { border: 1px solid var(--line); }
.login-link { display: block; text-align: center; font-size: 13px; color: var(--muted); padding: 2px 0; }
.login-link:hover { color: var(--ink); }
.login-card .wordmark img { height: 44px; width: auto; }
.locked-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--panel)); }
.login-head p + p { margin-top: 6px; }
.login-hint { margin: -6px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.login-hint a { color: var(--ink2); text-decoration: underline; text-underline-offset: 2px; }
.alert { margin: 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 10%, var(--panel)); color: var(--danger); font-size: 13px; }

/* dark: message bodies keep a light page, like printed mail */
@media (prefers-color-scheme: dark) {
  .kind-pdf { background: #3D2620; color: #F1B8A8; }
  .kind-img { background: #1F3140; color: #A9CBE6; }
  .kind-sheet { background: #1F3324; color: #A6D3AE; }
  .kind-doc { background: #262B45; color: #B8C2EE; }
  .kind-zip { background: #352F22; color: #DCC891; }
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .app, .app.composing { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: inline-grid; }
  .hide-mobile { display: none !important; }
  /* iPhone: only the panes scroll, never the page. When the page itself scrolls, Safari's collapsing
     bars move fixed things (top bar, reply box) off screen. */
  html:has(.app), html:has(.app) body { overflow: hidden; overscroll-behavior: none; }
  .app { position: fixed; inset: 0; height: auto; }
  .list, .reader-scroll, .compose-scroll { overscroll-behavior: contain; }
  .thread.is-ticket .reader-scroll { padding-top: 0; }
  /* The header's rows join the scrolling column, so its first row can stay pinned the whole way down. */
  .thread.is-ticket .thread-head { display: contents; }
  .thread.is-ticket .ticket-bar { position: sticky; top: 0; z-index: 3; margin: 0 -20px -12px; padding: 10px 20px 8px;
    background: var(--panel); }
  .sidebar {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: 280px; background: var(--bg);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-pop);
  }
  .app.composing .sidebar { padding: 20px 14px 14px; align-items: stretch; }
  .app.composing .sidebar .label, .app.composing .nav-section { display: revert; }
  .app.composing .nav-item { width: auto; height: 38px; padding: 0 10px; justify-content: flex-start; }
  .app.composing .compose-btn { width: auto; padding: 0 14px; justify-content: flex-start; }
  .app.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / 30%); }
  .app.nav-open .scrim { display: block; }
  .list, .reader { grid-column: 1; grid-row: 1; }
  .reader { display: none; padding: 0; }
  .app.has-reader .list { display: none; }
  .app.has-reader .reader { display: block; }
  .reader > .thread, .reader > .compose, .reader > .empty { border-radius: 0; box-shadow: none; }
  .list-head { padding: 14px 12px 8px; }
  .list-top .icon-btn { width: 44px; height: 44px; margin-left: -6px; }
  .search-box { height: 44px; }
  .search-box kbd, .btn kbd { display: none; }
  .list-title h1 { font-size: 28px; letter-spacing: -0.02em; }
  .list-title .seg { display: none; }
  .row { padding: 12px 10px; }
  .row .avatar { width: 40px; height: 40px; flex-basis: 40px; font-size: 15px; }
  .row-star { opacity: 1; }
  .row-star:not(.on) { display: none; }
  .fab {
    position: fixed; right: 20px; bottom: 24px; z-index: 10; display: inline-flex; align-items: center; gap: 10px;
    height: 56px; padding: 0 22px 0 18px; border-radius: 18px; background: var(--ink); color: var(--bg);
    font-weight: 600; box-shadow: 0 6px 20px rgb(22 24 28 / 22%);
  }
  .app.has-reader .fab { display: none; }
  .toolbar { padding: 8px 8px; }
  .toolbar .icon-btn { width: 44px; height: 44px; border-radius: 12px; }
  .toolbar .only-mobile + .icon-btn { margin-left: auto; }
  .reader-scroll { padding: 8px 20px 20px; }
  .thread-subject { font-size: 27px; }
  .msg-open > .msg-body, .msg-folded > .msg-body { padding-left: 0; }
  .msg-folded > .msg-body { padding: 4px 14px 14px; }
  .msg-folded .snippet { display: none; }
  .msg-folded strong { flex: 1; }
  .who-line .muted { display: none; }
  .reply-bar { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .reply-inner { border: 0; box-shadow: none; padding: 0; gap: 8px; }
  .reply-field { height: 48px; justify-content: center; background: var(--ink); color: var(--bg); font-weight: 600; border-radius: 14px; }
  .reply-field:hover { background: var(--ink); color: var(--bg); }
  .reply-inner .btn { width: 48px; height: 48px; padding: 0; border: 1px solid var(--line); border-radius: 14px; }
  .compose-scroll { padding: 8px 18px 20px; }
  .compose-foot { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
  .compose-bar { padding-left: 16px; }
  .subject-input { font-size: 26px; margin-top: 20px; }
  .seg-tools button:nth-child(n+5) { display: none; }
  .compose .file, .file { width: 100%; }
}
