:root {
  --bg: #1E1E40;
  --surface: #2C2C54;
  --surface-2: #1E1E40;
  --line: #444;
  --text: #ffffff;
  --muted: #e0e0e0;
  --accent: #FF7043;
  --accent-dark: #ff8c6a;
  --danger: #ff6b6b;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
  color: var(--text);
}

button {
  cursor: pointer;
  color: inherit;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-panel h1 {
  margin: 16px 0 8px;
  font-size: 28px;
}

.auth-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  font-size: 22px;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  font-size: 16px;
}

.primary-button,
.ghost-button,
.icon-button,
.app-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
}

.primary-button {
  width: 100%;
  margin-top: 18px;
  color: white;
  background: var(--accent);
  font-weight: 700;
  padding: 0 16px;
}

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

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
  padding: 0 12px;
}

.ghost-button:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(255, 112, 67, 0.1);
}

.ghost-button.compact {
  min-height: 34px;
}

.icon-button {
  width: 42px;
  height: 42px;
  background: var(--surface);
  border-color: var(--line);
  flex: 0 0 auto;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

svg {
  width: 18px;
  height: 18px;
}

.app-shell {
  min-height: 100vh;
  display: block;
}

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

.app-brand {
  background: transparent;
  color: var(--text);
  padding: 0;
  border: 0;
  text-align: left;
}

.app-brand strong {
  display: block;
  line-height: 1.1;
}

.app-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  max-width: min(52vw, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  min-width: 0;
  padding: 30px;
  max-width: 1280px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-header,
.detail-header,
.episode-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.page-header {
  justify-content: space-between;
}

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

h1 {
  margin-bottom: 4px;
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.search-box {
  width: min(360px, 100%);
  height: 42px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.podcast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.podcast-card,
.episode-row,
.insight-card,
.transcript-panel,
.insights-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.podcast-card {
  min-height: 232px;
  padding: 14px;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  color: var(--text);
}

.podcast-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.podcast-card img,
.podcast-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  margin-bottom: 12px;
}

.podcast-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  font-size: 34px;
  font-weight: 800;
}

.podcast-card strong {
  display: block;
  line-height: 1.3;
  margin-bottom: 6px;
  color: var(--text);
}

.detail-cover {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.episode-list {
  display: grid;
  gap: 10px;
}

.episode-row {
  width: 100%;
  min-height: 72px;
  padding: 14px 16px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  color: var(--text);
}

.episode-row:hover {
  border-color: var(--accent);
}

.episode-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.file-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.pill.warning {
  background: rgba(255, 112, 67, 0.16);
  color: #ffd1c3;
}

.pill.error-pill {
  background: rgba(255, 107, 107, 0.16);
  color: #ffc9c9;
}

.episode-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(360px, 1.08fr);
  gap: 18px;
}

.insights-panel,
.transcript-panel {
  padding: 16px;
  min-width: 0;
}

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

.insight-list {
  display: grid;
  gap: 10px;
}

.insight-card {
  padding: 14px;
}

.insight-header {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: start;
}

.audio-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: rgba(255, 112, 67, 0.1);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.audio-button[disabled] {
  opacity: 0.55;
  cursor: wait;
}

.insight-card h3 {
  margin: 0 0 5px;
  font-size: 16px;
  color: var(--text);
}

.insight-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.insight-card audio {
  width: 100%;
  margin-top: 12px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-width: 176px;
}

.segmented button {
  min-height: 32px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
}

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

.transcript-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.transcript-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  color: var(--muted);
  border-radius: 6px;
  padding: 14px;
  min-height: 440px;
  max-height: calc(100vh - 240px);
  overflow: auto;
  line-height: 1.55;
  font-size: 13px;
}

.status-text,
.empty-state {
  color: var(--muted);
}

.empty-action {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.03);
}

.empty-action svg {
  width: 30px;
  height: 30px;
  color: var(--accent);
}

.empty-action h3 {
  margin: 0;
  font-size: 18px;
}

.empty-action p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.empty-action .countdown {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
}

.empty-action .phase-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.primary-button.inline {
  width: auto;
  margin-top: 4px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  background: var(--surface);
  color: white;
  border-radius: 6px;
  padding: 10px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

@media (max-width: 680px) {
  .main {
    padding: 18px;
  }

  .app-header {
    align-items: flex-start;
  }

  .page-header,
  .detail-header,
  .episode-header {
    align-items: flex-start;
  }

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

  h1 {
    font-size: 27px;
  }

  .detail-cover {
    width: 72px;
    height: 72px;
  }
}
