:root {
  --bg: #f3f0e8;
  --paper: #fffdf8;
  --ink: #1f1a17;
  --muted: #5c564f;
  --line: #e3dcd0;
  --accent: #8f2d2a;
  --soft: #f6e8e4;
  --lead: #24344a;
  --lead-bg: #e7eef6;
  --plan: #1d4736;
  --plan-bg: #e4f0e8;
  --hold: #8f2d2a;
  --hold-bg: #f6e8e4;
  --due: #8a5a12;
  --due-bg: #f8efd8;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", "Microsoft YaHei", sans-serif;
}

a { color: inherit; }

.top, .foot, main {
  width: min(1120px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 8px;
}

.brand {
  font-family: "Palatino Linotype", "Songti SC", "SimSun", serif;
  font-size: 20px;
  text-decoration: none;
  letter-spacing: 0.04em;
}

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
}

nav form { margin: 0; }

.nav-user { color: var(--muted); }

.auth-card { max-width: 440px; }

.subnav {
  display: flex;
  gap: 18px;
  margin: 0 0 18px;
}

.subnav a {
  text-decoration: none;
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}

.subnav a.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

label.check { display: flex; gap: 8px; align-items: center; }

nav a:not(.btn) { text-decoration: none; }

main { padding-bottom: 48px; }

.foot {
  padding: 8px 0 28px;
  color: var(--muted);
  font-size: 13px;
}

h1, h2, .num {
  font-family: "Palatino Linotype", "Songti SC", "SimSun", serif;
  font-weight: 600;
}

h1 { font-size: 32px; line-height: 1.2; margin: 0; }

h2 { font-size: 18px; margin: 0 0 8px; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin: 12px 0 20px;
}

.lede { margin: 8px 0 0; max-width: 40em; color: var(--muted); }

.eyebrow { margin: 0 0 4px; color: var(--muted); letter-spacing: 0.04em; }

.stats {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.stat {
  min-width: 88px;
  padding: 8px 12px 10px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.stat.active { border-bottom-color: var(--ink); }

.num { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.filters .grow { flex: 1 1 220px; }

.lbl {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

textarea { resize: vertical; }

.btn, button.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.accent {
  background: var(--accent);
  border-color: var(--accent);
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.link.warn, .field-error { color: var(--accent); }

.banner {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--plan-bg);
}

.banner.warn { background: var(--due-bg); }

.errors {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--soft);
}

.errors p { margin: 0 0 8px; }

.errors ul { margin: 0; padding-left: 1.2em; }

.sheet, .panel, .empty {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 18px;
}

.sheet { display: grid; gap: 14px; }

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.block { display: block; }

fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
}

legend { padding: 0 6px; }

.hint, .muted, .meta { color: var(--muted); }

.hint { margin-top: 0; }

.form-actions, .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.row-actions { margin-top: 18px; }

.row-actions form, .review-form { margin: 0; }

.table-wrap { overflow-x: auto; }

.pool-table { min-width: 1200px; }

.up { color: var(--accent); }
.down { color: var(--plan); }
.quote-line { font-size: 22px; margin: 0 0 8px; }
.chart-wrap { overflow-x: auto; }
.kchart { width: 100%; height: auto; min-width: 640px; display: block; background: #fffdf8; border: 1px solid var(--line); }

.pool-table th,
.pool-table td { white-space: nowrap; }

.pool-table td.clamp { white-space: normal; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:hover { background: #faf6ef; }

.name { font-weight: 600; text-decoration: none; }

.clamp {
  max-width: 280px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nowrap { white-space: nowrap; }

tr.quiet { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 13px;
  background: var(--lead-bg);
  color: var(--lead);
}

.badge.plan { background: var(--plan-bg); color: var(--plan); }
.badge.holding { background: var(--hold-bg); color: var(--hold); }
.badge.due { background: var(--due-bg); color: var(--due); }
.badge.plain { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.tags { display: flex; gap: 8px; align-items: center; }

.split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.split > .panel { margin-top: 0; }

.prose { white-space: pre-wrap; margin-top: 0; }

.split + .panel,
.panel + .panel { margin-top: 16px; }

.split > .panel { margin-top: 0; }

.thesis { color: var(--accent); font-weight: 600; }

.review { margin-top: 16px; }

.flow-table { min-width: 860px; }

.flow-row:not([data-rule="net_above"]) .flow-amount { visibility: hidden; }
.flow-row:not([data-rule="streak"]) .flow-days { visibility: hidden; }

.news-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1.4fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.paste-shot {
  min-height: 96px;
  padding: 8px;
  border: 1px dashed var(--line);
  background: var(--bg);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  text-align: center;
  cursor: text;
}

.paste-hint { color: var(--muted); font-size: 13px; }

.paste-preview {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
}

.shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.shots figure {
  margin: 0;
  border: 1px solid var(--line);
  background: var(--paper);
}

button.shot-open {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
}

img.shot-open { cursor: zoom-in; }

.shots img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: var(--bg);
}

.shot-view {
  position: relative;
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 52px 16px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.shot-view::backdrop { background: rgba(31, 26, 23, 0.72); }

.shot-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.shot-view img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  margin: 0 auto;
  object-fit: contain;
  background: var(--bg);
}

.shot-cap {
  margin: 10px 0 0;
  text-align: center;
}

.shots figcaption { padding: 8px 10px; }

.check { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.check input { width: auto; }

.wire-tools {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.wire-tools .check { margin-top: 0; }

.wire-list { display: grid; gap: 14px; }

.wire-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}

.wire-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.wire-cat {
  background: var(--lead-bg);
  color: var(--lead);
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
}

.wire-body {
  white-space: pre-wrap;
  margin: 10px 0;
}

.wire-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.wire-images img {
  max-width: min(100%, 360px);
  max-height: 240px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: var(--bg);
}

.wire-card details { margin-bottom: 8px; }

.wire-analysis {
  background: var(--plan-bg);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0 12px;
}

.wire-analysis h2 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--plan);
}

.wire-analysis p { margin: 0 0 8px; }

.wire-analysis ul {
  margin: 0;
  padding-left: 1.1em;
}

.wire-analysis li { margin: 6px 0; }

.wire-analysis li span.wire-code {
  display: inline;
  margin-right: 6px;
  color: inherit;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.wire-analysis li span {
  display: block;
  color: var(--muted);
}

.pager {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 18px 0;
}

.judge-score {
  margin: 8px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.judge-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
}

.judge-table th,
.judge-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.judge-table th { color: var(--muted); font-weight: 600; }

.judge-on { color: var(--plan); font-weight: 600; }

.judge-off { color: var(--accent); font-weight: 600; }

.analyze-form { margin-bottom: 16px; }

.pool-add {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin: 12px 0;
}

.pool-add .hint { margin: 0; }

.banner + .panel,
.hint + .panel { margin-top: 16px; }

.review-form { display: grid; gap: 10px; margin-top: 12px; justify-items: start; }
.review-form textarea { width: 100%; }

.empty { max-width: 36em; }
.empty h2, .empty h1 { margin-bottom: 8px; }

.empty-inline { color: var(--muted); }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 800px) {
  .fields, .split, .page-head, .news-row { grid-template-columns: 1fr; display: grid; }
  .page-head { align-items: start; }
  h1 { font-size: 28px; }
}
