:root {
  --bg: #0f1218;
  --surface: #171b24;
  --elevated: #1e2430;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #8b95a8;
  --accent: #3d8bfd;
  --accent-dim: #2a5fbf;
  --success: #3dd68c;
  --warn: #f0c14b;
  --danger: #e85d5d;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar--single {
  grid-template-columns: minmax(0, 1fr) auto;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.1rem;
}

.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  justify-self: end;
  justify-content: flex-end;
}

.meta__limits {
  font-size: 0.78rem;
  max-width: 22rem;
  line-height: 1.35;
  text-align: right;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
}

.tag.pro {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.btn {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.btn:hover {
  background: #252b38;
}

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent);
}

.btn-danger {
  border-color: #8b3a3a;
  color: #ffb4b4;
}

.btn-danger:hover {
  background: #3a2222;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
  padding-bottom: 5rem;
}

.ui-mode-simple main {
  max-width: 720px;
}

.ui-mode-simple .simple-step-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.25;
}

.ui-mode-simple .panel h2.simple-step-title {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-size: 1.05rem;
}

.ui-mode-simple .simple-step-title--spaced {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.ui-mode-simple .simple-step-title--between {
  margin: 1.5rem 0 0.5rem;
}

.ui-mode-simple .simple-step-title--flat {
  margin-bottom: 0.5rem;
}

.ui-mode-simple .simple-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ui-mode-simple .simple-step-lead {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  max-width: 38rem;
  line-height: 1.45;
}

.ui-mode-simple .simple-micro {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.78rem;
  line-height: 1.35;
  max-width: 36rem;
}

.ui-mode-simple .simple-actions-row {
  gap: 0.6rem;
}

.ui-mode-simple .session-step {
  border-bottom: none;
  margin-bottom: 0.25rem;
  padding-bottom: 0;
}

.ui-mode-simple .simple-hero__title {
  font-size: 1.35rem;
}

.ui-mode-simple .simple-hero__lead {
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
}

.bottombar__simple-legend {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 2rem;
  margin-bottom: 0.35rem;
  padding: 0 0.5rem;
}

.bottombar__legend-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-align: center;
  min-width: 130px;
}

.bottombar__legend-k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.bottombar__legend-v {
  font-size: 0.82rem;
  color: var(--text);
}

.bottombar--simple {
  flex-wrap: wrap;
  justify-content: center;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 820px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input,
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.65rem;
}

.session-picker {
  align-items: stretch;
}

.session-picker select {
  flex: 1;
  min-width: min(100%, 220px);
  margin-bottom: 0;
  cursor: pointer;
}

.session-picker .btn {
  flex-shrink: 0;
  align-self: center;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.row-actions--toolbar {
  margin-top: 0.75rem;
}

.clear-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 42rem;
}

.row-actions--new-session {
  margin-top: 0.75rem;
}

.new-session-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 42rem;
}

.session-step {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.session-step__lead {
  margin: 0 0 0.5rem;
  max-width: 40rem;
}

.auto-run-hint {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.8rem;
  max-width: 44rem;
}

.footer-hint {
  margin: 0 0 0.5rem;
  width: 100%;
  max-width: 520px;
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: center;
}

.bottombar .footer-hint strong {
  font-weight: 600;
  color: var(--text);
}

.card {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: relative;
}

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

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

.badge.on {
  border-color: var(--success);
  color: var(--success);
}

.badge.next {
  border-color: var(--accent);
  color: var(--accent);
}

.iteration-banner {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.conversation-hint {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}

.conversation-feed {
  max-height: min(65vh, 560px);
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 0.75rem 0.4rem 0.4rem 0;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}

.conversation-empty {
  padding: 1.75rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.turn-msg {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 4px 8px 8px 8px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.turn-msg--b {
  border-left-color: var(--success);
}

.turn-msg__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.turn-msg__n {
  font-weight: 600;
  color: var(--accent);
}

.turn-msg--b .turn-msg__n {
  color: var(--success);
}

.turn-msg__who {
  font-weight: 600;
  color: var(--text);
}

.turn-msg__role {
  opacity: 0.9;
}

.turn-msg__role::before {
  content: "· ";
}

.turn-msg__body {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.turn-msg__section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.5rem 0 0.35rem;
}

.turn-msg__backstage {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px dashed var(--border);
  margin-bottom: 0.35rem;
}

.turn-msg__body--digest {
  border-left: 2px solid var(--success);
  padding-left: 0.65rem;
}

.turn-msg--simple-digest .turn-msg__body--digest {
  border-left-color: var(--accent);
}

.turn-msg__legacy {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
}

.summary-panel textarea#field-final-summary {
  min-height: 200px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.summary-hint {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}

.card-title {
  font-size: 1.05rem;
  color: var(--text);
}

.last-msg {
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  min-height: 4rem;
  white-space: pre-wrap;
}

.bottombar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}

.status-line {
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
  min-width: 200px;
}

.status-line.error {
  color: var(--danger);
}

.auth-page {
  max-width: 400px;
  margin: 3rem auto;
  padding: 1.5rem;
}

.auth-page h1 {
  margin-top: 0;
  font-size: 1.35rem;
}

.auth-page .panel {
  margin-top: 1rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.participants-toolbar {
  margin: 0.35rem 0 1.25rem;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.flow-toolbar {
  margin-bottom: 0.35rem;
}

.field-title-display {
  width: 100%;
  margin-bottom: 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.topbar__left {
  min-width: 0;
}

.topbar__tagline {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 22rem;
  line-height: 1.35;
}

.session-details {
  margin: 0.75rem 0 1rem;
  padding: 0.65rem 0 0;
  border-top: 1px solid var(--border);
}

.session-details__summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  font-size: 0.88rem;
}

.session-details__body {
  padding-top: 0.75rem;
}

.participant-more {
  margin-top: 0.65rem;
  border-top: 1px solid var(--border);
  padding-top: 0.35rem;
}

.participant-more__summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
}

.correction-draft {
  flex: 1 1 200px;
  min-width: 0;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.corrections-actions {
  align-items: stretch;
  margin-top: 0.5rem;
}

.bottombar--tight .bottombar__actions--main {
  width: 100%;
  justify-content: center;
}

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
  justify-self: center;
}

.mode-switch__btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.4rem 0.95rem;
  font-size: 0.82rem;
}

.mode-switch__btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.mode-switch__btn--active {
  background: var(--elevated);
  color: var(--text);
  font-weight: 600;
}

.simple-hero {
  text-align: center;
  padding: 1.75rem 1.25rem 2rem;
  margin: 0 0 1.25rem;
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(145deg, #1a2233 0%, #141a24 45%, #171b24 100%);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.simple-hero__title {
  margin: 0 0 0.65rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.simple-hero__lead {
  margin: 0 auto;
  max-width: 36rem;
  font-size: 0.98rem;
  color: var(--muted);
  line-height: 1.55;
}

.simple-preset__title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.simple-preset__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 720px) {
  .simple-preset__grid {
    grid-template-columns: 1fr;
  }
}

.btn-accent {
  background: linear-gradient(135deg, #2a6f4e 0%, #1e5a40 100%);
  border-color: #3dd68c;
  color: #f0fff6;
}

.btn-accent:hover {
  filter: brightness(1.08);
}

.bottombar {
  flex-direction: column;
  align-items: stretch;
}

.bottombar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
}

.ui-mode-simple .bottombar__next {
  flex: 1 1 160px;
  min-height: 2.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.ui-mode-simple .bottombar__result {
  flex: 1 1 140px;
  min-height: 2.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.bottombar__meta {
  text-align: center;
  width: 100%;
}

.conversation-feed--advanced {
  position: relative;
  padding-left: 1.35rem;
}

.conversation-feed--advanced::before {
  content: "";
  position: absolute;
  left: 0.45rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 3px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--success) 100%);
  opacity: 0.45;
}

.conversation-feed--advanced .turn-msg {
  position: relative;
}

.conversation-feed--advanced .turn-msg__n {
  font-variant-numeric: tabular-nums;
}

.ui-mode-simple .session-panel label[for="field-goal"] {
  font-size: 0.9rem;
  color: var(--text);
}

.ui-mode-simple .summary-panel h2 {
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.05rem;
  color: var(--text);
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .topbar__left {
    order: 0;
  }

  .meta {
    order: 1;
    justify-self: center;
  }
}
