:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #eef6f4;
  --ink: #172033;
  --muted: #657084;
  --line: #d8dee8;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --blue: #2563eb;
  --coral: #e85d3f;
  --amber: #b7791f;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.04) 34%, transparent 68%),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.login-panel {
  width: min(420px, 100%);
  border: 1px solid rgba(216, 222, 232, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  align-items: flex-start;
  margin-bottom: 22px;
}

.login-form {
  display: grid;
}

.login-error {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--coral);
  font-size: 0.9rem;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #12343b;
  color: #ffffff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.9rem;
}

.status-pill.ready {
  border-color: rgba(15, 118, 110, 0.25);
  color: var(--teal-dark);
  background: #e8f6f3;
}

.status-pill.warning {
  border-color: rgba(183, 121, 31, 0.3);
  color: var(--amber);
  background: #fff8e8;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.capture-column,
.review-column {
  display: grid;
  gap: 14px;
}

.panel,
.review-column {
  border: 1px solid rgba(216, 222, 232, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.review-column {
  min-height: calc(100vh - 116px);
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 0.98rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.dropzone {
  display: grid;
  gap: 6px;
  min-height: 136px;
  place-items: center;
  border: 1px dashed #9ab4c0;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.05)),
    #fbfdff;
  padding: 18px;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--teal);
  background: #eef8f6;
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone-title {
  font-weight: 750;
}

.dropzone-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 260px;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.divider::before,
.divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.record-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.record-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.record-meta span {
  color: var(--muted);
  font-size: 0.88rem;
}

.record-meta strong {
  font-variant-numeric: tabular-nums;
}

.field-label {
  display: block;
  margin: 12px 0 7px;
  color: #354052;
  font-size: 0.9rem;
  font-weight: 700;
}

textarea,
input[type="text"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

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

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.primary-button,
.secondary-button,
.tab-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 14px;
  font-weight: 750;
}

.primary-button {
  background: var(--teal);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.primary-button.recording {
  background: var(--coral);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.wide {
  width: 100%;
  margin-top: 16px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.secondary-button:hover:not(:disabled) {
  border-color: #9aa9bd;
  background: #f9fbfe;
}

.compact-button {
  min-height: 38px;
  padding: 8px 12px;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfe;
  padding: 10px;
}

.tab-button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.09);
}

.tab-panel {
  min-height: 0;
  padding: 18px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100vh - 184px);
  min-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.chat-message {
  max-width: 760px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
}

.chat-message.user {
  align-self: flex-end;
  border-color: rgba(37, 99, 235, 0.28);
  background: #eef4ff;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-message.system {
  align-self: center;
  max-width: 900px;
  border-color: rgba(183, 121, 31, 0.28);
  background: #fff9ea;
}

.chat-message strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-message p {
  margin: 0;
  line-height: 1.55;
}

.audio-console {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

audio {
  width: 100%;
}

.timeline-readout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timeline-readout strong {
  color: var(--ink);
}

.position-line {
  margin-left: auto;
  color: var(--teal-dark);
}

#waveformCanvas {
  width: 100%;
  height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

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

.transcript-surface,
.segment-surface {
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.transcript-text {
  max-height: 520px;
  overflow: auto;
  line-height: 1.8;
  font-size: 1.02rem;
}

.transcript-fragment {
  border-radius: 6px;
  padding: 2px 4px;
  transition: background 120ms ease, color 120ms ease;
}

.transcript-fragment:hover {
  background: #eef4ff;
}

.transcript-fragment.active {
  background: #dff5ef;
  box-shadow: inset 0 -2px 0 var(--teal);
}

.segment-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.segment-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
  color: var(--ink);
  text-align: left;
}

.segment-row:hover,
.segment-row.active {
  border-color: rgba(15, 118, 110, 0.35);
  background: #eef8f6;
}

.segment-time {
  color: var(--teal-dark);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.segment-text {
  line-height: 1.45;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

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

.detail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
  min-width: 0;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 5px;
}

.detail-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 236px);
  overflow: auto;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  text-align: left;
}

.history-row:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: #f5fbfa;
}

.history-title {
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta,
.history-preview {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.history-preview {
  margin-top: 6px;
}

.history-expiry {
  align-self: start;
  color: var(--teal-dark);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

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

  .topbar-actions {
    justify-content: flex-start;
  }

  .workspace,
  .sync-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .review-column {
    min-height: auto;
  }

  .chat-log {
    height: 460px;
    min-height: 360px;
  }

  .position-line {
    flex-basis: 100%;
    margin-left: 0;
  }

  .timeline-readout {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .brand p {
    display: none;
  }

  .tabs {
    overflow-x: auto;
  }

  .record-box,
  .export-row,
  .history-row {
    align-items: stretch;
    flex-direction: column;
  }

  .history-row {
    display: flex;
  }

  .segment-row {
    grid-template-columns: 1fr;
  }
}
