/* Earpad. Decisões em DESIGN.md. */

:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #161618;
  --raised: #202023;
  --line: rgb(255 255 255 / 0.08);
  --line-strong: rgb(255 255 255 / 0.18);
  --text: #f4f4f5;
  --text-2: #a3a3ab;
  --text-3: #8c8c94;
  --accent: #ff7a50;
  --on-accent: #0b0b0c;
  --negative: #ff5d5d;
  --glass: rgb(22 22 24 / 0.62);
  --track-rest: rgb(255 255 255 / 0.2);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px;
  --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 20px; --r-xl: 28px;

  --font-ui: "Onest", system-ui, sans-serif;
  --font-display: "Big Shoulders Display", "Arial Narrow", sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --dur-press: 140ms; --dur-ui: 200ms; --dur-panel: 320ms;

  --gutter: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

}

@media (min-width: 390px) { :root { --gutter: 20px; } }

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-ui);
  overscroll-behavior: none;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }

.display {
  font-family: var(--font-display);
  font-weight: 800; /* atelier-ok: heavy-weight (face display escolhida) */
  text-transform: uppercase;
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

/* ---------- capa desfocada atrás do conteúdo ---------- */

.backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.backdrop::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: var(--cover) center / cover no-repeat;
  filter: blur(56px) saturate(1.35) brightness(0.62); /* atelier-ok: blob (é a capa real da história, desfocada) */
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgb(11 11 12 / 0.15), rgb(11 11 12 / 0.55) 55%, var(--bg));
}

/* ---------- páginas ---------- */

#view {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + var(--space-5)) var(--gutter) calc(96px + var(--safe-b));
  outline: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 48px;
}
.brand { font-size: 40px; }

/* ---------- botões ---------- */

.round {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%; /* atelier-ok: radius-monotone (botões redondos) */
  background: transparent;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-ui) var(--ease-out);
}
.round:active { transform: scale(0.92); }
.round svg { width: 20px; height: 20px; }
.round[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.round--sm { width: 48px; height: 48px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 52px;
  padding: 0 var(--space-6);
  border: 0;
  border-radius: 999px; /* atelier-ok: radius-monotone (botão pílula é o estilo do app) */
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-ui) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.btn--accent { background: var(--accent); color: var(--on-accent); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn[disabled] { opacity: 0.6; cursor: default; }

@media (hover: hover) and (pointer: fine) {
  .round:hover { background: rgb(255 255 255 / 0.08); }
  .btn--accent:hover { filter: brightness(1.08); }
  .btn--ghost:hover { background: var(--raised); }
  .chapter:hover { background: rgb(255 255 255 / 0.04); }
  .tile:hover .tile__cover { filter: brightness(1.1); }
}

/* ---------- adicionar história ---------- */

.add { margin-top: var(--space-6); }
.add__field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);
  border: 1px solid var(--line);
  border-radius: 999px; /* atelier-ok: radius-monotone */
  background: var(--surface);
}
.add__field:focus-within { border-color: var(--line-strong); }
.add__field > svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.add input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px var(--font-ui);
  outline: none;
}
.add input::placeholder { color: var(--text-3); }
.add__go {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%; /* atelier-ok: radius-monotone */
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  flex: none;
}
.add__go svg { width: 20px; height: 20px; }
.add__go[disabled] { opacity: 0.7; }
.hint { font-size: 13px; color: var(--text-3); margin: var(--space-2) var(--space-4) 0; }
.error { font-size: 14px; color: var(--negative); margin: var(--space-2) var(--space-4) 0; }

/* ---------- continuar ouvindo ---------- */

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--space-4);
  width: 100%;
  margin-top: var(--space-8);
  padding: var(--space-4);
  border: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.hero .backdrop { z-index: -1; }
.hero .backdrop::after { background: linear-gradient(to right, rgb(11 11 12 / 0.25), rgb(11 11 12 / 0.6)); }
.hero__cover { width: 96px; aspect-ratio: 256/400; object-fit: cover; border-radius: var(--r-sm); box-shadow: 0 8px 24px rgb(0 0 0 / 0.35); }
.hero__body { display: flex; flex-direction: column; min-width: 0; }
.hero__kicker { font-size: 13px; color: var(--text-2); }
.hero__title { font-size: 30px; margin-top: var(--space-1); }
.hero__sub { font-size: 14px; color: var(--text-2); margin-top: var(--space-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero__foot { display: flex; align-items: center; gap: var(--space-3); margin-top: auto; padding-top: var(--space-3); }
.hero__foot .tile__bar { flex: 1; margin: 0; }
.hero__play {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%; /* atelier-ok: radius-monotone */
  background: var(--accent);
  color: var(--on-accent);
  flex: none;
}
.hero__play svg { width: 22px; height: 22px; }

/* ---------- biblioteca ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--space-10) 0 var(--space-4);
}
.section-head h2 { font-size: 32px; }
.section-head span { font-size: 14px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.tile__cover {
  width: 100%;
  aspect-ratio: 256 / 400;
  object-fit: cover;
  border-radius: var(--r-md);
  background: var(--raised);
  transition: filter var(--dur-ui) var(--ease-out);
}
.tile__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: var(--space-3);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.tile__meta { display: block; margin-top: 2px; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tile__bar { display: block; height: 3px; margin-top: var(--space-2); border-radius: 2px; background: rgb(255 255 255 / 0.12); overflow: hidden; }
.tile__bar span { display: block; height: 100%; background: var(--accent); }

.empty {
  margin-top: var(--space-10);
  padding: var(--space-6);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text-2);
  font-size: 15px;
}
.empty h2 { font-size: 30px; color: var(--text); margin-bottom: var(--space-3); }
.empty ol { margin: 0; padding-left: 20px; display: grid; gap: var(--space-2); }

/* ---------- história ---------- */

.story-top {
  position: relative;
  isolation: isolate;
  margin: calc((var(--safe-t) + var(--space-5)) * -1) calc(var(--gutter) * -1) 0;
  padding: calc(var(--safe-t) + var(--space-5)) var(--gutter) var(--space-6);
}
.story-top .backdrop { z-index: -1; }
.story-head { display: grid; grid-template-columns: 128px 1fr; gap: var(--space-5); align-items: end; margin-top: var(--space-6); }
.story-head .cover { width: 128px; aspect-ratio: 256/400; object-fit: cover; border-radius: var(--r-md); box-shadow: 0 12px 32px rgb(0 0 0 / 0.45); background: var(--raised); }
.story-head .by { color: var(--text-2); font-size: 15px; }
.story-title { font-size: clamp(36px, 11vw, 52px); margin-top: var(--space-5); }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.chip { padding: 6px var(--space-3); border: 1px solid var(--line-strong); border-radius: 999px; /* atelier-ok: radius-monotone */ font-size: 13px; color: var(--text-2); }

.story-actions { display: flex; gap: var(--space-3); margin-top: var(--space-6); }
.story-actions .btn--accent { flex: 1; }

.desc {
  margin-top: var(--space-6);
  color: var(--text-2);
  font-size: 15px;
  white-space: pre-line;
  overflow-wrap: anywhere;
  max-width: 65ch;
}
.desc.is-clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.more { min-height: 44px; padding: 0; border: 0; background: none; color: var(--text); font-weight: 600; cursor: pointer; }

.note { margin-top: var(--space-5); padding: var(--space-4); border-radius: var(--r-md); background: var(--surface); color: var(--text-2); font-size: 14px; }

.chapters { list-style: none; margin: 0; padding: 0; }
.chapter {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  width: calc(100% + var(--space-4));
  min-height: 60px;
  margin: 0 calc(var(--space-2) * -1);
  padding: var(--space-2);
  border: 0;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-ui) var(--ease-out);
}
.chapter__num { font-size: 15px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chapter__name { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.chapter__state { font-size: 13px; color: var(--text-3); }
.chapter.is-done .chapter__name { color: var(--text-2); font-weight: 400; }
.chapter.is-current { background: var(--surface); }
.chapter.is-current .chapter__name { color: var(--accent); }

.remove { margin-top: var(--space-8); }

/* barrinhas de "tocando agora" */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; height: 100%; border-radius: 1px; background: var(--accent); transform-origin: bottom; animation: eq 0.9s ease-in-out infinite; } /* atelier-ok: infinite-loop (indicador ao vivo) */
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
.eq.is-paused i { animation-play-state: paused; }
@keyframes eq { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }

/* ---------- barra de progresso ---------- */

.track { position: relative; display: block; height: 4px; border-radius: 2px; background: var(--track-rest); }
.track__fill { position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: inherit; background: var(--accent); }

/* Na tela do player a área de toque tem 44px e a barra fica no meio. */
.track--seek { height: 44px; background: none; cursor: pointer; touch-action: none; }
.track--seek::before { content: ""; position: absolute; left: 0; right: 0; top: 20px; height: 4px; border-radius: 2px; background: var(--track-rest); }
.track--seek .track__fill { top: 20px; bottom: auto; height: 4px; border-radius: 2px; }
.track--seek .track__fill::after {
  content: "";
  position: absolute;
  right: -8px;
  top: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%; /* atelier-ok: radius-monotone */
  background: var(--text);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.4);
}

.track--mini { position: absolute; left: var(--space-4); right: var(--space-4); bottom: 6px; height: 2px; }

/* ---------- mini-player flutuante ---------- */

.mini {
  position: fixed;
  left: var(--space-2);
  right: var(--space-2);
  bottom: calc(var(--space-2) + var(--safe-b));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 624px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: rgb(32 32 35 / 0.88);
  /* atelier-ok: glass (mini-player flutua sobre o conteúdo) */
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
          backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), 0 16px 40px rgb(0 0 0 / 0.45);
}
.mini__open { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-3); padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.mini__cover { width: 44px; height: 44px; object-fit: cover; border-radius: var(--r-sm); background: var(--raised); }
.mini__text { min-width: 0; display: grid; }
.mini__title, .mini__story { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini__title { font-size: 15px; font-weight: 600; }
.mini__story { font-size: 13px; color: var(--text-2); }
.mini__play { display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; /* atelier-ok: radius-monotone */ background: var(--text); color: var(--bg); cursor: pointer; flex: none; }
.mini__play svg { width: 20px; height: 20px; }
.mini__play .spin { width: 18px; height: 18px; }

/* ---------- player ---------- */

.player {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  isolation: isolate;
}
.player > .backdrop { position: fixed; z-index: -1; }

.player__top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: var(--space-3);
  padding: calc(var(--safe-t) + var(--space-3)) var(--gutter) 0;
}
.player__where { display: grid; text-align: center; min-width: 0; }
.player__from { font-size: 12px; color: var(--text-2); }
.player__story-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player__body {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--gutter) calc(var(--space-5) + var(--safe-b));
}

.player__art {
  position: relative;
  flex: 1 1 0;
  min-height: 140px;
  max-height: 420px;
  display: flex;
  justify-content: center;
}
.player__cover {
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 256 / 400;
  object-fit: cover;
  border-radius: var(--r-lg);
  background: var(--raised);
  box-shadow: 0 24px 56px rgb(0 0 0 / 0.5);
}

/* Texto do capítulo, com o trecho lido aceso. */
.lyrics {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2) 0 40%;
  -webkit-mask: linear-gradient(to bottom, transparent, #000 10%, #000 80%, transparent);
          mask: linear-gradient(to bottom, transparent, #000 10%, #000 80%, transparent);
  outline: none;
}
.lyrics p {
  margin: 0 0 var(--space-5);
  font-size: 19px;
  line-height: 1.55;
  font-weight: 500;
  color: rgb(255 255 255 / 0.32);
  white-space: pre-line;
  cursor: pointer;
  transition: color var(--dur-panel) var(--ease-out);
}
.lyrics p.is-read { color: rgb(255 255 255 / 0.48); }
.lyrics p.is-now { color: var(--text); }
.lyrics__loading { color: var(--text-2); font-size: 15px; }

.player__meta { margin-top: var(--space-5); }
.player__chapter { font-size: 22px; font-weight: 600; line-height: 1.25; text-wrap: balance; overflow-wrap: anywhere; }
.player__story { color: var(--text-2); margin-top: var(--space-1); font-size: 15px; }

.deck {
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-4) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--glass);
  /* atelier-ok: glass (controles sobre a capa desfocada) */
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
          backdrop-filter: blur(24px) saturate(1.3);
}
.deck__times {
  display: flex;
  justify-content: space-between;
  margin-top: calc(var(--space-2) * -1);
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.controls { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-3); }
.ctl {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%; /* atelier-ok: radius-monotone */
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out);
}
.ctl:active { transform: scale(0.9); }
.ctl svg { width: 26px; height: 26px; }
.ctl[disabled] { opacity: 0.3; cursor: default; }
.play {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 50%; /* atelier-ok: radius-monotone */
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--dur-press) var(--ease-out);
}
.play:active { transform: scale(0.94); }
.play svg { width: 30px; height: 30px; }
.play .spin { width: 26px; height: 26px; }
.play[disabled] { opacity: 0.5; }

.player__status { min-height: 20px; margin-top: var(--space-3); font-size: 14px; color: var(--text-2); text-align: center; }
.player__status.is-error { color: var(--negative); }

.extras { display: flex; justify-content: space-around; margin-top: var(--space-2); }
.extra { display: grid; justify-items: center; gap: var(--space-1); min-width: 88px; padding: 0; border: 0; background: none; cursor: pointer; }
.extra .round { pointer-events: none; }
.extra .round svg { width: 20px; height: 20px; }
.extra__label { font-size: 12px; color: var(--text-2); max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.extra.is-on .round { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.extra.is-on .extra__label { color: var(--text); }

/* ---------- folha de opções ---------- */

.sheet {
  width: min(100%, 480px);
  max-width: none;
  margin: auto auto 0;
  padding: var(--space-3) var(--gutter) calc(var(--space-4) + var(--safe-b));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -16px 48px rgb(0 0 0 / 0.4);
}
.sheet::before { content: ""; display: block; width: 36px; height: 4px; margin: 0 auto var(--space-4); border-radius: 2px; background: var(--line-strong); }
.sheet::backdrop { background: rgb(0 0 0 / 0.55); }
.sheet[open] { animation: sheet-in var(--dur-panel) var(--ease-out); }
@keyframes sheet-in { from { transform: translateY(32px); opacity: 0; } }
.sheet__title { font-size: 28px; margin-bottom: var(--space-3); }
.sheet__options { display: grid; }
.option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 56px;
  padding: 0 var(--space-3);
  margin: 0 calc(var(--space-3) * -1);
  border: 0;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
}
.option + .option::before { content: ""; position: absolute; top: 0; left: var(--space-3); right: var(--space-3); height: 1px; background: var(--line); }
.option small { display: block; font-size: 13px; color: var(--text-3); }
.option[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.option svg { width: 20px; height: 20px; flex: none; }
.sheet__cancel { width: 100%; margin-top: var(--space-2); }

/* ---------- carregando ---------- */

.spin { animation: spin 0.9s linear infinite; } /* atelier-ok: infinite-loop (carregando) */
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: var(--raised); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- senha ---------- */

.login { padding-top: var(--space-12); }
.login__lead { margin-top: var(--space-3); color: var(--text-2); max-width: 36ch; }
.login .add__field { padding-left: var(--space-5); }
