:root {
  color-scheme: light;
  --chrome: #f3f3ed;
  --paper: #fffefa;
  --surface: #f5f5ee;
  --ink: #202b24;
  --muted: #5c675e;
  --edge: #e2e5dc;
  --control: #c9d1c6;
  --green: #245b43;
  --primary: #214a38;
  --inverse: #ffffff;
  --danger: #a12d24;
  --focus: #377555;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Avenir Next', system-ui, sans-serif;
  --player-height: 0px;
  font-family: var(--sans);
  font-size: 16px;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --chrome: #181a18;
  --paper: #202320;
  --surface: #282d28;
  --ink: #f2f1e8;
  --muted: #b8c2b6;
  --edge: #363e37;
  --control: #525f54;
  --green: #a9d7b5;
  --primary: #c8e6cc;
  --inverse: #15281d;
  --danger: #ffa196;
  --focus: #a9d7b5;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--chrome); color: var(--ink); }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, input, select, textarea { scroll-margin: 20px; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -.025em; }
h1 { font: 600 clamp(2.1rem, 4vw, 3.2rem)/1.12 var(--serif); letter-spacing: -.035em; }
h2 { font-size: 1.2rem; line-height: 1.35; }
h3 { font-size: 1rem; }
p { line-height: 1.6; }
svg { width: 20px; height: 20px; flex: 0 0 auto; }
small, .muted { color: var(--muted); }
.muted { font-size: .875rem; }
.visually-hidden, .skip:not(:focus) { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip:focus { position: fixed; top: 10px; left: 10px; background: var(--paper); padding: 10px; z-index: 15; }
.layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: calc(100dvh - var(--player-height)); margin-bottom: var(--player-height); }
.sidebar { position: sticky; top: 0; height: calc(100dvh - var(--player-height)); display: flex; flex-direction: column; padding: 25px 14px 16px; }
.brand { display: inline-flex; gap: 10px; align-items: center; width: fit-content; font: 700 1.5rem/1 var(--serif); }
.brand img { width: 38px; height: 38px; }
.sidebar .brand { margin: 0 0 40px 12px; }
#nav { display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; border-radius: 9px; padding: 0 12px; color: var(--muted); font-size: .9rem; font-weight: 600; white-space: nowrap; }
.nav-link:hover, .nav-link[aria-current=page] { background: var(--edge); color: var(--ink); }
.nav-link[aria-current=page] svg { color: var(--green); }
.nav-link svg { width: 18px; height: 18px; }
.sidebar-bottom { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid var(--edge); }
.account-btn { width: 100%; display: flex; align-items: center; text-align: left; gap: 10px; background: none; border: 0; border-radius: 8px; padding: 6px; min-height: 48px; }
.account-btn:hover { background: var(--edge); }
.account-btn strong, .account-btn small { display: block; }
.account-btn strong { font-size: .875rem; overflow-wrap: anywhere; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--edge); color: var(--green); flex: none; font-weight: 700; }
.workspace { min-width: 0; padding: 0 10px 10px 0; display: flex; flex-direction: column; }
.top { height: 70px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 0 17px; }
#search-form { display: flex; position: relative; align-items: center; gap: 10px; width: min(100%, 370px); margin-right: auto; padding: 0 12px; min-height: 42px; border: 1px solid var(--edge); background: var(--paper); border-radius: 30px; }
#search-icon { color: var(--muted); display: flex; }
#search-icon svg { width: 17px; height: 17px; }
#search { width: 100%; min-width: 0; border: 0; background: none; padding: 8px 0; font-size: .9rem; outline: none; }
#search-form:focus-within { border-color: var(--focus); }
kbd { font: inherit; font-size: .75rem; line-height: 20px; min-width: 20px; text-align: center; border: 1px solid var(--edge); border-radius: 5px; color: var(--muted); }
.mobile-brand, .mobile-account { display: none !important; }
#main { outline: 0; flex: 1; min-width: 0; background: var(--paper); border: 1px solid var(--edge); border-radius: 18px; padding: clamp(24px, 3.6vw, 48px); }
.page { max-width: 1100px; margin-inline: auto; min-width: 0; }
.page-header { margin: 0 0 25px; display: flex; justify-content: space-between; gap: 15px; align-items: end; }
.page-header p { margin-top: 9px; }
.section { margin-top: 29px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 12px; }
.section-head small { font-size: .85rem; }
.feature { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); min-height: 278px; border-radius: 22px; overflow: hidden; background: #183b30; color: #fffdf0; }
.feature-copy { padding: clamp(25px, 4vw, 48px); display: flex; flex-direction: column; align-items: start; justify-content: center; gap: 12px; }
.feature-copy h2 { font: 500 clamp(1.8rem, 3.2vw, 2.75rem)/1.1 var(--serif); letter-spacing: -.035em; max-width: 21ch; }
.feature-copy p { color: #d5e1d5; max-width: 48ch; font-size: .9rem; }
.feature-copy .eyebrow { color: #c1ddca; font-size: .84rem; }
.feature-copy .button { margin-top: 6px; background: #e7eadb; color: #183429; border-color: #e7eadb; }
.feature-image { background: #234739; width: 100%; height: 100%; object-fit: cover; min-height: 180px; }
.home-resume { margin-top: 0; }
.panel { background: var(--surface); border-radius: 16px; padding: 16px 18px; min-width: 0; }
.empty { padding: 18px; color: var(--muted); background: var(--surface); border-radius: 11px; font-size: .9rem; }
.panel .empty { padding: 0; }
.list { display: grid; min-width: 0; }
.list > * + * { border-top: 1px solid var(--edge); }
.row { display: flex; min-height: 66px; gap: 12px; align-items: center; padding: 9px 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.row-main strong { font-size: .95rem; line-height: 1.3; }
.row-main small { font-size: .8rem; }
.row a:not(.button):hover, a.row-main:hover { color: var(--green); }
.row-actions, .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions { justify-content: flex-end; }
.row-number { min-width: 31px; color: var(--muted); font: 1rem var(--serif); font-variant-numeric: tabular-nums; }
.cover { overflow: hidden; flex: none; width: 42px; aspect-ratio: 3 / 4; border-radius: 5px; background: #26493b; color: #ddeddb; display: grid; place-items: center; object-fit: cover; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover svg { width: 43%; height: auto; }
.cover-large { width: min(25vw, 168px); border-radius: 11px; }
.story-intro { display: flex; align-items: flex-start; gap: clamp(16px, 4vw, 35px); margin-top: 20px; }
.story-copy { flex: 1; min-width: 0; display: grid; gap: 12px; }
.story-copy h1 { overflow-wrap: anywhere; }
.story-copy .description { white-space: pre-wrap; max-width: 70ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { color: var(--muted); font-size: .8rem; border: 1px solid var(--edge); padding: 3px 9px; border-radius: 20px; }
.story-meta { display: flex; flex-wrap: wrap; gap: 6px 15px; align-items: center; }
.story-meta a, .text-link { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.button { background: var(--paper); border: 1px solid var(--control); border-radius: 22px; min-height: 42px; padding: 7px 14px; display: inline-flex; gap: 7px; align-items: center; justify-content: center; font-size: .875rem; font-weight: 650; line-height: 1.25; }
.button:hover, .icon-button:hover { background: var(--surface); }
.button.primary { background: var(--primary); color: var(--inverse); border-color: var(--primary); }
.button.danger { color: var(--danger); }
.button.small { min-height: 37px; padding: 5px 10px; }
.button svg { width: 16px; height: 16px; }
.icon-button { background: transparent; border: 0; border-radius: 50%; display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; }
.icon-button[aria-pressed=true] { color: var(--green); background: var(--surface); }
.icon-button[aria-pressed=true] svg { fill: currentColor; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field, .filters select, .filters input, .player-select { border: 1px solid var(--control); border-radius: 9px; min-height: 42px; padding: 7px 11px; background: var(--paper); }
.filters input { width: min(100%, 230px); }
.chapter-tools { margin-bottom: 8px; }
.library .row { padding-inline: 4px; }
.library .row-main strong { font-size: 1rem; }
.library .row-main small { font-size: .85rem; }
.library .cover { width: 48px; }
.progress-mini { display: block; margin-top: 3px; width: min(140px, 100%); height: 4px; appearance: none; border: 0; border-radius: 5px; background: var(--edge); color: var(--green); }
.progress-mini::-webkit-progress-bar { background: var(--edge); border-radius: 5px; }
.progress-mini::-webkit-progress-value { background: var(--green); border-radius: 5px; }
.progress-mini::-moz-progress-bar { background: var(--green); border-radius: 5px; }
.history-list { display: grid; gap: 14px; }
.history-series > .row { padding-top: 0; }
.history-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 5px 0 12px; }
.history-metric { min-width: 0; display: grid; align-content: start; gap: 4px; padding-inline: clamp(8px, 2vw, 18px); }
.history-metric:first-child { padding-inline-start: 0; }
.history-metric:last-child { padding-inline-end: 0; }
.history-metric + .history-metric { border-inline-start: 1px solid var(--edge); }
.history-metric > div { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0 6px; }
.history-metric span { color: var(--muted); font-size: .875rem; }
.history-metric strong { font-variant-numeric: tabular-nums; }
.history-metric progress { width: 100%; margin: 0; }
.history-resume, .history-series > .sleep-mark { border-top: 1px solid var(--edge); }
.history-resume .button { background: var(--primary); color: var(--inverse); border-color: var(--primary); }
.history-resume .button:hover { filter: brightness(.94); }
.history-series > .sleep-mark { min-height: 0; padding-block: 9px; flex-wrap: wrap; }
.sleep-mark .row-main { min-width: min(100%, 11rem); }
.history-activity { border-top: 1px solid var(--edge); }
.history-activity summary { padding-block: 12px; cursor: pointer; font-size: .875rem; }
.panel.history-series { padding-bottom: 4px; }
.status { color: var(--muted); padding: 13px 0; }
.error { color: var(--danger); }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; font-size: .875rem; font-weight: 600; min-width: 0; }
.form .field { width: 100%; }
.form textarea { min-height: 100px; resize: vertical; }
.form small { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .actions { margin-top: 6px; }
.form [role=alert] { color: var(--danger); font-size: .9rem; overflow-wrap: anywhere; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
.admin-grid .section { margin-top: 0; margin-bottom: 22px; }
.account-row { flex-wrap: wrap; }
.account-row .row-main { min-width: min(100%, 8rem); }
.account-row .row-actions { justify-content: flex-start; }
.storage-usage, .storage-usage dd { margin: 0; }
.storage-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: baseline; }
.storage-row + .storage-row { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--edge); }
.storage-row dd { text-align: right; font-variant-numeric: tabular-nums; }
.storage-bar { grid-column: 1 / -1; }
.storage-meter { display: block; width: 100%; height: 8px; accent-color: var(--green); }
dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 44px); border: 1px solid var(--edge); border-radius: 16px; background: var(--paper); color: var(--ink); padding: 20px; box-shadow: 0 16px 50px #0003; }
dialog::backdrop { background: #111a15a6; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: -6px -7px 10px 0; }
.key { width: 100%; font: .9rem/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
#toast { position: fixed; z-index: 11; left: 50%; bottom: calc(var(--player-height) + 18px); transform: translateX(-50%); background: var(--primary); color: var(--inverse); border-radius: 10px; padding: 10px 15px; width: max-content; max-width: calc(100% - 32px); font-size: .875rem; }
#toast:empty { display: none; }
#player { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 1px solid var(--edge); display: grid; grid-template-columns: minmax(150px, 1fr) minmax(230px, 2fr) minmax(0, 1fr); align-items: center; gap: 12px; padding: 8px 18px max(8px, env(safe-area-inset-bottom)); }
#player .row { min-height: 0; padding: 0; }
#player .row-main { gap: 1px; }
#player .row-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player .cover { width: 35px; }
.play-controls { display: flex; justify-content: center; gap: 4px; align-items: center; }
.play-controls button { height: 38px; width: 41px; }
.play-controls button.primary { height: 38px; width: 38px; padding: 0; }
.play-controls button small { font: 700 .78rem var(--sans); }
.play-controls .skip-back, .play-controls .skip-forward { font-weight: 700; font-size: .8rem; color: var(--muted); }
.play-seek { display: flex; align-items: center; gap: 7px; font: .75rem var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); }
.play-seek input { width: 100%; min-width: 0; accent-color: var(--green); margin: 0; }
.play-seek time { min-width: 34px; }
.play-seek time:last-child { text-align: right; }
.player-settings { display: flex; justify-content: flex-end; gap: 5px; flex-wrap: wrap; }
.player-settings button { font-size: .8rem; }
#sleep { white-space: nowrap; font-variant-numeric: tabular-nums; }
#sleep[aria-pressed=true] { color: var(--green); border-color: var(--green); }
.timer-panel { width: min(380px, calc(100% - 32px)); }
.timer-panel .dialog-head h2 { font-size: 1.25rem; }
.timer-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.timer-panel [data-timer] { min-height: 44px; padding-inline: 4px; }
.timer-panel [data-timer="0"] { width: 100%; }
.reader { max-width: 720px; margin-inline: auto; }
.reader .page-header { display: block; margin-top: 16px; }
.reader .page-header h1 { font-size: clamp(1.8rem, 4vw, 2.65rem); }
.reader-tools { justify-content: space-between; margin: 12px 0; }
.reader-body { color: var(--ink); min-height: 210px; line-height: 1.75; font-family: var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; padding: 16px 0 26px; }
.reader-foot { justify-content: space-between; border-top: 1px solid var(--edge); padding-top: 16px; }
.library-footer { padding: 12px 20px; color: var(--muted); font-size: .875rem; }
.library-footer a:hover, .privacy-page p a { text-decoration: underline; }
.privacy-page { width: min(100% - 40px, 36rem); margin-inline: auto; padding: 32px 0 72px; }
.privacy-page header { margin: clamp(40px, 9vw, 96px) 0 42px; }
.privacy-page header p { margin-top: 18px; }
.privacy-page section + section { margin-top: 32px; }
.privacy-page section p { margin-top: 12px; }
@media (max-width: 1090px) {
  .layout { display: flex; flex-direction: column; }
  .sidebar { height: auto; position: static; padding: 0 16px; order: 1; }
  .sidebar .brand, .sidebar-bottom { display: none; }
  #nav { display: flex; gap: 4px; overflow-x: auto; }
  .workspace { display: contents; }
  .top { height: 60px; padding-inline: 16px; order: 0; }
  #main { order: 2; margin: 6px 10px 10px; }
  .library-footer { order: 3; }
  .top .brand { flex: none; }
  #search-form { margin-left: auto; margin-right: 0; }
  .mobile-brand, .mobile-account { display: inline-flex !important; }
  .mobile-account { display: inline-grid !important; }
}
@media (max-width: 680px) {
  .workspace { padding: 0; }
  .sidebar { padding-inline: 10px; }
  .nav-link { font-size: .8rem; padding-inline: 8px; gap: 5px; }
  .nav-link svg { width: 15px; height: 15px; }
  #search-form { flex: 1 1 190px; min-width: 0; }
  .top { gap: 5px; padding: 0 10px; }
  .top .brand { font-size: 1.1rem; gap: 5px; white-space: nowrap; }
  .top .brand img { width: 28px; height: 28px; }
  .top .icon-button { width: 44px; }
  #search-form { min-height: 38px; gap: 5px; padding-inline: 9px; }
  #search { font-size: 1rem; }
  kbd { display: none; }
  #main { border-radius: 0; border-inline: 0; margin: 0; padding: 22px 16px; min-height: calc(100dvh - 106px - var(--player-height)); }
  .page-header { align-items: start; margin-bottom: 16px; }
  .page-header h1 { font-size: 1.9rem; }
  .page-header p { margin-top: 5px; }
  .feature { min-height: unset; grid-template-columns: minmax(0, 1fr); }
  .feature-image { grid-row: 1; height: 145px; min-height: 0; object-position: 65% 42%; }
  .feature-copy { padding: 18px 20px 21px; gap: 7px; }
  .feature-copy h2 { max-width: none; }
  .feature-copy p { font-size: .85rem; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .panel { padding: 12px 14px; }
  .history-metric > div { display: grid; }
  .row { gap: 8px; }
  .row-actions { gap: 4px; }
  .button, .button.small { min-height: 44px; }
  .button.small { padding-inline: 8px; }
  .row-number { min-width: 23px; }
  .story-intro { gap: 12px; }
  .story-copy h1 { font-size: 1.8rem; }
  .story-copy .description { font-size: .9rem; }
  .form-grid { grid-template-columns: 1fr; }
  .history-list { margin-top: 18px; }
  .history-metric span { font-size: .8rem; }
  .history-resume .row-main strong { line-height: 1.3; }
}
@media (max-width: 800px) {
  #player {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 1px 4px;
    padding: 6px max(12px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  #player .row { grid-area: 1 / 1 / 2 / -1; padding-inline-end: 106px; }
  #player .cover { width: 30px; }
  #player .row-main strong { font-size: .875rem; }
  #player .row-main small { font-size: .75rem; }
  .player-center, .player-settings { display: contents; }
  .play-seek { grid-area: 2 / 1 / 3 / -1; min-height: 28px; }
  .play-seek input { height: 26px; }
  .play-controls { grid-area: 3 / 2; gap: 0; }
  #player .play-controls button { height: 44px; min-width: 0; width: 42px; }
  #player .play-controls button.primary { flex: 0 0 44px; }
  #speed { grid-area: 3 / 1; padding-inline: 4px; }
  #sleep { grid-area: 1 / 1 / 2 / -1; justify-self: end; }
  #player [popovertarget="play-settings"] { grid-area: 3 / 3; }
  .timer-panel {
    inset: auto 0 0;
    margin: 0 auto;
    width: min(100%, 430px);
    max-width: none;
    border-radius: 16px 16px 0 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}
.player-menu { position: fixed; inset: auto 14px calc(var(--player-height) + 8px) auto; width: min(260px, calc(100% - 28px)); margin: 0; background: var(--paper); color: var(--ink); border: 1px solid var(--edge); border-radius: 12px; padding: 12px; box-shadow: 0 8px 25px #0002; }
.player-menu:popover-open { display: flex; flex-wrap: wrap; gap: 6px; }
.player-menu strong, .play-option { width: 100%; padding: 4px 0; font-size: .875rem; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form .check input { accent-color: var(--green); width: 17px; height: 17px; flex: none; }
.feature-copy h2, .page-header h1 { overflow-wrap: anywhere; }

@media (max-width: 420px) {
  .nav-link svg { display: none; }
  #nav { justify-content: space-between; }
}
@media (max-width: 350px) {
  .top .brand { font-size: 1rem; }
  .top .brand img { width: 24px; height: 24px; }
  #search-icon { display: none; }
  #nav { gap: 0; }
  .nav-link { font-size: .75rem; padding-inline: 6px; }
}
.pager { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding-top: 16px; border-top: 1px solid var(--edge); }
