:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --paper: #f1f5f9;
  --panel: #ffffff;
  --accent: #0284c7;
  --accent-dark: #0369a1;
  --warm: #f59e0b;
  --warm-dark: #d97706;
  --shadow: 0 1px 4px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .05);
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5edf7;
  --muted: #9aa8ba;
  --line: #263244;
  --paper: #0d1117;
  --panel: #151b24;
  --accent: #38bdf8;
  --accent-dark: #7dd3fc;
  --warm: #fbbf24;
  --warm-dark: #fcd34d;
  --shadow: 0 1px 4px rgba(0, 0, 0, .24), 0 10px 28px rgba(0, 0, 0, .22);
}

* {
  box-sizing: border-box;
}

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

/* ── Topbar ── */
.topbar {
  --topbar-x: clamp(16px, 4vw, 56px);
  --micro-edge: clamp(18px, 1.8vw, 24px);
  --micro-size: clamp(58px, 6vw, 76px);
  --micro-gap: clamp(10px, 1.2vw, 16px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px var(--topbar-x) 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

[data-theme="dark"] .topbar {
  background: rgba(13, 17, 23, .92);
}

.topbar-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  margin-left: auto;
}

.topbar-main {
  display: flex;
  align-items: flex-end;
  gap: 24px;
}

.topbar-brand {
  position: relative;
  padding-left: calc(var(--micro-edge) + var(--micro-size) + var(--micro-gap) - var(--topbar-x));
}

.menu-microphone {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--micro-edge) - var(--topbar-x));
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--micro-size);
  color: var(--warm-dark);
  opacity: .95;
}

.menu-microphone i {
  font-size: clamp(4.15rem, 7.2vw, 5.75rem);
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  font-weight: 600;
  font-style: italic;
  line-height: 1.1;
  color: var(--warm-dark);
}

.topbar h1 + .meta {
  margin-top: 8px;
}

.quick-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.quick-menu a {
  display: inline-block;
  width: auto;
  min-height: 0;
  padding: 0 0 3px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
  transition: all .15s ease;
}

.quick-menu a:hover,
.quick-menu a[aria-current="page"] {
  border-bottom-color: var(--warm);
  color: var(--warm-dark);
}

/* ── Progress ── */
.progress-panel {
  min-width: min(280px, 38vw);
  color: var(--muted);
  font-size: .82rem;
}

.progress-track {
  height: 2px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--warm);
  transition: width .4s ease;
}

/* ── Controls ── */
main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 56px) 64px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

input,
select,
button {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  transition: border-color .15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

input,
select {
  padding: 0 10px;
}

button,
.source-link {
  cursor: pointer;
  font-weight: 600;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  color: var(--muted);
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-toggle {
  width: 28px;
  min-height: 28px;
  border-color: transparent;
  background: transparent;
  font-size: 1rem;
}

.theme-toggle {
  width: 28px;
  min-height: 28px;
  border-color: transparent;
  background: transparent;
  font-size: 1rem;
}

.search-toggle[aria-expanded="true"] {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
}

.header-search {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  width: min(620px, calc(100vw - 32px));
  min-width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .header-search {
  background: #101722;
}

.header-search[hidden] {
  display: none;
}

.header-search > i {
  color: var(--muted);
  font-size: .9rem;
  justify-self: center;
}

.header-search input {
  min-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
}

.header-search input:focus {
  border-color: transparent;
}

.header-search input::-webkit-search-cancel-button {
  display: none;
}

.search-close {
  width: 34px;
  min-height: 34px;
  border: 0;
  background: transparent;
}

[data-theme="dark"] .search-close {
  background: transparent;
}

.favorite-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  min-width: max-content;
  min-height: 32px;
  padding: 0 14px;
  border-color: var(--line);
  color: var(--muted);
  transition: all .15s ease;
}

.favorite-filter:hover {
  border-color: var(--warm);
  color: var(--warm-dark);
}

.favorite-filter[aria-pressed="true"] {
  border-color: var(--warm);
  background: #fffbeb;
  color: var(--warm-dark);
}

[data-theme="dark"] .favorite-filter[aria-pressed="true"],
[data-theme="dark"] .favorite-button[aria-pressed="true"] {
  background: rgba(251, 191, 36, .12);
}

/* ── Summary ── */
.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.summary div {
  padding: 9px 18px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.summary strong,
.summary span {
  display: block;
}

.summary strong {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.32rem;
  font-weight: 600;
  line-height: 1.1;
}

.summary span {
  margin-top: 1px;
  color: var(--muted);
  font-size: .78rem;
}

/* ── Tabs ── */
.tab-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0 16px;
}

.tabs {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  padding: 0;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  width: auto;
  min-width: max-content;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  transition: all .15s ease;
}

.tabs button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tabs button[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* ── Section ── */
.object-section {
  margin-top: 32px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
}

.section-title h2 {
  margin: 0;
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  font-weight: 600;
  font-style: italic;
  color: var(--warm-dark);
}

.section-title span {
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
}

/* ── Grid & Cards ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
}

.card {
  position: relative;
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  align-items: start;
  min-width: 0;
  overflow: hidden;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  transition: transform .2s ease, box-shadow .2s ease;
}

.card-extra {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card:hover {
  -webkit-transform: translateY(-2px) translateZ(0);
  transform: translateY(-2px) translateZ(0);
  box-shadow: 0 6px 20px rgba(26, 23, 20, .09);
}

.card-main {
  display: contents;
}

.card.is-done {
  background: linear-gradient(rgba(122, 45, 59, .04), rgba(122, 45, 59, .04)), var(--panel);
}

[data-theme="dark"] .card.is-done {
  background: linear-gradient(rgba(56, 189, 248, .05), rgba(56, 189, 248, .05)), var(--panel);
}

.card.is-favorite {
  border-color: rgba(245, 158, 11, .55);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.card-head h2 {
  margin: 0;
  flex: 1;
  font-family: 'Lora', Georgia, serif;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
  color: var(--accent);
}

/* ── Meta line ── */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.4;
}

[data-theme="dark"] .meta {
  color: #f8fafc;
}

.meta .dot {
  color: var(--line);
  font-size: .7rem;
}

/* ── Checkbox coin ── */
.listened {
  flex-shrink: 0;
  margin-top: 2px;
}

.listened input {
  display: block;
  width: 16px;
  min-height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.listened span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.favorite-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  flex: 0 0 34px;
  min-height: 34px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: .95rem;
  transition: all .15s ease;
}

[data-theme="dark"] .favorite-button,
[data-theme="dark"] .source-link,
[data-theme="dark"] .quiz-link,
[data-theme="dark"] .listen-button,
[data-theme="dark"] .summary-button {
  background: #101722;
}

.favorite-button:hover {
  border-color: var(--warm);
  color: var(--warm-dark);
}

.favorite-button[aria-pressed="true"] {
  border-color: var(--warm);
  background: #fffbeb;
  color: var(--warm);
}

.favorite-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Actions ── */
.actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.source-link[hidden],
.quiz-link[hidden],
.listen-button[hidden],
.summary-button[hidden] {
  display: none;
}

.source-link,
.quiz-link,
.listen-button,
.summary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  flex: 0 0 34px;
  min-height: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: 6px;
  appearance: none;
  text-decoration: none;
  font-size: .9rem;
  transition: all .15s ease;
}

.source-link {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.source-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quiz-link {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.quiz-link:hover {
  border-color: var(--warm);
  color: var(--warm-dark);
}

.listen-button {
  border-color: var(--accent);
  background: #fff;
  color: var(--accent);
}

.listen-button:hover {
  background: var(--accent);
  color: var(--paper);
}

.summary-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.summary-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Summary panel ── */
.summary-panel {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: .86rem;
  line-height: 1.55;
  color: var(--ink);
}

.summary-panel h3 {
  font-size: .9rem;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--ink);
}

.summary-panel h3:first-child { margin-top: 0; }

.summary-panel p { margin: 4px 0; }

.summary-panel ul {
  margin: 4px 0 4px 16px;
  padding: 0;
}

.summary-panel li { margin: 3px 0; }

/* ── Player ── */
.player {
  position: relative;
  min-width: 0;
  width: 100%;
  height: 136px;
  border-radius: 6px;
  overflow: hidden;
  background: #2b2747;
  margin-top: 10px;
}

.player::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 6px solid #2b2747;
  border-radius: 6px;
}

.player iframe {
  display: block;
  width: calc(100% + 12px);
  height: 148px;
  margin: -6px 0 -6px -6px;
  border: none;
  background: #2b2747;
  color-scheme: dark;
}

.player.is-podcastics {
  height: 58px;
  background: transparent;
}

.player.is-podcastics::after {
  border-width: 0;
}

.player.is-podcastics iframe {
  width: 100%;
  height: 58px;
  margin: 0;
  background: transparent;
}


/* ── Empty / error ── */
.empty,
.error {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-style: italic;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: start;
  }

  .topbar-tools {
    width: min(420px, 45vw);
  }

  .topbar-main {
    width: 100%;
    justify-content: flex-end;
  }

  .favorite-filter {
    min-width: 0;
  }
}

@media (max-width: 680px) {
  .topbar {
    --micro-edge: clamp(12px, 4vw, 18px);
    --micro-size: clamp(40px, 12vw, 48px);
    --micro-gap: 9px;
    display: block;
  }

  .quick-menu {
    margin-bottom: 12px;
  }

  .menu-microphone i {
    font-size: clamp(3.15rem, 14vw, 3.7rem);
  }

  .topbar-tools {
    width: 100%;
    align-items: flex-start;
    margin-left: 0;
    margin-top: 14px;
  }

  .topbar-main {
    justify-content: flex-start !important;
  }

  main {
    padding-inline: 12px;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .tab-row {
    align-items: stretch;
    flex-direction: column;
  }

  .favorite-filter {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .controls,
  .summary {
    grid-template-columns: 1fr;
  }

  .summary div {
    padding: 10px 14px;
  }

  .summary strong {
    font-size: 1.2rem;
  }
}

/* ── Footer ── */
.footer {
  max-width: 900px;
  width: 100%;
  margin: 96px auto 56px;
  text-align: center;
  color: var(--muted);
  position: relative;
}

.footer::before {
  content: '';
  display: block;
  width: 60%;
  max-width: 320px;
  height: 2px;
  margin: 0 auto 28px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
  opacity: 0.45;
}

.footer-content {
  display: grid;
  gap: 28px;
  justify-items: center;
}

.made-with {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.made-with a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.made-with a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.made-with .fa-heart {
  color: var(--accent);
  margin: 0 3px;
  animation: footerHeartBeat 3.2s infinite ease-in-out;
  transform-origin: center;
}

@keyframes footerHeartBeat {
  0%, 100% { transform: scale(1); }
  20%       { transform: scale(1.15); }
  40%       { transform: scale(1); }
  60%       { transform: scale(1.07); }
}

.license p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.year {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0.7;
}
