:root {
  --bg: #faf9f6;
  --panel: #ffffff;
  --fg: #1f1e1c;
  --muted: #6b6862;
  --line: #e4e1da;
  --accent: #2f5d8a;
  --warn: #9a5b00;
  --radius: 10px;
  --gap: 16px;
  --serif: 'Iowan Old Style', 'Hiragino Mincho ProN', 'Yu Mincho', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1b1a18;
    --panel: #24231f;
    --fg: #ecebe7;
    --muted: #a6a39b;
    --line: #3a3833;
    --accent: #8ab4e0;
    --warn: #e0a64a;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #1b1a18;
  --panel: #24231f;
  --fg: #ecebe7;
  --muted: #a6a39b;
  --line: #3a3833;
  --accent: #8ab4e0;
  --warn: #e0a64a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 0;
}
.brand { font-family: var(--serif); font-size: 1.1rem; color: var(--fg); text-decoration: none; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lang button {
  font: inherit;
  font-size: 0.85rem;
  padding: 4px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.lang button[aria-pressed='true'] { background: var(--panel); color: var(--fg); }
.lang button:focus-visible { outline: 2px solid var(--fg); outline-offset: -2px; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 16px 48px;
  display: grid;
  gap: 24px;
  /* make casual copying harder; screenshots are out of scope (spec §6) */
  -webkit-user-select: none;
  user-select: none;
}
main > * { min-width: 0; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.4rem, 4vw, 2rem); margin: 8px 0 0; text-wrap: balance; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 8px; }
.week, .list { display: grid; gap: 24px; min-width: 0; }
.back { margin: 0; font-size: 0.9rem; }
.banner {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  background: var(--panel);
}
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-actions button {
  font: inherit;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
.admin-actions .status { font-size: 0.9rem; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: var(--gap); }
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.tile .lab { font-size: 0.85rem; color: var(--muted); }
.tile .big { font-family: var(--serif); font-size: 1.8rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .cmp { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile .cmp b { font-weight: 600; color: var(--fg); }

.body { display: grid; gap: 12px; min-width: 0; }
.body > * { max-width: 85ch; margin: 0; }
.body h1, .body h2 { font-family: var(--serif); font-weight: 400; }
.body h2 { font-size: 1.3rem; margin-top: 12px; }
.body h3 { font-size: 1.05rem; margin: 8px 0 0; }
.body ul, .body ol { padding-left: 1.3em; }
.body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.body th, .body td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.body th { color: var(--muted); font-weight: 600; }
.body th:first-child, .body td:first-child { text-align: left; white-space: normal; min-width: 8em; }
.body code { font-size: 0.9em; overflow-wrap: anywhere; }

.trend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: var(--gap); }
.card {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.card figcaption { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.card svg { display: block; width: 100%; height: 64px; overflow: visible; }
.card .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.card .dot { fill: var(--accent); }
.week-links { padding-left: 1.2em; margin: 0; display: grid; gap: 4px; }

.tbl { overflow-x: auto; }
.tbl table { border-collapse: collapse; font-size: 0.85rem; width: 100%; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.empty, .error { color: var(--muted); }

/* watermark: viewer's email + time, tiled diagonally over everything, never blocks clicks */
#wm {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-repeat: repeat;
  z-index: 10;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) #wm { filter: invert(1); opacity: 0.1; }
}
:root[data-theme='dark'] #wm { filter: invert(1); opacity: 0.1; }

.print-note { display: none; }
@media print {
  .top, main, #wm { display: none !important; }
  .print-note { display: block; font: 16px/1.6 sans-serif; padding: 24px; }
}
