:root {
  --bg: #ffffff;
  --fg: #1c1c1e;
  --muted: #6b6b70;
  --border: #e2e2e6;
  --bar-bg: #f6f6f8;
  --accent: #2f6fed;
  --accent-fg: #ffffff;
  --code-bg: #f2f2f5;
  --table-stripe: #f7f7f9;
  --max-width: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --fg: #e9e9ec;
    --muted: #9a9aa1;
    --border: #2c2d31;
    --bar-bg: #1d1e22;
    --accent: #4f86ff;
    --accent-fg: #ffffff;
    --code-bg: #232429;
    --table-stripe: #1c1d21;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
}

.topbar .left { flex: 0 0 auto; }
.topbar .title {
  flex: 1 1 auto;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .right { flex: 0 0 auto; }

#report-select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 15px;
  padding: 9px 30px 9px 12px;
  max-width: 46vw;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 10px center;
  color: var(--fg);
}

#calendar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 15px;
  padding: 9px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}
#calendar-btn:active { opacity: 0.85; }
.cal-icon { font-size: 16px; line-height: 1; }

.hidden-date {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 22px 18px 80px;
  padding-bottom: max(80px, env(safe-area-inset-bottom));
}

.placeholder {
  color: var(--muted);
  text-align: center;
  margin-top: 40px;
}

/* ---- rendered markdown ---- */
.content h1 { font-size: 1.7em; line-height: 1.25; margin: 0.2em 0 0.5em; }
.content h2 { font-size: 1.35em; margin: 1.3em 0 0.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
.content h3 { font-size: 1.12em; margin: 1.2em 0 0.4em; }
.content p { margin: 0.7em 0; }
.content ul, .content ol { padding-left: 1.4em; }
.content li { margin: 0.25em 0; }
.content a { color: var(--accent); }
.content blockquote {
  margin: 0.8em 0;
  padding: 0.2em 1em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.content code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.content pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
}
.content pre code { background: none; padding: 0; }
.content hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.content img { max-width: 100%; height: auto; }

/* ---- csv tables ---- */
.csv-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.5em 0; }
table.csv {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
table.csv th, table.csv td {
  border: 1px solid var(--border);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
}
table.csv th { background: var(--bar-bg); position: sticky; top: 0; }
table.csv tbody tr:nth-child(even) { background: var(--table-stripe); }

@media (max-width: 560px) {
  .topbar .title { display: none; }
  #report-select { max-width: 52vw; }
}

.error { color: #c0392b; }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
