/* Court rules. Layout and tokens follow the Paper reference design:
   white surface, #EEEEEE hairlines, 6px radius, 14px system-ui, black text. */
:root {
  --bg: #ffffff;
  --ink: #000000;
  --muted: #5f6368;
  --line: #eeeeee;
  --line-strong: #dcdcdc;
  --hover: rgba(0, 0, 0, 0.05);
  --active: rgba(0, 0, 0, 0.08);
  --radius: 6px;
  --warn: #7a5200;
  --warn-bg: #fff5dc;
  --bad: #9b1c1c;
  --bad-bg: #fdeded;
  --ok: #1b6b3f;
  --ok-bg: #e8f5ed;
  --info-bg: #f3f3f3;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111; --ink: #f2f2f2; --muted: #a3a3a3; --line: #262626; --line-strong: #3a3a3a;
    --hover: rgba(255, 255, 255, 0.07); --active: rgba(255, 255, 255, 0.12);
    --warn: #f0c46a; --warn-bg: #33290f; --bad: #f4a3a3; --bad-bg: #3a1c1c; --ok: #86d9a8; --ok-bg: #16301f; --info-bg: #1c1c1c;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
#app, .shell { height: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.icon { flex: 0 0 auto; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; flex-direction: column; min-height: 0; }
.body { flex: 1; display: flex; min-height: 0; }

/* ---------------------------------------------------------------- top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.brand { font-size: 16px; line-height: 20px; white-space: nowrap; }
.slash { font-size: 16px; line-height: 20px; }
.menu-wrap { position: relative; min-width: 0; flex: 0 1 auto; }
.menu-wrap.right { margin-left: auto; flex: 0 0 auto; }
.court-switch { max-width: 100%; display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 6px; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; text-align: left; min-width: 0; }
.court-switch span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.court-switch:hover, .icon-btn:hover { background: var(--hover); }
.icon-btn { display: grid; place-items: center; padding: 8px; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; }
.menu { position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; min-width: 320px; padding: 6px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); }
.menu-wrap.right .menu { left: auto; right: 0; min-width: 240px; }
.menu-item { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius); background: transparent; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--hover); }
.menu-item.sel { background: var(--active); }
.menu-note { padding: 8px 10px 4px; color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- rail */
.rail { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-right: 1px solid var(--line); }
.rail-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px; border-radius: var(--radius); text-decoration: none; }
.rail-item:hover { background: var(--hover); }
.rail-item.active { background: var(--active); }

/* ---------------------------------------------------------------- list */
.list { flex: 0 0 350px; display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 16px 0 0 16px; border-right: 1px solid var(--line); }
.search { position: relative; margin-right: 16px; }
.search-input { width: 100%; padding: 12px 36px 12px 12px; border: 1px solid #ededed; border-radius: var(--radius); background: transparent; color: var(--ink); font: inherit; }
.search-input::placeholder { color: var(--muted); }
.search .icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.list-body { flex: 1; overflow-y: auto; padding: 4px 16px 24px 0; margin-right: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: var(--radius); text-decoration: none; }
.row:hover { background: var(--hover); }
.row.sel { background: var(--active); }
.row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { flex: 0 0 auto; padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 99px; color: var(--muted); font-size: 11px; }
.group { margin: 14px 8px 4px; color: var(--muted); font-size: 12px; }
.group:first-child { margin-top: 4px; }
.empty { color: var(--muted); padding: 8px; }

/* ---------------------------------------------------------------- detail pane */
.pane { flex: 1; min-width: 0; overflow-y: auto; padding: 32px 40px 80px; }
.back { display: none; margin-bottom: 16px; color: var(--muted); text-decoration: none; }
.blank { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.wiz, .doc { max-width: 680px; }
.pane h2 { margin: 0 0 8px; font-size: 24px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.pane h2:focus { outline: none; }
.lead { margin: 0 0 24px; color: var(--muted); font-size: 15px; }
.placeholder { color: var(--muted); font-size: 15px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ---------------------------------------------------------------- wizard */
.progress { height: 3px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); transition: width 0.2s; }
.stepno { margin: 6px 0 20px; color: var(--muted); font-size: 12px; }
.field { border: 0; padding: 0; margin: 0 0 24px; min-width: 0; }
.field legend { padding: 0; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.hint { margin: -2px 0 10px; color: var(--muted); font-size: 13px; }
.opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; }
.opt:hover { background: var(--hover); }
.opt.sel { border-color: var(--ink); background: var(--active); }
.opt input { margin: 3px 0 0; accent-color: var(--ink); flex: 0 0 auto; }
.opt b { font-weight: 500; }
.opt .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.tag { margin-left: 8px; padding: 1px 7px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 500; }
input.text { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: transparent; color: var(--ink); font: inherit; max-width: 240px; }
.nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.btn { padding: 9px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: transparent; cursor: pointer; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; }
.btn.primary:hover:not(:disabled) { opacity: 0.85; background: var(--ink); }
.disclaimer { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.summary dt { margin-top: 12px; font-weight: 600; }
.summary dd { margin: 2px 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- checklist */
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
.flag { padding: 10px 12px; margin-bottom: 10px; border-radius: var(--radius); font-size: 13px; }
.flag.warn { background: var(--warn-bg); color: var(--warn); }
.flag.bad { background: var(--bad-bg); color: var(--bad); }
.flag.ok { background: var(--ok-bg); color: var(--ok); }
.flag.info { background: var(--info-bg); }
.facts { width: 100%; border-collapse: collapse; margin: 16px 0 8px; }
.facts th, .facts td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.facts th { width: 38%; color: var(--muted); font-weight: 400; }
.phase { margin-top: 32px; }
.phase h3 { margin: 0 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--ink); font-size: 15px; font-weight: 600; }
.blurb { margin: 8px 0 4px; color: var(--muted); font-size: 13px; }
.ck { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ck input { flex: 0 0 auto; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--ink); }
.ck .t { flex: 1; min-width: 0; }
.ck.done .m { color: var(--muted); text-decoration: line-through; }
.cite { color: var(--muted); font-size: 12px; }
.note { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.verify { margin: 8px 0 0; padding-left: 18px; }
.verify li { margin: 4px 0; }
.srcs { margin-top: 24px; font-size: 13px; }
.srcs summary { cursor: pointer; font-weight: 500; }

/* ---------------------------------------------------------------- documents */
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0 20px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.doc-text { max-height: 70vh; overflow: auto; padding: 16px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--info-bg); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc { max-width: 900px; }

/* ---------------------------------------------------------------- forms */
.form-note { margin: 4px 0 20px; padding: 10px 12px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.actions { margin-top: 24px; }
a.btn { display: inline-block; text-decoration: none; }
.usedby-h { margin: 28px 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--ink); font-size: 15px; font-weight: 600; }
.usedby { margin: 10px 0 0; padding-left: 20px; }
.usedby li { margin: 4px 0; }
.usedby a { color: inherit; }
.fatal { padding: 40px; max-width: 560px; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 900px) {
  .body { flex-direction: column; }
  .rail { flex-direction: row; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .list { flex: 1; padding: 12px 0 0 16px; border-right: 0; }
  .pane { padding: 20px 16px 64px; }
  .shell[data-view="detail"] .list { display: none; }
  .shell[data-view="list"] .pane { display: none; }
  .back { display: inline-block; }
  .menu { min-width: 260px; max-width: calc(100vw - 32px); }
}

/* ---------------------------------------------------------------- print */
@media print {
  .topbar, .rail, .list, .back, .tools, .nav, .progress, .stepno, .srcs { display: none !important; }
  .body, .shell { display: block; height: auto; }
  .pane { overflow: visible; padding: 0; }
  .shell[data-view] .pane { display: block !important; }
  .ck { break-inside: avoid; }
  body { background: #fff; color: #000; }
}
