/* Qaraly — calm paper, ink and a little gold. */
:root {
  --paper: #f6f1e7; --paper-2: #efe7d8; --card: #fffcf6; --ink: #1d2331; --ink-2: #4b5264; --mute: #8b8f99; --line: #e4dac9;
  --accent: #b45a31; --accent-ink: #fffaf2; --gold: #c9954e; --hl: rgba(214, 160, 84, .30); --hl-line: rgba(180, 90, 49, .55);
  --glass: rgba(255, 252, 246, .78); --shadow: 0 1px 2px rgba(29, 35, 49, .05), 0 10px 30px rgba(29, 35, 49, .09);
  --shadow-lg: 0 2px 6px rgba(29, 35, 49, .06), 0 24px 60px rgba(29, 35, 49, .16);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "Noto Serif", "Source Serif 4", "Songti SC", "Noto Serif CJK SC", "Noto Serif CJK JP", "Hiragino Mincho ProN", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", "Apple SD Gothic Neo", Arial, sans-serif;
  --fs: 1; --r: 18px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #121418; --paper-2: #191c22; --card: #1b1e25; --ink: #ece6da; --ink-2: #b8b1a4; --mute: #7f838c; --line: #2a2e37;
  --accent: #e08a5c; --accent-ink: #1a1410; --gold: #d9a35b; --hl: rgba(217, 163, 91, .22); --hl-line: rgba(224, 138, 92, .6);
  --glass: rgba(27, 30, 37, .8); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121418; --paper-2: #191c22; --card: #1b1e25; --ink: #ece6da; --ink-2: #b8b1a4; --mute: #7f838c; --line: #2a2e37;
    --accent: #e08a5c; --accent-ink: #1a1410; --gold: #d9a35b; --hl: rgba(217, 163, 91, .22); --hl-line: rgba(224, 138, 92, .6);
    --glass: rgba(27, 30, 37, .8); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100vh; }
body.reading { overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 20px; height: 20px; flex: none; }
.muted { color: var(--mute); }
em { font-style: italic; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top, 0px)) 20px 10px;
  background: linear-gradient(var(--paper) 60%, transparent); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: var(--shadow); }
.wordmark { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 1.5rem; letter-spacing: .01em; }
.wordmark.sm { font-size: 1.05rem; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--ink-2); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn.sm { width: 34px; height: 34px; }

/* home */
.home { max-width: 760px; margin: 0 auto; padding: 8px 20px calc(140px + var(--safe-b)); }
.hero { text-align: center; padding: 34px 0 26px; position: relative; }
.hero::before { content: ""; position: absolute; inset: -40px -10vw auto; height: 320px; z-index: -1;
  background: radial-gradient(60% 70% at 50% 30%, rgba(201, 149, 78, .18), transparent 70%); }
.hero-title { font-family: var(--serif); font-weight: 500; font-size: clamp(2rem, 6vw, 3.1rem); line-height: 1.08; letter-spacing: -.01em; margin: 0 0 12px; }
.hero-sub { color: var(--ink-2); font-size: 1.05rem; max-width: 34em; margin: 0 auto 26px; }
.omni { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow); max-width: 620px; margin: 0 auto; transition: box-shadow .2s, border-color .2s; }
.omni:focus-within { border-color: var(--gold); box-shadow: var(--shadow-lg); }
.omni-ico { color: var(--gold); }
.omni input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 1.02rem; padding: 10px 4px; }
.omni-paste { border: 0; background: transparent; color: var(--mute); width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; }
.omni-paste:hover { color: var(--ink); background: var(--paper-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 999px; padding: 11px 20px; font-weight: 600;
  text-decoration: none; transition: transform .1s, background .15s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(180, 90, 49, .28); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.sm { padding: 7px 14px; font-size: .9rem; }
.btn.danger { color: #b3261e; }
.hero-links { margin-top: 14px; display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--mute); }
.link-btn { border: 0; background: none; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; padding: 6px 4px; font-size: .95rem; }
.link-btn:hover { color: var(--accent); }
.link-btn .i { width: 17px; height: 17px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; }
.tab { border: 0; background: none; padding: 12px 14px; font-weight: 600; color: var(--mute); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }
.panel { min-height: 200px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px 7px 8px; font-size: .92rem; color: var(--ink-2); max-width: 220px; }
.chip img { width: 20px; height: 20px; border-radius: 6px; object-fit: cover; background: var(--paper-2); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--paper-2); }
.chip.add { padding: 7px 14px; }
.feed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 10px; }
.feed-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.feed-title h2 { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; margin: 0; }
.feed-title p { margin: 2px 0 0; font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.feed-icon { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--paper-2); flex: none; }
.feed-actions { display: flex; gap: 6px; align-items: center; flex: none; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 14px 16px;
  cursor: pointer; transition: transform .15s, box-shadow .2s, border-color .2s; }
.card:hover { box-shadow: var(--shadow); border-color: transparent; transform: translateY(-1px); }
.card h3 { font-family: var(--serif); font-weight: 600; font-size: 1.12rem; line-height: 1.3; margin: 0 0 6px; }
.card .meta { font-size: .82rem; color: var(--mute); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .sum { font-size: .93rem; color: var(--ink-2); margin: 6px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.card .thumb { width: 92px; height: 72px; border-radius: 12px; object-fit: cover; background: var(--paper-2); }
.card .play { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--accent); display: grid; place-items: center; }
.card .play:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.card .play .i { width: 18px; height: 18px; }
.card.now { border-color: var(--gold); box-shadow: 0 0 0 3px var(--hl); }
.card .x { border: 0; background: none; color: var(--mute); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.card .x:hover { color: var(--ink); background: var(--paper-2); }
.empty { text-align: center; color: var(--mute); padding: 40px 10px; }
.skeleton { height: 96px; border-radius: var(--r); background: linear-gradient(90deg, var(--paper-2), var(--card), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.suggest { margin-top: 26px; }
.eyebrow { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); font-weight: 700; margin: 0 0 10px; }
.suggest-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.sg { display: flex; align-items: center; gap: 10px; border: 1px dashed var(--line); border-radius: 14px; padding: 10px 12px; background: transparent; text-align: left; width: 100%; color: var(--ink); }
.sg:hover { border-style: solid; background: var(--card); }
.sg .i { color: var(--accent); }
.sg small { display: block; color: var(--mute); font-size: .78rem; }
.sg.on { border-style: solid; border-color: var(--gold); }

.foot { margin-top: 56px; text-align: center; font-size: .88rem; color: var(--ink-2); }
.foot p { margin: 4px 0; }

/* reader: the internal frame */
.reader { position: fixed; inset: 0; z-index: 20; background: var(--paper); display: flex; flex-direction: column; animation: rise .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.r-top { display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; border-bottom: 1px solid var(--line); background: var(--glass); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
.r-src { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink-2); }
.r-src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-icon { width: 20px; height: 20px; border-radius: 5px; background: var(--paper-2); }
.seg { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg-btn { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-size: .88rem; font-weight: 600; color: var(--mute); }
.seg-btn[aria-selected="true"], .seg-btn[aria-checked="true"], .seg-btn.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.big { display: flex; }
.seg.big .seg-btn { flex: 1; padding: 10px 14px; font-size: 1rem; }
.r-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
.r-loading, .r-error { text-align: center; padding: 18vh 24px; color: var(--ink-2); }
.r-error p { max-width: 30em; margin: 0 auto 18px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); margin: 0 auto 16px; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.article { max-width: 680px; margin: 0 auto; padding: 34px 22px calc(160px + var(--safe-b)); font-family: var(--serif); font-size: calc(1.17rem * var(--fs)); line-height: 1.72; color: var(--ink); }
.article .a-kicker { font-family: var(--sans); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 12px; }
.article h1 { font-size: calc(2.1rem * var(--fs)); line-height: 1.15; font-weight: 600; margin: 0 0 14px; letter-spacing: -.01em; }
.article .a-meta { font-family: var(--sans); font-size: .86rem; color: var(--mute); display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 26px; }
.article .a-hero { margin: 0 -22px 28px; }
.article .a-hero img { width: 100%; max-height: 420px; object-fit: cover; display: block; border-radius: 0; }
@media (min-width: 720px) { .article .a-hero { margin: 0 0 30px; } .article .a-hero img { border-radius: 16px; } }
.article p { margin: 0 0 1.1em; }
.article h2, .article h3, .article h4 { font-weight: 600; line-height: 1.25; margin: 1.6em 0 .6em; }
.article h2 { font-size: 1.45em; } .article h3 { font-size: 1.22em; } .article h4 { font-size: 1.06em; }
.article blockquote { margin: 1.4em 0; padding: .2em 0 .2em 1.1em; border-left: 3px solid var(--gold); color: var(--ink-2); font-style: italic; }
.article ul, .article ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.article li { margin: .3em 0; }
.article pre { font: .85em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--paper-2); padding: 14px; border-radius: 12px; overflow-x: auto; white-space: pre-wrap; }
.article figure { margin: 1.6em 0; }
.article figure img { width: 100%; height: auto; border-radius: 12px; background: var(--paper-2); display: block; }
.article figcaption { font-family: var(--sans); font-size: .82rem; color: var(--mute); margin-top: 8px; line-height: 1.45; }
.article .s { border-radius: 4px; transition: background-color .25s, color .25s; cursor: pointer; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.article .s:hover { background: var(--paper-2); }
.article .s.on { background: var(--hl); box-shadow: 0 0 0 2px var(--hl); }
.article.playing .s.done { color: var(--ink-2); }
.article .a-end { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); font-family: var(--sans); font-size: .9rem; color: var(--mute); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.article .a-follow { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 18px; font-family: var(--sans); font-size: .93rem; }
.article .a-follow .btn { margin-left: auto; }
.r-page { flex: 1; position: relative; display: flex; flex-direction: column; background: #fff; }
.r-page iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.frame-note { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 14px calc(96px + var(--safe-b)); background: var(--paper); border-top: 1px solid var(--line); font-size: .88rem; color: var(--ink-2); }
.frame-note.blocked { flex-direction: column; justify-content: center; flex: 1; text-align: center; padding: 18vh 24px; font-size: 1rem; }

/* player */
.player { position: fixed; z-index: 30; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); width: min(720px, calc(100% - 20px));
  background: var(--glass); backdrop-filter: saturate(1.5) blur(18px); -webkit-backdrop-filter: saturate(1.5) blur(18px); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise .3s cubic-bezier(.2, .8, .2, 1); }
.pl-bar { height: 3px; background: var(--line); }
.pl-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width .35s; }
.pl-row { display: flex; align-items: center; gap: 8px; padding: 9px 10px 9px 14px; }
.pl-meta { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0; display: flex; flex-direction: column; }
.pl-title { font-weight: 600; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-sub { font-size: .78rem; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-ctrls { display: flex; align-items: center; gap: 2px; }
.pl-play { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(180, 90, 49, .35); transition: transform .1s; }
.pl-play:active { transform: scale(.94); }
.pl-play .i { width: 22px; height: 22px; }
.pl-play.busy { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px var(--hl); } }
.pl-opts { display: flex; gap: 6px; }
.pill { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 11px; font-size: .84rem; font-weight: 600; color: var(--ink-2); display: inline-flex; gap: 5px; align-items: center; }
.pill:hover { color: var(--ink); }
.g-ico { font-family: var(--sans); color: var(--accent); font-weight: 700; }
@media (max-width: 560px) {
  .pl-row { flex-wrap: wrap; row-gap: 6px; }
  .pl-meta { flex-basis: calc(100% - 160px); }
  .pl-opts { order: 3; width: 100%; justify-content: center; }
  .seg-btn { padding: 6px 11px; }
  .hero { padding-top: 18px; }
  .card .thumb { width: 76px; height: 62px; }
}

/* sheets */
.sheet { border: 0; padding: 0; background: transparent; max-width: 520px; width: calc(100% - 20px); color: var(--ink); }
.sheet::backdrop { background: rgba(10, 12, 16, .42); backdrop-filter: blur(3px); }
.sheet[open] { animation: rise .25s cubic-bezier(.2, .8, .2, 1); }
.sheet-in { background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 18px 20px 20px; border: 1px solid var(--line); max-height: 88vh; overflow-y: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { font-family: var(--serif); font-weight: 600; font-size: 1.4rem; margin: 0; }
.field { display: block; margin: 16px 0; }
.field.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.field.row .label { margin-bottom: 2px; }
.help { display: block; color: var(--mute); font-size: .84rem; line-height: 1.45; }
.about { margin-top: 18px; }
select, textarea { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 11px 12px; }
textarea { resize: vertical; min-height: 180px; font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; }
.speeds { display: flex; gap: 6px; flex-wrap: wrap; }
.speeds button { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 7px 13px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.speeds button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.switch { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .2s; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.voice-now { font-size: .86rem; color: var(--ink-2); background: var(--paper-2); border-radius: 12px; padding: 10px 12px; margin: 8px 0 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.aa { font-family: var(--serif); font-weight: 600; }
.aa.s1 { font-size: .8rem; } .aa.s2 { font-size: .95rem; } .aa.s3 { font-size: 1.1rem; } .aa.s4 { font-size: 1.25rem; }

.toast { position: fixed; z-index: 50; left: 50%; top: calc(16px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow-lg); transition: opacity .25s, transform .25s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { text-align: center; padding: 40px; }

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