:root {
  color-scheme: light;
  --background: #f7f9fb;
  --surface: #ffffff;
  --surface-low: #f2f4f6;
  --surface-mid: #eceef0;
  --surface-high: #e6e8ea;
  --text: #191c1e;
  --muted: #454652;
  --quiet: #757684;
  --outline: #c5c5d4;
  --primary: #24389c;
  --primary-soft: #dee0ff;
  --primary-mid: #3f51b5;
  --success: #006c49;
  --success-soft: #dff8ec;
  --warning: #f97316;
  --warning-soft: #fff0e7;
  --danger: #ba1a1a;
  --danger-soft: #ffdad6;
  --shadow: 0 10px 30px rgba(25, 28, 30, 0.05);
  --shadow-strong: 0 18px 52px rgba(25, 28, 30, 0.09);
  --radius: 8px;
  --radius-lg: 16px;
  --sidebar-width: 256px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
}

.protocol-shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.side-nav {
  position: sticky;
  top: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px;
  border-right: 1px solid rgba(197, 197, 212, 0.58);
  background: var(--surface-low);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 16px;
  color: var(--text);
  text-decoration: none;
}

.brand-copy {
  display: grid;
  gap: 4px;
}

.brand-block h1 {
  margin: 0;
  color: var(--primary);
  font-size: 1.5rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.logo-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: block;
  overflow: visible;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-copy > span,
.eyebrow,
.state-pill,
.meta-row span,
.composer-actions > span,
.objective-box span,
.briefing-metrics span,
.profile-chip small {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-copy > span,
.composer-actions > span,
.profile-chip small {
  color: var(--quiet);
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-button,
.primary-button,
.secondary-button,
.ghost-button,
.text-button,
.featured-scenario {
  border: 0;
  font-weight: 700;
  letter-spacing: 0;
}

.nav-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  transition:
    background 170ms ease,
    color 170ms ease,
    transform 170ms ease;
}

.nav-button:hover {
  background: rgba(224, 227, 229, 0.68);
  transform: translateX(3px);
}

.nav-button.is-active {
  background: var(--primary-mid);
  color: #fff;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0 16px;
  text-decoration: none;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(36, 56, 156, 0.16);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.secondary-button,
.ghost-button {
  border: 1px solid rgba(197, 197, 212, 0.82);
  background: var(--surface);
  color: var(--primary);
}

.auth-actions {
  display: grid;
  gap: 10px;
  padding: 4px 0;
}

.auth-actions form,
.mobile-header form {
  margin: 0;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.full-width {
  width: 100%;
}

.as-label {
  width: fit-content;
  pointer-events: none;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid rgba(197, 197, 212, 0.65);
}

.profile-chip > span:last-child {
  display: grid;
  gap: 2px;
}

.profile-chip strong {
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.avatar-dot {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-high);
  color: var(--muted);
  font-weight: 800;
}

.protocol-main {
  min-width: 0;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px clamp(20px, 4vw, 48px) 56px;
}

.mobile-header {
  display: none;
}

.mobile-brand,
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.mobile-brand .logo-mark,
.auth-brand .logo-mark {
  width: 36px;
  height: 36px;
}

.screen {
  display: none;
  animation: screenIn 260ms ease both;
}

.screen.is-active {
  display: block;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  display: grid;
  gap: 10px;
  max-width: 760px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
}

.page-header h2,
.briefing-panel h2,
.scenario-status h2,
.chat-head h2,
.report-hero h2 {
  margin: 0;
  font-family: "Hanken Grotesk", Inter, sans-serif;
  letter-spacing: 0;
}

.page-header h2 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  line-height: 1.05;
}

.page-header p,
.briefing-panel > p,
.scenario-status p,
.report-hero p,
.locked-category p,
.featured-copy > span:nth-child(3) {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.section-stack {
  display: grid;
  gap: 16px;
  margin-top: 34px;
}

.section-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.featured-scenario {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 42%) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(197, 197, 212, 0.52);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: left;
  transition:
    transform 220ms ease,
    box-shadow 220ms ease,
    border-color 220ms ease;
}

.featured-scenario:hover {
  transform: translateY(-4px);
  border-color: rgba(36, 56, 156, 0.25);
  box-shadow: var(--shadow-strong);
}

.featured-image {
  position: relative;
  min-height: 270px;
  overflow: hidden;
  background: var(--surface-mid);
}

.featured-image img,
.briefing-image img,
.category-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.featured-image img {
  transition: transform 700ms ease;
}

.featured-scenario:hover .featured-image img {
  transform: scale(1.04);
}

.featured-copy {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: clamp(22px, 4vw, 40px);
}

.featured-copy strong {
  display: block;
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  line-height: 1.04;
}

.meta-row,
.action-row,
.button-row,
.learning-objectives,
.signal-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-row span,
.state-pill,
.learning-objectives span,
.signal-list span,
.skill-preview span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
}

.meta-row span {
  background: var(--surface-low);
  color: var(--muted);
}

.state-pill {
  width: fit-content;
}

.featured-image .state-pill {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: var(--shadow);
}

.state-pill.is-live::before {
  width: 7px;
  height: 7px;
  content: "";
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--success);
}

.state-pill.is-muted {
  background: var(--primary-soft);
  color: var(--primary);
}

.coming-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.locked-category {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 312px;
  padding: 14px;
  border: 1px dashed rgba(117, 118, 132, 0.48);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.58);
}

.category-image {
  aspect-ratio: 1.45;
  border-radius: 12px;
  background: var(--surface-mid);
  filter: saturate(0.72);
}

.locked-category h4 {
  margin: 0;
  font-size: 1rem;
}

.text-link {
  width: fit-content;
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.briefing-shell {
  min-height: calc(100svh - 88px);
  display: grid;
  grid-template-columns: minmax(280px, 42%) minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(197, 197, 212, 0.52);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.briefing-image {
  min-height: 560px;
  background: var(--surface-mid);
}

.briefing-panel {
  display: grid;
  align-content: center;
  gap: 20px;
  padding: clamp(24px, 4vw, 48px);
}

.briefing-panel h2,
.report-hero h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.02;
}

.briefing-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.briefing-metrics div,
.objective-box,
.report-card {
  border: 1px solid rgba(197, 197, 212, 0.56);
  border-radius: 12px;
  background: var(--surface-low);
}

.briefing-metrics div {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.briefing-metrics span,
.objective-box span {
  color: var(--primary);
}

.briefing-metrics strong {
  font-size: 0.95rem;
}

.objective-box {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.objective-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.learning-objectives span,
.skill-preview span {
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.78rem;
  font-weight: 800;
}

.button-row {
  align-items: center;
}

.button-row.is-centered {
  justify-content: center;
  margin-top: 28px;
}

.simulation-layout {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  gap: 24px;
  min-height: calc(100svh - 88px);
}

.scenario-status {
  display: grid;
  align-content: start;
  gap: 24px;
  padding: 22px;
  border-right: 1px solid rgba(197, 197, 212, 0.58);
  background: var(--surface-low);
}

.text-button {
  width: fit-content;
  padding: 0;
  background: transparent;
  color: var(--primary);
}

.scenario-status h2 {
  font-size: 1.35rem;
  line-height: 1.15;
}

.meter-group {
  display: grid;
  gap: 9px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.meter-label strong {
  color: var(--danger);
}

.meter-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--danger-soft);
}

.meter-track span {
  display: block;
  width: 20%;
  height: 100%;
  border-radius: inherit;
  background: var(--warning);
  transition:
    width 220ms ease,
    background 220ms ease;
}

.signal-list span {
  background: var(--surface);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(197, 197, 212, 0.56);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(197, 197, 212, 0.56);
}

.chat-head h2 {
  font-size: clamp(1.35rem, 2.6vw, 2.05rem);
}

.turn-counter {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(197, 197, 212, 0.7);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.message-list {
  min-height: 420px;
  max-height: calc(100svh - 330px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  overflow-y: auto;
}

.message {
  max-width: min(76ch, 84%);
  display: grid;
  gap: 6px;
  animation: messageIn 180ms ease both;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: end;
}

.message.npc,
.message.system {
  align-self: start;
}

.message strong {
  color: var(--quiet);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bubble {
  border-radius: 12px;
  padding: 13px 15px;
  line-height: 1.52;
}

.message.user .bubble {
  background: var(--primary);
  color: #fff;
}

.message.npc .bubble {
  border: 1px solid rgba(36, 56, 156, 0.18);
  background: rgba(242, 244, 246, 0.92);
}

.message.system .bubble {
  border: 1px solid rgba(197, 197, 212, 0.68);
  background: var(--surface-low);
  color: var(--muted);
}

.composer {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid rgba(197, 197, 212, 0.56);
  background: rgba(247, 249, 251, 0.92);
}

.composer textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid rgba(197, 197, 212, 0.78);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  color: var(--text);
  line-height: 1.45;
}

.composer textarea:focus {
  outline: 3px solid rgba(63, 81, 181, 0.18);
  border-color: rgba(63, 81, 181, 0.72);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.composer-actions > div {
  display: flex;
  gap: 10px;
}

.report-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 0 0;
}

.report-hero {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-bottom: 32px;
  text-align: center;
}

.score-ring {
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  border: 10px solid var(--success-soft);
  border-top-color: #10b981;
  border-radius: 50%;
  background: var(--surface);
  color: var(--success);
  font-size: 2.35rem;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
}

.report-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.report-card.is-wide {
  grid-column: 1 / -1;
}

.report-card h3 {
  margin: 0;
  font-size: 1rem;
}

.quote-copy {
  margin: 0;
  padding: 16px;
  border-left: 4px solid var(--primary);
  border-radius: 0 12px 12px 0;
  background: var(--primary-soft);
  color: var(--muted);
  line-height: 1.55;
}

.score-list {
  display: grid;
  gap: 12px;
}

.score-item {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(100px, 1fr) 32px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.score-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-high);
}

.score-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
}

.plain-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.skill-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 720px;
  padding: 22px;
  border: 1px solid rgba(197, 197, 212, 0.56);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 0 56px;
}

.history-list,
.dashboard-grid,
.badge-wall {
  display: grid;
  gap: 16px;
}

.history-item,
.dashboard-card,
.stat-card,
.empty-state,
.run-detail-hero,
.profile-hero {
  border: 1px solid rgba(197, 197, 212, 0.58);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 28px;
}

.profile-hero h2 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.98;
}

.profile-hero p {
  margin-bottom: 0;
  color: var(--muted);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 20px;
}

.history-item h3,
.history-item h4,
.dashboard-card h3,
.empty-state h3 {
  margin: 0;
}

.history-item h3 a,
.history-item h4 a,
.last-report-layout h4 a {
  color: var(--text);
  text-decoration: none;
}

.history-item p,
.empty-state p,
.muted-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.history-score {
  min-width: 124px;
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 4px;
  color: var(--quiet);
}

.history-score strong {
  color: var(--success);
  font-size: 2.2rem;
  line-height: 1;
}

.history-score span {
  color: var(--primary);
  font-weight: 900;
}

.history-score small {
  font-weight: 700;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.earned-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--warning-soft);
  color: #9a3412;
  font-size: 0.78rem;
  font-weight: 900;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 28px;
}

.run-detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 18px;
  padding: 28px;
}

.run-detail-hero h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.02;
}

.run-detail-hero p {
  color: var(--muted);
}

.score-ring.is-large {
  width: 156px;
  height: 156px;
  align-content: center;
  gap: 2px;
  font-size: 2.5rem;
  line-height: 1;
}

.score-ring.is-large span {
  max-width: 110px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.15;
  text-align: center;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.dashboard-card {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 20px;
}

.dashboard-card.is-wide {
  grid-column: 1 / -1;
}

.saved-message-list {
  display: grid;
  gap: 12px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.stat-card span {
  color: var(--quiet);
  font-weight: 800;
}

.stat-card strong {
  color: var(--primary);
  font-size: 2.2rem;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 1.45rem;
}

.last-report-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.last-report-layout h4 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.last-report-layout p {
  color: var(--muted);
  line-height: 1.55;
}

.badge-card {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(249, 115, 22, 0.22);
  border-radius: 12px;
  padding: 14px;
  background: var(--warning-soft);
}

.badge-card strong {
  color: #9a3412;
}

.badge-card span {
  color: var(--muted);
  line-height: 1.45;
}

.leaderboard-section {
  overflow: hidden;
}

.leaderboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid rgba(197, 197, 212, 0.58);
  padding-bottom: 12px;
}

.leaderboard-tab {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 13px;
  background: var(--surface-low);
  color: var(--muted);
  font-weight: 900;
}

.leaderboard-tab:hover,
.leaderboard-tab.is-active {
  background: var(--primary);
  color: #fff;
}

.leaderboard-panel {
  display: grid;
  gap: 14px;
}

.leaderboard-panel[hidden] {
  display: none;
}

.leaderboard-panel h3 {
  margin: 0;
}

.leaderboard-table {
  display: grid;
  gap: 4px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 92px 52px;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--muted);
}

.leaderboard-row:not(.is-head) {
  background: var(--surface-low);
}

.leaderboard-row.is-head {
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-row small {
  display: block;
  color: var(--quiet);
}

.save-status {
  min-height: 1.4em;
  color: var(--quiet);
  font-weight: 800;
}

.save-status a {
  color: var(--primary);
  text-decoration: none;
}

.save-status a:hover {
  text-decoration: underline;
}

.flash-stack {
  position: fixed;
  z-index: 50;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.flash-message {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(197, 197, 212, 0.72);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-weight: 700;
}

.flash-message.alert {
  border-color: rgba(186, 26, 26, 0.28);
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at 50% 0%, rgba(63, 81, 181, 0.14), transparent 28rem),
    var(--background);
}

.auth-panel {
  width: min(100%, 520px);
  display: grid;
  gap: 24px;
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid rgba(197, 197, 212, 0.58);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-strong);
}

.auth-brand {
  width: fit-content;
  color: var(--text);
  text-decoration: none;
}

.auth-brand > span:last-child {
  display: grid;
  gap: 2px;
}

.auth-brand strong {
  color: var(--primary);
  font-size: 1.25rem;
}

.auth-brand small {
  color: var(--quiet);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-copy {
  display: grid;
  gap: 10px;
}

.auth-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.02;
}

.auth-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field label,
.field-label,
.check-field {
  color: var(--muted);
  font-weight: 800;
}

.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="text"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(197, 197, 212, 0.78);
  border-radius: 12px;
  padding: 0 13px;
  background: #fff;
  color: var(--text);
}

.handle-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(197, 197, 212, 0.78);
  border-radius: 12px;
  background: #fff;
}

.handle-input span {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 100%;
  border-right: 1px solid rgba(197, 197, 212, 0.58);
  background: var(--surface-low);
  color: var(--primary);
  font-weight: 900;
}

.handle-input input[type="text"] {
  border: 0;
  border-radius: 0;
}

.locked-handle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 46px;
  overflow: hidden;
  border: 1px solid rgba(197, 197, 212, 0.78);
  border-radius: 12px;
  background: var(--surface-low);
  color: var(--text);
}

.locked-handle span {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 100%;
  border-right: 1px solid rgba(197, 197, 212, 0.58);
  color: var(--primary);
  font-weight: 900;
}

.locked-handle strong {
  min-width: 0;
  padding: 0 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-field input:focus {
  outline: 3px solid rgba(63, 81, 181, 0.18);
  border-color: rgba(63, 81, 181, 0.72);
}

.handle-input:focus-within {
  outline: 3px solid rgba(63, 81, 181, 0.18);
  border-color: rgba(63, 81, 181, 0.72);
}

.handle-input input:focus {
  outline: 0;
}

.form-field small {
  color: var(--quiet);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.auth-links a {
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

#error_explanation {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(186, 26, 26, 0.28);
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
}

#error_explanation h2 {
  margin: 0;
  font-size: 1rem;
}

#error_explanation ul {
  margin: 0;
  padding-left: 18px;
}

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

@media (max-width: 1120px) {
  .coming-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .featured-scenario,
  .briefing-shell,
  .simulation-layout,
  .report-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .featured-image,
  .briefing-image {
    min-height: 320px;
  }

  .scenario-status {
    border-right: 0;
    border-radius: var(--radius-lg);
  }

  .message-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .protocol-shell {
    display: block;
  }

  .side-nav {
    display: none;
  }

  .protocol-main {
    padding: 0 16px 32px;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    margin: 0 -16px 24px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(197, 197, 212, 0.58);
    background: rgba(247, 249, 251, 0.86);
    backdrop-filter: blur(12px);
    color: var(--primary);
  }

  .page-header h2,
  .briefing-panel h2,
  .report-hero h2 {
    font-size: 2rem;
  }

  .coming-grid,
  .briefing-metrics {
    grid-template-columns: 1fr;
  }

  .featured-image,
  .briefing-image {
    min-height: 240px;
  }

  .briefing-panel,
  .featured-copy {
    padding: 20px;
  }

  .simulation-layout {
    gap: 16px;
  }

  .scenario-status {
    padding: 18px;
  }

  .chat-head,
  .composer-actions {
    display: grid;
  }

  .composer-actions > div,
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 94%;
  }

  .score-item {
    grid-template-columns: 1fr;
  }

  .history-item,
  .run-detail-hero,
  .profile-hero,
  .last-report-layout {
    grid-template-columns: 1fr;
    display: grid;
    justify-items: start;
  }

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

  .stat-grid {
    display: grid;
  }

  .history-score {
    justify-items: start;
  }

  .leaderboard-row {
    grid-template-columns: 36px minmax(0, 1fr) 72px 44px;
    font-size: 0.88rem;
  }
}
