/* Allocation Studio v3
   A task-first operations workspace. This file intentionally loads after the
   legacy surface so the redesign remains isolated, reviewable, and reversible. */

:root {
  --page: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f7f8fb;
  --surface-strong: #edf0f5;
  --surface-strong-hover: #e4e8ef;
  --text: #17191f;
  --text-muted: #646b78;
  --text-faint: #69717e;
  --primary: #3157f6;
  --primary-hover: #2448dc;
  --primary-soft: #edf1ff;
  --focus: #3157f6;
  --line: #dce1e9;
  --line-soft: #e9ecf1;
  --field: #fbfcfd;
  --field-focus: #ffffff;
  --table-head: #f4f6f9;
  --row-alt: #f8f9fb;
  --tile: #f7f8fb;
  --hairline: rgb(23 25 31 / 0.09);
  --overlay-weak: rgb(23 25 31 / 0.045);
  --overlay: rgb(23 25 31 / 0.075);
  --header-bg: rgb(255 255 255 / 0.9);
  --shadow: 0 1px 2px rgb(17 24 39 / 0.04), 0 12px 36px rgb(17 24 39 / 0.07);
  --radius-small: 6px;
  --radius: 10px;
  --radius-large: 14px;
  --content: 1480px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-head: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d1117;
    --surface: #141a23;
    --surface-soft: #181f2a;
    --surface-strong: #222b38;
    --surface-strong-hover: #2b3645;
    --text: #f1f4f8;
    --text-muted: #a1a9b7;
    --text-faint: #8f98a6;
    --primary: #8096ff;
    --primary-hover: #9aabff;
    --primary-soft: #202944;
    --on-primary: #0b1020;
    --focus: #91a4ff;
    --line: #2d3745;
    --line-soft: #232c38;
    --field: #101620;
    --field-focus: #141a23;
    --table-head: #1b2330;
    --row-alt: #171e28;
    --tile: #181f2a;
    --hairline: rgb(255 255 255 / 0.09);
    --overlay-weak: rgb(255 255 255 / 0.05);
    --overlay: rgb(255 255 255 / 0.08);
    --header-bg: rgb(13 17 23 / 0.88);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.28), 0 18px 54px rgb(0 0 0 / 0.28);
  }
}

:root[data-theme="dark"] {
  --page: #0d1117;
  --surface: #141a23;
  --surface-soft: #181f2a;
  --surface-strong: #222b38;
  --surface-strong-hover: #2b3645;
  --text: #f1f4f8;
  --text-muted: #a1a9b7;
  --text-faint: #8f98a6;
  --primary: #8096ff;
  --primary-hover: #9aabff;
  --primary-soft: #202944;
  --on-primary: #0b1020;
  --focus: #91a4ff;
  --line: #2d3745;
  --line-soft: #232c38;
  --field: #101620;
  --field-focus: #141a23;
  --table-head: #1b2330;
  --row-alt: #171e28;
  --tile: #181f2a;
  --hairline: rgb(255 255 255 / 0.09);
  --overlay-weak: rgb(255 255 255 / 0.05);
  --overlay: rgb(255 255 255 / 0.08);
  --header-bg: rgb(13 17 23 / 0.88);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.28), 0 18px 54px rgb(0 0 0 / 0.28);
}

[hidden] {
  display: none !important;
}

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

body {
  background: var(--page);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.48;
}

h1,
h2,
h3,
.button,
legend,
.team-name-input,
.brand__name {
  font-family: var(--font);
}

h1,
.content-section h2,
.results-header h2 {
  font-family: var(--font);
  font-weight: 720;
  letter-spacing: -0.035em;
  text-transform: none;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 3.2vw, 3rem);
  line-height: 1.02;
}

h2 {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

h3 {
  font-size: 1rem;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.site-header {
  border-bottom-color: var(--line-soft);
  background: var(--header-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.site-header__inner {
  width: min(calc(100% - 28px), var(--content));
  min-height: 58px;
}

.brand {
  gap: 10px;
}

.brand__mark {
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  gap: 2px;
  width: 18px;
  height: 18px;
  transform: rotate(0deg);
}

.brand__mark i {
  border-radius: 2px;
  background: var(--text);
}

.brand__mark i:nth-child(2),
.brand__mark i:nth-child(3) {
  background: var(--primary);
}

.brand__name {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.utility-nav {
  gap: 3px;
}

.button {
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 8px;
  font-weight: 650;
  letter-spacing: -0.01em;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms var(--ease-out), opacity 150ms ease;
}

.button:hover:not(:disabled) {
  transform: none;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button--primary {
  background: var(--primary);
  box-shadow: 0 1px 2px rgb(23 37 84 / 0.18), 0 7px 18px color-mix(in srgb, var(--primary) 18%, transparent);
}

.button--primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 1px 2px rgb(23 37 84 / 0.2), 0 9px 22px color-mix(in srgb, var(--primary) 22%, transparent);
}

.button--secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 1px rgb(17 24 39 / 0.03);
}

.button--secondary:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--line) 45%, var(--text-muted));
  background: var(--surface-soft);
}

.button--quiet {
  color: var(--text-muted);
}

.button--small {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 0.82rem;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  font-size: 1rem;
}

.icon-glyph {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.count-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 0.7rem;
}

main {
  width: min(calc(100% - 28px), var(--content));
}

.tool-shell,
.share-view {
  padding: 24px 0 56px;
}

.tool-shell::before,
.tool-shell::after {
  display: none;
}

.tool-intro {
  align-items: center;
  gap: 28px;
  margin-bottom: 20px;
}

.tool-intro > div:first-child {
  max-width: 900px;
}

.tool-intro__lede {
  max-width: 880px;
  color: var(--text-muted);
  font-size: 1rem;
}

.eyebrow,
.step-label,
.stage-label {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 720;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.tool-intro .eyebrow {
  display: block;
}

.tool-intro .eyebrow::before {
  display: none;
}

.privacy-status {
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(17 24 39 / 0.03);
}

.privacy-status strong {
  font-size: 0.82rem;
}

.privacy-status small {
  font-size: 0.7rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 12%, transparent);
}

.workspace-tabs {
  display: none;
}

.app-workspace {
  display: grid;
  grid-template-columns: minmax(620px, 1.06fr) minmax(380px, 0.94fr);
  width: 100%;
  height: clamp(600px, calc(100svh - 210px), 820px);
  min-height: 600px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 64px;
  transition: grid-template-columns 260ms var(--ease-out);
}

#generator-view[data-workspace-state="results"] .app-workspace,
#generator-view[data-workspace-state="rounds"] .app-workspace {
  grid-template-columns: minmax(350px, 0.38fr) minmax(0, 1fr);
}

.generator-form {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  scrollbar-gutter: stable;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  min-height: 100%;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#generator-view[data-workspace-state="results"] .setup-grid,
#generator-view[data-workspace-state="rounds"] .setup-grid {
  grid-template-columns: 1fr;
  align-content: start;
}

.setup-panel {
  min-width: 0;
  padding: 22px;
}

.setup-panel--roster {
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.setup-panel--options {
  background: var(--surface-soft);
}

#generator-view[data-workspace-state="results"] .setup-panel--roster,
#generator-view[data-workspace-state="rounds"] .setup-panel--roster {
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.panel-heading {
  margin-bottom: 12px;
}

.panel-heading h2 {
  font-size: 1.1rem;
  letter-spacing: -0.025em;
}

.participant-counter {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 0.72rem;
  font-weight: 650;
}

textarea,
input[type="text"],
input[type="url"],
input[type="number"],
select {
  border-color: var(--line);
  border-radius: 7px;
  background: var(--surface);
}

textarea,
input[type="text"],
input[type="url"],
input[type="number"] {
  padding: 9px 10px;
}

select {
  min-height: 38px;
  padding: 7px 32px 7px 10px;
}

#names-input {
  min-height: 264px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  box-shadow: none;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.58;
}

#names-input:focus {
  border-color: var(--focus);
  background: var(--field-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 14%, transparent);
}

#generator-view[data-workspace-state="results"] #names-input,
#generator-view[data-workspace-state="rounds"] #names-input {
  min-height: 150px;
}

.field-help,
.input-status,
.storage-description,
.result-subtitle,
.muted {
  font-size: 0.78rem;
}

.field-help {
  margin: 7px 0 10px;
}

.input-status {
  margin-top: 9px;
}

.compact-select {
  width: 116px;
}

.compact-select select {
  min-height: 34px;
  font-size: 0.78rem;
}

legend {
  margin-bottom: 7px;
  font-size: 0.66rem;
  letter-spacing: 0.09em;
}

.split-control {
  gap: 6px;
  margin-bottom: 16px;
}

.split-option {
  grid-template-columns: 18px 1fr 66px;
  min-height: 44px;
  gap: 8px;
  padding: 5px 7px 5px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
}

.split-option:hover {
  border-color: var(--line);
}

.split-option:has(input[type="radio"]:checked) {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: var(--primary-soft);
  box-shadow: none;
}

.split-option input[type="radio"],
.mode-option input[type="radio"],
.check-row input,
.checkbox-grid input {
  width: 15px;
  height: 15px;
}

.number-input {
  height: 32px;
  border-radius: 6px !important;
  font-size: 0.82rem;
}

.mode-control {
  grid-template-columns: 1fr;
  gap: 5px;
  margin-bottom: 14px;
}

.mode-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  grid-template-rows: auto auto;
  min-height: 0;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  flex-direction: initial;
  align-items: center;
}

.mode-option:hover {
  border-color: var(--line);
}

.mode-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: var(--primary-soft);
  box-shadow: none;
}

.mode-option input {
  position: static;
  grid-row: 1 / span 2;
  grid-column: 1;
}

.mode-option__title {
  grid-column: 2;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 680;
}

.mode-option__description {
  grid-column: 2;
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1.3;
}

.seed-row {
  grid-template-columns: 42px 1fr;
  margin-bottom: 12px;
}

.seed-row > label {
  font-size: 0.7rem;
}

.seed-control {
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.seed-control input {
  font-size: 0.75rem;
}

.seed-control .icon-button {
  width: 34px;
  height: 34px;
}

.button--generate {
  min-height: 48px;
  margin-bottom: 6px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 720;
  letter-spacing: -0.005em;
  text-transform: none;
}

.button--generate:disabled {
  animation: none;
}

.button--generate[data-working="true"] {
  position: relative;
  overflow: hidden;
}

.button--generate[data-working="true"]::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: color-mix(in srgb, var(--on-primary) 85%, transparent);
  content: "";
  animation: allocation-progress 900ms ease-in-out infinite;
  transform-origin: left;
}

@keyframes allocation-progress {
  0% { transform: translateX(-100%) scaleX(0.42); }
  50% { transform: translateX(20%) scaleX(0.72); }
  100% { transform: translateX(120%) scaleX(0.36); }
}

.button--generate kbd {
  border-color: color-mix(in srgb, var(--on-primary) 28%, transparent);
  border-radius: 4px;
  font-size: 0.62rem;
}

.inline-actions--between {
  margin-top: 2px;
}

.inline-actions--between .button {
  padding-right: 5px;
  padding-left: 5px;
  font-size: 0.74rem;
}

.workspace-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  scrollbar-gutter: stable;
}

.workspace-empty {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100%;
  color: var(--text);
}

.workspace-empty__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
}

.stage-label {
  margin: 0;
}

.workspace-readiness {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 620;
}

.workspace-readiness i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.workspace-readiness[data-ready="true"] {
  color: var(--success);
}

.workspace-readiness[data-ready="true"] i {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 12%, transparent);
}

.workspace-empty__body {
  display: grid;
  place-items: center;
  align-content: center;
  max-width: 520px;
  padding: 40px;
  margin: 0 auto;
  text-align: center;
}

.workspace-empty__mark {
  display: grid;
  grid-template-columns: repeat(2, 18px);
  gap: 5px;
  margin-bottom: 24px;
}

.workspace-empty__mark i {
  width: 18px;
  height: 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--line));
  border-radius: 4px;
  background: var(--primary-soft);
}

.workspace-empty__mark i:nth-child(2),
.workspace-empty__mark i:nth-child(3) {
  background: var(--primary);
}

.workspace-empty__kicker {
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 720;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.workspace-empty h2 {
  max-width: 410px;
  margin-bottom: 10px;
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  letter-spacing: -0.04em;
}

.workspace-empty__body > p:not(.workspace-empty__kicker) {
  max-width: 470px;
  margin-bottom: 26px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.workspace-empty__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  width: min(100%, 430px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.workspace-empty__stats > span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 12px 10px;
  border-right: 1px solid var(--line);
}

.workspace-empty__stats > span:last-child {
  border-right: 0;
}

.workspace-empty__stats strong {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-empty__stats small {
  color: var(--text-muted);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.workspace-empty__footer {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-faint);
  font-size: 0.68rem;
}

.workspace-empty__footer span {
  position: relative;
}

.workspace-empty__footer span + span::before {
  position: absolute;
  top: 50%;
  left: -12px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentcolor;
  content: "";
}

.validation-panel {
  margin: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: 9px;
}

.results-workspace,
.round-results {
  margin: 0;
  padding: 0;
  border: 0;
  scroll-margin-top: 0;
}

.results-header {
  align-items: center;
  min-height: 72px;
  padding: 14px 18px;
  margin: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}

.results-header .eyebrow {
  margin-bottom: 3px;
}

.results-header h2 {
  margin-bottom: 2px;
  font-size: 1.35rem;
}

.project-name-field {
  width: min(210px, 32vw);
}

.project-name-field input {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 0.78rem;
}

.result-toolbar {
  position: sticky;
  top: 0;
  z-index: 8;
  gap: 8px;
  padding: 8px 12px;
  margin: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 7px 18px rgb(17 24 39 / 0.045);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
}

.result-toolbar__group {
  gap: 4px;
}

.result-toolbar .button--secondary {
  background: var(--surface-soft);
}

.result-toolbar .button--quiet:not(:disabled) {
  color: var(--text);
}

.metric-rail {
  grid-template-columns: repeat(6, minmax(112px, 1fr));
  gap: 7px;
  padding: 14px 14px 8px;
  overflow-x: auto;
}

.metric {
  min-width: 112px;
  padding: 10px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: none;
}

.metric__value {
  margin-bottom: 3px;
  font-family: var(--font);
  font-size: 1.25rem;
  font-weight: 740;
  letter-spacing: -0.03em;
}

.metric__label {
  font-size: 0.72rem;
  font-weight: 680;
}

.metric__hint {
  margin-top: 2px;
  font-size: 0.62rem;
}

.result-explanation {
  margin: 6px 14px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: transparent;
}

.result-explanation summary {
  padding: 10px 12px;
  font-size: 0.78rem;
}

.result-explanation__content {
  padding: 0 12px 12px;
  font-size: 0.76rem;
}

.team-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  padding: 0 14px 18px;
}

.team-card {
  border-color: var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgb(17 24 39 / 0.04);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.team-card:hover {
  transform: none;
  border-color: color-mix(in srgb, var(--team-color) 36%, var(--line));
  box-shadow: 0 6px 18px rgb(17 24 39 / 0.06);
}

.team-card[data-drag-over="true"] {
  border-color: var(--team-color);
  background: color-mix(in srgb, var(--team-color) 5%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--team-color) 15%, transparent);
}

.team-card__header {
  grid-template-columns: 4px minmax(0, 1fr) auto;
  min-height: 54px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--team-color) 5%, var(--surface));
}

.team-card__header::after {
  display: none;
}

.team-card__title-wrap {
  padding: 9px 8px 8px 11px;
}

.team-name-input {
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 720;
}

.team-card__summary {
  margin-top: 1px;
  font-size: 0.66rem;
}

.team-card__controls {
  gap: 2px;
  padding: 7px 7px 7px 0;
}

.team-color-input {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.team-card__controls .icon-button {
  width: 30px;
  height: 30px;
}

.participant-list {
  min-height: 48px;
}

.participant-row {
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 7px;
  min-height: 45px;
  padding: 6px 7px 6px 9px;
  border-top: 1px solid var(--line-soft);
}

.participant-row:first-child {
  border-top: 0;
}

.participant-row:hover {
  background: var(--surface-soft);
}

.participant-row[draggable="true"]:active {
  position: relative;
  z-index: 2;
  background: var(--surface);
  box-shadow: 0 6px 18px rgb(17 24 39 / 0.12);
  transform: scale(1.01);
}

.drag-handle {
  width: 18px;
  height: 26px;
  font-size: 0;
}

.drag-handle .icon-glyph,
.drag-handle > svg {
  width: 14px;
  height: 14px;
}

.participant-row__name {
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 650;
}

.participant-row__meta {
  font-size: 0.64rem;
}

.captain-mark {
  font-size: 0.62rem;
}

.participant-actions {
  gap: 1px;
  opacity: 0.34;
  transition: opacity 140ms ease;
}

.participant-row:hover .participant-actions,
.participant-row:focus-within .participant-actions,
.participant-actions:has([aria-pressed="true"]) {
  opacity: 1;
}

.participant-action {
  width: 29px;
  height: 29px;
  border-radius: 6px;
  font-size: 0;
}

.participant-action .icon-glyph {
  width: 14px;
  height: 14px;
}

.participant-action:hover,
.participant-action[aria-pressed="true"] {
  background: var(--surface-strong);
}

.participant-action[data-action="swap"][aria-pressed="true"] {
  color: var(--on-primary);
  background: var(--primary);
}

.team-card__footer {
  gap: 12px;
  padding: 7px 10px 8px;
  font-size: 0.62rem;
}

.bench-panel,
.fairness-insights,
.rotation-summary {
  margin: 0 14px 14px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--surface-soft);
}

.round-results > .section-heading-row {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.round-results > .rotation-summary {
  margin-top: 14px;
}

.round-list {
  padding: 0 14px 18px;
}

/* Result reveal is now a quiet workspace activation, not a game-like deal. */
@keyframes studio-enter {
  from { transform: translateY(7px); }
  to { transform: translateY(0); }
}

.team-grid[data-reveal="true"] .team-card,
.metric-rail[data-reveal="true"] .metric {
  animation-name: studio-enter;
  animation-duration: 220ms;
  animation-timing-function: var(--ease-out);
}

.team-grid[data-reveal="true"] .participant-list {
  animation: none;
}

.generator-form[data-busy="true"] {
  opacity: 1;
}

.content-section {
  padding: 76px 0;
  border-top-color: var(--line);
}

.content-section__intro {
  max-width: 780px;
}

.content-section h2 {
  max-width: 820px;
  font-size: clamp(1.75rem, 3vw, 2.55rem);
}

.mode-guide,
.use-case-list,
.method-columns {
  gap: 18px;
}

.mode-guide article,
.use-case-list article {
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.site-footer {
  border-top-color: var(--line);
}

.app-dialog,
.app-dialog--wide {
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.26);
}

.dialog-header {
  border-bottom: 1px solid var(--line-soft);
}

.dialog-footer {
  border-top: 1px solid var(--line-soft);
}

@media (max-width: 1240px) {
  .app-workspace {
    grid-template-columns: minmax(540px, 1fr) minmax(360px, 0.82fr);
  }

  #generator-view[data-workspace-state="results"] .app-workspace,
  #generator-view[data-workspace-state="rounds"] .app-workspace {
    grid-template-columns: 330px minmax(0, 1fr);
  }

  .setup-grid {
    grid-template-columns: 1fr;
  }

  .setup-panel--roster {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #names-input {
    min-height: 180px;
  }
}

@media (max-width: 1040px) {
  .site-header__inner,
  main,
  .site-footer {
    width: min(calc(100% - 22px), var(--content));
  }

  .tool-intro {
    margin-bottom: 16px;
  }

  .workspace-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: min(100%, 360px);
    padding: 3px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-strong);
  }

  .workspace-tab {
    min-height: 36px;
    border: 0;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    background: transparent;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 680;
  }

  .workspace-tab[aria-selected="true"] {
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 1px 2px rgb(17 24 39 / 0.08);
  }

  .workspace-tab:disabled {
    cursor: not-allowed;
    opacity: 0.42;
  }

  .app-workspace,
  #generator-view[data-workspace-state="results"] .app-workspace,
  #generator-view[data-workspace-state="rounds"] .app-workspace {
    display: block;
    height: auto;
    min-height: 640px;
  }

  .generator-form,
  .workspace-stage {
    min-height: 640px;
    border: 0;
  }

  #generator-view[data-mobile-pane="setup"] .workspace-stage,
  #generator-view[data-mobile-pane="results"] .generator-form {
    display: none;
  }

  .setup-grid,
  #generator-view[data-workspace-state="results"] .setup-grid,
  #generator-view[data-workspace-state="rounds"] .setup-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  }

  .setup-panel--roster,
  #generator-view[data-workspace-state="results"] .setup-panel--roster,
  #generator-view[data-workspace-state="rounds"] .setup-panel--roster {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  #names-input,
  #generator-view[data-workspace-state="results"] #names-input,
  #generator-view[data-workspace-state="rounds"] #names-input {
    min-height: 250px;
  }

  .result-toolbar {
    position: sticky;
  }
}

@media (max-width: 760px) {
  .site-header__inner {
    min-height: 54px;
  }

  .site-header .utility-nav .button:not(#header-saved-button) {
    display: none;
  }

  .tool-shell,
  .share-view {
    padding-top: 18px;
  }

  .tool-intro {
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }

  .tool-intro h1 {
    font-size: 1.85rem;
  }

  .tool-intro__lede {
    font-size: 0.88rem;
  }

  .privacy-status {
    display: none;
  }

  .workspace-tabs {
    width: 100%;
  }

  .app-workspace,
  .generator-form,
  .workspace-stage {
    min-height: calc(100svh - 174px);
  }

  .setup-grid,
  #generator-view[data-workspace-state="results"] .setup-grid,
  #generator-view[data-workspace-state="rounds"] .setup-grid {
    grid-template-columns: 1fr;
  }

  .setup-panel {
    padding: 17px;
  }

  .setup-panel--roster,
  #generator-view[data-workspace-state="results"] .setup-panel--roster,
  #generator-view[data-workspace-state="rounds"] .setup-panel--roster {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #names-input,
  #generator-view[data-workspace-state="results"] #names-input,
  #generator-view[data-workspace-state="rounds"] #names-input {
    min-height: 220px;
  }

  .mode-control {
    grid-template-columns: 1fr;
  }

  .results-header {
    align-items: stretch;
    min-height: 0;
    padding: 13px;
  }

  .results-header__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .project-name-field {
    width: 100%;
  }

  .result-toolbar {
    align-items: stretch;
    padding: 7px;
    flex-direction: column;
  }

  .result-toolbar__group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .result-toolbar__group .button {
    width: 100%;
  }

  .metric-rail {
    grid-template-columns: repeat(3, minmax(108px, 1fr));
    padding: 10px 10px 6px;
  }

  .result-explanation {
    margin: 5px 10px 10px;
  }

  .team-grid {
    grid-template-columns: 1fr;
    padding: 0 10px 14px;
  }

  .participant-actions {
    opacity: 1;
  }

  .participant-actions .participant-action[data-action="lock"],
  .participant-actions .participant-action[data-action="captain"] {
    display: inline-grid;
  }

  .bench-panel,
  .fairness-insights,
  .rotation-summary {
    margin-right: 10px;
    margin-left: 10px;
  }

  .workspace-empty__body {
    padding: 28px 20px;
  }

  .workspace-empty__stats {
    grid-template-columns: 1fr;
  }

  .workspace-empty__stats > span {
    grid-template-columns: 1fr auto;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  .workspace-empty__stats > span:last-child {
    border-bottom: 0;
  }

  .workspace-empty__stats small {
    grid-column: 2;
    grid-row: 1;
  }

  .workspace-empty__footer {
    flex-wrap: wrap;
    gap: 8px 18px;
  }

  .content-section {
    padding: 58px 0;
  }
}

@media (max-width: 420px) {
  .brand__name {
    max-width: 180px;
    overflow: hidden;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .utility-nav {
    gap: 0;
  }

  .utility-nav .button {
    padding-right: 7px;
    padding-left: 7px;
  }

  .tool-intro h1 {
    font-size: 1.65rem;
  }

  .tool-intro__lede {
    font-size: 0.82rem;
  }

  .setup-panel {
    padding: 14px;
  }

  .panel-heading {
    gap: 8px;
  }

  .compact-select {
    width: 108px;
  }

  .metric-rail {
    grid-template-columns: repeat(2, minmax(108px, 1fr));
  }

  .participant-row {
    grid-template-columns: 15px minmax(0, 1fr) auto;
    gap: 4px;
    padding-left: 6px;
  }

  .participant-action {
    width: 30px;
  }
}

@media (pointer: coarse) {
  .participant-action {
    width: 38px;
    height: 38px;
  }

  .team-card__controls .icon-button,
  .seed-control .icon-button {
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-workspace {
    transition: none;
  }

  .button--generate[data-working="true"]::after {
    animation: none;
  }
}

@media print {
  .workspace-tabs,
  .workspace-empty,
  .workspace-stage > .validation-panel {
    display: none !important;
  }

  .app-workspace {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  .workspace-stage {
    overflow: visible;
  }
}
