:root {
  color-scheme: light dark;
  --bg: #faf8f4;
  --surface: #ffffff;
  --text: #1c1a17;
  --muted: #77716a;
  --line: #e7e2d9;
  --accent: #b4532a;
  --accent-text: #ffffff;
  --press: rgba(0, 0, 0, 0.05);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140f;
    --surface: #1e1c17;
    --text: #ece8e0;
    --muted: #9a938a;
    --line: #2e2b25;
    --accent: #e08a5c;
    --accent-text: #1a1206;
    --press: rgba(255, 255, 255, 0.07);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--sans);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.view { max-width: 44rem; margin: 0 auto; }

/* ---- Inbox ---- */
#inbox {
  padding: calc(env(safe-area-inset-top) + 18px) 0 calc(env(safe-area-inset-bottom) + 32px);
  min-height: 100%;
}
.top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 0 max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
}
.top h1 { font: 700 30px/1.15 var(--serif); letter-spacing: -0.01em; margin: 0; }
.status { margin: 4px 0 0; font-size: 13px; color: var(--muted); min-height: 18px; }
.status.busy::after { content: "…"; }
.icon-btn {
  width: 44px; height: 44px; margin: -6px -10px 0 0; border-radius: 50%;
  display: grid; place-items: center; fill: var(--muted); flex: none;
}
.icon-btn:active, .text-btn:active { background: var(--press); }

.notice {
  margin: 0 16px 14px; padding: 14px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.notice p { margin: 0 0 12px; font-size: 15px; }
.notice p:last-child { margin-bottom: 0; }
.notice .code {
  font: 13px/1.4 ui-monospace, Menlo, monospace; word-break: break-all;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; user-select: all; -webkit-user-select: all;
}

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list a {
  display: grid; grid-template-columns: 14px 1fr; column-gap: 8px;
  padding: 14px max(20px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.list a:active { background: var(--press); }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; background: transparent; }
.unread .dot { background: var(--accent); }
.row-head { display: flex; align-items: baseline; gap: 10px; }
.row-title {
  flex: 1; min-width: 0; font: 400 17px/1.3 var(--serif); color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.unread .row-title { font-weight: 700; color: var(--text); }
.row-date { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-summary {
  margin-top: 3px; font-size: 14.5px; line-height: 1.4; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-flag { margin-top: 5px; font-size: 12px; color: var(--muted); }
.row-flag::before { content: "↓ "; }

.empty { padding: 48px 28px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; margin: 0; }

/* ---- Reader ---- */
#reader { position: fixed; inset: 0; max-width: none; display: flex; flex-direction: column; background: var(--bg); }
.bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 4px) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}
.text-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px;
  border-radius: 10px; color: var(--accent); font-size: 16px;
}
.bar-date { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---- Settings sheet ---- */
dialog {
  width: min(100%, 30rem); max-width: 100%; max-height: 88dvh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 18px 18px 0 0; background: var(--surface); color: var(--text);
}
@media (min-width: 40rem) { dialog { margin: auto; border-radius: 18px; } }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.sheet { padding: 6px 20px calc(env(safe-area-inset-bottom) + 24px); }
.sheet header { display: flex; align-items: center; justify-content: space-between; margin-right: -10px; }
.sheet h2 { font: 700 20px var(--serif); margin: 0; }
.sheet h3 { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.sheet section { padding: 16px 0; border-top: 1px solid var(--line); }
.muted { color: var(--muted); font-size: 14.5px; margin: 0 0 12px; line-height: 1.45; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 11px; font-size: 15.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--bg);
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
