:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --panel-strong: rgba(242, 246, 246, 0.88);
  --text: #162124;
  --muted: #5e6b70;
  --line: #d9e1e4;
  --accent: #0f8b8d;
  --accent-strong: #0a6f70;
  --good: #268b55;
  --warn: #b7791f;
  --bad: #b42318;
  --shadow: 0 18px 45px rgba(22, 33, 36, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 139, 141, 0.06), transparent 34rem),
    linear-gradient(180deg, #fbfbf7 0%, var(--bg) 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("./assets/kitten-soundscape-bg.png");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.46;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  min-width: 116px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

.status-pill.live {
  border-color: rgba(38, 139, 85, 0.35);
  background: #e8f6ee;
  color: var(--good);
}

.status-pill.busy {
  border-color: rgba(183, 121, 31, 0.35);
  background: #fff7e7;
  color: var(--warn);
}

.status-pill.error {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff0ee;
  color: var(--bad);
}

.mode-switch {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mode-button {
  min-width: 96px;
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.mode-button.active {
  background: var(--accent);
  color: #ffffff;
}

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

.control-band,
.action-row,
.caption-stage,
.upload-strip,
.data-notice,
.details-grid,
.feedback {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(22, 33, 36, 0.07);
  backdrop-filter: blur(12px);
}

.public-control-band {
  display: grid;
  grid-template-columns: minmax(170px, 230px) minmax(130px, 170px) minmax(150px, 190px) repeat(2, minmax(120px, 160px));
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.upload-strip {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 420px);
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.data-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border-color: rgba(183, 121, 31, 0.38);
  background: rgba(255, 248, 232, 0.9);
  color: #5f430c;
}

.data-notice strong {
  flex: 0 0 auto;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.data-notice span {
  color: #5f430c;
  font-size: 0.93rem;
  line-height: 1.4;
}

.field,
.toggle-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field span,
.toggle-field span,
.caption-label,
.details-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field small {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.toggle-field {
  min-height: 66px;
  justify-content: end;
  flex-direction: row;
  align-items: center;
  padding-bottom: 11px;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.threshold-field input {
  font-variant-numeric: tabular-nums;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: rgba(251, 252, 252, 0.92);
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.13);
}

input[type="file"] {
  padding: 7px 10px;
}

audio {
  display: block;
  width: 100%;
  min-height: 40px;
}

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

.action-hint {
  flex: 1 1 260px;
  margin: 0 0 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.secondary-button {
  background: #253236;
  color: white;
}

.ghost-button,
.feedback-button {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.caption-stage {
  margin-top: 12px;
  overflow: visible;
}

.current-caption {
  min-height: 176px;
  padding: 20px 22px;
  background: rgba(252, 254, 254, 0.72);
}

.compact-caption {
  min-height: 132px;
}

.final-transcript {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.final-transcript li {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.final-transcript time {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.final-transcript .enriched-output {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.08rem;
}

.enriched-output {
  min-height: clamp(164px, 18vh, 320px);
  margin: 10px 0 0;
  padding: clamp(16px, 1.5vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font-size: 1.12rem;
  line-height: 1.72;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.clean-output {
  min-height: 72px;
  margin: 10px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.large-output {
  font-size: clamp(1.5rem, 2.7vw, 3.15rem);
  line-height: 1.24;
  max-height: min(48vh, 520px);
  overflow-y: auto;
  scrollbar-color: rgba(15, 139, 141, 0.38) transparent;
}

.span-tag {
  --span-accent: 15, 139, 141;
  display: inline;
  padding: 0.02rem 0.04rem 0.07rem;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  background: rgba(var(--span-accent), 0.045);
  color: inherit;
  border-bottom: 2px solid rgba(var(--span-accent), 0.28);
}

.span-tag .span-tag {
  margin-inline: 0.02rem;
}

.span-tag.nested-2 {
  outline: 1px solid rgba(15, 139, 141, 0.15);
  outline-offset: 1px;
}

.span-tag.nested-3 {
  outline: 1px dashed rgba(183, 121, 31, 0.22);
  outline-offset: 2px;
}

.span-tag.nested-4 {
  outline: 1px dotted rgba(168, 85, 247, 0.22);
  outline-offset: 3px;
}

.span-formal,
.span-calm,
.span-neutral {
  --span-accent: 37, 99, 235;
}

.span-angry,
.span-frustrated,
.span-sad {
  --span-accent: 239, 68, 68;
}

.span-happy,
.span-excited,
.span-confident {
  --span-accent: 34, 197, 94;
}

.span-surprised,
.span-uncertain {
  --span-accent: 245, 158, 11;
}

.tag-pill,
.event {
  display: inline-block;
  vertical-align: baseline;
  margin: 0 0.28rem 0 0;
  padding: 0.06rem 0.38rem;
  border-radius: 999px;
  font-size: 0.66rem;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tag-pill {
  border: 1px solid rgba(29, 78, 216, 0.22);
  background: rgba(29, 78, 216, 0.075);
  color: #1d4ed8;
}

.event {
  margin: 0 0.28rem;
  background: rgba(255, 244, 220, 0.58);
  color: #8a5418;
  border: 1px solid rgba(183, 121, 31, 0.28);
}

.stress {
  display: inline-block;
  margin: 0 0.06rem;
  padding: 0.02rem 0.2rem 0.03rem 0.28rem;
  border-radius: 6px;
  font-weight: 800;
  background: rgba(255, 247, 237, var(--stress-fill, 0.62));
  color: #7c4a03;
  border: 1px solid rgba(217, 119, 6, var(--stress-border, 0.3));
}

.stress-1 {
  --stress-fill: 0.5;
  --stress-border: 0.26;
}

.stress-2 {
  --stress-fill: 0.72;
  --stress-border: 0.4;
}

.stress-3 {
  --stress-fill: 0.92;
  --stress-border: 0.58;
}

.stress sup {
  margin-left: 0.12rem;
  padding: 0.02rem 0.22rem;
  border-radius: 999px;
  font-size: 0.62rem;
  line-height: 1;
  font-weight: 900;
  background: #9a5b0a;
  color: #ffffff;
}

.empty {
  color: #64748b;
}

.transcript-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.transcript-guide div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(242, 246, 246, 0.7);
}

.transcript-guide p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.guide-accent {
  color: var(--accent-strong);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding: 14px;
}

.details-grid div {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: rgba(242, 246, 246, 0.72);
}

.details-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.feedback {
  margin-top: 12px;
  padding: 12px;
}

.feedback[hidden],
.feedback-panel[hidden],
.feedback-thanks[hidden] {
  display: none;
}

.feedback-row,
.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.feedback-row span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.feedback-button.active {
  border-color: rgba(15, 139, 141, 0.35);
  background: #e6f6f2;
  color: var(--accent-strong);
}

.feedback-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.reason-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.reason-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

.reason-grid input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.feedback-thanks {
  margin: 10px 0 0;
  color: var(--good);
  font-weight: 800;
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .public-control-band,
  .upload-strip,
  .data-notice,
  .details-grid,
  .transcript-guide,
  .action-row {
    grid-template-columns: 1fr;
  }

  .data-notice {
    align-items: flex-start;
    flex-direction: column;
  }

  .transcript-guide div {
    grid-template-columns: 1fr;
  }

  .action-row {
    display: grid;
  }

  .action-hint {
    margin-left: 0;
  }

  .final-transcript li {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
