:root {
  --bg-app: #f7f6f3;
  --bg-stage: #ebe9e4;
  --bg-rail: #f8f7f4;
  --bg-panel: #ffffff;
  --bg-soft: #faf9f7;
  --bg-muted: #f4f2ee;
  --text: #292524;
  --text-strong: #1c1917;
  --text-muted: #78716c;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 10px 30px rgba(28, 25, 23, 0.06);
  --shadow-inset: inset -10px 0 20px -20px rgba(0, 0, 0, 0.16);
  --easy: #10b981;
  --easy-soft: #ecfdf5;
  --medium: #f59e0b;
  --medium-soft: #fffbeb;
  --hard: #f43f5e;
  --hard-soft: #fff1f2;
  --song: #4f46e5;
  --song-soft: #eef2ff;
  --call: #7c3aed;
  --call-soft: #f5f3ff;
  --keep: #059669;
  --keep-soft: #d1fae5;
  --borderline: #d97706;
  --borderline-soft: #fef3c7;
  --replace: #dc2626;
  --replace-soft: #fee2e2;
  --focus: #2563eb;
  --focus-soft: #dbeafe;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
}

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

button {
  cursor: pointer;
}

audio {
  width: 100%;
  height: 34px;
}

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.topbar__brand {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.topbar h1,
.module-header__title,
.lane__title {
  margin: 0;
}

.topbar h1 {
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

.lede {
  display: none;
}

.topbar__controls {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

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

.control-row--inline {
  gap: 8px;
}

.control-row--actions {
  gap: 6px;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-field--name {
  width: 140px;
}

.control-field input,
.control-field select,
.task-form textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text-strong);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.control-field input:focus,
.control-field select:focus,
.task-form textarea:focus {
  border-color: rgba(41, 37, 36, 0.4);
  box-shadow: 0 0 0 3px rgba(41, 37, 36, 0.08);
  background: #fff;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.toggle input {
  margin: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: var(--text-strong);
  color: #fff;
}

.button--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.button--ghost:hover {
  color: var(--replace);
  background: var(--replace-soft);
}

.save-indicator {
  min-width: 112px;
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
}

.capsule {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: min(540px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 18px;
  background:
    linear-gradient(135deg, rgba(48, 48, 54, 0.78), rgba(20, 20, 23, 0.88));
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.capsule-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: 9999px;
  font-variant-numeric: tabular-nums;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.hint-text {
  color: rgba(255, 255, 255, 0.76);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 180ms ease;
}

.export-btn {
  flex-shrink: 0;
  min-width: 132px;
  border: 1px solid transparent;
  border-radius: 9999px;
  padding: 10px 18px;
  background-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.42);
  font-size: 14px;
  font-weight: 700;
  cursor: not-allowed;
  box-shadow: none;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.capsule.ready {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(245, 247, 250, 0.92));
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.18),
    0 0 0 4px rgba(34, 197, 94, 0.16);
}

.capsule.ready .count-badge {
  background: #22c55e;
  border-color: rgba(22, 163, 74, 0.18);
  color: #fff;
}

.capsule.ready .hint-text {
  color: #1f2937;
}

.capsule.ready .export-btn {
  background-color: #111827;
  border-color: rgba(17, 24, 39, 0.9);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.22);
}

.capsule.ready .export-btn:hover:not(:disabled) {
  background-color: #0f172a;
  transform: translateY(-1px);
}

.capsule .export-btn:disabled {
  pointer-events: none;
}

.workspace {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace__feed {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow-y: auto;
  background: var(--bg-stage);
  padding: 32px;
}

.feed-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.feed-empty {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.feed-empty__label {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.feed-empty h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 18px;
  font-weight: 800;
}

.feed-empty p {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.meta-pill,
.difficulty-pill,
.sound-pill,
.status-pill,
.score-chip,
.sample-chip,
.candidate-meta span,
.selected-candidate-pill,
.decision-chip,
.confidence-chip,
.lane-complete-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.meta-pill {
  background: rgba(41, 37, 36, 0.06);
  color: var(--text);
}

.meta-pill[data-tone="keep"] {
  background: var(--keep-soft);
  color: var(--keep);
}

.meta-pill[data-tone="borderline"] {
  background: var(--borderline-soft);
  color: var(--borderline);
}

.meta-pill[data-tone="replace"] {
  background: var(--replace-soft);
  color: var(--replace);
}

.review-feed {
  display: flex;
  flex-direction: column;
  gap: 40px;
  max-width: 1180px;
  margin: 0 auto;
  padding-bottom: 148px;
}

.module {
  position: relative;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

.module::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--line-strong);
}

.module[data-difficulty="Easy"]::before {
  background: var(--easy);
}

.module[data-difficulty="Medium"]::before {
  background: var(--medium);
}

.module[data-difficulty="Hard"]::before {
  background: var(--hard);
}

.module.is-complete {
  border-color: rgba(5, 150, 105, 0.18);
}

.target-column {
  width: 320px;
  flex-shrink: 0;
  padding: 24px;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.module-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.module-header__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.difficulty-pill {
  border: 1px solid transparent;
}

.difficulty-pill[data-difficulty="Easy"] {
  color: #065f46;
  background: var(--easy-soft);
  border-color: rgba(16, 185, 129, 0.2);
}

.difficulty-pill[data-difficulty="Medium"] {
  color: #92400e;
  background: var(--medium-soft);
  border-color: rgba(245, 158, 11, 0.2);
}

.difficulty-pill[data-difficulty="Hard"] {
  color: #9f1239;
  background: var(--hard-soft);
  border-color: rgba(244, 63, 94, 0.18);
}

.module-header__title {
  color: var(--text-strong);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
}

.module-header__subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
}

.target-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px;
  background: #e7e5e4;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.target-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.score-chip {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.target-rationale {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.sample-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sample-row {
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.sample-row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.sample-chip {
  color: #fff;
  letter-spacing: 0.08em;
}

.sample-chip[data-sound-type="song"] {
  background: var(--song);
}

.sample-chip[data-sound-type="call"] {
  background: var(--call);
}

.sample-meta {
  color: var(--text-muted);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.task-column {
  flex: 1;
  min-width: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: var(--bg-panel);
}

.task-lane {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(250, 250, 249, 0.86), rgba(255, 255, 255, 1));
}

.task-lane.is-complete {
  background: linear-gradient(180deg, rgba(236, 253, 245, 0.32), rgba(255, 255, 255, 1));
}

.lane-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
}

.lane-header__main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.lane__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--text-strong);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sound-pill {
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sound-pill[data-sound-type="song"] {
  background: var(--song);
}

.sound-pill[data-sound-type="call"] {
  background: var(--call);
}

.lane-complete-pill {
  background: var(--keep-soft);
  color: var(--keep);
}

.status-pill {
  color: #fff;
  text-transform: uppercase;
}

.status-pill[data-status="keep"] {
  background: var(--keep);
}

.status-pill[data-status="borderline"] {
  background: var(--borderline);
}

.status-pill[data-status="replace"] {
  background: var(--replace);
}

.selected-candidate-pill {
  max-width: 240px;
  align-self: flex-end;
  background: var(--focus-soft);
  color: var(--focus);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.lane-rationale {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.candidate-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.candidate-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.candidate-card.is-selected {
  border-color: var(--focus);
  box-shadow: inset 0 0 0 1px var(--focus);
}

.candidate-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.candidate-card__eyebrow {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.candidate-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.candidate-card.is-selected .candidate-select {
  background: var(--focus);
  color: #fff;
}

.candidate-thumb {
  width: 100%;
  aspect-ratio: 1.35 / 1;
  object-fit: cover;
  border-radius: 10px;
  background: #e7e5e4;
}

.candidate-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.candidate-title strong {
  color: var(--text-strong);
  font-size: 17px;
  line-height: 1.1;
}

.candidate-title span {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.candidate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.candidate-meta span {
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--line);
}

.candidate-note {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.task-form {
  padding: 18px;
  background: var(--bg-muted);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 18px;
}

.module-selection {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}

.module-select-button {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--text-strong);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.module-select-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.module-select-button:disabled {
  cursor: not-allowed;
  background: var(--bg-muted);
  color: var(--text-muted);
  border-color: var(--line);
}

.module-select-button.is-selected {
  background: var(--keep-soft);
  color: var(--keep);
  border-color: rgba(5, 150, 105, 0.24);
}

.module-selection__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.form-row {
  display: grid;
  gap: 10px;
}

.form-row--split {
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

.form-row__label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.score-group,
.decision-group,
.confidence-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.score-group {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 52px));
}

.score-button,
.decision-chip,
.confidence-chip {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.score-button:hover,
.decision-chip:hover,
.confidence-chip:hover {
  transform: translateY(-1px);
}

.score-button.is-active,
.decision-chip.is-active,
.confidence-chip.is-active {
  background: var(--text-strong);
  border-color: var(--text-strong);
  color: #fff;
}

.task-form textarea {
  min-height: 86px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

@media (max-width: 1440px) {
  .candidate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1220px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar__controls {
    width: 100%;
    justify-content: flex-start;
  }

  .workspace__feed {
    padding: 24px;
  }
}

@media (max-width: 980px) {
  .module {
    flex-direction: column;
  }

  .target-column {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 720px) {
  .topbar,
  .workspace__feed {
    padding-left: 16px;
    padding-right: 16px;
  }

  .control-row {
    width: 100%;
  }

  .control-field--name {
    width: 100%;
  }

  .topbar__controls {
    align-items: stretch;
  }

  .button,
  .toggle,
  .control-field input,
  .control-field select {
    width: 100%;
  }

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

  .selected-candidate-pill {
    max-width: none;
    align-self: stretch;
  }

  .lane-header {
    flex-direction: column;
  }

  .score-group {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .capsule {
    right: 12px;
    left: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: none;
    width: auto;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    padding: 12px;
  }

  .capsule-progress {
    min-width: 0;
    gap: 10px;
  }

  .hint-text {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .export-btn {
    min-width: 120px;
    padding-inline: 16px;
  }

  .review-feed {
    padding-bottom: 164px;
  }
}

@media (max-width: 560px) {
  .capsule {
    flex-direction: column;
    align-items: stretch;
    border-radius: 24px;
  }

  .capsule-progress {
    flex-wrap: wrap;
  }

  .hint-text {
    white-space: normal;
  }

  .export-btn {
    width: 100%;
  }
}
