/* Davraz themes — White (default), Dark, Sepia.
   Shared by index.html and blog.html. theme.js sets <html data-theme="white|dark|sepia">.

   Naming: --bg is the page, --surface is a card/input/dropdown sitting on it, --mist is a subtle fill
   (table header, code chip, hover). Text steps down --ink > --body > --muted.
   Anything that is ALWAYS white (text on --navy / --accent fills) is written as #fff in the page CSS. */

/* ---------- 1. WHITE (default; also the no-JS fallback) ---------- */
:root,
:root[data-theme="white"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --mist: #F4F7FA;
  --line: #D9E0E8;
  --ink: #0E1216;
  --body: #48535F;
  --muted: #5C6B7A;
  --silver: #B9C2CC;
  --on-navy-accent: #5B9BD5;   /* accent text sitting on a --navy fill (eyebrows, check marks) */
  --on-navy-muted: #B9C2CC;    /* secondary text sitting on a --navy fill */
  --steel: #2C5F8D;
  --steel-light: #5B9BD5;
  --accent: #E07B39;
  --accent-hover: #c96a2c;
  --navy: #0A1A2F;
  --nav-bg: rgba(255, 255, 255, .96);
  --scrim: rgba(10, 26, 47, .45);
  --ok: #1f7a45;      --ok-bg: #e5f6eb;      --ok-ink: #146c36;   --ok-line: #c3e6cb;
  --danger: #a33b32;  --danger-bg: #fdecea;                       --danger-line: #f0d0cb;
  --warn-bg: #fff4d6; --warn-ink: #7a5b10;                        --warn-line: #f0e0c2;
  --pre-bg: #F4F7FA;
  --logo-1: #16385C;  --logo-2: #2C5F8D;     --logo-3: #5B9BD5;
  /* code highlighting */
  --hl-comment: #5E6B7A; --hl-keyword: #B0342B; --hl-string: #1F7A45; --hl-number: #A65200;
  --hl-title: #2C5F8D;   --hl-attr: #8A3FA0;    --hl-builtin: #0B7285;
}

/* ---------- 2. DARK ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F141A;
  --surface: #161D26;
  --mist: #1C2530;
  --line: #2A3643;
  --ink: #E7ECF1;
  --body: #B7C2CE;
  --muted: #8E9BAA;
  --silver: #96A3B1;
  --on-navy-accent: #8EBDE8;
  --on-navy-muted: #B4C0CC;
  --steel: #6FA8DC;
  --steel-light: #8EBDE8;
  --accent: #E07B39;
  --accent-hover: #ee8b4a;
  --navy: #1B3A5F;
  --nav-bg: rgba(15, 20, 26, .94);
  --scrim: rgba(0, 0, 0, .6);
  --ok: #2FA36B;      --ok-bg: #12301F;      --ok-ink: #7FE0AE;   --ok-line: #1E4D33;
  --danger: #E5645B;  --danger-bg: #3A1A18;                       --danger-line: #5A2A27;
  --warn-bg: #3A2D12; --warn-ink: #F0C46A;                        --warn-line: #5A4620;
  --pre-bg: #0B1016;
  --logo-1: #2A5A8C;  --logo-2: #4A82B8;     --logo-3: #7DB4E6;
  --hl-comment: #8896A5; --hl-keyword: #FF7B72; --hl-string: #8FD19E; --hl-number: #F2A65A;
  --hl-title: #79C0FF;   --hl-attr: #D2A8FF;    --hl-builtin: #7EE0D2;
}

/* ---------- 3. SEPIA (page #F4ECD8) ---------- */
:root[data-theme="sepia"] {
  color-scheme: light;
  --bg: #F4ECD8;
  --surface: #FAF4E3;
  --mist: #EDE3C9;
  --line: #D9CCAA;
  --ink: #3B2F1E;
  --body: #5A4B34;
  --muted: #6E5E42;
  --silver: #786A4D;
  --on-navy-accent: #E0A877;
  --on-navy-muted: #CDBE9E;
  --steel: #8A4B1D;
  --steel-light: #A8683A;
  --accent: #B5541F;
  --accent-hover: #9A4619;
  --navy: #3B2F1E;
  --nav-bg: rgba(244, 236, 216, .94);
  --scrim: rgba(59, 47, 30, .45);
  --ok: #2F6B3F;      --ok-bg: #E1EBCF;      --ok-ink: #2A5E38;   --ok-line: #C4D5A6;
  --danger: #9A3A2E;  --danger-bg: #F3D9CC;                       --danger-line: #E3BBA8;
  --warn-bg: #F1DFA9; --warn-ink: #6B4E0F;                        --warn-line: #DEC987;
  --pre-bg: #EDE3C9;
  --logo-1: #6B4A2B;  --logo-2: #9A6B3F;     --logo-3: #C79A66;
  --hl-comment: #6F6044; --hl-keyword: #9A3A2E; --hl-string: #3F6B2F; --hl-number: #9A5210;
  --hl-title: #7A4A1E;   --hl-attr: #7B3F86;    --hl-builtin: #2F6B73;
}

/* ---------- Header theme button (markup: <button data-theme-toggle class="theme-btn">; theme.js fills the icon) ---------- */
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.theme-btn:hover { border-color: var(--steel); color: var(--steel); }
.theme-btn:focus-visible { outline: 2px solid var(--steel-light); outline-offset: 2px; }
.theme-btn svg { width: 17px; height: 17px; display: block; }

/* Smooth the switch, but never for people who ask for less motion */
@media (prefers-reduced-motion: no-preference) {
  body, .nav, .post-card, .article, .sheet, .form-card, footer { transition: background-color .2s, border-color .2s, color .2s; }
}

/* ---------- New Top Bar Layout ---------- */
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 100%; padding: 0 16px; white-space: nowrap; }
.nav-left { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.hamburger-btn { background: none; border: none; cursor: pointer; font-size: 1.5rem; color: var(--ink); padding: 0; display: flex; align-items: center; transition: opacity 0.2s; }
.hamburger-btn:hover { opacity: 0.7; }
.nav-search { flex-grow: 1; max-width: 400px; margin: 0 auto; }
.nav-search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-family: var(--sans); font-size: 0.9rem; outline: none; transition: border-color 0.2s; }
.nav-search input:focus { border-color: var(--steel); }
@media (max-width: 600px) { .nav-search { display: none; } }

/* ---------- Fix Nav Layout ---------- */
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 100%; padding: 0 20px; }
.nav-left { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.nav-search { flex-grow: 1; max-width: 400px; margin: 0 20px; }
.nav-search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-family: var(--sans); font-size: 0.9rem; outline: none; }
.nav-search input:focus { border-color: var(--steel); }
.hamburger-btn { background: none; border: none; cursor: pointer; font-size: 1.4rem; color: var(--ink); padding: 0; display: flex; align-items: center; }
.hamburger-btn:hover { opacity: 0.7; }

/* Hide search only on small screens */
@media (max-width: 768px) { 
  .nav-search { display: none; } 
}

.nav-icon-btn { background: none; border: 1px solid var(--line); border-radius: 50%; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); padding: 0; }
.nav-icon-btn:hover { border-color: var(--steel); }
.nav-icon-btn svg { width: 16px; height: 16px; }
.search-dropdown { display: none; position: absolute; top: 100%; right: 16px; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); z-index: 100; width: 320px; }
.search-dropdown.is-open { display: block; }
.search-dropdown input { width: 100%; padding: 10px 14px; font-size: 0.95rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); outline: none; }
.search-dropdown input:focus { border-color: var(--steel); }

    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}
    padding: 0 16px !important;
    border-radius: 999px !important;
    border: 1px solid #d1c5b4 !important;
    background-color: #fdfaf6 !important;
    color: #6b6359 !important;
    font-family: inherit !important;
    font-size: .75rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    cursor: pointer !important;
}
    border-color: #4a7c59 !important;
    color: #4a7c59 !important;
    background-color: rgba(74, 124, 89, 0.08) !important;
}
    border-color: #4a7c59 !important;
    color: #4a7c59 !important;
}
.article-meta { display: flex !important; align-items: center !important; gap: 12px !important; flex-wrap: wrap !important; }
.article-meta .author-link { display: inline-flex !important; align-items: center !important; margin-right: auto !important; }
.article-meta button.tts-btn, .article-meta button.read-toggle { height: 32px !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; box-sizing: border-box !important; margin: 0 !important; }
.article-meta button.read-toggle { padding: 0 16px !important; border-radius: 999px !important; border: 1px solid var(--line) !important; background-color: var(--surface) !important; color: var(--ink) !important; font-family: inherit !important; font-size: .75rem !important; font-weight: 700 !important; line-height: 1 !important; cursor: pointer !important; }
.article-meta button.read-toggle:hover { border-color: var(--steel) !important; }
.article-meta button.read-toggle.is-read { border-color: #4a7c59 !important; color: #4a7c59 !important; background-color: var(--surface) !important; }
.is-unread { position: relative !important; }
.is-unread::before { content: '' !important; position: absolute !important; right: 20px !important; top: 20px !important; width: 8px !important; height: 8px !important; border-radius: 50% !important; background: #E07B39 !important; }

/* ================= Read-aloud player ================= */
#custom-audio-player {
  position: fixed; left: 50%; bottom: 20px; z-index: 9999;
  width: min(480px, calc(100vw - 24px)); box-sizing: border-box;
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 16px 13px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .06);
  transform: translate(-50%, 16px); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .25s ease, opacity .2s ease, visibility 0s linear .25s;
}
#custom-audio-player.is-active { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
#custom-audio-player *, #custom-audio-player *::before, #custom-audio-player *::after { box-sizing: border-box; }
#custom-audio-player button, #custom-audio-player select, #custom-audio-player input { font-family: inherit; -webkit-tap-highlight-color: transparent; }

/* ---------- header ---------- */
.ap-head { display: flex; align-items: center; gap: 4px; }
.ap-info { flex: 1; min-width: 0; margin-right: 6px; }
.ap-title { font-size: .9rem; font-weight: 700; line-height: 1.3; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-status { margin-top: 1px; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.ap-icon:hover, .ap-gear[aria-expanded="true"] { background: var(--mist); color: var(--ink); }
.ap-icon svg { width: 17px; height: 17px; }
.ap-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- settings menu (gear) ---------- */
.ap-menu {
  position: absolute; z-index: 8; top: 50px; right: 12px; width: min(300px, calc(100% - 24px)); padding: 6px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
}
.ap-menu[hidden] { display: none; }
.ap-menu-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; cursor: pointer; }
.ap-menu-row + .ap-menu-row { border-top: 1px solid var(--line); }
.ap-menu-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ap-menu-txt b { font-size: .8rem; font-weight: 700; }
.ap-menu-txt small { font-size: .7rem; line-height: 1.35; color: var(--muted); }
.ap-sw { flex: none; appearance: none; -webkit-appearance: none; position: relative; width: 38px; height: 22px; margin: 0; border-radius: 999px; background: var(--line); cursor: pointer; transition: background .15s; }
.ap-sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.ap-sw:checked { background: var(--accent); }
.ap-sw:checked::after { transform: translateX(16px); }
.ap-sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ap-seg { flex: none; display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; }
.ap-seg button { height: 26px; min-width: 34px; padding: 0 9px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1; cursor: pointer; font-variant-numeric: tabular-nums; transition: background .15s, color .15s; }
.ap-seg button:hover:not([aria-pressed="true"]) { color: var(--ink); }
.ap-seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.ap-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- views: choose / loading / preparing / play ---------- */
.ap-choose, .ap-load, .ap-prep { display: none; }
#custom-audio-player[data-view="choose"] .ap-choose,
#custom-audio-player[data-view="loading"] .ap-load,
#custom-audio-player[data-view="preparing"] .ap-prep { display: flex; flex-direction: column; gap: 10px; }
#custom-audio-player:not([data-view="play"]) .ap-map,
#custom-audio-player:not([data-view="play"]) .ap-controls,
#custom-audio-player:not([data-view="play"]) .ap-gear,
#custom-audio-player:not([data-view="play"]) .ap-status { display: none; }

/* ---------- contents map: a narrow window onto the article's headings ---------- */
.ap-map { position: relative; height: 78px; border: 1px solid var(--line); border-radius: 12px; background: var(--mist); overflow: hidden; }
.ap-map[hidden] { display: none; }
.ap-map-list {
  position: relative; height: 100%; padding: 26px 0; overflow-y: auto; overscroll-behavior: contain; scroll-snap-type: y proximity; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent 0, #000 26%, #000 74%, transparent 100%); mask-image: linear-gradient(transparent 0, #000 26%, #000 74%, transparent 100%);
}
.ap-map-list::-webkit-scrollbar { display: none; }
.ap-sec {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 26px; padding: 0 12px 0 calc(12px + var(--lv, 0) * 16px); border: 0; background: transparent;
  color: var(--muted); text-align: left; font-size: .78rem; font-weight: 600; cursor: pointer; scroll-snap-align: center; transition: color .15s, background .15s;
}
.ap-sec:hover { color: var(--ink); background: rgba(0, 0, 0, .04); }
.ap-sec:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ap-sec-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: background .2s, box-shadow .2s; }
.ap-sec-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-sec.is-current { color: var(--ink); font-weight: 700; }
.ap-sec.is-current .ap-sec-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(224, 123, 57, .22); }

/* ---------- transport ---------- */
.ap-controls { display: flex; flex-direction: column; gap: 8px; }
.ap-transport { display: flex; align-items: center; justify-content: center; gap: 6px; }
.ap-round { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; transition: background .12s, transform .06s ease-out; }
.ap-round:hover { background: var(--mist); }
.ap-round:active { transform: scale(.94); }
.ap-round svg { width: 24px; height: 20px; }
.ap-round:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-skip { position: relative; width: 44px; height: 44px; border: 1px solid var(--line); background: var(--surface); }
.ap-skip:hover { border-color: var(--ink); background: var(--surface); }
.ap-skip svg { width: 25px; height: 25px; }
.ap-skipn { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 4px; font: 800 .54rem/1 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; pointer-events: none; font-variant-numeric: tabular-nums; }

/* The dial: a bezel with a progress ring (it never moves), and a button that sits in a recess and is pressed IN. */
.ap-dial {
  position: relative; flex: none; width: 100px; height: 100px; margin: 0 4px; border-radius: 50%;
  background: linear-gradient(145deg, var(--surface) 0%, var(--mist) 55%, var(--line) 100%);
  box-shadow: 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -1px 2px rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .08);
}
.ap-dial::before {                                                     /* the recess the button sits in */
  content: ''; position: absolute; inset: 16px; border-radius: 50%; background: var(--mist);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .2), 0 1px 0 rgba(255, 255, 255, .55);
}
.ap-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; touch-action: none; outline: none; }
.ap-ring circle { fill: none; }
.ap-ring-track { stroke: rgba(0, 0, 0, .13); stroke-width: 6; }
.ap-ring-buf, .ap-ring-fill { stroke-width: 6; stroke-linecap: round; transition: opacity .15s; }
.ap-ring-buf { stroke: rgba(224, 123, 57, .34); }                      /* how much of the article is prepared */
.ap-ring-fill { stroke: var(--muted); }
#custom-audio-player.is-playing .ap-ring-fill { stroke: var(--accent); }
.ap-ring .ap-ring-knob { fill: var(--muted); stroke: var(--surface); stroke-width: 2; }
#custom-audio-player.is-playing .ap-ring .ap-ring-knob { fill: var(--accent); }
.ap-ring .ap-ring-hit { stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: grab; }
.is-drag .ap-ring-hit { cursor: grabbing; }
.no-scrub .ap-ring .ap-ring-hit { pointer-events: none; cursor: default; }
.ap-ring:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 50%; }

.ap-play {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; color: var(--ink); cursor: pointer;
  background: linear-gradient(150deg, var(--surface), var(--mist));
  box-shadow: 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -2px 3px rgba(0, 0, 0, .08), 0 2px 4px rgba(0, 0, 0, .2);
  transition: transform .09s ease-out, box-shadow .09s ease-out, filter .09s ease-out;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
@supports (color: color-mix(in srgb, red, blue)) { .ap-play { background: linear-gradient(150deg, color-mix(in srgb, var(--surface) 50%, #fff), var(--mist)); } }
.ap-play svg { width: 34px; height: 19px; opacity: .92; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .6)); }
.ap-play:hover { filter: brightness(1.03); }
.ap-play:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
#custom-audio-player .ap-play:active {                                 /* pressed in, quickly, no bounce; the ring stays put */
  transform: translateY(1px) scale(.955); filter: brightness(.95);
  box-shadow: 0 0 0 1px var(--line), inset 0 2px 5px rgba(0, 0, 0, .24), 0 0 1px rgba(0, 0, 0, .25);
  transition-duration: .04s;
}

/* ---------- options row: voice, speed, sync ---------- */
.ap-opts { display: flex; align-items: center; gap: 8px; }
.ap-voicebtn {
  flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font-size: .78rem; font-weight: 700; cursor: pointer; transition: border-color .15s;
}
.ap-voicebtn:hover { border-color: var(--ink); }
.ap-voicebtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-vb-ico { flex: none; display: grid; place-items: center; width: 14px; height: 14px; color: var(--accent); }
.ap-vb-ico svg { width: 14px; height: 14px; }
.ap-vb-txt { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-voicebtn > svg { flex: none; width: 12px; height: 12px; color: var(--muted); }
.ap-speedbox { flex: none; display: flex; align-items: center; gap: 6px; }
.ap-speed { -webkit-appearance: none; appearance: none; width: 86px; height: 22px; margin: 0; background: transparent; cursor: pointer; --p: 21%; }
.ap-speed::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--p), var(--line) var(--p)); }
.ap-speed::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
.ap-speed::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.ap-speed::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.ap-speed::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.ap-speed:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.ap-speed-val { flex: none; min-width: 44px; height: 28px; padding: 0 6px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; }
.ap-speed-val:hover { border-color: var(--ink); }
.ap-pill {
  height: 34px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background-color: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer; outline: none;
  transition: border-color .15s, color .15s, background-color .15s;
}
.ap-pill:hover { border-color: var(--ink); }
.ap-pill svg { width: 14px; height: 14px; flex: none; }
.ap-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-sync { flex: none; width: 34px; padding: 0; color: var(--muted); }
.ap-sync svg { width: 16px; height: 16px; }
.ap-sync.is-on { color: var(--accent); border-color: var(--accent); background-color: rgba(224, 123, 57, .10); }

/* ---------- the second window: voice ---------- */
.ap-choose { position: relative; }
.ap-choose-top { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.ap-choose-title { flex: 1; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ap-back { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px 0 6px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font-size: .72rem; font-weight: 700; cursor: pointer; }
.ap-back[hidden] { display: none; }
.ap-back svg { width: 12px; height: 12px; }
.ap-back:hover { border-color: var(--ink); }
.ap-infobtn {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 1.5px solid var(--muted); border-radius: 50%; background: transparent; color: var(--muted);
  font: italic 700 .8rem/1 Georgia, 'Times New Roman', serif; cursor: pointer; transition: color .15s, border-color .15s;
}
.ap-infobtn:hover, .ap-choose.tip-open .ap-infobtn { color: var(--accent); border-color: var(--accent); }
.ap-infobtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ap-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--mist); }
.ap-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: .8rem; font-weight: 700; cursor: pointer; transition: background .15s, color .15s; }
.ap-tabs button svg { width: 13px; height: 13px; }
.ap-tabs button:hover:not(:disabled):not(.is-on) { color: var(--ink); }
.ap-tabs button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.ap-tabs button[data-tab="ai"].is-on svg { color: var(--accent); }
.ap-tabs button:disabled { opacity: .4; cursor: not-allowed; }
.ap-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ap-panel { display: flex; flex-direction: column; gap: 10px; }
.ap-panel[hidden] { display: none; }
.ap-panel.is-off { opacity: .55; }
.ap-panel-desc { margin: 0; font-size: .78rem; line-height: 1.45; color: var(--muted); }
.ap-badge { display: inline-block; margin-left: 4px; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .58rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; vertical-align: 1px; }
.ap-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .78rem; font-weight: 700; }
.ap-field[hidden] { display: none; }
.ap-sel {
  flex: 1; max-width: 62%; height: 34px; padding: 0 28px 0 12px; appearance: none; -webkit-appearance: none; border: 1px solid var(--line); border-radius: 999px; background-color: transparent; color: var(--ink);
  font-size: .78rem; font-weight: 600; text-overflow: ellipsis; cursor: pointer; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a93a0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 10px 6px;
}
.ap-sel:hover { border-color: var(--ink); }
.ap-sel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-sel option { color: var(--ink); background: var(--surface); }
.ap-note { margin: 0; font-size: .72rem; line-height: 1.45; color: var(--muted); }
.ap-note[hidden] { display: none; }
.ap-note.ap-err { color: #a33b32; font-weight: 600; }
.ap-gobtn {
  height: 42px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-size: .84rem; font-weight: 700; cursor: pointer; transition: filter .12s, transform .06s ease-out;
}
.ap-gobtn:hover:not(:disabled) { filter: brightness(1.07); }
.ap-gobtn:active:not(:disabled) { transform: scale(.985); }
.ap-gobtn:disabled { opacity: .45; cursor: not-allowed; }
.ap-gobtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ap-go-std { background: var(--ink); color: var(--surface); }

.ap-warn { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: .74rem; line-height: 1.45; color: var(--ink); background: rgba(224, 123, 57, .1); border: 1px solid rgba(224, 123, 57, .35); }
.ap-warn svg { flex: none; width: 16px; height: 16px; margin-top: 1px; color: var(--accent); }

.ap-chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.ap-chip {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; background: var(--mist); color: var(--ink);
  border: 1.5px solid transparent; border-radius: 10px; cursor: pointer; transition: border-color .12s, background-color .12s, transform .06s ease-out;
}
.ap-chip:hover:not(:disabled):not(.is-picked) { border-color: var(--line); }
.ap-chip:active:not(:disabled) { transform: scale(.97); }
.ap-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-chip:disabled { cursor: not-allowed; opacity: .6; }
.ap-chip-name { font-size: .76rem; font-weight: 700; line-height: 1.2; }
.ap-chip-size { font-size: .64rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ap-chip-time { margin-top: 1px; font-size: .64rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ap-chip-time:empty { display: none; }
.ap-chip.is-picked { border-color: var(--accent); background: rgba(224, 123, 57, .12); }
.ap-chip.is-ready .ap-chip-ok { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok, #1f7a45); }

.ap-detail { display: flex; flex-direction: column; gap: 9px; padding: 12px; border-radius: 12px; background: var(--mist); }
.ap-d-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-d-name { font-size: .92rem; font-weight: 700; }
.ap-d-tag { padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; font-size: .66rem; font-weight: 600; color: var(--muted); }
.ap-d-beta { padding: 1px 6px; border: 1px solid var(--accent); border-radius: 999px; font-size: .58rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.ap-d-beta[hidden] { display: none; }
.ap-d-state { margin-left: auto; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ap-d-state.is-ready { color: var(--ok, #1f7a45); }
.ap-d-desc { margin: 0; font-size: .76rem; line-height: 1.45; color: var(--muted); }
.ap-d-meters { display: flex; gap: 20px; }
.ap-d-meters[hidden] { display: none; }
.ap-meter { display: inline-flex; align-items: center; gap: 8px; font-size: .7rem; }
.ap-meter em { font-style: normal; font-weight: 600; color: var(--muted); }
.ap-dots i { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 50%; background: var(--line); }
.ap-dots i.on { background: var(--accent); }
.ap-d-est { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); }
.ap-d-est[hidden] { display: none; }
.ap-d-est-main { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ap-d-est-note { font-size: .7rem; line-height: 1.4; color: var(--muted); }
.ap-custom { display: flex; flex-direction: column; gap: 6px; }
.ap-custom[hidden] { display: none; }
.ap-custom-row { display: flex; gap: 6px; }
.ap-custom-input { flex: 1; min-width: 0; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: .8rem; outline: none; }
.ap-custom-input:focus { border-color: var(--accent); }
.ap-custom-status { margin: 0; min-height: 1.1em; font-size: .74rem; line-height: 1.4; color: var(--muted); word-break: break-word; }
.ap-custom-status.is-ok { color: var(--ok, #1f7a45); }
.ap-custom-status.is-err { color: #a33b32; }

.ap-tip {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; overflow: auto; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  font-size: .8rem; line-height: 1.5; opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility 0s linear .15s;
}
.ap-choose.tip-open .ap-tip { opacity: 1; visibility: visible; transition-delay: 0s; }
.ap-choose.by-hover .ap-tip { pointer-events: none; }
.ap-choose.by-hover .ap-tip-x { visibility: hidden; }
.ap-tip-title { font-size: .86rem; font-weight: 700; }
.ap-tip-p { display: block; }
.ap-tip-last { color: var(--muted); }
.ap-tip-x { margin-top: auto; font-size: .68rem; color: var(--muted); text-align: right; }

/* ---------- download + preparing ---------- */
.ap-load-title { font-size: .9rem; font-weight: 700; color: var(--ink); }
.ap-load-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.ap-load-fill, .ap-prep-fill { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.ap-load-meta { display: flex; justify-content: space-between; gap: 12px; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ap-load-cancel { align-self: flex-start; }
.ap-hint { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(224, 123, 57, .1); border: 1px solid rgba(224, 123, 57, .35); font-size: .76rem; line-height: 1.5; color: var(--ink); }
.ap-linkbtn { display: inline; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.ap-linkbtn:hover { filter: brightness(.9); }
.ap-linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.ap-prep-std { align-self: stretch; height: auto; min-height: 40px; padding: 9px 14px; white-space: normal; text-align: center; line-height: 1.3; }

@media (max-width: 460px) {
  #custom-audio-player { bottom: 12px; padding: 10px 12px 12px; border-radius: 20px; gap: 8px; }
  .ap-transport { gap: 2px; }
  .ap-dial { width: 94px; height: 94px; margin: 0 2px; }
  .ap-dial::before { inset: 15px; }
  .ap-play { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
  .ap-skip { width: 40px; height: 40px; }
  .ap-round { width: 36px; height: 36px; }
  .ap-speed { width: 64px; }
  .ap-speed-val { min-width: 40px; }
  .ap-opts { gap: 6px; }
  .ap-chips { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ap-chip { padding: 9px 2px 8px; }
  .ap-sel { max-width: 66%; }
}
@media (prefers-reduced-motion: reduce) { #custom-audio-player, .ap-play, .ap-round, .ap-chip, .ap-gobtn, .ap-sw::after { transition: none; } }

/* paragraph currently being read */
.post-body .tts-current, .page-title.tts-current {
  background: rgba(224, 123, 57, .12); box-shadow: 0 0 0 6px rgba(224, 123, 57, .12); border-radius: 4px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background .25s, box-shadow .25s;
}
