:root {
  --navy: #0a1628;
  --navy-2: #11233d;
  --gold: #c9a84c;
  --gold-soft: #eadca7;
  --ink: #172033;
  --muted: #657086;
  --line: #d9dee8;
  --paper: #f7f8fb;
  --white: #ffffff;
  --danger: #9f2d2d;
  --success: #2f7d58;
  --focus: #4c7dc9;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

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

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

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  border-color: var(--gold);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(76, 125, 201, 0.28);
  outline-offset: 2px;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.history-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 22px 18px;
  background: var(--navy);
  color: var(--white);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.butterfly-mark {
  position: relative;
  width: 42px;
  height: 38px;
  flex: 0 0 auto;
}

.butterfly-mark span {
  position: absolute;
  display: block;
  background: var(--gold);
  opacity: 0.94;
}

.butterfly-mark span:nth-child(1) {
  left: 3px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 18px 14px 14px 4px;
  transform: rotate(-28deg);
}

.butterfly-mark span:nth-child(2) {
  right: 3px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 14px 18px 4px 14px;
  transform: rotate(28deg);
}

.butterfly-mark span:nth-child(3) {
  left: 8px;
  bottom: 4px;
  width: 13px;
  height: 15px;
  border-radius: 12px 5px 12px 12px;
  transform: rotate(22deg);
}

.butterfly-mark span:nth-child(4) {
  right: 8px;
  bottom: 4px;
  width: 13px;
  height: 15px;
  border-radius: 5px 12px 12px 12px;
  transform: rotate(-22deg);
}

.brand {
  font-size: 1.15rem;
  font-weight: 800;
}

.brand span {
  color: var(--gold);
  font-style: italic;
}

.app-name {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.history-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font-size: 1.2rem;
}

.icon-button:hover {
  background: rgba(201, 168, 76, 0.18);
}

.icon-button.danger:hover {
  border-color: #f1b8b8;
  background: rgba(159, 45, 45, 0.35);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.history-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 78px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
  text-align: left;
}

.history-item.active,
.history-item:hover {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.14);
}

.history-code {
  color: var(--gold-soft);
  font-weight: 700;
}

.history-date,
.history-themes {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.78rem;
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  color: var(--navy);
  font-size: clamp(1.45rem, 2.6vw, 2.25rem);
  line-height: 1.1;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(47, 125, 88, 0.28);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(47, 125, 88, 0.09);
  color: var(--success);
  font-weight: 700;
  font-size: 0.85rem;
}

.input-band,
.analysis-band {
  padding: 24px 28px;
}

.input-band {
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.case-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr) minmax(180px, 0.9fr);
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--navy);
  font-weight: 700;
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--white);
}

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

.transcript-label {
  margin-bottom: 8px;
}

textarea {
  min-height: 260px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

.draft-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.draft-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--white);
}

.draft-row .recording {
  border-color: rgba(159, 45, 45, 0.28);
  background: rgba(159, 45, 45, 0.08);
  color: var(--danger);
  font-weight: 800;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.primary {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--navy);
  font-weight: 800;
}

.primary:hover {
  background: #d8bb62;
}

.microcopy {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 16px;
  margin-bottom: 18px;
}

.summary-box {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--white);
}

.summary-box h2 {
  margin-bottom: 12px;
  color: var(--navy);
  font-size: 1rem;
}

.summary-box p {
  color: var(--muted);
  line-height: 1.5;
}

.chip-row,
.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.tag {
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(201, 168, 76, 0.16);
  color: #6b5514;
  font-weight: 700;
  font-size: 0.78rem;
}

.chip.empty {
  background: #edf0f5;
  color: var(--muted);
}

.results-list {
  display: grid;
  gap: 16px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--white);
  box-shadow: 0 10px 28px rgba(10, 22, 40, 0.06);
}

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

.rank {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-card h3 {
  margin-top: 4px;
  color: var(--navy);
  font-size: 1.25rem;
}

.source {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.score {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(17, 35, 61, 0.08);
  color: var(--navy);
  font-weight: 800;
  font-size: 0.8rem;
}

.why {
  margin-top: 14px;
  color: var(--ink);
  line-height: 1.55;
}

.script-block {
  margin-top: 14px;
  border-left: 4px solid var(--gold);
  padding: 12px 14px;
  background: #fffaf0;
  color: var(--navy);
  line-height: 1.55;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.result-grid h4 {
  margin-bottom: 6px;
  color: var(--navy);
  font-size: 0.9rem;
}

.result-grid p {
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .history-panel {
    min-height: auto;
  }

  .history-list {
    max-height: 220px;
  }

  .case-grid,
  .summary-row,
  .result-grid {
    grid-template-columns: 1fr;
  }
}

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

  .input-band,
  .analysis-band,
  .topbar {
    padding: 20px 16px;
  }

  .toolbar button {
    width: 100%;
  }
}
