@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,650;9..144,700&family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --ink: #12263a;
  --ink-soft: #2a3f55;
  --muted: #5b6b7c;
  --line: rgba(18, 38, 58, 0.12);
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-soft: #eef3f6;
  --brand: #0a5c63;
  --brand-deep: #07454a;
  --brand-soft: rgba(10, 92, 99, 0.1);
  --listen: #b7791f;
  --listen-soft: rgba(183, 121, 31, 0.14);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);
  --success: #0f766e;
  --bg: #edf2f5;
  --bg-2: #dfe8ee;
  --shadow: 0 18px 40px rgba(18, 38, 58, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --text: var(--ink);
  --accent: var(--brand);
  --panel: var(--surface);
  --panel-solid: var(--surface-solid);
  --panel-soft: var(--surface-soft);
  --border: var(--line);
}

[data-theme="dark"] {
  --ink: #eef4f7;
  --ink-soft: #d5e0e8;
  --muted: #9db0bf;
  --line: rgba(238, 244, 247, 0.14);
  --surface: rgba(16, 28, 40, 0.88);
  --surface-solid: #132233;
  --surface-soft: #1a3044;
  --brand: #3db8c1;
  --brand-deep: #2a9aa2;
  --brand-soft: rgba(61, 184, 193, 0.16);
  --listen: #e0a53a;
  --listen-soft: rgba(224, 165, 58, 0.16);
  --danger: #f97066;
  --danger-soft: rgba(249, 112, 102, 0.14);
  --success: #2dd4bf;
  --bg: #0c1520;
  --bg-2: #132233;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --text: var(--ink);
  --accent: var(--brand);
  --panel: var(--surface);
  --panel-solid: var(--surface-solid);
  --panel-soft: var(--surface-soft);
  --border: var(--line);
}

[data-theme="high_contrast"],
[data-theme="high-contrast"] {
  --ink: #000;
  --ink-soft: #111;
  --muted: #222;
  --line: #000;
  --surface: #fff;
  --surface-solid: #fff;
  --surface-soft: #f2f2f2;
  --brand: #000;
  --brand-deep: #000;
  --brand-soft: #eee;
  --listen: #000;
  --listen-soft: #eee;
  --danger: #900;
  --danger-soft: #fee;
  --success: #060;
  --bg: #fff;
  --bg-2: #fff;
  --shadow: none;
  --text: #000;
  --accent: #000;
  --panel: #fff;
  --panel-solid: #fff;
  --panel-soft: #f2f2f2;
  --border: #000;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 55% at 10% -10%, rgba(10, 92, 99, 0.16), transparent 55%),
    radial-gradient(ellipse 60% 45% at 100% 0%, rgba(183, 121, 31, 0.1), transparent 50%),
    linear-gradient(165deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

.page,
.reader-app {
  position: relative;
  z-index: 1;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* —— Topbar —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 32px;
}

.brand-link {
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

/* —— Buttons —— */
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--brand);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover,
button:hover:not(:disabled) {
  background: var(--brand-deep);
  transform: translateY(-1px);
}

.btn:active,
button:active:not(:disabled) {
  transform: translateY(0);
}

.btn.secondary,
button.secondary {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.secondary:hover,
button.secondary:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: rgba(10, 92, 99, 0.28);
}

.btn.danger,
button.danger {
  color: #fff;
  background: var(--danger);
}

.btn.success,
button.success {
  color: #fff;
  background: var(--success);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

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

/* —— Forms —— */
.form {
  display: grid;
  gap: 16px;
  max-width: 520px;
}

.form.wide { max-width: none; }

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  color: var(--text);
  outline: none;
  padding: 13px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 280px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.alert,
.notice {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

.alert {
  border: 1px solid rgba(180, 35, 24, 0.25);
  background: var(--danger-soft);
  color: var(--danger);
}

.notice {
  border: 1px solid rgba(10, 92, 99, 0.18);
  background: var(--brand-soft);
  color: var(--ink-soft);
}

.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }

/* —— App panels (interaction surfaces) —— */
.card,
.panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.page > .card + .card { margin-top: 20px; }

.card h1,
.panel h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.card h2,
.panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.card p,
.panel p {
  color: var(--muted);
  line-height: 1.55;
}

/* —— Library table —— */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th,
.table td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: var(--brand-soft);
}

.table strong {
  font-weight: 700;
  color: var(--ink);
}

.progress-chip {
  display: inline-flex;
  align-items: center;
  min-width: 3.2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--brand-deep);
}

/* —— Auth layout —— */
body.auth-page {
  display: grid;
  align-items: stretch;
}

.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.auth-visual {
  position: relative;
  overflow: hidden;
  padding: 48px;
  color: #f4fafb;
  background:
    radial-gradient(circle at 20% 20%, rgba(61, 184, 193, 0.35), transparent 40%),
    linear-gradient(155deg, #07454a 0%, #12263a 55%, #0a5c63 100%);
}

.auth-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(transparent 0%, transparent 48%, rgba(18, 38, 58, 0.15) 49%, transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(255, 255, 255, 0.035) 28px,
      rgba(255, 255, 255, 0.035) 29px
    );
  opacity: 0.9;
}

.auth-visual-inner {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin-top: 18vh;
  animation: rise 0.7s ease both;
}

.auth-visual .brand-mark {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.auth-visual p {
  margin: 0;
  color: rgba(244, 250, 251, 0.78);
  font-size: 1.05rem;
  line-height: 1.55;
}

.auth-panel {
  display: grid;
  align-content: center;
  padding: 48px 40px;
  background: rgba(255, 255, 255, 0.55);
}

[data-theme="dark"] .auth-panel {
  background: rgba(12, 21, 32, 0.72);
}

.auth-panel .form { max-width: 400px; }
.auth-panel .topbar { margin-bottom: 28px; }
.auth-switch {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}
.auth-switch a {
  color: var(--brand-deep);
  font-weight: 700;
  text-decoration: none;
}

/* —— Marketing landing —— */
body.marketing {
  background:
    radial-gradient(ellipse 90% 70% at 70% 10%, rgba(10, 92, 99, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 40% at 0% 80%, rgba(183, 121, 31, 0.12), transparent 50%),
    linear-gradient(180deg, #e7eef3 0%, #f3f6f8 45%, #e8eef2 100%);
}

.site-nav {
  position: relative;
  z-index: 2;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-nav .brand-link {
  font-size: 1.05rem;
}

.hero-bleed {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: stretch;
  overflow: hidden;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 6vw, 72px) clamp(24px, 5vw, 64px) clamp(40px, 7vw, 80px);
  max-width: 640px;
}

.hero-brand {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 8vw, 5.6rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--ink);
  animation: rise 0.75s ease both;
}

.hero-brand span {
  display: block;
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero-copy h1 {
  margin: 0 0 16px;
  max-width: 18ch;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3.2vw, 2.15rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink-soft);
  animation: rise 0.75s ease 0.08s both;
}

.hero-copy .lede {
  margin: 0 0 28px;
  max-width: 36ch;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
  animation: rise 0.75s ease 0.16s both;
}

.hero-copy .actions {
  animation: rise 0.75s ease 0.24s both;
}

.hero-visual {
  position: relative;
  min-height: 520px;
  background:
    radial-gradient(circle at 70% 30%, rgba(61, 184, 193, 0.22), transparent 40%),
    linear-gradient(145deg, #0a5c63 0%, #12263a 48%, #07454a 100%);
  animation: ambient 12s ease-in-out infinite alternate;
}

.hero-visual-frame {
  position: absolute;
  inset: 10% 8% 12% 10%;
  padding: 28px 26px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.hero-visual-frame::before {
  content: "Listening session";
  display: block;
  margin-bottom: 18px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.wave {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 42px;
  margin-bottom: 22px;
}

.wave span {
  width: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  animation: pulseBar 1.4s ease-in-out infinite;
}

.wave span:nth-child(1) { height: 28%; animation-delay: 0s; }
.wave span:nth-child(2) { height: 58%; animation-delay: 0.1s; }
.wave span:nth-child(3) { height: 90%; animation-delay: 0.2s; }
.wave span:nth-child(4) { height: 46%; animation-delay: 0.3s; }
.wave span:nth-child(5) { height: 72%; animation-delay: 0.4s; }
.wave span:nth-child(6) { height: 38%; animation-delay: 0.5s; }
.wave span:nth-child(7) { height: 64%; animation-delay: 0.15s; }
.wave span:nth-child(8) { height: 84%; animation-delay: 0.25s; }

.hero-line {
  height: 10px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.hero-line.short { width: 62%; }
.hero-line.active {
  width: 78%;
  background: linear-gradient(90deg, rgba(224, 165, 58, 0.95), rgba(61, 184, 193, 0.85));
  box-shadow: 0 0 24px rgba(224, 165, 58, 0.35);
}

.section {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 72px 24px;
}

.section h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.section > p {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.section-split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}

.feature-list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.feature-list li {
  padding: 16px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.45;
}

.feature-list li span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.section-cta {
  text-align: center;
  padding-bottom: 96px;
}

.section-cta .brand-inline {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
  color: var(--muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--line);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseBar {
  0%, 100% { transform: scaleY(0.55); opacity: 0.55; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes ambient {
  from { filter: saturate(1); }
  to { filter: saturate(1.08) brightness(1.04); }
}

/* —— PWA install bar —— */
.pwa-install-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.pwa-install-bar.is-visible {
  display: flex;
}

.pwa-install-actions .btn {
  position: relative;
  z-index: 1;
  cursor: pointer;
  pointer-events: auto;
}

[data-theme="dark"] .pwa-install-bar {
  background: rgba(16, 28, 40, 0.96);
}

.pwa-install-copy {
  display: grid;
  gap: 2px;
  min-width: 200px;
  flex: 1;
}

.pwa-install-copy strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.pwa-install-copy span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.pwa-install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.reader-page .pwa-install-bar {
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 960px) {
  .hero-bleed,
  .auth-shell,
  .section-split {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    min-height: 380px;
    order: -1;
  }

  .auth-visual {
    min-height: 280px;
    padding: 32px 24px;
  }

  .auth-visual-inner { margin-top: 24px; }
  .auth-panel { padding: 32px 24px 48px; }
}

@media (max-width: 820px) {
  .page { padding: 18px 16px 48px; }
  .topbar,
  .site-nav {
    align-items: flex-start;
    flex-direction: column;
  }
  .table,
  .table tbody,
  .table tr,
  .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table td {
    padding: 8px 0;
    border-bottom: 0;
  }
  .table tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }
}
