:root {
  --bg: #f3f4f6;
  --rail: #f7f7f8;
  --card: #ffffff;
  --fg: #1a1c1e;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --ring: #c45c4a;
  --ok: #3d9a5f;
  --play: #3b82f6;
  --share: #c45c4a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; width: 100%; background: var(--bg); color: var(--fg); }
body { font: 14px/1.45 var(--font); }
button, input { font: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico {
  appearance: none;
  width: 32px; height: 32px;
  border: 0; background: #eceef1;
  border-radius: 999px;
  color: var(--fg);
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
}
.ico:disabled { opacity: 0.4; cursor: default; }
.ico.back { background: #eceef1; }

#gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
#gate[hidden], #desk[hidden] { display: none !important; }
[hidden] { display: none !important; }
#gate form {
  width: min(360px, 100%);
  background: var(--card);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
#gate h1 { margin: 0 0 6px; font-size: 22px; }
#gate .lede { margin: 0 0 18px; color: var(--muted); }
#gate label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
#gate input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
#gate button[type="submit"] {
  margin-top: 16px;
  width: 100%;
  border: 0;
  background: var(--ring);
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.err { color: var(--ring); font-size: 13px; min-height: 1.2em; }

#desk {
  height: 100%;
  width: 100%;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  background: var(--bg);
}
#desk.nav-open {
  grid-template-columns: 232px 292px minmax(0, 1fr);
}
#desk.drop {
  outline: 2px dashed var(--ring);
  outline-offset: -6px;
}
#desk > .nav { display: none; }
#desk.nav-open > .nav { display: flex; }

.nav {
  flex-direction: column;
  background: #eef0f5;
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  min-width: 0;
}
.nav-head {
  display: flex;
  justify-content: space-between;
  padding: 0 4px 16px;
}
.nav-items { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  appearance: none;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--fg);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.55); }
.nav-item.on { background: #fff; font-weight: 650; box-shadow: var(--shadow); }
.nav-item svg { width: 18px; height: 18px; color: var(--muted); }
.nav-item .n { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }

.rail {
  position: relative;
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 10px 56px;
}
.rail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 10px;
}
.rail-head h1 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}
.pw {
  display: flex;
  gap: 6px;
  margin: 0 6px 10px;
}
.pw[hidden] { display: none !important; }
.pw input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.pw button {
  border: 0;
  background: var(--ring);
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #eceef1;
  border-radius: 10px;
  padding: 0 10px;
  margin: 0 6px 10px;
}
.search svg { width: 15px; height: 15px; color: var(--muted); }
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 0;
  outline: none;
}
.cards {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 6px 12px;
}
.card {
  appearance: none;
  text-align: left;
  border: 1.5px solid transparent;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: inherit;
  width: 100%;
}
.card.on { border-color: var(--ring); }
.card.stage { border-style: dashed; border-color: #d1d5db; }
.card h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .snip {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .foot {
  display: flex;
  gap: 12px;
  color: var(--faint);
  font-size: 11px;
  align-items: center;
}
.card .gone {
  margin-left: auto;
  opacity: 0;
  color: var(--ring);
}
.card:hover .gone, .card:focus-within .gone { opacity: 1; }
.fab {
  position: absolute;
  left: 18px;
  bottom: 16px;
  z-index: 8;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--share);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(196, 92, 74, 0.35);
}
.rail-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 12px;
  text-align: center;
}
.rail-empty.bin { padding-top: 80px; font-size: 15px; }

.tape {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  position: relative;
}
.tape-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.tape-doc {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.tape-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 22px 8px;
}
.tape-titles { min-width: 0; flex: 1; }
.tape-titles h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  word-break: break-word;
}
.tape-titles .meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.badge {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  align-self: center;
}
.badge.High { color: var(--ok); border-color: #9ad0ad; }
.badge.Low { color: var(--ring); border-color: #e8b4ab; }
.who {
  appearance: none;
  border: 0;
  background: #eef0f3;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  margin: 0 0 8px;
}
.who:hover { background: #e4e6ea; }
.who.generic { font-weight: 500; color: var(--muted); }
.assign {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 0 22px 10px;
}
.assign[hidden] { display: none !important; }
.assign-generics { display: flex; flex-wrap: wrap; gap: 6px; }
.assign-generics button {
  border: 0;
  background: #eef0f3;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.assign input {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
}
.assign [data-assign-save] {
  border: 0;
  background: var(--ring);
  color: #fff;
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
}
.tabs {
  display: flex;
  gap: 8px;
  padding: 8px 22px 12px;
}
.tabs button {
  border: 0;
  background: #eef0f3;
  color: var(--fg);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.tabs button.on { background: #e4e6ea; font-weight: 650; }
.tabs button:disabled { color: var(--faint); cursor: default; }
.body {
  flex: 1;
  overflow: auto;
  min-width: 0;
  width: 100%;
  padding: 4px 36px 120px 20px;
}
.turn {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 48px;
  gap: 4px 14px;
  align-items: start;
  margin: 0 0 26px;
}
.turn .t {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.turn .copy { min-width: 0; }
.turn p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.65;
  max-width: none;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
}
.turn .p {
  color: var(--ok);
  font-size: 12px;
  text-align: right;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.body .none { color: var(--muted); padding: 24px 0; }

.player {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, #fff 28%);
  padding: 8px 22px 16px;
}
.scrub {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 10px;
  align-items: center;
  color: var(--faint);
  font-size: 12px;
}
.scrub input[type="range"] { width: 100%; accent-color: var(--play); }
.controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.play {
  width: 40px; height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--play);
  color: #fff;
  display: grid; place-items: center;
  cursor: default;
}
.play svg { width: 16px; height: 16px; }
.rate {
  border: 0;
  background: #eceef1;
  border-radius: 999px;
  width: 36px; height: 36px;
  color: var(--muted);
}
.share {
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--share);
  color: #fff;
  padding: 0 12px;
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 650;
}
.share:disabled { opacity: 0.4; }
.w {
  display: inline;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  line-height: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 2px;
  white-space: inherit;
}
.w.low { text-decoration: underline wavy rgba(196, 92, 74, 0.7); }
.w.now { background: rgba(59, 130, 246, 0.18); }
.miniplay {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  font-size: 10px;
}

@media (max-width: 780px) {
  #desk { grid-template-columns: 1fr; }
  #desk.nav-open { grid-template-columns: 1fr; }
  #desk.nav-open .rail, #desk.nav-open .tape { display: none; }
  #desk.nav-open > .nav { display: flex; }
  #desk.show-tape .rail { display: none; }
  #desk:not(.show-tape) .tape { display: none; }
  .tape-head .back { display: grid; }
  .body { padding: 4px 16px 120px 10px; }
}
@media (min-width: 781px) {
  .tape-head .back { display: none; }
}

#settings {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 24, 0.35);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 24px;
}
#settings[hidden] { display: none !important; }
.settings-sheet {
  width: min(820px, 100%);
  max-height: min(88vh, 720px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(16, 24, 40, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.settings-top h2 { margin: 0; font-size: 18px; }
.settings-layout { display: grid; grid-template-columns: 180px 1fr; min-height: 0; flex: 1; }
.settings-nav {
  border-right: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #f7f7f8;
}
.settings-nav button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.settings-nav button.on { background: #fff; font-weight: 650; box-shadow: var(--shadow); }
.settings-body { padding: 20px 24px 24px; overflow: auto; }
.settings-body h3 { margin: 0 0 6px; }
.settings-body .lede { margin: 0 0 16px; }
.settings-body label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}
.settings-body input, .settings-body textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}
.facts { color: var(--muted); padding-left: 18px; }
.settings-body label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--fg); }
.settings-body label.check input { width: auto; margin: 0; }
.note { font-size: 13px; min-height: 1.2em; color: var(--ok); }
.note:empty { min-height: 0; }
a.primary { display: inline-block; text-decoration: none; }
.primary {
  border: 0;
  background: var(--ring);
  color: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}
@media (max-width: 720px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); }
}
