:root {
  --night: #18110f;
  --night-soft: #241916;
  --panel: #2f211d;
  --paper: #f3eee2;
  --paper-edge: #ded4c1;
  --ink: #171311;
  --rust: #a55138;
  --brass: #c49a61;
  --cream: #e8ddc9;
  --muted: #a99b8d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--night); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% -20%, rgba(165, 81, 56, .22), transparent 42rem),
    linear-gradient(180deg, #1b1311, var(--night));
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  width: min(100% - 32px, 720px);
  margin: 0 auto;
  padding: max(26px, env(safe-area-inset-top)) 4px 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid rgba(232, 221, 201, .14);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: "Songti SC", "Noto Serif SC", serif; font-size: 2rem; font-weight: 600; }
h2 { margin-bottom: 0; font-family: "Songti SC", "Noto Serif SC", serif; font-size: 1.5rem; }
.eyebrow { margin-bottom: 5px; color: var(--brass); font: 600 .68rem/1.3 ui-monospace, monospace; letter-spacing: .14em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; line-height: 1.6; }

.text-button {
  padding: 8px 0 8px 18px;
  color: var(--muted);
  border: 0;
  background: transparent;
}

main { width: min(100% - 28px, 700px); margin: 0 auto; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

.printer { margin-top: 28px; }

.printer-face {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 16px 20px 12px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #bcaa98;
  background: linear-gradient(180deg, #35241f, #241916);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 18px 18px 5px 5px;
  box-shadow: 0 18px 44px rgba(0,0,0,.25);
}

.machine-label { color: var(--brass); font: 600 .64rem/1.3 ui-monospace, monospace; letter-spacing: .12em; }
.machine-status { font-size: .73rem; }

.slot {
  position: relative;
  z-index: 2;
  width: min(calc(100% - 34px), 586px);
  height: 16px;
  margin: -1px auto 0;
  border: 3px solid #3a2924;
  border-radius: 8px;
  background: linear-gradient(180deg, #080605, #211714 64%, #4b342c);
  box-shadow: inset 0 3px 6px #000, 0 3px 0 #130d0c;
}

.feed {
  width: min(calc(100% - 44px), 550px);
  margin: -1px auto 0;
  overflow: hidden;
  filter: drop-shadow(0 22px 22px rgba(0,0,0,.35));
}

.sheet {
  position: relative;
  min-height: 340px;
  padding: clamp(28px, 7vw, 48px) clamp(24px, 8vw, 52px) 54px;
  color: var(--ink);
  background:
    linear-gradient(rgba(90,70,45,.035) 1px, transparent 1px) 0 0 / 100% 5px,
    var(--paper);
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
}

.sheet::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -8px;
  left: 0;
  height: 12px;
  background: linear-gradient(135deg, var(--paper) 6px, transparent 0) 0 0 / 12px 12px repeat-x;
}

.paper-masthead { text-align: center; border-bottom: 2px solid var(--ink); padding-bottom: 18px; }
.paper-kind { margin-bottom: 10px; font: 700 .65rem/1.2 ui-monospace, monospace; letter-spacing: .2em; text-transform: uppercase; }
.paper-date { margin-bottom: 2px; font: 500 clamp(2.6rem, 12vw, 4.4rem)/1 Georgia, serif; letter-spacing: -.06em; }
.paper-weekday { margin-bottom: 0; font-size: .8rem; letter-spacing: .32em; }
.paper-title { margin: 24px 0 22px; font-size: clamp(1.6rem, 7vw, 2.2rem); line-height: 1.25; text-align: center; }
.paper-section { margin: 22px 0; }
.paper-section h3 { margin: 0 0 8px; font-size: .82rem; letter-spacing: .18em; }
.paper-section p { margin: 0 0 10px; font-size: .98rem; line-height: 1.9; white-space: pre-wrap; }
.paper-signoff { margin: 30px 0 0; padding-top: 18px; border-top: 1px solid var(--ink); font-size: .93rem; line-height: 1.8; text-align: right; white-space: pre-wrap; }
.paper-seen { position: absolute; right: 24px; bottom: 22px; color: #7c2f21; font: 700 .62rem/1 ui-monospace, monospace; letter-spacing: .1em; transform: rotate(-7deg); opacity: .74; }

.empty-state { margin: 24px auto; color: var(--muted); text-align: center; }
.controls { min-height: 74px; padding: 22px 0 6px; text-align: center; }

.primary-button {
  min-height: 46px;
  padding: 10px 22px;
  color: #fff8eb;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: var(--rust);
  box-shadow: 0 8px 22px rgba(88,28,17,.35);
}

.primary-button:disabled { cursor: not-allowed; opacity: .55; }

.archive { margin-top: 28px; padding-top: 24px; border-top: 1px solid rgba(232, 221, 201, .14); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; }
.count { color: var(--muted); font-size: .78rem; }
.paper-list { margin: 16px 0 0; padding: 0; list-style: none; }
.paper-list li + li { border-top: 1px solid rgba(232, 221, 201, .1); }
.archive-button {
  width: 100%;
  padding: 16px 2px;
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 12px;
  align-items: center;
  color: inherit;
  border: 0;
  background: transparent;
  text-align: left;
}
.archive-date { color: var(--brass); font: .72rem/1.2 ui-monospace, monospace; }
.archive-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-mark { color: var(--rust); font-size: .7rem; }
.archive-button[aria-current="true"] .archive-title { color: #fff6e6; }

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 10;
  max-width: 440px;
  margin: auto;
  padding: 12px 16px;
  color: #fff8eb;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: #39251f;
  box-shadow: 0 14px 44px rgba(0,0,0,.38);
  text-align: center;
  font-size: .84rem;
}

.login-page { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 410px); padding: 38px 32px; border: 1px solid rgba(232,221,201,.14); border-radius: 18px; background: rgba(47,33,29,.72); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.seal { width: 58px; height: 58px; margin-bottom: 26px; display: grid; place-items: center; color: #f4dfcc; border: 2px solid #be684c; border-radius: 50%; font-family: "Songti SC", serif; font-size: 1.6rem; transform: rotate(-5deg); }
.login-card h1 { margin-bottom: 12px; }
.login-form { margin-top: 26px; }
.login-form label { display: block; margin-bottom: 8px; color: #cdbfaf; font-size: .82rem; }
.login-form input { width: 100%; min-height: 48px; padding: 10px 14px; color: #fff; border: 1px solid #59443b; border-radius: 8px; outline: none; background: #180f0d; }
.login-form input:focus { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(196,154,97,.12); }
.login-form .primary-button { width: 100%; margin-top: 16px; }
.form-error { padding: 10px 12px; color: #ffd9ce; border: 1px solid rgba(190,104,76,.35); border-radius: 8px; background: rgba(120,42,27,.22); font-size: .82rem; }

@media (max-width: 480px) {
  .topbar { width: min(100% - 24px, 720px); }
  main { width: min(100% - 18px, 700px); }
  .feed { width: calc(100% - 22px); }
  .printer-face { padding-right: 14px; padding-left: 14px; }
  .archive-button { grid-template-columns: 4.8rem 1fr auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
