:root,
[data-theme="default"] {
  color-scheme: light;
  --bg: #f3f0ea;
  --surface: #fffdf9;
  --ink: #1c1916;
  --muted: #5f574f;
  --line: #8f867a;
  --line-soft: #e3dbd0;
  --accent: #9a3412;
  --accent-ink: #fff7f2;
  --hot: #9a3412;
  --danger: #9f1239;
  --notice-bg: #dcfce7;
  --notice-ink: #14532d;
  --notice-border: #15803d;
  --alert-bg: #ffe4e6;
  --alert-ink: #881337;
  --alert-border: #be123c;
  --font: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif;
  --display: var(--font);
  --radius: 12px;
  --shadow: 0 1px 0 rgba(28, 25, 22, 0.04);
}

[data-theme="streets-of-rage"] {
  color-scheme: dark;
  --bg: #100712;
  --surface: #1b0e22;
  --ink: #f6f0ff;
  --muted: #c9b6d8;
  --line: #83639e;
  --line-soft: #3d2752;
  --accent: #ffe14a;
  --accent-ink: #160910;
  --hot: #ff2d95;
  --ice: #2de2e6;
  --danger: #ff5d4a;
  --notice-bg: #123b32;
  --notice-ink: #b6f7df;
  --notice-border: #34d399;
  --alert-bg: #501a32;
  --alert-ink: #ffe4e6;
  --alert-border: #fb7185;
  --font: "Avenir Next", "Segoe UI", sans-serif;
  --display: Impact, "Arial Black", "Avenir Next Condensed", sans-serif;
  --radius: 4px;
  --shadow: none;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--hot) 12%, transparent), transparent 28rem),
    var(--bg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
}

a { color: var(--hot); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
.panel-head > a, .lede a { display: inline-flex; align-items: center; min-height: 44px; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 0.4rem;
}

[data-theme="streets-of-rage"] h1,
[data-theme="streets-of-rage"] .mark {
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); }
h2 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

:target, [id] { scroll-margin-top: 5.5rem; }

:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 2px;
}
::placeholder { color: var(--muted); opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.skip-link {
  position: absolute;
  inset: 0.5rem auto auto 0.5rem;
  z-index: 5;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus {
  transform: none;
}

.mark {
  font-family: var(--display);
  font-weight: 750;
  color: var(--ink);
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  position: sticky;
  top: 0;
  z-index: 2;
}

.nav-panel, .nav-end, .actions, .auth-links, .auth-brand, .page-head, .panel-head, .search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.nav-panel { flex: 1; gap: 0.6rem 1rem; }
.nav-panel a, .nav-meta {
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.5rem;
  border-radius: 8px;
}
.nav-panel a.is-active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--hot); }
.nav-end { margin-left: auto; }
.public-footer {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.cta-panel { padding: 1.5rem; }
.pitch { margin: 0 0 1.2rem; padding-left: 1.2rem; }
.pitch li { margin-bottom: 0.3rem; }
.sharing { display: grid; gap: 0.75rem; }
.sharing h2 { margin: 0; }
.sharing label, .share-box label { font-size: 0.9rem; color: var(--ink); }
.share-box { display: grid; gap: 0.35rem; }
.share-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.share-row input { flex: 1 1 16rem; }
.share-row .btn { gap: 0.4rem; }
.share-row svg { width: 1.1rem; height: 1.1rem; }
select.compact { width: auto; }
fieldset.field { border: 0; margin: 0 0 0.9rem; padding: 0; }
fieldset.field legend { font-size: 0.9rem; color: var(--ink); margin-bottom: 0.35rem; }
.choice { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; margin-right: 1rem; color: var(--ink); }
.choice input { width: auto; min-height: 0; }
.public-nav { display: flex; gap: 0.75rem; align-items: center; margin-left: auto; }
.public-nav a:not(.btn) { color: var(--muted); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.nav-meta { font-size: 0.92rem; }

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  min-height: 44px;
  margin-left: auto;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.burger:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 2px;
}
.burger span:not(.sr) {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
}

.shell { width: min(920px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }

.page-head, .panel-head { justify-content: space-between; align-items: end; margin-bottom: 1rem; }
.lede, .empty, .notes { color: var(--muted); }


.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat, .panel, .auth-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  color: inherit;
  text-decoration: none;
  padding: 1rem;
  min-height: 92px;
}
.stat span { display: block; color: var(--muted); font-size: 0.9rem; }
.stat strong { font-size: 1.8rem; font-family: var(--display); }

.panel { padding: 1rem 1.1rem 1.2rem; margin-bottom: 1rem; }

.rows, .sets { list-style: none; margin: 0; padding: 0; }
.rows li, .sets li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border-top: 1px solid var(--line-soft);
  min-height: 56px;
}
.rows a, .sets li div { display: flex; flex-direction: column; gap: 0.1rem; color: inherit; text-decoration: none; padding: 0.7rem 0; }
.rows a span, .sets span { color: var(--muted); font-size: 0.92rem; }

.badge {
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  white-space: nowrap;
}
.badge-done { color: var(--ink); background: color-mix(in srgb, var(--hot) 10%, var(--surface)); }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; flex: 1; }
.field label { font-size: 0.9rem; color: var(--ink); }
.split { display: flex; flex-wrap: wrap; gap: 0.75rem; }
[hidden] { display: none !important; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 1px;
  border-color: var(--hot);
}

.btn, button, input[type="submit"] {
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary, input[type="submit"].btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover, .btn-ghost:focus-visible { color: var(--ink); background: color-mix(in srgb, var(--hot) 8%, transparent); }
.btn-icon { width: 44px; padding: 0; }
.btn-icon svg { width: 1.2rem; height: 1.2rem; }

.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker,
.dropdown summary::marker { display: none; content: ""; }
.dropdown-panel {
  position: absolute;
  inset: 100% 0 auto auto;
  z-index: 4;
  min-width: 11rem;
  padding: 0.35rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.dropdown-panel .button_to { display: block; width: 100%; }
.dropdown-item {
  width: 100%;
  justify-content: flex-start;
  gap: 0.55rem;
  background: transparent;
  border: 0;
}
.dropdown-item svg { width: 1.1rem; height: 1.1rem; }
.dropdown-item:hover, .dropdown-item:focus-visible { background: color-mix(in srgb, var(--hot) 12%, var(--surface)); }
.dropdown summary:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }

.sets .round-summary { color: var(--ink); font-size: 1rem; }
.round-note { margin: 0.15rem 0 0; color: var(--muted); }
.round-video {
  display: block;
  width: min(100%, 22rem);
  margin-top: 0.4rem;
  border-radius: 8px;
  background: #000;
}
.round-form { margin-top: 0.75rem; }
.upload-progress { display: grid; gap: 0.3rem; }
.upload-progress progress { width: 100%; height: 0.6rem; accent-color: var(--accent); }
.field-error { margin: 0; font-size: 0.9rem; color: var(--danger); }
input[aria-invalid="true"], select[aria-invalid="true"], lexxy-editor[aria-invalid="true"] { border-color: var(--danger); }
.errors { margin: 0 0 1rem; padding: 0.7rem 0.9rem 0.7rem 1.6rem; border: 1px solid var(--danger); border-radius: 8px; color: var(--danger); }
.errors li { margin: 0.15rem 0; }
.errors a { color: inherit; }
.hint { margin: 0; font-size: 0.9rem; color: var(--muted); }
.log-flags { display: inline-flex; gap: 0.35rem; color: var(--muted); }
.log-flags svg { width: 1rem; height: 1rem; }
.history { list-style: none; margin: 0; padding: 0; }
.history > li { padding-block: 0.75rem; border-top: 1px solid var(--line-soft); }
.history > li:first-child { border-top: 0; }
.history h3 { font-size: 1rem; margin: 0; }
.rows .actions { flex-wrap: nowrap; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.button_to { display: inline; margin: 0; }
.search { margin-bottom: 1rem; align-items: end; }
.search .field { margin-bottom: 0; flex: 0 1 auto; }
.search input { min-width: 14rem; }
.search select { width: auto; }
.rows-plain li { justify-content: flex-start; gap: 0.75rem; padding: 0.55rem 0; min-height: 44px; }

.flash {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--notice-border);
  border-inline-start-width: 4px;
  background: var(--notice-bg);
  color: var(--notice-ink);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 1rem;
}
.flash-alert { border-color: var(--alert-border); background: var(--alert-bg); color: var(--alert-ink); }
.flash-icon { display: inline-flex; flex-shrink: 0; }
.flash-icon svg, .flash-dismiss svg { width: 1.25rem; height: 1.25rem; }
.flash-message { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.flash-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.flash-dismiss[hidden] { display: none; }
.flash-dismiss:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.flash-dismiss:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card { width: min(100%, 26rem); padding: 1.4rem; }
.auth-brand { justify-content: space-between; margin-bottom: 1rem; }
.auth-brand .mark { margin: 0; }
.auth-brand select { width: auto; min-width: 9.5rem; }
.flash:focus-visible, .errors:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }
.auth-links { gap: 1rem; }
.inline-form { margin: 0; }
.inline-form { display: flex; gap: 0.4rem; align-items: center; }
.inline-form input[type="number"] { width: 6.5rem; }
.theme-preview select { width: auto; min-width: 9.5rem; }

[data-theme="streets-of-rage"] .auth-card,
[data-theme="streets-of-rage"] .panel,
[data-theme="streets-of-rage"] .stat {
  border-color: color-mix(in srgb, var(--hot) 55%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ice) 35%, transparent);
}
[data-theme="streets-of-rage"] .btn-primary { box-shadow: 3px 3px 0 var(--hot); }

@media (max-width: 700px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-head { align-items: start; }
  .burger { display: inline-flex; }
  .nav-panel {
    position: absolute;
    inset: 100% 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.6rem 1.25rem 0.9rem;
    border-bottom: 1px solid var(--line-soft);
    background: var(--surface);
  }
  .nav.has-js:not(.is-open) .nav-panel { display: none; }
  .nav:not(.has-js) .nav-panel { position: static; }
  .nav:not(.has-js) .burger { display: none; }
  .nav-end {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-left: 0;
  }
  .nav-panel a, .nav-meta, .nav-end .btn {
    width: 100%;
    justify-content: flex-start;
  }
  .nav-panel a.is-active { box-shadow: inset 3px 0 0 var(--hot); }
}

@media print {
  :root, [data-theme] {
    --bg: #fff;
    --surface: #fff;
    --ink: #000;
    --muted: #333;
    --line: #bbb;
  }
  body { background: #fff; color: #000; font-size: 11pt; }
  .nav, .skip-link, .flash, .dropdown, .round-form, .no-print, .round-video, .page-head .actions, .btn, button {
    display: none !important;
  }
  .shell { width: auto; margin: 0; }
  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin-bottom: 1rem;
    break-inside: avoid;
  }
  .sets li { min-height: 0; padding-block: 0.2rem; }
  .sets li div { padding: 0; }
  a { color: #000; text-decoration: none; }
}

/* Lexxy editor + rendered rich text follow the app theme */
:root, [data-theme] {
  --lexxy-color-ink: var(--ink);
  --lexxy-color-ink-medium: var(--muted);
  --lexxy-color-ink-light: var(--muted);
  --lexxy-color-ink-lighter: var(--line);
  --lexxy-color-ink-lightest: color-mix(in srgb, var(--line) 45%, var(--surface));
  --lexxy-color-ink-inverted: var(--surface);
  --lexxy-color-canvas: var(--bg);
  --lexxy-color-text: var(--ink);
  --lexxy-color-text-subtle: var(--muted);
  --lexxy-color-link: var(--hot);
  --lexxy-color-accent-dark: var(--hot);
  --lexxy-color-accent-medium: color-mix(in srgb, var(--hot) 70%, var(--surface));
  --lexxy-color-accent-light: color-mix(in srgb, var(--hot) 25%, var(--surface));
  --lexxy-color-accent-lightest: color-mix(in srgb, var(--hot) 12%, var(--surface));
  --lexxy-focus-ring-color: var(--hot);
  --lexxy-font-base: var(--font);
  --lexxy-radius: 8px;
}

lexxy-editor {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  min-height: 7rem;
}
lexxy-editor:focus-within { outline: 2px solid var(--hot); outline-offset: 1px; border-color: var(--hot); }
.round-note .lexxy-content, .notes .lexxy-content { color: var(--muted); }
.round-note .lexxy-content > :first-child, .notes .lexxy-content > :first-child { margin-top: 0; }
.round-note .lexxy-content > :last-child, .notes .lexxy-content > :last-child { margin-bottom: 0; }

/* Markdown headings in notes stay smaller than page headings */
.lexxy-content :is(h1, h2, h3, h4) { font-family: var(--font); letter-spacing: 0; text-transform: none; margin: 0.8em 0 0.3em; }
.lexxy-content h1 { font-size: 1.2rem; }
.lexxy-content h2 { font-size: 1.1rem; }
.lexxy-content :is(h3, h4) { font-size: 1rem; }

/* Inline editors loaded into a round via Turbo Frame */
.round-body { flex: 1; min-width: 0; }
turbo-frame.inline-editor:not(:empty) {
  display: block;
  margin-top: 0.6rem;
  padding: 0.9rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
}
turbo-frame.inline-editor h3 { font-size: 1rem; margin: 0 0 0.2rem; }
turbo-frame[busy] { opacity: 0.6; }
.sets li { align-items: flex-start; }
.sets li > details { margin-top: 0.4rem; }
.eyebrow { margin-bottom: 0.2rem; font-size: 0.9rem; }

/* Exercise combobox */
.combobox { position: relative; }
.combobox-list {
  position: absolute;
  inset: 100% 0 auto 0;
  z-index: 4;
  margin: 0.25rem 0 0;
  padding: 0.3rem;
  list-style: none;
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.combobox-option {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
}
.combobox-option small { color: var(--muted); font-size: 0.85rem; }
.combobox-option.is-active, .combobox-option:hover { background: color-mix(in srgb, var(--hot) 12%, var(--surface)); }
.combobox-create { color: var(--hot); font-weight: 600; border-top: 1px solid var(--line-soft); border-radius: 0 0 8px 8px; }
