:root {
  color-scheme: light;

  /* Enterprise palette borrowed from the sentry-go frontend's design
     system: a blue brand accent on neutral surfaces, replacing the
     previous warm tan "arena.ai" theme. No dark mode, by the same
     design choice as that reference. */
  --brand: #315f9f;
  --brand-hover: #264f89;
  --brand-pressed: #1d3e6d;
  --brand-soft: #e8eff8;
  --success: #22a06b;

  --bg: #f5f6f8;
  --panel-bg: #ffffff;
  --tan-bg: #eef1f7;
  --tan-bg-light: #f8faff;
  --border: #d9dee7;
  --border-subtle: #e9edf2;
  --text: #1f2937;
  --muted: #667085;
  --error: #ca3521;
  --error-bg: #fef2f2;
  /* Warning (orange): used by the Battle Mode role notice, which has
     to be noticed but is not an error. */
  --warn: #b45309;
  --warn-bg: #ffedd5;

  --radius: 7px;
  --shadow-raised: 0 1px 2px rgba(31, 41, 55, .05);
  --shadow-card: 0 4px 14px rgba(27, 52, 93, .06);

  --apertera: #315f9f;
  --competitor: #eb6834;
}

* {
  box-sizing: border-box;
}

/* Several components below set their own `display` (flex/grid) so they
   can be toggled with the `hidden` attribute from JS. Author CSS with
   an explicit `display` always beats the UA stylesheet's
   `[hidden] { display: none }`, even at equal specificity, so without
   this rule a hidden .chat-view/.lang-row/.notice stays visible —
   e.g. the previous chat's turns showing through the new-chat picker. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Down from the browser's 16px default, matching sentry-go's own
     dense UI-text tier (its --text-ads-14 token). Only affects text
     that doesn't set its own font-size (translation panels, chat
     bubbles) — the many already-small rem-based component sizes below
     are untouched since they're sized off the (unchanged) root
     font-size, not body's. */
  font-size: 14px;
  letter-spacing: -.01em;
}

/* ---- layout (also unused by the current sidebar shell; kept alongside .topbar) ---- */
.arena {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.eyebrow {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand);
}

/* ---- top bar (unused by the current single-sidebar layout, kept for
   any page that still links this stylesheet without the sidebar shell) ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
}

.mode-select {
  margin-left: auto;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

/* ---- brand mark (sidebar header, login) ---- */
.brand-mark {
  width: 44px;
  height: 28px;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -.02em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- signed-in account card (sidebar header) ----
   A <button> (not a plain div) — clicking it is now the only way to
   open the Account dialog; there is no separate "Account" nav button.
   Avatar icon varies by role (account.js's ROLE_META picks the SVG). */
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 24px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--brand-soft);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.user-info:hover {
  box-shadow: 0 6px 18px rgba(27, 52, 93, .12);
}

.user-info-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel-bg);
  color: var(--brand);
}

.user-info-avatar svg {
  width: 22px;
  height: 22px;
}

.user-info-divider {
  flex-shrink: 0;
  width: 1px;
  align-self: stretch;
  background: var(--border);
}

.user-info-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.user-info-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info-role-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--brand);
  background: var(--panel-bg);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--brand);
}

/* ---- source controls ---- */
.source-controls {
  margin: 20px 0;
  padding: 18px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-raised);
}

.source-mode {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.source-mode label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---- composer (the unified textarea + toolbar input box) ---- */
.composer {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-raised);
  padding: 16px 18px 12px;
}

.composer-input {
  display: block;
  width: 100%;
  min-height: 44px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 300;
  color: var(--text);
  resize: none;
  padding: 0;
}

.composer-input:focus {
  outline: none;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.composer-toolbar-spacer {
  flex: 1;
}

.composer-icon-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.composer-icon-btn:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand);
}

.composer-select {
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.composer-select:focus {
  outline: none;
}

.composer-send-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.composer-send-btn:hover:not(:disabled) {
  background: var(--brand-hover);
}

/* chat.js disables the button for the whole in-flight translation;
   without this rule it kept its full colour and hover, so it read as
   still clickable. */
.composer-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.lang-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.lang-row span {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- buttons ---- */
button,
select {
  font-family: inherit;
}

.lang-row select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  color: var(--text);
}

#run-btn {
  margin-left: auto;
  padding: 9px 20px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

#run-btn:hover {
  background: var(--brand-hover);
}

#run-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---- info / warning banners ---- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--tan-bg);
  color: var(--text);
}

.notice::before {
  content: "\24D8";
  /* circled i */
  font-weight: 700;
  flex-shrink: 0;
}

#custom-notice,
.notice-error {
  background: var(--error-bg);
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
}

#custom-notice::before,
.notice-error::before {
  content: "\26A0";
}

/* Role notice (role-notice.js): room on the right for its × button,
   which is taken out of the flex flow so the icon + sentence layout
   above is unchanged. */
#role-notice {
  position: relative;
  padding-right: 36px;
  /* Orange so it stands out from the grey info notices, without
     reading as an error like the red .notice-error variant. */
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  color: var(--warn);
}

#role-notice::before {
  content: "\26A0";
}

#role-notice a {
  color: inherit;
  font-weight: 600;
}

#role-notice .notice-close {
  color: var(--warn);
}

#role-notice .notice-close:hover {
  color: var(--text);
}

.notice-close {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 2px 6px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.notice-close:hover {
  color: var(--text);
}

/* ---- panels ---- */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

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

/* .panels' grid already stretches both cards to the taller one's
   height; the column flex here is what pins each footer (the A/B
   badge + engine name) to the card's bottom edge, so the two labels
   line up even when one translation runs longer than the other. */
.panel {
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--panel-bg);
  overflow: hidden;
  box-shadow: var(--shadow-raised);
}

/* No header bar — the engine name reads as a caption under the
   translation, not a title above it, so it's a plain right-aligned
   footer line instead of its own bordered/tinted section. */
.panel-footer {
  margin-top: auto;
  padding: 4px 16px 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.panel-thumb {
  font-size: 1.05rem;
  line-height: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  background: var(--panel-bg);
}

.panel-body {
  padding: 16px 16px 4px;
}

.label {
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.text {
  font-weight: 300;
  white-space: pre-wrap;
}

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

/* ---- vote buttons ---- */
/* The judging step is the whole point of a Battle turn, so it sits in
   its own brand-tinted, bordered panel with a prompt line instead of
   a bare row of outlined buttons that blends into the page. */
.votes {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  padding: 16px 20px 20px;
  flex-wrap: wrap;
  border: 1px solid var(--brand);
  border-radius: 16px;
  background: var(--brand-soft);
}

.votes-prompt {
  flex-basis: 100%;
  margin: 0 0 4px;
  text-align: center;
  font-weight: 600;
  color: var(--brand);
}

.vote-btn {
  padding: 10px 18px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--panel-bg);
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.vote-btn:hover:not(:disabled) {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

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

.votes[hidden] {
  display: none;
}

/* ---- login page ---- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 56fr) minmax(360px, 44fr);
  background: var(--bg);
}

.login-visual {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  padding: 64px;
  background: #101b55;
}

.login-visual::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, rgba(16, 27, 85, .18), rgba(16, 27, 85, .88));
}

.login-visual-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-visual-copy {
  position: relative;
  z-index: 1;
  max-width: 620px;
  color: #fff;
}

.login-visual-copy h2 {
  margin: 0 0 24px;
  font-size: clamp(2.4rem, 4vw, 3.25rem);
  line-height: 1.15;
  letter-spacing: -.03em;
}

.login-visual-rule {
  display: block;
  width: 48px;
  height: 4px;
  margin-bottom: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, #8ec5ff, #b9e6ff);
}

.login-visual-copy p {
  margin: 0;
  color: rgba(255, 255, 255, .76);
  font-size: 18px;
  line-height: 1.5;
}

.login-main {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 56px 64px;
  background: var(--bg);
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 64px;
  width: 100%;
  max-width: 480px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.login-logo {
  width: 72px;
  height: 48px;
  flex-shrink: 0;
  object-fit: contain;
}

.login-app-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.login-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.login-heading h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -.03em;
}

.login-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1.4;
}

.login-fields {
  display: grid;
  gap: 28px;
  margin-top: 48px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.login-input {
  width: 100%;
  height: 64px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.login-input::placeholder {
  color: var(--muted);
  opacity: .8;
}

.login-input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.login-submit {
  width: 100%;
  height: 64px;
  margin-top: 52px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.login-submit:hover {
  background: var(--brand-hover);
}

.login-submit:active {
  background: var(--brand-pressed);
}

.login-submit:disabled {
  cursor: wait;
  opacity: .65;
}

.login-error {
  margin-top: 24px;
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-visual {
    display: none;
  }

  .login-main {
    min-height: 100vh;
    padding: 40px 24px;
  }

  .login-card {
    gap: 48px;
  }

  .login-heading h1 {
    font-size: 34px;
  }

  .login-subtitle {
    font-size: 19px;
  }
}

/* ---- app shell ---- */
.app-shell {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
}

.sidebar-btn-subtle {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-list-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 8px 4px;
}

.chat-list-row {
  display: flex;
  align-items: center;
  border-radius: var(--radius);
}

.chat-list-row:hover,
.chat-list-row-active {
  background: var(--brand-soft);
}

.chat-list-link {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  padding: 8px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.chat-list-delete {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
}

.chat-list-delete:hover {
  color: var(--error);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-link {
  padding: 6px 8px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.sidebar-btn-subtle {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar-btn-subtle:hover {
  color: var(--text);
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.sidebar-nav-btn:hover {
  background: var(--tan-bg);
  color: var(--text);
}

/* Exactly one nav item carries is-active at a time — the one whose
   view is showing (see Sidebar.setActiveNav). Hover (--tan-bg) and
   --brand-soft are near-identical, so the active state also switches
   text color and weight to stay distinguishable from a hovered item. */
.sidebar-nav-btn.is-active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

/* Battle glyph is a text character, not an SVG; box it to the same
   18px as the SVG nav icons so all four labels line up. */
.icon-battle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.chat-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ---- new-chat picker ---- */
.new-chat-picker {
  max-width: 900px;
  margin: 12vh auto 0;
  padding: 0 20px;
  text-align: center;
}

.new-chat-picker h1 {
  font-size: 1.8rem;
}

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 40px;
}

@media (max-width: 700px) {
  .mode-cards {
    grid-template-columns: 1fr;
  }
}

/* When a mode is hidden (e.g. Side by Side), collapse the empty grid
   column instead of leaving a lopsided gap next to the remaining card. */
.mode-cards:has(.mode-card[hidden]) {
  grid-template-columns: 1fr;
  max-width: 420px;
  margin-inline: auto;
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-raised);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.mode-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.mode-card-icon {
  font-size: 2rem;
  color: var(--brand);
}

.mode-card-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.mode-card-desc {
  font-size: 0.95rem;
  color: var(--muted);
}

.new-chat-picker-note {
  max-width: 560px;
  margin: 32px auto 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---- search view ---- */
.search-view {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px 0;
}

.search-view-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.6rem;
  margin: 0 0 28px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-raised);
  padding: 14px 18px;
}

.search-box-icon {
  color: var(--muted);
  flex-shrink: 0;
}

/* Outline SVG icon (stroke: currentColor, no fill) instead of the
   colored search emoji, so it always matches the surrounding text
   color rather than carrying its own fixed color. */
.icon-search {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.search-view-title .icon-search {
  width: 22px;
  height: 22px;
}

#search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

#search-input:focus {
  outline: none;
}

.search-results {
  margin-top: 24px;
}

.search-group-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 16px 4px 6px;
}

.search-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.search-result-row:hover {
  background: var(--brand-soft);
}

.search-result-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
}

.search-result-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Titles can run to 120 characters (store.maxTitleRunes); show up to
   two lines here rather than the sidebar's single ellipsized line. */
.search-result-title {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
}

.search-result-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.search-empty {
  color: var(--muted);
  padding: 16px 4px;
}

/* ---- chat view ----
   .chat-main (not .chat-view or .turns) owns the one scrollbar for
   this whole pane — .chat-view is left unbounded so it grows with its
   content instead of clipping it. .submit-form then sticks to the
   bottom of that same scroll, rather than being carved into its own
   flex partition, so turns scroll underneath the floating composer
   exactly like arena.ai/Claude's chat input. */
.chat-view {
  display: flex;
  flex-direction: column;
  /* Fills .chat-main's height (its only other siblings are the
     [hidden]-toggled picker/search/leaderboard views, so this is
     always the sole flex item when shown) so a fresh, empty chat still
     anchors its composer to the bottom of the viewport instead of
     leaving it stranded right under the header. */
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

/* Sticks to the top of .chat-main the same way .submit-form sticks to
   its bottom, with a matching fade so turns scrolling up underneath
   it fade out instead of being clipped by a hard edge. */
.chat-view-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  padding: 40px 0 12px;
}

.chat-view-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -32px;
  height: 32px;
  background: linear-gradient(to top, transparent, var(--bg));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Only fade once there's actually something scrolled out of view on
   that side (chat.js's updateScrollFades) — otherwise the band washes
   out the first/last turn even at rest, with nothing scrolled at all. */
.chat-view.can-scroll-up .chat-view-header::after {
  opacity: 1;
}

/* The chat view's title ("⚔ Battle Mode"), sized to match
   .search-view-title / .leaderboard-title so switching views doesn't
   change the heading scale. Weight and color come from the global h1. */
.mode-badge {
  font-size: 1.6rem;
  margin: 0;
}

.turns {
  display: flex;
  flex-direction: column;
  /* Grows to fill whatever space .chat-view isn't using, pushing
     .submit-form down to the true bottom of the view when there are
     few (or zero) turns, rather than leaving it floating right below
     the last one. */
  flex: 1;
  gap: 20px;
  margin-top: 8px;
  padding-bottom: 20px;
}

.submit-form {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--bg);
  padding-bottom: 20px;
}

/* A band faded from transparent to the page background, sitting just
   above the sticky composer, so turns scrolling up from underneath it
   fade out instead of being clipped by a hard edge. */
.submit-form::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -32px;
  height: 32px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.chat-view.can-scroll-down .submit-form::before {
  opacity: 1;
}

/* ---- turns (Battle + Side by Side) ---- */
.turn {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Groups one exchange's source text and its two result cards into a
   single bordered unit, so a chat with several turns reads as a list
   of distinct request/response groups rather than one long stream. */
.turn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 16px;
  padding: 16px;
  background: var(--tan-bg-light);
  box-shadow: var(--shadow-raised);
}

.turn-langs {
  align-self: flex-end;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.user-msg {
  align-self: flex-end;
  background: var(--tan-bg);
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 70%;
  white-space: pre-wrap;
}

/* .panel has no border to recolor now, so the winner highlight is a
   ring drawn with box-shadow instead — same idea, border-free. */
.panel-winner {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 45%, transparent);
}

/* ---- processing animation (shown in the turns list while a
   translation is in flight, in place of the old "Running..." status
   text — see chat.js/battle.js/sidebyside.js) ---- */
.turn-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: loading-dots-bounce 1.2s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loading-dots-bounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- management view: users tab (also reused nowhere else) ---- */
/* ---- account dialog (sidebar footer > Account) ---- */
.account-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 24px 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-bg);
  color: var(--text);
  box-shadow: var(--shadow-raised);
}

.account-dialog::backdrop {
  background: rgba(20, 30, 50, 0.35);
}

.account-dialog h2 {
  margin: 0 0 16px;
  font-size: 1.3rem;
}

.account-dialog h3 {
  margin: 20px 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.account-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 0.9rem;
}

.account-facts dt {
  color: var(--muted);
}

.account-facts dd {
  margin: 0;
  font-weight: 600;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-form input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
}

.account-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.account-actions button {
  padding: 9px 16px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
}

.account-actions .account-close {
  background: var(--panel-bg);
  color: var(--text);
  border-color: var(--border);
}

.create-user-form {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.create-user-form input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
}

.create-user-form button {
  padding: 9px 16px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.create-user-form button:hover {
  background: var(--brand-hover);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.users-table th,
.users-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.users-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.users-table button {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  cursor: pointer;
}

.users-table button:hover {
  background: var(--tan-bg);
  border-color: var(--brand);
  color: var(--brand);
}

/* ---- leaderboard view ---- */
.icon-leaderboard,
.icon-compare {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.leaderboard-view,
.compare-view,
.management-view {
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px 40px;
}

.management-tab-panel {
  margin-top: 20px;
}

/* Left-aligned and full-width here, unlike .new-chat-picker-note's
   centered splash-screen treatment — this sits above a plain form,
   not a centered hero. */
.management-export-note {
  max-width: none;
  margin: 0 0 16px;
}

.management-export-btn {
  padding: 10px 20px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.management-export-btn:hover {
  background: var(--brand-hover);
}

.leaderboard-title {
  font-size: 1.6rem;
  margin: 0 0 4px;
}

.leaderboard-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

.leaderboard-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.leaderboard-filters select {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 0.85rem;
  color: var(--text);
  font-family: inherit;
}

/* The "Exclude tester account votes" checkbox sits in the same filter
   row as the <select>s, so it takes their font size and vertical
   alignment. */
.leaderboard-filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.leaderboard-filter-check input {
  margin: 0;
  accent-color: var(--brand);
}

.leaderboard-kpis {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.leaderboard-kpi {
  flex: 1;
  min-width: 150px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow-raised);
}

.leaderboard-kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.leaderboard-kpi-value {
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.leaderboard-kpi-value small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.leaderboard-legend {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 16px;
}

.leaderboard-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.leaderboard-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.leaderboard-swatch-apertera {
  background: var(--apertera);
}

.leaderboard-swatch-competitor {
  background: var(--competitor);
}

.leaderboard-swatch-tie {
  background: var(--muted);
}

.leaderboard-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-raised);
}

.leaderboard-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.leaderboard-tab {
  padding: 6px 28px;
  border-radius: 20px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--tan-bg);
  color: var(--muted);
  cursor: pointer;
}

.leaderboard-tab.is-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* The Leaderboard chart has one metric, so its "tab" is a static caption. */
span.leaderboard-tab {
  cursor: default;
}

.leaderboard-row {
  display: grid;
  /* Name track fits a category pill plus a full OpenRouter model id
     such as "deepseek/deepseek-v4.1-flash" at 0.85rem. */
  grid-template-columns: 300px 1fr 70px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  position: relative;
}

.leaderboard-row-name {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The id is a flex child, so it needs its own ellipsis rule — the
   parent's text-overflow doesn't reach into flex items — or an id
   longer than the track clips mid-character instead of trailing off. */
.leaderboard-row-engine {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The id is a flex child, so it needs its own ellipsis rule — the
   parent's text-overflow doesn't reach into flex items — or an id
   longer than the track clips mid-character instead of trailing off. */
.leaderboard-row-engine {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-pill {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
  flex-shrink: 0;
}

.leaderboard-pill-apertera {
  background: rgba(49, 95, 159, 0.13);
  color: var(--apertera);
}

.leaderboard-pill-competitor {
  background: rgba(235, 104, 52, 0.13);
  color: var(--competitor);
}

.leaderboard-track {
  height: 12px;
  background: var(--tan-bg);
  border-radius: 3px;
  overflow: hidden;
}

.leaderboard-fill {
  height: 100%;
  border-radius: 0 4px 4px 0;
}

.leaderboard-fill-apertera {
  background: var(--apertera);
}

.leaderboard-fill-competitor {
  background: var(--competitor);
}

.leaderboard-fill-tie {
  background: var(--muted);
}

/* Win/tie/loss for one pairing, as three side-by-side segments rather
   than the single left-aligned .leaderboard-fill bar above — each
   segment's own width is its share of that pairing's comparisons. */
.leaderboard-track-stacked {
  display: flex;
}

.leaderboard-track-stacked .leaderboard-fill {
  border-radius: 0;
}

.leaderboard-track-stacked .leaderboard-fill:first-child {
  border-radius: 3px 0 0 3px;
}

.leaderboard-track-stacked .leaderboard-fill:last-child {
  border-radius: 0 3px 3px 0;
}

/* Arena Score renders as a dot-and-whisker row rather than a bar: it
   is a point estimate with a confidence interval, and a bar would
   imply a zero-based scale that ratings do not have. The track goes
   transparent and lets marks overflow so a marker's ring isn't
   clipped. */
.leaderboard-track-interval {
  background: transparent;
  overflow: visible;
  position: relative;
}

.leaderboard-interval {
  position: absolute;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  border-radius: 1px;
  opacity: 0.45;
}

.leaderboard-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  transform: translateY(-50%);
  /* a surface-colored ring keeps overlapping markers legible */
  box-shadow: 0 0 0 2px var(--panel-bg);
}

.leaderboard-interval-apertera,
.leaderboard-marker-apertera {
  background: var(--apertera);
}

.leaderboard-interval-competitor,
.leaderboard-marker-competitor {
  background: var(--competitor);
}

.leaderboard-row-value {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
}

.leaderboard-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 10px 0;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.leaderboard-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table .leaderboard-num {
  text-align: right;
}

.leaderboard-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table td.leaderboard-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}