:root {
  --paper: #f3efe4;
  --paper-2: #e7e0d1;
  --ink: #1e1a14;
  --muted: #5e574c;
  --line: #d5ccbb;
  --green: #1f6b4a;
  --green-deep: #143f2d;
  --rust: #8d3b28;
  --card: #fbf8f2;
  --shadow: 0 16px 40px rgba(30, 26, 20, 0.08);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 180px),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(30,26,20,0.035) 28px),
    var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--green-deep); }
h1, h2 { font-family: Palatino, "Palatino Linotype", Georgia, serif; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 2.1rem; margin: 0 0 0.3rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.6rem; }
p { line-height: 1.5; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail {
  padding: 1.25rem 1rem 1.5rem;
  border-right: 1px solid var(--line);
  background: rgba(251, 248, 242, 0.72);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-family: Palatino, Georgia, serif; font-size: 1.45rem; text-decoration: none; color: var(--ink); }
.who { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.85rem; }
.who span { display: block; letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.68rem; }
.rail nav { display: flex; flex-direction: column; gap: 0.15rem; }
.rail nav a { text-decoration: none; color: var(--ink); padding: 0.35rem 0.45rem; border-radius: 8px; }
.rail nav a:hover { background: var(--paper-2); }
.rail nav em { font-style: normal; background: var(--green); color: white; border-radius: 99px; padding: 0 0.4rem; font-size: 0.75rem; }
.rail form { margin-top: auto; }
main { padding: 1.5rem 1.6rem 3rem; max-width: 1100px; }

.page-head, .row-form, .stats { display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.page-head { align-items: flex-start; margin-bottom: 1rem; }
.page-head p { margin: 0; max-width: 46rem; color: var(--muted); }
.kicker { letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.75rem; color: var(--muted); margin: 0; }
.stats { align-items: stretch; margin: 0.5rem 0 1rem; }
.stats a, .stats div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  min-width: 7rem;
  text-decoration: none;
  color: inherit;
}
.stats strong { display: block; font-size: 1.4rem; font-family: Palatino, Georgia, serif; }
.stats span, .hint { color: var(--muted); font-size: 0.85rem; }
.switch-line { color: var(--muted); }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.92rem; }
th { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: #f6f1e6; }
.tier { display: inline-block; min-width: 1.4rem; text-align: center; border-radius: 99px; padding: 0.05rem 0.4rem; font-size: 0.75rem; background: var(--paper-2); }
.tier-A { background: #d7efe3; color: var(--green-deep); }
.tier-B { background: #efe6cf; }
.tier-skip { background: #f0d9d2; color: var(--rust); }

.panel, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  margin: 0.8rem 0;
}
.notice { background: #e5f2ea; border: 1px solid #b7d8c6; padding: 0.6rem 0.8rem; border-radius: 10px; }
.error { background: #f8e8e3; border: 1px solid #e3c2b8; padding: 0.6rem 0.8rem; border-radius: 10px; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
input, select, textarea, button, .button {
  font: inherit;
  color: var(--ink);
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.5rem 0.65rem;
  background: white;
}
button, .button {
  background: var(--green);
  color: white;
  border-color: var(--green-deep);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.quiet { background: transparent; color: var(--ink); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; align-items: end; }
.check { flex-direction: row; align-items: center; gap: 0.4rem; }
.stack { display: flex; flex-direction: column; gap: 0.7rem; }
.pair, .colors { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.colors { grid-template-columns: repeat(4, 1fr); }
.split { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1.2rem; }
.edit-split iframe { width: 100%; min-height: 720px; border: 1px solid var(--line); border-radius: 16px; background: white; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.7rem; }
.board section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem; }
.board h2 span { color: var(--muted); font-family: "Avenir Next", sans-serif; font-size: 0.85rem; }
pre { white-space: pre-wrap; font-family: inherit; font-size: 0.85rem; }
.score-block { font-family: Palatino, Georgia, serif; font-size: 2rem; margin: 0; }
.gate { display: grid; place-items: center; padding: 2rem 1rem; }
.card.wide { width: min(640px, 100%); }
.gate .card { width: min(440px, 100%); }
.stamp { letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.72rem; color: var(--rust); margin: 0; }
.lede { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips button { background: var(--paper-2); color: var(--ink); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .rail form { margin-top: 0.4rem; }
  .split, .edit-split, .colors { grid-template-columns: 1fr; }
  .stats { display: grid; grid-template-columns: repeat(2, 1fr); }
  main { overflow-x: auto; padding: 1rem; }
  table { min-width: 640px; }
}
