:root {
  color-scheme: light;
  font: 100%/1.5 system-ui, "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--page);
  --text: #15213b;
  --page: #eef2fa;
  --surface: #fff;
  --blue: #2449b5;
  --accent: #2449b5;
  --soft: #edf2fc;
  --soft-text: #23438a;
  --tag: #e0e9ff;
  --active: #e8eeff;
  --input-line: #aab9d2;
  --error-text: #931d3e;
  --error-bg: #fff0f3;
  --muted: #536581;
  --line: #dce4f2;
}
[data-theme="dark"] {
  color-scheme: dark;
  --text: #e6edf9;
  --page: #101623;
  --surface: #1b2435;
  --blue: #3659c1;
  --accent: #a8bdff;
  --muted: #acb9d0;
  --line: #34405a;
  --soft: #24334e;
  --soft-text: #c4d2ff;
  --tag: #2b3d65;
  --active: #293b61;
  --input-line: #687997;
  --error-text: #ffc0cf;
  --error-bg: #432332;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body { margin: 0; min-width: 0; }
main { width: min(100%, 43rem); margin: auto; padding: max(1rem, env(safe-area-inset-top)) 1rem calc(7rem + env(safe-area-inset-bottom)); }
.brand { display: flex; align-items: center; gap: .55rem; margin-bottom: .65rem; font-weight: 800; letter-spacing: -.02em; }
.brand-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .7rem; background: var(--blue); color: white; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
#status { margin: 0 0 .6rem; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; }
.topic-tag { display: inline-block; padding: .26rem .55rem; border-radius: 1rem; background: var(--tag); color: var(--soft-text); font-size: .75rem; font-weight: 750; }
.surface, article, .empty, #topic-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; }
.empty { text-align: center; padding-block: 2rem; }
.empty span { color: var(--accent); font-size: 2rem; }
.empty h2 { margin: .25rem 0; }
.empty p, details p { color: var(--muted); font-size: .9rem; }
.filters { display: flex; gap: .45rem; overflow-x: auto; padding: .15rem .15rem .55rem; margin-bottom: .4rem; }
.filters button { flex: 0 0 auto; max-width: 13rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button, input, textarea, select { font: inherit; border-radius: .7rem; padding: .6rem .8rem; }
button, select { min-height: 44px; }
button { border: 1px solid transparent; background: var(--blue); color: white; cursor: pointer; font-weight: 650; }
button:disabled { opacity: .55; cursor: wait; }
button.secondary, .filters button[aria-pressed="false"] { background: var(--soft); color: var(--soft-text); border-color: var(--line); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea, select { color: inherit; border: 1px solid var(--input-line); background: var(--surface); min-width: 0; }
.row input { flex: 1; width: 0; }
label { display: block; margin-bottom: .4rem; font-weight: 700; }
.copy-row { margin-bottom: .7rem; }
.copy-row button { flex-shrink: 0; }
.preference label { margin: 0; }
.preference + .preference { margin-top: .65rem; }
.preference h2 { margin: 0; }
.usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: .7rem 0 .4rem; }
.usage-grid > div { min-width: 0; padding: .55rem .65rem; border-radius: .65rem; background: var(--soft); overflow-wrap: anywhere; }
.usage-wide { grid-column: 1 / -1; }
.usage-grid dt, .usage-note { color: var(--muted); font-size: .78rem; }
.usage-grid dd { margin: .15rem 0 0; font-size: 1.35rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.usage-grid dd.usage-note { font-size: .78rem; font-weight: 400; }
p.usage-note { margin: 0; }
#notification-state { margin: .4rem 0 .7rem; color: var(--muted); font-size: .85rem; }
.notification-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
summary { cursor: pointer; font-weight: 750; }
#topic-list { padding: 0; list-style: none; margin: .65rem 0; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; }
#topic-list:empty { display: none; }
#topic-list li { display: flex; align-items: center; gap: .15rem; flex-wrap: nowrap; border: 0; border-radius: 0; background: transparent; padding: .55rem .5rem; }
#topic-list li + li { border-top: 1px solid var(--line); }
#topic-list strong { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topic-list button { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: .6rem; background: transparent; border-color: transparent; color: var(--muted); }
#topic-list button:hover, #topic-list button:focus-visible { background: var(--soft); color: var(--accent); }
#topic-list button[aria-pressed="true"] { color: var(--accent); background: var(--soft); }
#topic-list button[data-topic-action="delete"]:hover { color: var(--error-text); background: var(--error-bg); }
#topic-list button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
html.modal-open { overflow: hidden; }
#publish { width: min(40rem, calc(100% - 2rem)); max-height: 85vh; max-height: 85dvh; margin: auto; padding: 1.1rem; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); color: var(--text); box-shadow: 0 1rem 4rem #0004; }
#publish::backdrop { background: #10162399; backdrop-filter: blur(2px); }
.publish-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.publish-header h2 { margin: 0; overflow-wrap: anywhere; }
#close-publish { flex-shrink: 0; font-size: 1.4rem; line-height: 1; min-width: 44px; }
#publish p { color: var(--muted); font-size: .9rem; }
#messages { display: grid; gap: .65rem; }
.meta { display: flex; gap: .45rem .6rem; align-items: center; flex-wrap: wrap; color: var(--muted); overflow-wrap: anywhere; }
.unread .meta::before { content: ''; width: .45rem; height: .45rem; border-radius: 50%; background: #b9233c; }
article pre, article p { margin: .65rem 0; }
article form { display: grid; gap: .5rem; }
article form button { text-align: start; }
#inbox-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; margin-bottom: .65rem; }
#inbox-actions button, .message-read { padding: .35rem .6rem; font-size: .85rem; }
.message-select { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); }
pre, p { overflow-wrap: anywhere; }
pre { white-space: pre-wrap; font: inherit; }
#error { color: var(--error-text); background: var(--error-bg); padding: .65rem; border-radius: .7rem; }
.dock { position: fixed; inset: auto 0 0; z-index: 1; display: flex; justify-content: center; gap: .3rem; border-top: 1px solid var(--line); background: var(--surface); padding: .45rem .75rem max(.45rem, env(safe-area-inset-bottom)); }
.dock button { flex: 0 1 7rem; display: grid; justify-items: center; align-content: center; gap: .15rem; color: var(--muted); background: transparent; font-size: .78rem; min-height: 53px; padding: .25rem; }
.dock button[aria-current="page"] { color: var(--accent); background: var(--active); }
.dock svg { width: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dock-icon { position: relative; display: flex; }
.unread-badge { position: absolute; top: -.32rem; left: calc(100% - .38rem); min-width: 1rem; height: 1rem; padding: 0 .2rem; border-radius: 1rem; background: #b9233c; color: #fff; font-size: .65rem; line-height: 1rem; font-weight: 750; text-align: center; }
@media (min-width: 44rem) { main { padding-top: 2rem; } }

.account-number-row { display: flex; align-items: center; gap: .15rem; margin-top: .3rem; }
#login-account { flex: 1 1 0; min-width: 0; width: 0; border: 0; background: transparent; padding: .4rem 0; font-size: clamp(.85rem, 4.3vw, 1.15rem); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.account-number-row button { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: .6rem; background: transparent; color: var(--text); }
.account-number-row button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#toggle-account[aria-pressed="true"] svg { opacity: .5; }

#topic-index {display:grid;gap:.4rem}
#topic-index button {position:relative;display:grid;text-align:start;padding:.85rem 3rem .85rem 1rem;background:var(--surface);color:var(--text)}
#topic-index small {color:var(--muted)}
#topic-index b {position:absolute;right:.75rem;top:50%;transform:translateY(-50%);background:#af263e;color:white;border-radius:2rem;padding:.1rem .5rem}
#detail-bar {margin-bottom:.7rem}
#detail-menu {position:relative}
#detail-menu summary {list-style:none;text-align:center;min-width:44px;padding:.5rem}
#menu-items {position:absolute;right:0;z-index:3;background:var(--surface);border:1px solid var(--line);border-radius:.7rem;padding:.4rem;min-width:9rem}
#menu-items button {display:block;width:100%}

html,body {overscroll-behavior-y:contain}
#pull-refresh {position:fixed;top:1rem;left:50%;transform:translateX(-50%);z-index:5;padding:.45rem 1rem;border-radius:2rem;color:var(--accent);background:var(--surface);box-shadow:0 2px 8px #0003}
.topic-entry {display:flex;align-items:center;background:var(--surface);border-radius:.7rem}
.topic-entry > button {flex:1;min-width:0;overflow-wrap:anywhere}
.topic-menu {position:relative;margin-left:auto}
.topic-menu summary {list-style:none;cursor:pointer;text-align:center;min-width:44px;padding:.6rem}
.topic-menu[open] {z-index:4}
.topic-menu > div {position:absolute;right:0;top:100%;background:var(--surface);border:1px solid var(--line);padding:.3rem;border-radius:.7rem;min-width:10rem;box-shadow:0 4px 12px #0002}
#topic-index .topic-menu button,#topic-list .topic-menu button {display:flex;align-items:center;gap:.5rem;width:100%;height:auto;padding:.4rem .6rem;text-align:start;color:var(--text)}
.topic-menu svg {width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7}
