:root {
  --bg: #f3efe6;
  --bg-strong: #efe8da;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #fffdfa;
  --line: rgba(103, 90, 69, 0.18);
  --line-strong: rgba(103, 90, 69, 0.34);
  --ink: #1d2430;
  --muted: #657082;
  --muted-strong: #445062;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --accent-strong: #0b5e58;
  --blue: #215ea8;
  --blue-soft: rgba(33, 94, 168, 0.12);
  --amber: #9a6a1f;
  --amber-soft: rgba(154, 106, 31, 0.12);
  --red: #b33b3b;
  --red-soft: rgba(179, 59, 59, 0.12);
  --shadow-lg: 0 24px 70px rgba(29, 36, 48, 0.12);
  --shadow-md: 0 14px 34px rgba(29, 36, 48, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 28rem),
    radial-gradient(circle at right top, rgba(33, 94, 168, 0.14), transparent 22rem),
    linear-gradient(180deg, #f8f4ec 0%, #f3efe6 50%, #efe9dd 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.icon.tiny {
  width: 0.9rem;
  height: 0.9rem;
}

.app-body {
  min-height: 100vh;
}

.app-shell {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
}

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

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff;
  box-shadow: 0 18px 30px rgba(15, 118, 110, 0.22);
}

.brand-mark .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--accent);
}

.topbar h1,
.hero h2,
.section-head h2,
.login-panel h1 {
  margin: 0;
  line-height: 1.08;
}

.topbar h1 {
  font-size: clamp(1.35rem, 2vw, 2rem);
  max-width: 18ch;
}

.secondary-button,
.primary-button,
.play-button {
  border: 1px solid transparent;
  border-radius: 14px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

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

.secondary-button {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
  color: var(--ink);
  padding: 0 16px;
}

.secondary-button:hover {
  background: #fff;
  border-color: var(--line-strong);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff;
  box-shadow: 0 14px 24px rgba(15, 118, 110, 0.22);
  padding: 0 20px;
}

.primary-button:hover {
  box-shadow: 0 18px 26px rgba(15, 118, 110, 0.28);
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.logout-button {
  flex-shrink: 0;
}

.hero {
  margin-top: 20px;
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 24px;
}

.hero-summary {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.65;
  font-size: 1rem;
}

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

.hero-stat {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(103, 90, 69, 0.12);
  border-radius: 18px;
}

.hero-stat .icon {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 2px;
  color: var(--accent);
}

.hero-stat strong,
.hero-stat span {
  display: block;
}

.hero-stat strong {
  font-size: 0.98rem;
}

.hero-stat span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(101, 112, 130, 0.12);
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.is-idle {
  background: rgba(101, 112, 130, 0.12);
}

.status-pill.is-queued {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.is-running {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill.is-completed {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.is-failed {
  background: var(--red-soft);
  color: var(--red);
}

.workspace {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.sidebar,
.main-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.run-card,
.history-card,
.overview-card,
.metrics-card,
.panel {
  padding: 22px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.job-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 250, 0.96);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: rgba(33, 94, 168, 0.4);
  box-shadow: 0 0 0 4px rgba(33, 94, 168, 0.08);
}

.field input[type="file"] {
  padding: 11px 14px;
}

.file-field input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}

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

.submit-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.helper-copy,
.panel-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

#global-audio {
  width: 100%;
  margin-top: 2px;
}

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

.metric-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(251, 247, 240, 0.88));
  border: 1px solid rgba(103, 90, 69, 0.12);
  box-shadow: var(--shadow-md);
}

.metric-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.metric-icon .icon {
  width: 1rem;
  height: 1rem;
}

.metric-label {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.83rem;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.05rem;
}

.history-list,
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  width: 100%;
  border: 1px solid rgba(103, 90, 69, 0.12);
  border-radius: 18px;
  background: rgba(255, 253, 250, 0.92);
  color: var(--ink);
  padding: 14px 16px;
  text-align: left;
}

.history-item:hover {
  background: #fff;
  border-color: var(--line-strong);
}

.history-item.active {
  border-color: rgba(15, 118, 110, 0.32);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

.history-main,
.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.history-audio {
  font-weight: 700;
  line-height: 1.4;
}

.history-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-meta span,
.summary-pill,
.latency-pill,
.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.76rem;
  font-weight: 700;
}

.status-chip.is-queued {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-chip.is-running {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-chip.is-completed {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-chip.is-failed {
  background: var(--red-soft);
  color: var(--red);
}

.status-chip.is-idle {
  background: rgba(101, 112, 130, 0.12);
  color: var(--muted-strong);
}

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

.panel {
  min-height: 62vh;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.target-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.summary-pill,
.latency-pill,
.mini-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.94);
  border: 1px solid rgba(103, 90, 69, 0.12);
  color: var(--muted-strong);
  font-size: 0.8rem;
}

.summary-pill strong {
  color: var(--ink);
}

.message {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(103, 90, 69, 0.12);
  background: rgba(255, 253, 250, 0.92);
  box-shadow: var(--shadow-md);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.message.primary {
  border-left: 4px solid var(--accent);
}

.message.secondary {
  border-left: 4px solid var(--blue);
}

.message.active {
  background: #fff;
  border-color: rgba(15, 118, 110, 0.28);
  transform: translateY(-2px);
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.message-title {
  min-width: 0;
}

.speaker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.speaker {
  font-weight: 700;
}

.segment-tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(101, 112, 130, 0.12);
  color: var(--muted-strong);
  font-size: 0.75rem;
  font-weight: 700;
}

.meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.message-text {
  margin: 14px 0 0;
  line-height: 1.65;
  white-space: pre-wrap;
}

.chunk-latencies {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.play-button {
  min-height: 38px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.76);
  border-color: var(--line);
  color: var(--ink);
}

.play-button:hover {
  background: #fff;
  border-color: var(--line-strong);
}

.latency {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.error {
  color: var(--red);
}

.empty {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: rgba(255, 253, 250, 0.72);
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 560px);
  padding: 28px;
}

.login-panel h1 {
  font-size: clamp(2rem, 4vw, 3rem);
}

.login-copy-block {
  margin: 24px 0;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(244, 239, 230, 0.9));
  border: 1px solid rgba(103, 90, 69, 0.12);
}

.login-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.login-points {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid rgba(103, 90, 69, 0.12);
  color: var(--muted-strong);
  font-size: 0.8rem;
  font-weight: 600;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-button {
  width: 100%;
}

.login-status {
  min-height: 22px;
  color: var(--red);
  font-size: 0.9rem;
}

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

  .sidebar {
    order: 2;
  }

  .main-stack {
    order: 1;
  }

  .panels,
  .metrics-grid,
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell,
  .login-shell {
    padding: 16px;
  }

  .topbar,
  .hero,
  .run-card,
  .history-card,
  .overview-card,
  .metrics-card,
  .panel,
  .login-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .topbar,
  .panel-head,
  .message-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .target-summary {
    justify-content: flex-start;
  }
}

@media (max-width: 540px) {
  .brand-block,
  .login-brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
  }

  .summary-pill,
  .latency-pill,
  .mini-pill,
  .status-pill,
  .status-chip {
    font-size: 0.76rem;
  }
}
