:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #142033;
  --muted: #66758a;
  --line: #d9e2ec;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --danger: #b91c1c;
  --shadow: 0 12px 30px rgba(20, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.65;
}

.app-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 16px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

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

.status-pill.ok {
  color: var(--primary-dark);
  border-color: rgba(15, 118, 110, 0.25);
}

.tabs,
.segmented,
.toolbar,
.row,
.player-controls {
  display: flex;
  gap: 8px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 0 14px;
  background: var(--bg);
  overflow-x: auto;
}

.tab,
.segment,
button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.tab.is-active,
.segment.is-active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.panel,
.listen-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head p {
  color: var(--muted);
  margin-bottom: 0;
}

.manual-panel {
  margin-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
}

textarea {
  resize: vertical;
  min-height: 220px;
  line-height: 1.5;
}

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

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

.ghost {
  background: var(--surface-2);
}

.big {
  min-height: 56px;
  flex: 1;
  font-size: 1.05rem;
}

.message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
}

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

.item-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

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

.item-title {
  margin: 0 0 4px;
  font-size: 1.08rem;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.badge {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.item p {
  margin-bottom: 8px;
  line-height: 1.45;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.item-actions button {
  min-height: 38px;
}

.forms-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
  margin: 10px 0;
}

.forms-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.85rem;
}

.forms-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.form-cell {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.form-cell span,
.form-cell strong {
  display: block;
}

.form-cell span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.form-cell strong {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.form-cell.is-muted strong {
  color: var(--muted);
  font-weight: 700;
}

.toolbar {
  align-items: center;
  flex-wrap: wrap;
}

.toolbar select {
  width: min(210px, 100%);
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.listen-panel {
  min-height: 70vh;
  display: grid;
  align-content: stretch;
  gap: 16px;
}

.listen-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.listen-top select {
  max-width: 160px;
}

.session-builder {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.session-head h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.session-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.session-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

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

.picker-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  background: var(--surface-2);
}

.picker-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.picker-item span,
.picker-item strong,
.picker-item small {
  min-width: 0;
}

.picker-item strong,
.picker-item small {
  display: block;
  overflow-wrap: anywhere;
}

.picker-item small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.listen-card {
  display: grid;
  align-content: center;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #eef7f6 100%);
  padding: 22px;
}

#listenPrompt {
  margin-bottom: 14px;
  font-size: clamp(2rem, 11vw, 5rem);
  line-height: 1.05;
  font-weight: 800;
}

#listenSubtext {
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 4vw, 1.35rem);
  line-height: 1.4;
}

.hidden-meaning {
  filter: blur(5px);
  user-select: none;
}

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

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

  .row,
  .player-controls,
  .session-head,
  .session-actions {
    flex-direction: column;
  }

  .forms-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .listen-panel {
    padding: 13px;
  }
}
