:root {
  --ink: #e9ecee;
  --dim: #94a0a8;
  --bg: #15191c;
  --panel: #1d2327;
  --edge: #313b42;
  --paper: #efe9dc;
  --paper-ink: #22201c;
  --tag: #f2c230; /* safety yellow */
  --rust: #c8643a;
  --ok: #6cc29a;
  --bad: #e2685f;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.45 "Helvetica Neue",
    Helvetica,
    Arial,
    sans-serif;
  overflow: hidden;
}
button {
  font: inherit;
  cursor: pointer;
}
#app {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 420px 1fr;
  grid-template-rows: 44px 1fr 30px;
  grid-template-areas: "hdr hdr" "left right" "keys keys";
  gap: 10px;
  padding: 10px;
}
#hdr {
  grid-area: hdr;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-left: 6px solid var(--tag);
  border-radius: 4px;
  letter-spacing: 0.08em;
  font-size: 13px;
  text-transform: uppercase;
}
#hdr .inc {
  font-weight: 700;
  color: var(--tag);
}
#hdr .site {
  color: var(--dim);
}
#hdr .spacer {
  flex: 1;
}
#hdr-par,
#hdr-wll {
  color: var(--dim);
}
#hdr-hours {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.04em;
}
#hdr-hours.low {
  color: var(--bad);
}

#left {
  grid-area: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
#right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 10px 12px;
  overflow: auto;
}
.card h2 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--dim);
  font-weight: 700;
}
.card h2.sub {
  margin-top: 12px;
}
.card h2 .hint {
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  margin-left: 6px;
  font-size: 12px;
}
#briefcard {
  flex: 1 1 auto;
  min-height: 0;
}
#brief p {
  margin: 0 0 7px;
}
#brief .lock {
  color: var(--tag);
  font-weight: 600;
}
.say {
  margin: 0 0 7px;
  padding: 6px 9px;
  border-left: 3px solid var(--edge);
  background: #181d20;
}
.say .who {
  display: block;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#lugcard {
  flex: 0 0 260px;
  padding: 0;
  overflow: hidden;
}
#lug {
  width: 100%;
  height: 100%;
  display: block;
}

#rack {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 11px;
  background: #242c31;
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 3px;
  text-align: left;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.ex:hover:not(:disabled) {
  border-color: var(--tag);
}
.ex .cost {
  color: var(--tag);
  font-weight: 700;
}
.ex.pulled {
  opacity: 0.5;
}
.ex.locked {
  text-decoration: line-through;
  color: var(--dim);
}
.ex.dear .cost {
  color: var(--bad);
}

#deskcard {
  flex: 1 1 auto;
  min-height: 0;
}
#desk {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-content: start;
}
.empty-note {
  grid-column: 1 / -1;
  color: var(--dim);
  padding: 6px 0;
}
.exh {
  position: relative;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 2px;
  padding: 9px 11px 10px;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.08s;
}
.exh:hover {
  transform: translateY(-1px);
}
.exh .lbl {
  font-size: 12px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #5d574c;
}
.exh .val {
  font-size: 26px;
  font-weight: 700;
  font-family: "SF Mono", Menlo, monospace;
  margin: 2px 0;
}
.exh .ref {
  font-size: 12px;
  color: #4b463d;
}
.exh.cited {
  border-color: var(--tag);
  background: #fff7d8;
}
.exh.cited::after {
  content: "CITED";
  position: absolute;
  top: 7px;
  right: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #7a5c00;
  background: var(--tag);
  padding: 1px 5px;
  border-radius: 2px;
}
.exh.fresh {
  animation: drop 0.35s ease-out;
}
@keyframes drop {
  from {
    transform: translateY(-14px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

#formcard {
  flex: 0 0 auto;
}
#causes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.cause {
  padding: 9px 6px;
  background: #242c31;
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 13px;
}
.cause .k {
  color: var(--dim);
  font-weight: 400;
  margin-right: 6px;
}
.cause.on {
  background: var(--tag);
  color: #1b1608;
  border-color: var(--tag);
}
.cause.on .k {
  color: #5a4700;
}
#formline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 9px;
}
#citeline {
  flex: 1;
  color: var(--dim);
}
#citeline b {
  color: var(--ink);
}
#filebtn {
  padding: 8px 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--paper);
  color: var(--paper-ink);
  border: 0;
  border-radius: 3px;
}
#filebtn:disabled {
  opacity: 0.4;
  cursor: default;
}

#keys {
  grid-area: keys;
  display: flex;
  gap: 22px;
  align-items: center;
  font-size: 13px;
  color: var(--dim);
  padding: 0 4px;
}
#keys b {
  color: var(--ink);
  background: #2a3338;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

#coach {
  position: fixed;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  max-width: 640px;
  background: #fff7d8;
  color: #201b0c;
  border-left: 6px solid var(--tag);
  padding: 10px 16px;
  border-radius: 3px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  font-size: 15px;
  z-index: 5;
}
#coach .who {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: #6b5a1d;
  margin-bottom: 2px;
}
#coach[hidden],
.overlay[hidden] {
  display: none;
}

#toasts {
  position: fixed;
  top: 62px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 6;
}
.toast {
  background: #2a3338;
  border-left: 4px solid var(--dim);
  padding: 8px 12px;
  border-radius: 3px;
  max-width: 420px;
  animation: drop 0.25s ease-out;
}
.toast.warn {
  border-left-color: var(--bad);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 16, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.sheet {
  background: var(--paper);
  color: var(--paper-ink);
  width: min(680px, 92vw);
  max-height: 92vh;
  overflow: auto;
  padding: 26px 32px;
  border-radius: 3px;
  border-top: 10px solid var(--tag);
}
.sheet.wide {
  width: min(900px, 94vw);
}
.sheet h1 {
  margin: 2px 0 10px;
  font-size: 40px;
  letter-spacing: 0.06em;
}
.sheet .kicker {
  font-size: 12px;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: #6d665a;
}
.sheet .pitch {
  font-size: 15px;
}
.sheet p {
  margin: 0 0 9px;
}
.sheet table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
}
.sheet td {
  padding: 3px 14px 3px 0;
  vertical-align: top;
}
.controls td:first-child {
  font-weight: 700;
  font-family: "SF Mono", Menlo, monospace;
  white-space: nowrap;
}
.ladder td.stars {
  color: #9b7400;
  letter-spacing: 0.1em;
}
.ladder td.locked {
  color: #8c8578;
}
.go {
  margin-top: 14px;
  font-size: 14px;
  color: #5d574c;
}
.hb-law {
  margin: 0 0 8px;
}
.hb-tab td,
.hb-tab th {
  border-bottom: 1px solid #d6cdb8;
  padding: 4px 12px 4px 0;
  text-align: left;
}
.rs-stars {
  font-size: 30px;
  color: #9b7400;
  letter-spacing: 0.12em;
  margin: 4px 0 8px;
}
.rs-row {
  margin: 3px 0;
}
.rs-row.yes::before {
  content: "★ ";
  color: #9b7400;
}
.rs-row.no::before {
  content: "☆ ";
  color: #9b7400;
}
.rs-proof {
  margin-top: 10px;
  padding: 8px 10px;
  background: #e5dcc7;
  border-radius: 2px;
}

@media (max-width: 900px) {
  html, body { overflow: auto; }
  #app {
    position: static;
    display: flex;
    flex-direction: column;
    min-height: 100%;
  }
  #right { order: 1; }
  #left { order: 2; }
  #keys, #hdr .site { display: none; }
  #hdr { flex: 0 0 auto; min-height: 44px; flex-wrap: wrap; gap: 10px; padding: 6px 12px; }
  #lugcard { flex: 0 0 240px; }
  #deskcard { min-height: 170px; }
  #rack, #desk { grid-template-columns: repeat(2, 1fr); }
  #causes { grid-template-columns: repeat(3, 1fr); }
}

.hb-tabs { display: flex; gap: 28px; align-items: flex-start; }
.sheet .kicker + #hb-body { margin-top: 10px; }
