:root {
  --apple-canvas: #03040d;
  --apple-panel: rgba(17, 18, 35, 0.72);
  --apple-panel-strong: rgba(20, 21, 42, 0.9);
  --apple-line: rgba(255, 255, 255, 0.12);
  --apple-line-soft: rgba(255, 255, 255, 0.075);
  --apple-text: #f5f5f7;
  --apple-muted: #a1a1aa;
  --apple-blue: #2997ff;
  --apple-purple: #a65cff;
  --apple-pink: #ff3b9d;
  --apple-green: #4ee29a;
  --apple-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --apple-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", sans-serif;
}

html {
  background: var(--apple-canvas);
}

body {
  color: var(--apple-text);
  background:
    radial-gradient(900px 620px at -4% 0%, rgba(42, 114, 255, 0.18), transparent 67%),
    radial-gradient(820px 640px at 104% 20%, rgba(211, 43, 184, 0.14), transparent 69%),
    linear-gradient(155deg, #02030a 0%, #07091a 52%, #03040d 100%);
  font-family: var(--apple-font);
  letter-spacing: -0.012em;
}

body::before {
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 80px 80px;
}

button,
input,
textarea,
select {
  font-family: var(--apple-font);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(41, 151, 255, 0.72);
  outline-offset: 3px;
}

/* Shared creator/legal header */
body > header {
  width: min(1400px, calc(100% - 28px));
  height: 64px;
  margin: 14px auto 0;
  padding: 7px 10px 7px 14px;
  border: 1px solid var(--apple-line);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), transparent 45%),
    rgba(10, 11, 25, 0.74);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 16px 48px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(30px) saturate(155%);
  -webkit-backdrop-filter: blur(30px) saturate(155%);
}

body > header .brand {
  min-width: 0;
  gap: 9px;
  padding: 0;
  font-size: 17px;
  letter-spacing: -0.035em;
}

body > header .brand img {
  width: 38px;
  height: 36px;
  filter: drop-shadow(0 8px 14px rgba(64, 93, 255, 0.24));
}

body > header .brand em {
  color: transparent;
  background: linear-gradient(90deg, #ad69ff, #ff4ca5);
  background-clip: text;
  -webkit-background-clip: text;
}

.back-link,
.back,
.account-link {
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--apple-line-soft);
  border-radius: 14px;
  color: #d0d0d7;
  background: rgba(255, 255, 255, 0.045);
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.back-link:hover,
.back:hover,
.account-link:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.085);
  transform: translateY(-1px);
}

.toast {
  border-color: rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  background: rgba(24, 25, 48, 0.9);
  box-shadow: var(--apple-shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* Account */
.auth-story .free-badge,
.section-kicker,
.kicker,
.legal-content > span,
.form-heading > span,
.connected-card > small {
  letter-spacing: 0.13em;
}

.auth-story h1 {
  max-width: 760px;
  font-size: clamp(58px, 6vw, 88px);
  line-height: 0.96;
  letter-spacing: -0.068em;
}

.auth-story h1 span {
  background-image: linear-gradient(92deg, #60a5ff 4%, #ae6cff 52%, #ff4da8 96%);
}

.auth-story > p {
  color: #b6b6bf;
  font-size: clamp(17px, 1.4vw, 20px);
}

.auth-story li > span {
  border-color: rgba(78, 226, 154, 0.25);
  color: var(--apple-green);
  background: rgba(78, 226, 154, 0.095);
}

.story-card,
.auth-card {
  border-color: var(--apple-line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.075), transparent 35%),
    var(--apple-panel);
  box-shadow: var(--apple-shadow), 0 1px 0 rgba(255, 255, 255, 0.07) inset;
  backdrop-filter: blur(30px) saturate(145%);
  -webkit-backdrop-filter: blur(30px) saturate(145%);
}

.story-card {
  border-radius: 20px;
}

.story-covers img {
  border-color: rgba(12, 13, 27, 0.9);
  border-radius: 12px;
}

.auth-card {
  width: min(510px, 100%);
  padding: 14px 38px 36px;
  border-radius: 28px;
}

.panel-glow {
  inset-inline: 0;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(125deg, rgba(41, 151, 255, 0.52), rgba(166, 92, 255, 0.1) 46%, rgba(255, 59, 157, 0.46));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.auth-card .tabs,
.periods {
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.auth-card .tab {
  min-height: 44px;
  border-radius: 11px;
}

.auth-card .tab.active,
.periods button.active {
  background: rgba(255, 255, 255, 0.11);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.form-heading h2,
.connected-card h2 {
  letter-spacing: -0.045em;
}

.field,
.account-settings input,
.edit-grid input,
.edit-grid select,
.edit-grid textarea {
  border-color: rgba(255, 255, 255, 0.105);
  border-radius: 14px;
  background: rgba(2, 3, 13, 0.62);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset;
}

.field:focus-within,
.account-settings input:focus,
.edit-grid input:focus,
.edit-grid select:focus,
.edit-grid textarea:focus {
  border-color: rgba(41, 151, 255, 0.68);
  box-shadow: 0 0 0 4px rgba(41, 151, 255, 0.12);
}

.primary-button,
.primary-action,
.field button,
.preview-actions button:last-child,
.dialog-actions .save-edit,
.gate a,
.account-settings form button {
  border-radius: 14px;
  background: linear-gradient(112deg, #168bff 0%, #7c49ff 52%, #f8329a 100%);
  box-shadow: 0 13px 34px rgba(92, 57, 238, 0.25), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.secondary-button,
.account-settings,
.delete-account {
  border-color: var(--apple-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

/* Studio dashboard */
.sidebar {
  inset: 12px auto 12px 12px;
  width: 246px;
  padding: 20px 14px 17px;
  border: 1px solid var(--apple-line);
  border-radius: 26px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.055), transparent 28%),
    rgba(9, 10, 25, 0.86);
  box-shadow: var(--apple-shadow), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
}

.sidebar .brand {
  padding: 1px 8px 25px;
  letter-spacing: -0.035em;
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.sidebar-close {
  display: none;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--apple-line-soft);
  border-radius: 12px;
  color: #d7d7de;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  font-size: 22px;
  line-height: 1;
}

.sidebar nav {
  gap: 4px;
}

.sidebar nav a {
  min-height: 47px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 12px;
  transition: 180ms ease;
}

.sidebar nav a:hover {
  border-color: rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar nav a.active {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 9px 26px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.07) inset;
}

.sidebar nav a.active::after {
  content: "";
  width: 5px;
  height: 5px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--apple-pink);
  box-shadow: 0 0 12px rgba(255, 59, 157, 0.85);
}

.sidebar-help {
  border-color: rgba(166, 92, 255, 0.22);
  border-radius: 18px;
  background: rgba(166, 92, 255, 0.07);
}

.app-shell {
  margin-left: 270px;
}

.topbar {
  top: 12px;
  height: 62px;
  margin: 0 12px;
  padding: 0 16px;
  border: 1px solid var(--apple-line);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 48%),
    rgba(9, 10, 25, 0.76);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
}

.notification,
.user-chip,
.mobile-menu,
.search,
.panel-tools > button,
.row-actions a,
.row-actions button,
.demo-feed,
.preview-actions button,
.dialog-head button,
.dialog-actions button {
  border-color: var(--apple-line-soft);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.045) inset;
}

.notification,
.mobile-menu {
  border-radius: 12px;
}

.user-chip {
  border-radius: 14px;
}

.welcome {
  margin-bottom: 30px;
}

.welcome h1,
.page-head h1,
.import-copy h2,
.legal-content h1 {
  letter-spacing: -0.052em;
}

.welcome h1 {
  font-size: clamp(38px, 4vw, 52px);
}

.metric-grid {
  gap: 15px;
  margin-bottom: 24px;
}

.metric-grid article,
.podcast-panel,
.activity-panel,
.import-section,
.import-card,
.chart-card,
.completion-card,
.performance-card,
.top-card,
.kpi-grid article,
.gate > div,
.edit-dialog {
  border-color: var(--apple-line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), transparent 36%),
    var(--apple-panel);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}

.metric-grid article,
.kpi-grid article {
  border-radius: 20px;
}

.metric-grid article {
  min-height: 118px;
}

.metric-icon {
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.16), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.podcast-panel,
.activity-panel,
.import-section {
  border-radius: 24px;
}

.podcast-row {
  border-color: rgba(255, 255, 255, 0.045);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.podcast-row:hover {
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.podcast-row img {
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
}

.import-card {
  border-radius: 20px;
}

.drop-zone {
  border-color: rgba(166, 92, 255, 0.34);
  border-radius: 17px;
  background: rgba(166, 92, 255, 0.055);
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.drop-zone:hover {
  border-color: rgba(166, 92, 255, 0.62);
  background: rgba(166, 92, 255, 0.095);
  transform: translateY(-1px);
}

.edit-dialog {
  border-radius: 24px;
}

/* Statistics */
body > header nav {
  margin: auto;
  padding: 4px;
  gap: 2px;
  border: 1px solid var(--apple-line-soft);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.04);
}

body > header nav a {
  min-height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  color: #9d9da8;
}

body > header nav a:hover,
body > header nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.account-link {
  padding: 4px 8px 4px 4px;
}

.account-link span {
  border-radius: 11px;
  box-shadow: 0 8px 18px rgba(92, 57, 238, 0.23);
}

.page-head h1 {
  font-size: clamp(42px, 4.4vw, 62px);
}

.periods {
  padding: 4px;
  border-radius: 13px;
}

.periods button {
  min-height: 36px;
  border-radius: 10px;
}

.export {
  min-height: 45px;
  border-radius: 13px;
  background:
    linear-gradient(rgba(16, 17, 35, 0.9), rgba(16, 17, 35, 0.9)) padding-box,
    linear-gradient(105deg, #2997ff, #9858ff, #ff3b9d) border-box;
}

.kpi-grid {
  gap: 15px;
}

.kpi-grid article {
  min-height: 128px;
}

.chart-card,
.completion-card,
.performance-card,
.top-card {
  border-radius: 24px;
}

.chart {
  border-color: rgba(255, 255, 255, 0.08);
  background-image: linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
}

.donut {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 20px 45px rgba(0, 0, 0, 0.25);
}

.donut::after {
  background: #101124;
}

/* Legal reading experience */
.legal-shell {
  width: min(1180px, calc(100% - 48px));
  padding-top: 54px;
  gap: 54px;
}

.legal-nav {
  top: 96px;
  padding: 12px;
  border-color: var(--apple-line);
  border-radius: 20px;
  background: var(--apple-panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.legal-nav strong {
  padding: 8px 9px;
  color: #74747e;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.legal-nav a {
  min-height: 42px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 11px;
  transition: 160ms ease;
}

.legal-nav a:hover,
.legal-nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.075);
}

.legal-content {
  padding: clamp(26px, 4.4vw, 52px);
  border: 1px solid var(--apple-line);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.045), transparent 32%),
    rgba(12, 13, 28, 0.58);
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.045) inset;
}

.legal-content h1 {
  font-size: clamp(42px, 5vw, 64px);
}

.legal-content > .intro {
  color: #b5b5be;
  font-size: 16px;
}

.legal-content section {
  border-color: rgba(255, 255, 255, 0.085);
}

.legal-content h2 {
  letter-spacing: -0.025em;
}

.legal-content p,
.legal-content li {
  color: #a7a7b0;
  font-size: 13px;
}

.notice {
  border-color: rgba(255, 184, 76, 0.2);
  border-radius: 16px;
  background: rgba(255, 175, 55, 0.055);
}

footer {
  border-color: rgba(255, 255, 255, 0.075);
}

@media (max-width: 980px) {
  body > header {
    width: calc(100% - 24px);
    margin-top: 12px;
  }

  .auth-story h1 {
    max-width: none;
  }
}

@media (max-width: 850px) {
  .app-shell {
    margin-left: 0;
  }

  .sidebar {
    inset: 10px auto 10px 10px;
    width: min(310px, calc(100vw - 20px));
    transform: translateX(calc(-100% - 20px));
  }

  .sidebar .brand {
    padding-bottom: 25px;
  }

  .sidebar-close {
    display: grid;
    place-items: center;
  }

  .menu-open .sidebar {
    width: min(310px, calc(100vw - 20px));
  }

  body.menu-open::after {
    content: "";
    position: fixed;
    z-index: 25;
    inset: 0;
    background: rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .topbar {
    top: 10px;
    margin: 0 10px;
  }
}

@media (max-width: 760px) {
  body > header {
    top: 8px;
    height: 60px;
    margin-top: 8px;
    padding-inline: 9px;
    border-radius: 19px;
  }

  body > header .brand {
    font-size: 15px;
  }

  .back-link,
  .back {
    min-height: 40px;
    padding: 0 11px;
    font-size: 11px;
  }

  .legal-shell {
    width: calc(100% - 24px);
    padding-top: 28px;
    gap: 18px;
  }

  .legal-nav {
    position: static;
    margin: 0;
    padding: 6px;
    border-radius: 16px;
  }

  .legal-nav a {
    min-height: 42px;
    flex: 0 0 auto;
    padding-inline: 12px;
  }

  .legal-content {
    padding: 26px 20px;
    border-radius: 22px;
  }
}

@media (max-width: 700px) {
  body > header nav {
    display: none;
  }

  .page-head h1 {
    font-size: clamp(38px, 12vw, 50px);
  }

  .head-actions {
    gap: 8px;
  }

  .kpi-grid article,
  .metric-grid article {
    border-radius: 18px;
  }

  .chart-card,
  .completion-card,
  .performance-card,
  .top-card,
  .podcast-panel,
  .activity-panel,
  .import-section {
    border-radius: 20px;
  }
}

@media (max-width: 600px) {
  .topbar {
    height: 60px;
    padding-inline: 10px;
    border-radius: 18px;
  }

  .welcome h1 {
    font-size: 38px;
  }

  .auth-card {
    padding: 11px 20px 28px;
    border-radius: 24px;
  }

  .auth-story h1 {
    font-size: clamp(47px, 14vw, 58px);
  }
}

@media (max-width: 380px) {
  body > header {
    width: calc(100% - 16px);
    padding-inline: 8px;
  }

  body > header .brand img {
    width: 34px;
    height: 32px;
  }

  .back-link,
  .back {
    min-width: 68px;
    font-size: 0;
  }

  .back-link::after,
  .back::after {
    content: "← Retour";
    font-size: 11px;
    white-space: nowrap;
  }

  .legal-content {
    padding: 23px 17px;
  }
}

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