:root {
  --paper: #f4efe6;
  --paper-2: #fffdf8;
  --ink: #1c1915;
  --muted: #6a6256;
  --line: #e0d6c6;
  --pine: #1e4638;
  --pine-deep: #143328;
  --up: #1b6b42;
  --down: #a33b24;
  --gold: #8a5a12;
  --agent: #2f4572;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.7), rgba(244, 239, 230, 0) 280px),
    var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: Palatino, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}

h1 { font-size: 2.1rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

a { color: var(--pine); text-underline-offset: 0.15em; }
a:hover { color: var(--pine-deep); }

p { margin: 0.4rem 0; }

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.mast {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  font-family: Palatino, Georgia, serif;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
}

.mast nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.review-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  font-weight: 600;
}

.count {
  background: var(--gold);
  color: white;
  border-radius: 999px;
  min-width: 1.3rem;
  padding: 0 0.35rem;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.3rem;
}

main {
  width: min(1040px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.page-head, .panel-head, .button-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-head { margin-bottom: 1.2rem; }

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede, .muted, .hint { color: var(--muted); }
.hint { font-size: 0.9rem; }

.panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.15rem;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}

.panel-head { margin-bottom: 0.6rem; }

.site-list, .plain-list, .timeline { list-style: none; margin: 0; padding: 0; }

.site-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.site-card strong, .site-card .muted { display: block; }
.site-meta { color: var(--muted); white-space: nowrap; }

.table-wrap { overflow-x: auto; }

.rank-table {
  width: 100%;
  border-collapse: collapse;
}

.rank-table th {
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.rank-table td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.rank-table td .muted { display: block; font-size: 0.85rem; }
.rank-table .num, .position, .sha, .movement {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 650;
}

.is-inactive { opacity: 0.55; }

.movement-up { color: var(--up); }
.movement-down { color: var(--down); }
.movement-flat, .movement-none { color: var(--muted); }

.timeline { display: flex; flex-direction: column; gap: 0.35rem; }

.event {
  display: grid;
  grid-template-columns: 4.2rem 2.6rem 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--line);
}

.event time { color: var(--muted); font-size: 0.9rem; padding-top: 0.2rem; }

.mark {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 1.6rem;
  border-radius: 6px;
  background: #efe6d6;
  color: var(--pine-deep);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.event-proposal .mark, .event-proposal_approved .mark { background: #e7eef8; color: var(--agent); }
.event-change .mark { background: #e5f2ea; color: var(--up); }
.event-proposal_rejected .mark { background: #f8e8e3; color: var(--down); }

.event-body { display: flex; flex-wrap: wrap; gap: 0.45rem 0.7rem; align-items: center; }
.event-body a { text-decoration: none; }
.event-body a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  background: #efe6d6;
  color: var(--ink);
  text-transform: capitalize;
}

.badge-agent { background: #e7eef8; color: var(--agent); }
.badge-human { background: #e5f2ea; color: var(--up); }
.badge-system { background: #eeeae3; color: var(--muted); }
.badge-pending, .badge-investigating { background: #f8efd8; color: var(--gold); }
.badge-approved, .badge-implemented, .badge-confirmed, .badge-active, .badge-completed { background: #e5f2ea; color: var(--up); }
.badge-rejected, .badge-removed, .badge-inactive, .badge-revoked { background: #f8e8e3; color: var(--down); }

.stat-row, .split {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.stat-row article, .split .panel { margin: 0; }
.stat-row article {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}
.stat-row p { margin: 0; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }
.stat-row strong { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.8rem; margin: 0.2rem 0; }
.stat-row span { color: var(--muted); font-size: 0.88rem; }

.facts { display: grid; grid-template-columns: 9rem 1fr; gap: 0.35rem 0.8rem; margin: 0.4rem 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.stack-form, .field-row { display: grid; gap: 0.45rem; }
.stack-form { max-width: 40rem; }
.field-row { grid-template-columns: 1fr 1fr; }
label, legend { font-weight: 650; font-size: 0.92rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0.3rem 0; }
input, textarea, select {
  width: 100%;
  border: 1px solid #cfc4b2;
  background: white;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
}
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; }
.check input { width: auto; }

.button, button, input[type="submit"] {
  appearance: none;
  border: 0;
  background: var(--pine);
  color: white;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}
.button:hover, button:hover, input[type="submit"]:hover { background: var(--pine-deep); }
.button-quiet { background: transparent; color: var(--pine); border: 1px solid #b7c9c0; }
.button-quiet:hover { background: #e7f1ec; }
.button-danger { background: var(--down); }
.button-danger:hover { background: #7d2c1b; }
.text-button { background: transparent; color: var(--muted); padding: 0; border-radius: 0; }
form.button_to { display: inline; }

.flash { padding: 0.7rem 0.85rem; border-radius: 10px; margin: 0 0 1rem; }
.flash-notice { background: #e5f2ea; color: var(--pine-deep); }
.flash-alert { background: #f8e8e3; color: #6d2618; }
.form-errors { background: #f8e8e3; border-radius: 10px; padding: 0.7rem 0.9rem; margin-bottom: 0.8rem; }
.form-errors ul { margin: 0.3rem 0 0; }

.token-reveal {
  background: var(--pine-deep);
  color: #f4efe6;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.token-reveal code {
  display: block;
  margin-top: 0.4rem;
  word-break: break-all;
  color: white;
  font-size: 0.95rem;
}

.review-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}
.review-card h3 { margin-bottom: 0.25rem; }

.empty { color: var(--muted); margin: 0.4rem 0; }

.session-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.session-card {
  width: min(28rem, calc(100% - 2rem));
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem;
}

@media (max-width: 800px) {
  .stat-row, .split, .facts, .field-row { grid-template-columns: 1fr; }
  .review-card, .site-card, .mast { flex-direction: column; align-items: flex-start; }
  .event { grid-template-columns: 3.4rem 2.4rem 1fr; }
  h1 { font-size: 1.7rem; }
  .site-meta { white-space: normal; }
}
