:root {
  --bg-a: #080d17;
  --bg-b: #0b1322;
  --panel: #111927;
  --card: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.1);
  --ink: #e8eefc;
  --muted: #9baed1;
  --accent: #3D5A80;
  --danger: #ff6b6b;
  --court-line: #ffffff;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: linear-gradient(180deg, var(--bg-a), var(--bg-b));
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
.file-button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-weight: 750;
}

button,
select,
.file-button,
summary,
.token-button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.workspace {
  min-height: 45dvh;
  padding: 10px;
  overflow: auto;
}

.controls-panel {
  border-top: 2px solid rgba(61, 90, 128, 0.6);
  background: var(--panel);
  padding: 10px;
  display: grid;
  gap: 10px;
}

.brand-row,
.section-row,
.action-row,
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-row strong {
  color: var(--accent);
}

.icon-button {
  width: 36px;
  min-height: 36px;
  border-radius: 999px;
}

.title-input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  padding: 12px;
  font-weight: 850;
}

.control-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 12px;
}

.control-card h2,
.control-card summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 900;
}

.control-card summary {
  list-style: none;
}

.control-card summary::-webkit-details-marker {
  display: none;
}

.stack,
.token-grid,
.tool-grid,
.mini-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.token-grid {
  grid-template-columns: repeat(5, minmax(38px, 1fr));
}

.tool-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-actions button {
  min-height: 34px;
  padding: 0 6px;
  font-size: 0.76rem;
}

.token-button {
  margin: auto;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  font-weight: 950;
}

.token-button.offense {
  background: #edf5fa;
  color: #151a24;
}

.token-button.defense {
  background: #3a1515;
  border-color: rgba(255, 107, 107, 0.7);
  color: #ffd6d6;
}

.token-button.active,
.tool-button.active {
  outline: 2px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(61, 90, 128, 0.16);
}

.tool-button {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 52px;
  color: var(--muted);
}

.tool-button.active {
  color: var(--accent);
  background: rgba(61, 90, 128, 0.16);
}

.primary-button {
  background: var(--accent);
  color: #0b1322;
}

.field-row span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.field-row input,
.field-row select {
  min-width: 116px;
}

.file-button {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0 12px;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.frames-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  max-width: 1300px;
  margin: 0 auto;
}

.frames-grid.two,
.frames-grid.four {
  grid-template-columns: 1fr;
}

.frame-card {
  border-radius: 10px;
  padding: 4px;
}

.frame-card.active {
  background: rgba(61, 90, 128, 0.14);
}

.frame-top {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.frame-top button {
  min-height: 28px;
  padding: 0 10px;
  color: var(--accent);
  background: rgba(61, 90, 128, 0.16);
}

.court-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.42);
  touch-action: none;
}

.court-wrap.active {
  outline: 3px solid var(--accent);
}

.court-svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 10 / 7;
  background: #c9984b;
}

.note-input {
  min-height: 46px;
  margin-top: 8px;
  resize: vertical;
  font-weight: 650;
}

.status {
  min-height: 1.2em;
  margin: 0;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 750;
}

.help-dialog {
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #111927;
  color: var(--ink);
}

.help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.help-dialog form {
  display: grid;
  gap: 12px;
}

.help-dialog h2,
.help-dialog p {
  margin: 0;
}

.fullscreening .controls-panel {
  display: none;
}

.fullscreening .workspace {
  min-height: 100dvh;
  padding: 14px;
}

.fullscreening .frames-grid {
  max-width: min(1400px, 100%);
}

@media (min-width: 760px) {
  .frames-grid.two,
  .frames-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .app-shell {
    flex-direction: row-reverse;
  }

  .workspace {
    flex: 1;
    height: 100dvh;
    padding: 18px;
  }

  .controls-panel {
    width: 310px;
    height: 100dvh;
    overflow: auto;
    border-top: 0;
    border-right: 1px solid var(--border);
  }
}

@media (max-width: 430px) {
  .mini-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Recording and app-style focused animation controls. */
[hidden] { display: none !important; }
.record-options { display: grid; gap: 8px; margin-top: 10px; }
.record-hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
.fullscreening { position: fixed; inset: 0; z-index: 50; background: #080d17; overflow: auto; }
.fullscreening .workspace { width: 100%; height: calc(100dvh - 88px); min-height: 0; padding: 12px; }
.fullscreening .frames-grid { display: block; max-width: min(1400px, calc((100dvh - 140px) / .7)); margin: auto; }
.fullscreening .frame-card:not(.active), .fullscreening .note-input, .fullscreening [data-fullscreen] { display: none; }
.fullscreen-bar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); background: #111927f5; z-index: 60; }
.fullscreen-bar button { padding: 10px 18px; }
.record-dialog { color: var(--ink); background: #111927; border: 1px solid var(--border); border-radius: 16px; width: min(600px, 94vw); max-height: 94dvh; padding: 18px; overflow: auto; }
.record-dialog::backdrop { background: #000b; }
.record-dialog h2 { margin: 0; font-size: 20px; }
.record-dialog p { color: var(--muted); font-size: 14px; }
.record-dialog canvas, .record-dialog video { display: block; width: 100%; max-height: 60dvh; object-fit: contain; background: black; margin: 12px 0; }
.download-button { background: var(--accent); color: #080d17; padding: 12px; border-radius: 8px; text-decoration: none; font-weight: 750; text-align: center; }
.record-dialog .action-row { flex-wrap: wrap; }
@media (max-width: 430px) { .fullscreen-bar button { padding: 8px; font-size: 13px; } }

/* TST website brand: navy, cream, slate, sky and orange. */
:root { --bg-a:#F4F1EB; --bg-b:#F4F1EB; --panel:#fff; --card:#F4F1EB; --border:rgba(1,17,54,.14); --ink:#011136; --muted:#3D5A80; --accent:#3D5A80; --danger:#b53223; color-scheme:light; font-family:'DM Sans',system-ui,sans-serif; }
.site-header { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:14px 24px; border-bottom:1px solid var(--border); background:#F4F1EB; }
.site-brand { display:flex; align-items:center; gap:12px; font-size:15px; font-weight:800; letter-spacing:.2px; color:#011136; text-decoration:none; }
.site-brand img { object-fit:contain; border-radius:50%; }
.site-header nav { display:flex; gap:20px; }
.site-header nav a { color:#3D5A80; font-size:13px; font-weight:700; text-decoration:none; }
.site-header a:hover { color:#E8611A; }
.app-shell { min-height:calc(100dvh - 73px); }
.workspace { background:#011136; }
.controls-panel { border-color:#98B4CC; }
button,select,.file-button { background:#fff; }
button:hover,.file-button:hover { border-color:#3D5A80; }
button.active,button.selected,[data-command="play"] { background:#3D5A80; color:#fff; }
[data-command="record"],.download-button { background:#E8611A; border-color:#E8611A; color:#fff; }
.frame-card { color:#F4F1EB; }
.frame-card textarea { color:#011136; background:#F4F1EB; }
dialog { background:#F4F1EB!important; color:#011136; }
.fullscreen-bar { background:#011136; }
:focus-visible { outline:3px solid #E8611A; outline-offset:3px; }
@media(max-width:600px) { .site-header {padding:10px 14px; flex-wrap:wrap; gap:10px;} .site-brand {font-size:12px;} .site-header nav {gap:16px;} .site-header nav a {font-size:12px;} }
.frame-top {color:#98B4CC;}
.frame-top button {color:#F4F1EB;background:#3D5A80;}
.primary-button {color:#fff;}
@media(min-width:980px) { .workspace,.controls-panel {height:calc(100dvh - 73px);} }

/* Account box (Save & Export) */
.account-box { display: grid; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid rgba(253, 91, 2, .45); background: rgba(253, 91, 2, .08); }
.account-box__lead { margin: 0; font-size: 13px; font-weight: 600; }
.account-box__signin { display: inline-flex; justify-content: center; padding: 10px 14px; border-radius: 999px; background: #fd5b02; color: #fff; font-weight: 700; font-size: 14px; text-decoration: none; }
.account-box__in { display: grid; gap: 8px; }
.account-box [hidden] { display: none !important; }

/* Calmer panel, account gate (Oct 31, 2026) */
.controls-panel { align-content: start; }
.control-card h2 small, .control-card summary small { margin-left: 6px; color: #7b8fa8; font-size: .68rem; letter-spacing: .02em; text-transform: none; font-weight: 700; }
.control-card summary { display: flex; align-items: center; gap: 4px; }
.control-card summary::after { content: "▾"; margin-left: auto; font-size: .9rem; transition: transform .15s; }
.control-card[open] > summary::after { transform: rotate(180deg); }
.control-card > summary { padding: 2px 0; }
.tool-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tool-button { min-height: 48px; font-size: .78rem; }
.edit-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.edit-row button, .more-menu summary { min-height: 34px; padding: 0 4px; font-size: .76rem; }
.more-menu { position: relative; }
.more-menu summary { display: grid; place-items: center; list-style: none; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-weight: 750; cursor: pointer; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu__panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; display: grid; gap: 4px; min-width: 140px; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: 0 10px 24px rgba(1,17,54,.18); }
.more-menu__panel button { min-height: 34px; text-align: left; padding: 0 10px; }
.selected-box { display: grid; gap: 8px; margin-top: 10px; padding: 10px; border-radius: 8px; background: rgba(61,90,128,.08); border: 1px dashed rgba(61,90,128,.4); }
.selected-box .action-row button { flex: 1; min-height: 34px; }
.selection-label { color: #E8611A; font-size: .78rem; font-weight: 800; }
.sub-details summary { color: var(--muted); font-size: .82rem; font-weight: 750; cursor: pointer; padding: 4px 0; }
.beta-tag { margin-left: 6px; padding: 2px 7px; border-radius: 999px; background: #E8611A; color: #fff; font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; vertical-align: 2px; }
.signed-out .needs-account::after { content: "🔒"; margin-left: 6px; font-size: .75em; }
.frame-top button.frame-play { background: #E8611A; border-color: #E8611A; color: #fff; padding: 0 12px; }
.frame-top button[data-command] { min-width: 32px; padding: 0 8px; }
.frame-top button[data-command]:disabled { opacity: .4; }
.gate-dialog { max-width: 400px; border: 0; border-radius: 16px; padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.gate-dialog::backdrop { background: rgba(1,17,54,.6); }
.gate-dialog h2 { margin: 8px 0 10px; font-size: 1.3rem; line-height: 1.25; }
.gate-dialog p { margin: 0 0 10px; font-size: .92rem; line-height: 1.5; }
.gate-dialog .gate-note { color: var(--muted); font-size: .84rem; }
.gate-dialog button, .gate-email { display: block; width: 100%; margin-top: 8px; min-height: 44px; }
.gate-email { display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #011136; font-weight: 750; text-decoration: none; }
.gate-dialog .gate-signin { margin-top: 10px; text-align: center; font-size: .85rem; }
.gate-dialog .gate-signin a { color: #3D5A80; font-weight: 800; }
.gate-error { color: var(--danger); font-size: .85rem; min-height: 0; }
.gate-error:empty { display: none; }
.free-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: #e6f4ea; color: #1e6b34; font-size: .75rem; font-weight: 800; }
[data-gate-close] { background: transparent !important; border: 0 !important; color: var(--muted) !important; }
.more-menu summary, .sub-details summary { text-transform: none; letter-spacing: 0; }
.more-menu summary::after, .sub-details summary::after { content: none; }
.sub-details summary { display: list-item; list-style: disclosure-closed; }
.sub-details[open] summary { list-style: disclosure-open; }
/* Match the navy tool theme in /assets/tst-tools.css */
body[data-tool="diagram"] .frame-top button.frame-play { background: #fd5b02; border-color: #fd5b02; color: #fff; }
body[data-tool="diagram"] .more-menu summary { background: #12306a; border-color: rgba(255,255,255,.2); color: #f5f7fa; }
body[data-tool="diagram"] .more-menu__panel { background: #0d2552; border-color: rgba(255,255,255,.2); }
body[data-tool="diagram"] .selected-box { background: rgba(255,255,255,.05); border-color: rgba(253,91,2,.5); }
body[data-tool="diagram"] .gate-email { background: transparent; border-color: rgba(255,255,255,.35); color: #f5f7fa; }
body[data-tool="diagram"] .gate-dialog .gate-signin a { color: #ff9a5c; }
body[data-tool="diagram"] .gate-dialog .gate-note, body[data-tool="diagram"] [data-gate-close] { color: #a9bcd6 !important; }
.export-box { display: grid; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.export-box .action-row button { flex: 1; }
