:root {
  --paper: #f4eee4;
  --paper-2: #fbf7f1;
  --ink: #241c16;
  --muted: #7d7166;
  --line: #e6dacb;
  --seal: #9d3a32;
  --seal-dark: #7d2d27;
  --pine: #1c3129;
  --pine-2: #29483d;
  --gold: #c4a574;
  --shadow: 0 20px 50px rgba(36, 28, 22, .08);
  --sans: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --serif: "Palatino Linotype", "Songti SC", "SimSun", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(196, 165, 116, .22), transparent 55%),
    linear-gradient(180deg, #f7f2ea 0%, var(--paper) 40%, #efe6d8 100%);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.rail {
  background:
    linear-gradient(180deg, rgba(196, 165, 116, .16), transparent 28%),
    var(--pine);
  color: #f6efe4;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; }
.brand strong { display: block; font-size: 18px; letter-spacing: .08em; }
.brand small { color: rgba(246, 239, 228, .62); letter-spacing: .12em; }
.seal {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--gold); color: #f6efe4;
  font-family: var(--serif); font-size: 22px;
  box-shadow: inset 0 0 0 3px rgba(196, 165, 116, .35);
}
.seal.large { width: 72px; height: 72px; font-size: 36px; margin-bottom: 28px; }
.rail-nav { display: grid; gap: 6px; margin-top: 42px; }
.rail-nav a {
  text-decoration: none; padding: 12px 14px; border-radius: 10px; color: rgba(246, 239, 228, .78);
}
.rail-nav a.active, .rail-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rail-nav a.active { box-shadow: inset 3px 0 0 var(--gold); }
.rail-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.who { display: grid; min-width: 0; font-size: 14px; color: rgba(246, 239, 228, .8); }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--gold); letter-spacing: .14em; font-size: 11px; }
.rail-foot button {
  background: transparent; color: #f6efe4; border: 1px solid rgba(246, 239, 228, .25);
  border-radius: 999px; padding: 6px 12px;
}

main { padding: 42px 56px 72px; }
.page-head, .actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.page-head h1, .gate h1, .card h2, .sheet h2 { font-family: var(--serif); font-weight: 600; letter-spacing: .02em; margin: 0; }
.page-head h1 { font-size: 42px; }
.page-head h1::after {
  content: "";
  display: block;
  width: 46px;
  height: 2px;
  margin-top: 14px;
  background: var(--gold);
}
.eyebrow { margin: 0 0 8px; color: var(--seal); letter-spacing: .18em; font-size: 12px; }
.sub, .lede, .meta, .notes, .quiet { color: var(--muted); }
.sub, .lede { margin: 8px 0 0; line-height: 1.7; max-width: 46rem; }
.flash { margin: 18px 0 0; padding: 12px 14px; border-radius: 10px; }
.flash.ok { background: #e7f2ec; color: #215744; }
.flash.bad, small { color: var(--seal); }
.flash.bad { background: #f8e8e4; }

.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; border-radius: 12px; padding: 12px 18px; border: 0;
}
.primary { background: var(--seal); color: #fffaf6; box-shadow: 0 8px 18px rgba(157, 58, 50, .18); }
.primary:hover { background: var(--seal-dark); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 180px)); gap: 14px; margin: 28px 0; }
.stats a {
  text-decoration: none; background: rgba(255, 252, 248, .72); border: 1px solid transparent;
  border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow);
}
.stats a.on { border-color: var(--seal); }
.stats b { display: block; font-family: var(--serif); font-size: 32px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 13px; }

.board { display: grid; gap: 16px; max-width: 980px; }
.case, .sheet, .card, .team-card {
  background: var(--paper-2); border: 1px solid rgba(228, 216, 203, .9); border-radius: 18px; box-shadow: var(--shadow);
}
.case { padding: 22px 24px 18px; position: relative; overflow: hidden; transition: transform .18s ease; }
.case:hover { transform: translateY(-2px); }
.case::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #c8bba8; }
.case.overdue::before { background: var(--seal); }
.case.today::before { background: #c47a32; }
.case.soon::before { background: #d7a15a; }
.case.later::before { background: #6f947f; }
.case-top, .clock, .team-card, .split { display: flex; }
.case-top { gap: 8px; align-items: center; }
.stage, .team-tag, .clock em {
  font-size: 12px; letter-spacing: .08em; border-radius: 999px; padding: 4px 9px;
}
.stage { background: #f3e4d4; color: #6d4124; }
.team-tag { color: var(--muted); }
.parties { font-family: var(--serif); font-size: 28px; margin: 14px 0 8px; }
.parties em { font-style: normal; color: var(--gold); margin: 0 8px; font-size: 16px; }
.parties span { overflow-wrap: anywhere; }
.meta { display: flex; gap: 16px; margin: 0; }
.notes {
  margin: 10px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.clocks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.clock {
  flex-direction: column; gap: 4px; padding: 14px; border-radius: 14px; background: #f6f1e8;
}
.clock span, .clock em { color: var(--muted); }
.clock strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.clock time { font-family: var(--serif); }
.clock.overdue { background: #f8ece8; }
.clock.overdue strong, .clock.overdue em { color: var(--seal); }
.clock.today { background: #f8efe4; }
.clock.today strong { color: #9a5b22; }
.clock.soon strong { color: #8a6233; }
.clock em { align-self: flex-start; padding-left: 0; }
.text-link { display: inline-block; margin-top: 14px; color: var(--seal); text-underline-offset: 3px; }

.empty { max-width: 520px; margin-top: 48px; }
.empty h2 { font-family: var(--serif); font-size: 32px; margin-bottom: 8px; }
.empty.slim { margin-top: 24px; }

.sheet { max-width: 860px; padding: 28px; margin-top: 22px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.wide { grid-column: 1 / -1; }
label, .wide { display: grid; gap: 8px; }
.label, label span { font-size: 13px; color: var(--muted); }
input, select, textarea, output {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(157, 58, 50, .14); border-color: var(--seal); }
output { background: #f6f1e8; min-height: 46px; }
textarea { resize: vertical; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.picks button, .code {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px;
}
.picks button.on, .code.copied { background: var(--pine); color: #f6efe4; border-color: var(--pine); }
.actions { margin-top: 22px; justify-content: flex-start; align-items: center; }
.danger { margin-top: 18px; }
.danger button { background: transparent; border: 0; color: var(--seal); padding: 0; }

.split { gap: 16px; align-items: stretch; max-width: 860px; }
.split .sheet { flex: 1; margin-top: 0; }
.team-list { display: grid; gap: 12px; max-width: 860px; margin-top: 18px; }
.team-card { justify-content: space-between; align-items: center; padding: 18px 20px; }
.team-card h2 { margin: 0 0 6px; font-size: 24px; }
.team-card p { margin: 0; color: var(--muted); }
.code { font-variant-numeric: tabular-nums; letter-spacing: .14em; font-weight: 700; }

.desk { display: grid; gap: 28px; max-width: 980px; margin-top: 28px; }
.desk-block { display: grid; gap: 12px; }
.desk-block h2 { font-family: var(--serif); font-size: 28px; margin: 0; }
.person, .group {
  background: var(--paper-2);
  border: 1px solid rgba(228, 216, 203, .9);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: grid;
  gap: 12px;
}
.person-top, .group-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.person-top h3, .group-top h3 { margin: 0; font-family: var(--serif); font-size: 24px; }
.badges, .inline, .chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badges { margin-top: 8px; }
.badge {
  font-size: 12px; letter-spacing: .08em; border-radius: 999px; padding: 4px 9px; background: #f3e4d4; color: #6d4124;
}
.badge.admin { background: var(--pine); color: #f6efe4; }
.when { color: var(--muted); font-size: 13px; }
.inline input, .inline select { width: auto; min-width: 160px; }
.mini {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px;
}
.mini.danger-text { color: var(--seal); border-color: #e7cfcb; }
.chips { margin: 0; padding: 0; list-style: none; }
.chips li { display: flex; gap: 8px; align-items: center; background: #f6f1e8; border-radius: 999px; padding: 4px 4px 4px 12px; }
.chips form { margin: 0; }
.chips button { border: 0; background: transparent; color: var(--seal); padding: 4px 8px; }
details summary { cursor: pointer; color: var(--muted); width: fit-content; }
details form { margin-top: 10px; }

.gate { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.gate-story {
  background:
    radial-gradient(500px 280px at 20% 20%, rgba(196, 165, 116, .2), transparent 60%),
    var(--pine);
  color: #f6efe4; padding: 72px;
  display: flex; flex-direction: column; justify-content: center;
}
.gate-story .eyebrow { color: var(--gold); }
.gate-story h1 { font-size: 58px; line-height: 1.15; }
.gate-story .lede { color: rgba(246, 239, 228, .78); }
.points { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.points li::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 10px; background: var(--gold); border-radius: 50%; }
.gate-panel { display: grid; place-items: center; padding: 40px; }
.card { width: min(420px, 100%); padding: 32px; }
.card h2 { font-size: 34px; }
.card .primary, .sheet.compact .primary { width: 100%; margin-top: 8px; }
.quiet { display: inline-block; margin-top: 16px; }

@media (max-width: 980px) {
  .shell, .gate { grid-template-columns: 1fr; }
  .rail { height: auto; position: relative; }
  .rail-nav { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); margin-top: 22px; }
  .person-top, .group-top { flex-direction: column; }
  main, .gate-story, .gate-panel { padding: 28px 20px; }
  .fields, .clocks, .stats, .split { grid-template-columns: 1fr; display: grid; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .gate-story h1, .page-head h1 { font-size: 36px; }
}
