:root {
  --bg: #10141a;
  --bg-2: #171d27;
  --bg-3: #202836;
  --line: rgba(232, 238, 247, 0.1);
  --text: #e8eef7;
  --muted: #93a0b4;
  --amber: #f0a202;
  --amber-2: #ffd78a;
  --green: #3dbe86;
  --blue: #8eb6ff;
  --teal: #7fd1c7;
  --red: #ff6b6b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Outfit", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(240, 162, 2, 0.16), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(61, 190, 134, 0.08), transparent 45%),
    var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(12, 15, 20, 0.72);
  backdrop-filter: blur(10px);
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: radial-gradient(circle at 40% 35%, var(--amber-2), var(--amber) 42%, #8a5a00);
  box-shadow: 0 0 0 4px rgba(240, 162, 2, 0.12);
}
.brand strong { display: block; font-family: var(--display); font-size: 22px; font-weight: 560; letter-spacing: -0.03em; }
.brand em { display: block; margin-top: 2px; color: var(--muted); font-style: normal; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; }
.rail-nav a, .sheet a, .tabbar a, .tabbar button {
  text-decoration: none; border: 0; background: transparent; text-align: left;
  border-radius: 12px; padding: 10px 12px; color: var(--muted);
}
.rail-nav a.active, .tabbar a.active { background: var(--bg-3); color: var(--text); }
.player-link {
  margin-top: auto; text-decoration: none; text-align: center;
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 12px; color: var(--amber-2);
}
.workspace { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: grid; grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 18px; align-items: end; padding: 22px 28px 8px;
}
.eyebrow { margin: 0 0 4px; color: var(--amber); letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; }
h1 { margin: 0; font-family: var(--display); font-weight: 560; font-size: 40px; letter-spacing: -0.03em; }
.search { position: relative; }
.search input, .field input, .field select, .field textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; outline: none;
}
.search input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(240, 162, 2, 0.7); }
.search-pop {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px);
  background: #1c2430; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.search-pop a, .search-pop button {
  display: block; width: 100%; text-align: left; text-decoration: none;
  padding: 10px 12px; background: transparent; border: 0; border-bottom: 1px solid var(--line);
}
.search-pop a:hover, .search-pop button:hover { background: var(--bg-3); }
.hit-kind { display: inline-block; min-width: 88px; color: var(--amber-2); font-family: var(--mono); font-size: 11px; text-transform: uppercase; }
.top-clock { text-align: right; }
.top-clock span:first-child { display: block; font-family: var(--mono); font-size: 22px; }
.top-clock span:last-child { color: var(--muted); font-size: 12px; }
main { padding: 12px 28px 88px; }
.tabbar, .sheet { display: none; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1.4fr 0.8fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  min-width: 0;
}
.card h2, .card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 560; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: center; }

.btn, .btn-ghost, .btn-danger {
  border-radius: 999px; padding: 10px 16px; border: 1px solid transparent;
  background: var(--amber); color: #1a1203; font-weight: 650;
}
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); font-weight: 560; }
.btn-danger { background: transparent; border-color: rgba(255, 107, 107, 0.45); color: var(--red); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border-radius: 999px; padding: 4px 10px; background: var(--bg-3);
  color: var(--muted); font-size: 12px; letter-spacing: 0.04em;
}
.pill.on { color: #123226; background: var(--green); }
.pill.warn { color: #3a2a05; background: var(--amber-2); }

.list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.list li, .item, a.item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px; border-radius: 14px; background: rgba(0,0,0,0.18);
  text-decoration: none; color: inherit;
}
.item .hint, .list .hint { font-size: 14px; }
.item strong, .list strong { font-weight: 560; }
.when { font-family: var(--mono); font-size: 12px; color: var(--amber-2); }

.industries { display: flex; gap: 8px; overflow: auto; padding-bottom: 6px; }
.industries button, .msgs button, .tabs button {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 14px; padding: 10px 12px;
}
.industries button.active, .msgs button.active, .tabs button.active { border-color: var(--amber); color: var(--amber-2); }
.composer { display: grid; grid-template-columns: 280px 1fr; gap: 16px; margin-top: 14px; }
.msgs { display: flex; flex-direction: column; gap: 8px; }
.msgs button { text-align: left; }
.msgs small, .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.template-line { font-family: var(--display); font-size: 28px; line-height: 1.25; margin: 8px 0 16px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field span { color: var(--muted); font-size: 13px; }
.segments { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  border-radius: 12px; padding: 8px 10px; background: var(--bg-3); max-width: 100%;
}
.chip b { display: block; font-weight: 560; }
.chip i { font-style: normal; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.chip.recorded { outline: 1px solid rgba(61, 190, 134, 0.7); }
.chip.library { outline: 1px solid rgba(142, 182, 255, 0.8); }
.chip.phrase { outline: 1px solid rgba(127, 209, 199, 0.8); }
.chip.tts { outline: 1px solid rgba(240, 162, 2, 0.85); }
.flags { margin: 0 0 12px; padding-left: 18px; color: var(--amber-2); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; min-width: 0; }
.day { min-height: 140px; min-width: 0; padding: 10px; border-radius: 14px; background: rgba(0,0,0,0.18); }
.day strong { display: block; margin-bottom: 8px; }
.day em { display: block; font-style: normal; font-size: 12px; margin: 0 0 6px; color: var(--text); }
.switch { display: flex; align-items: center; gap: 8px; }

.ptt-wrap { display: grid; justify-items: center; gap: 16px; padding: 12px 0 8px; }
.ptt {
  width: min(280px, 70vw); height: min(280px, 70vw); border-radius: 50%;
  border: 10px solid #2a2418; background: radial-gradient(circle at 40% 30%, #3a3328, #16130f 62%);
  color: var(--amber-2); font-family: var(--display); font-size: 42px; letter-spacing: -0.03em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 20px 50px rgba(0,0,0,0.35);
}
.ptt.hot {
  border-color: var(--amber);
  color: #1a1203; background: radial-gradient(circle at 40% 30%, #ffe1a3, var(--amber) 55%, #c47d00);
  box-shadow: 0 0 0 8px rgba(240, 162, 2, 0.18), 0 20px 50px rgba(0,0,0,0.35);
}
meter, .meter {
  width: min(520px, 100%); height: 56px; border-radius: 12px; background: #0c0f14;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.swatch.recorded { background: var(--green); }
.swatch.library { background: var(--blue); }
.swatch.phrase { background: var(--teal); }
.swatch.tts { background: var(--amber); }

.token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.token {
  text-align: left; border-radius: 12px; border: 1px solid var(--line); background: #121820; padding: 10px;
}
.token.have { border-color: rgba(61, 190, 134, 0.55); }
.token.miss { border-color: rgba(255, 107, 107, 0.4); }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: grid; place-items: center; padding: 18px; z-index: 20;
}
.modal { width: min(560px, 100%); background: #1a212c; border-radius: 20px; border: 1px solid var(--line); padding: 16px; box-shadow: var(--shadow); }
.modal header { display: flex; justify-content: space-between; align-items: center; }
.modal h2 { margin: 0; font-family: var(--display); font-weight: 560; }
.read-line { font-family: var(--display); font-size: 32px; line-height: 1.2; margin: 8px 0; }
#toasts { position: fixed; right: 16px; bottom: 76px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: #243044; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; max-width: 320px; }
.sheet {
  position: fixed; left: 12px; right: 12px; bottom: 72px; z-index: 15;
  background: #1c2430; border: 1px solid var(--line); border-radius: 16px; padding: 8px;
}
.sheet[hidden] { display: none !important; }
.sheet a { display: block; }
code, pre { font-family: var(--mono); font-size: 12px; }
pre {
  white-space: pre-wrap; background: #0c1016; border-radius: 12px; padding: 12px; overflow: auto;
}
.empty { padding: 28px 8px; color: var(--muted); }
.error { color: var(--red); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .top { grid-template-columns: 1fr; padding: 16px 16px 0; }
  h1 { font-size: 32px; }
  main { padding: 12px 16px 108px; }
  .grid.two, .grid.three, .composer, .fields { grid-template-columns: 1fr; }
  .week { display: flex; overflow-x: auto; max-width: 100%; }
  .day { flex: 0 0 200px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
    background: rgba(16, 20, 26, 0.94); border-top: 1px solid var(--line); padding: 6px;
  }
  .tabbar a, .tabbar button { text-align: center; font-size: 13px; }
  .sheet:not([hidden]) { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
