:root {
  --bg: #FFFFFF; --panel: #F5F6F8; --line: #E3E6EA; --line2: #EEF0F3;
  --text: #15181E; --text2: #3C4450; --muted: #5B6470;
  --accent: #0B6B5D; --accent-ink: #084F45; --accent-tint: #E3F3EF; --accent-tint2: #F0F7F5; --accent-line: #CFE6E0;
  --warn: #9A4B00; --warn-tint: #FFF1E0; --danger: #B3261E; --chip: #ECEFF2;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; left: -9999px; }

/* layout */
.app { display: flex; height: 100vh; height: 100dvh; width: 100%; }
.side { flex: 0 0 240px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 12px; gap: 4px; overflow-y: auto; }
.list { flex: 0 1 400px; min-width: 320px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.main { flex: 1 1 560px; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 700; font-size: 16px; letter-spacing: -0.2px; }
.brand .logo { display: flex; align-items: center; color: #01725B; }
.brand .logo svg { width: 34px; height: 24px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 500; border: 0; background: transparent; width: 100%; text-align: left; }
.nav:hover { background: #ECEFF2; }
.nav.active { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(21,24,30,0.06); }
.nav .n { flex: 1; }
.nav .count { font-size: 12px; color: var(--muted); }
.nav .count.hot { color: #fff; background: var(--warn); border-radius: 999px; padding: 1px 7px; font-weight: 600; }
.sect { font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); padding: 18px 10px 6px; }
.grow { flex: 1; }
.storage { padding: 10px; border-radius: 10px; background: #fff; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted); }
.storage .row { display: flex; justify-content: space-between; }
.storage b { color: var(--text); }
.bar { height: 6px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; }
.avatar { width: 30px; height: 30px; border-radius: 999px; background: #D7E9E5; color: var(--accent); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.grey { background: #E8ECF0; color: var(--text); font-weight: 600; width: 36px; height: 36px; }
.who .u { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.who .u span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .u b { font-weight: 600; }
.who.me { padding: 0 0 6px; }
.who.me .u { font-size: 15px; }
.who.me .u span { font-size: 13px; }
.item.cur { background: var(--accent-tint2); border-color: var(--accent-line); }
.item .tag { margin-left: 6px; font-size: 11px; padding: 1px 7px; vertical-align: middle; white-space: nowrap; }
.btn.signout { align-self: flex-start; padding: 10px 16px; font-size: 14px; font-weight: 600; color: #B42318; border-color: #F0B8B2; background: #FFF5F4; }
.btn.signout:hover { background: #FDE8E6; }
@media (max-width: 900px) { .btn.signout { align-self: stretch; justify-content: center; padding: 12px 16px; font-size: 16px; } }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12px; text-align: left; }

/* list column */
.listhead { padding: 16px 16px 10px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid #D5D9DF; background: #fff; font-size: 12px; font-weight: 500; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rows { overflow-y: auto; flex: 1; }
.row-m { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) auto; grid-template-areas: "from line when" "addr tags tags"; align-items: center; gap: 3px 12px; padding: 10px 16px; border-bottom: 1px solid var(--line2); border-left: 3px solid transparent; width: 100%; text-align: left; background: none; border-top: 0; border-right: 0; font-size: 14px; }
.row-m:hover { background: var(--panel); }
.row-m.sel { border-left-color: var(--accent); background: var(--accent-tint2); }
.row-m .from { grid-area: from; font-weight: 400; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-m.unread .from { font-weight: 600; color: var(--text); }
.row-m .line { grid-area: line; display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.row-m .addr { grid-area: addr; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-m .tags { grid-area: tags; display: flex; gap: 4px; min-height: 18px; overflow: hidden; }
.tag.att { display: inline-flex; align-items: center; gap: 2px; padding: 2px 5px; }
.row-m .subj { color: var(--text); overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; max-width: 100%; }
.row-m .sum { color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; white-space: pre; }
.row-m mark { background: #FFF3BF; color: var(--text); border-radius: 2px; padding: 0 1px; }
.row-m.unread .subj { color: var(--text); font-weight: 600; }
.row-m .when { grid-area: when; justify-self: end; text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.app.onepane .row-m { grid-template-columns: minmax(140px, 220px) minmax(0, 1fr) auto; }
.tag { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 7px; background: var(--chip); color: var(--text); }
.tag.ok { background: var(--accent-tint); color: var(--accent); }
.tag.warn { background: var(--warn-tint); color: var(--warn); }
.tag.bad { background: #FBE9E7; color: var(--danger); }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; }
.more { margin: 12px auto; }

/* reading pane */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px max(24px, 3vw); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; border: 1px solid #D5D9DF; background: #fff; font-size: 13px; font-weight: 500; }
.btn:hover { background: var(--panel); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--danger); }
.lock { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-left: auto; }
.article { padding: 28px max(32px, 4vw) 48px; display: flex; flex-direction: column; gap: 20px; width: 100%; overflow-y: auto; }
.article > * { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; }
.article h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.3; }
.hdr { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hdr .who2 { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hdr .who2 .muted { font-size: 13px; }
.muted { color: var(--muted); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.ai { border: 1px solid var(--accent-line); background: var(--accent-tint2); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.ai .t { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: .3px; text-transform: uppercase; }
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--text2); flex-wrap: wrap; }
.notice span { flex: 1; }
.attach { display: flex; gap: 8px; flex-wrap: wrap; }
.attach .a { display: inline-flex; gap: 8px; align-items: center; padding: 6px 8px 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; max-width: 100%; }
.attach .fn { font-weight: 600; overflow-wrap: anywhere; }
.ex-body { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--panel); }
.ex-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; overflow-wrap: anywhere; }
.btn.sm.on { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent); }
.ex-body pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.overlay { position: fixed; inset: 0; background: rgba(21,24,30,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.viewer { background: #fff; border-radius: 12px; width: min(1000px, 100%); height: min(92vh, 100%); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.viewer-head .fn { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.viewer-head .grow { flex: 1; }
.viewer-frame { flex: 1; border: 0; width: 100%; background: #525659; }
.viewer-img { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; background: var(--panel); }
.viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
@media (max-width: 900px) { .overlay { padding: 0; } .viewer { border-radius: 0; height: 100%; } }
iframe.body { width: 100%; border: 0; min-height: 120px; background: #fff; overflow: hidden; flex: none; }
.placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* settings */
.page { padding: 32px max(40px, 4vw) 48px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.page > * { width: 100%; max-width: 1040px; margin-left: auto; margin-right: auto; }
.page h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); max-width: 1040px; flex-wrap: wrap; }
.tab { padding: 10px 14px; font-weight: 500; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 1040px; }
.pagehead p { color: var(--muted); max-width: 560px; }
.table { max-width: 1040px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex-shrink: 0; } /* overflow:hidden lets a flex column shrink it; never clip the rows */
.tr { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 3fr) 320px; gap: 12px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line2); }
.tr:last-child { border-bottom: 0; }
.tr.head { background: var(--panel); border-bottom-color: var(--line); font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; padding: 10px 20px; }
.tr.off { color: var(--muted); }
.tr.off .mono { text-decoration: line-through; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell small { font-size: 12px; color: var(--muted); }
.right { justify-self: end; display: flex; gap: 6px; }
.notebtn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; margin: 0; border-radius: 4px; font: inherit; color: inherit; text-align: left; min-width: 0; justify-self: start; }
.notebtn svg { color: var(--muted); opacity: 0; flex: none; }
.notebtn:hover, .notebtn:focus-visible { background: var(--panel); box-shadow: 0 0 0 6px var(--panel); }
.notebtn:hover svg, .notebtn:focus-visible svg { opacity: 1; }
.note-edit { width: 100%; padding: 6px 8px; border: 1px solid var(--accent); border-radius: 6px; font: inherit; outline: none; }
.form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form input { padding: 8px 10px; border: 1px solid #D5D9DF; border-radius: 8px; min-width: 240px; }
.note { font-size: 13px; color: var(--muted); max-width: 1040px; }
.err { color: var(--danger); font-size: 13px; }

/* login */
.center { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px calc(20px + env(safe-area-inset-bottom, 0px)); gap: 28px; background: var(--panel); }
.center .brand { font-size: 22px; letter-spacing: -0.3px; gap: 12px; padding: 0 0 4px; }
.center .brand .logo svg { width: 48px; height: 34px; }
.legal { margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.legal .links { display: flex; gap: 16px; }
.legal a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.legal a:hover { color: var(--text); }
.card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 8px 24px rgba(21,24,30,0.06); }
.card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }

.card .lbl { font-size: 13px; font-weight: 600; margin-top: 4px; }
.card input { border: 1px solid #D5D9DF; border-radius: 10px; padding: 11px 12px; font-size: 15px; outline: none; width: 100%; }
.card input:focus { border-color: var(--accent); }
.card input.big { font-size: 24px; letter-spacing: 4px; text-align: center; font-variant-numeric: tabular-nums; }
.readonly { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 15px; background: var(--panel); color: var(--text2); overflow-wrap: anywhere; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.suffix { display: flex; align-items: center; border: 1px solid #D5D9DF; border-radius: 10px; overflow: hidden; }
.suffix input { border: 0; border-radius: 0; flex: 1; min-width: 0; }
.suffix span { padding: 11px 12px; color: var(--muted); background: var(--panel); border-left: 1px solid var(--line); white-space: nowrap; }
.btn.lg { justify-content: center; padding: 13px 16px; font-size: 15px; border-radius: 10px; gap: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.or span { flex: 1; height: 1px; background: var(--line); }
.invite-by { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--accent-tint2); border: 1px solid var(--accent-line); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; max-width: 1040px; }
.cards.stack { grid-template-columns: 1fr; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.box h2 { font-size: 16px; font-weight: 600; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.item .cell { flex: 1; }
.item .ico { color: var(--accent); display: flex; }
.sub { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.sub .k { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }

.nav .dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; margin: 0 5px; }
.tag.code { font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.ai.dim { background: var(--panel); border-color: var(--line); }
.ai .todo { margin: 0; padding-left: 18px; font-size: 14px; }
.ai .xr { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ai .xv { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.ai .mono.big { font-size: 20px; letter-spacing: 2px; background: var(--chip); padding: 4px 10px; border-radius: 8px; }
.ai .foot .reply { flex: 1 1 100%; }
.reply { display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid var(--accent-line); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: var(--text); }
.reply-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.reply-head .t { text-transform: none; letter-spacing: 0; font-size: 13px; }
.tones { display: flex; gap: 4px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text2); }
.pill.on { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent); font-weight: 600; }
.reply-meta { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text2); overflow-wrap: anywhere; }
.reply-meta b { color: var(--muted); font-weight: 600; margin-right: 6px; }
.reply-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; padding: 10px 12px; background: var(--panel); border-radius: 8px; }
.reply-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ai .foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--accent-line); padding-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

/* chat */
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.chat-log { flex: 1; overflow-y: auto; padding: 24px max(32px, 4vw); display: flex; flex-direction: column; gap: 14px; }
.chat-log > * { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; }
.chat-empty { max-width: 640px; margin: auto; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.sugg { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.bubble { padding: 12px 16px; border-radius: 14px; line-height: 1.5; }
/* Bubbles hug their text and sit at either edge of the centred 820px column. */
.chat-log > .bubble { width: fit-content; max-width: min(760px, 100%); }
.chat-log > .bubble.user { background: var(--accent); color: #fff; margin-left: auto; margin-right: max(0px, calc((100% - 820px) / 2)); }
.chat-log > .bubble.assistant { background: var(--panel); border: 1px solid var(--line); margin-right: auto; margin-left: max(0px, calc((100% - 820px) / 2)); }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .tools { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.bubble .tools span::before { content: '› '; }
.cards-m { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.card-m { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; color: inherit; }
.card-m:hover { border-color: var(--accent-line); background: var(--accent-tint2); }
.card-m .l1 { display: flex; justify-content: space-between; gap: 10px; }
.card-m .l1 b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card-m .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.card-m .l2 { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-m .l3 { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cite { background: var(--accent-tint); color: var(--accent); border: 0; border-radius: 6px; padding: 0 5px; font-weight: 600; font-size: 13px; }
.cursor { display: inline-block; width: 8px; height: 14px; background: var(--muted); animation: blink 1s steps(2) infinite; vertical-align: text-bottom; }
@keyframes blink { to { opacity: 0; } }
.chat-input { display: flex; gap: 8px; padding: 12px max(24px, 4vw) calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.chat-input > * { max-width: 820px; }
.chat-input { justify-content: center; }
.chat-input input { flex: 1; min-width: 0; padding: 11px 14px; border: 1px solid #D5D9DF; border-radius: 10px; font-size: 15px; outline: none; }
.chat-input input:focus { border-color: var(--accent); }
.tag .x { background: none; border: 0; padding: 0 0 0 4px; font-size: 14px; color: inherit; }
@media (max-width: 900px) { .chat-log { padding: 16px; } }

/* one-pane reading layout (a per-user preference; phones are always one pane) */
@media (min-width: 901px) {
  .app.onepane .list { flex: 1 1 auto; border-right: 0; }
  .app.onepane.reading .list { display: none; }
  .app.onepane:not(.reading) .main.msgpane { display: none; }
  .app.onepane .back { display: inline-flex; }
}
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.choice.on { border-color: var(--accent); background: var(--accent-tint2); }
.choice input { margin: 3px 0 0; flex: 0 0 auto; }
.choice span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice small { color: var(--muted); }

.linkbtn.center { align-self: center; margin-top: 4px; }

/* phone */
.back { display: none; }
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .side { display: none; }
  .list { flex: 1 1 auto; border-right: 0; min-height: 0; }
  .main { flex: 1 1 auto; min-height: 0; }
  .app.reading .list { display: none; }
  .app:not(.reading) .main.msgpane { display: none; }
  .app.reading .phonenav { display: none; }
  .back { display: inline-flex; }
  /* iOS Safari zooms the page when a focused field is smaller than 16px. */
  input, textarea, select, .note-edit, .chat-input input, .form input, .card input { font-size: 16px; }
  .card input.big { font-size: 24px; }
  .article { padding: 16px 16px 32px; gap: 14px; }
  .list { min-width: 0; }
  .page { padding: 20px 16px 32px; }
  .toolbar { padding: 10px 12px; }
  .chat-log { padding: 16px; }
  .chat-input { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .article h1 { font-size: 19px; }
  .ai { padding: 12px 14px; gap: 8px; font-size: 14px; }
  .toolbar { padding: 10px 12px; }
  .tr { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 14px; }
  .tr .cell { flex: 1 1 100%; }
  .tr .notebtn, .tr .note-edit { flex: 1 1 100%; }
  .tr .notebtn svg { opacity: 1; }
  .tr .right { margin-left: auto; display: flex; gap: 6px; }
  .tr.head { display: none; }
  .page { padding: 20px 16px; }
  .app .phonenav { display: flex; }
  .row-m { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "from when" "line line" "addr tags"; gap: 3px 10px; padding: 12px 14px; font-size: 15px; }
  .row-m .tags { justify-self: end; }
  /* Settings tabs: one row that scrolls sideways, edge to edge, scrollbar hidden. */
  .tabs { flex-shrink: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: none; margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; padding: 10px 12px; }
  .tab:disabled { display: none; }
  .row-m .from { font-size: 16px; }
}
.phonenav { display: none; justify-content: space-around; border-top: 1px solid var(--line); padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); background: #fff; }
.phonenav button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px; padding: 4px; color: var(--muted); font-size: 11px; font-weight: 500; background: none; border: 0; }
.phonenav button.on { color: var(--accent); font-weight: 600; }
.phonenav svg { width: 24px; height: 24px; }
.badge-wrap { position: relative; display: inline-flex; }
.badge { position: absolute; top: -6px; right: -10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
