:root {
  color-scheme: light dark;
  --background: #f6f5f1;
  --surface: #ffffff;
  --surface-soft: #eeede7;
  --text: #232b28;
  --muted: #63706a;
  --border: #dddfd7;
  --accent: #265c43;
  --accent-hover: #1d4934;
  --accent-text: #ffffff;
  --accent-soft: #e7eee5;
  --warning: #795620;
  --warning-bg: #f7efdf;
  --shadow: 0 8px 32px rgb(31 46 35 / 4%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #141716;
    --surface: #1e2320;
    --surface-soft: #262d28;
    --text: #ecefe7;
    --muted: #a6b1a7;
    --border: #343d35;
    --accent: #bbd7ab;
    --accent-hover: #cce4bf;
    --accent-text: #1c3020;
    --accent-soft: #29372a;
    --warning: #e3c491;
    --warning-bg: #342d20;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--text); line-height: 1.5; }
button, input { font: inherit; }
button, a, input, summary { -webkit-tap-highlight-color: transparent; }
button, summary { touch-action: manipulation; }
a { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
::selection { background: var(--accent-soft); color: var(--text); }
.app-shell { max-width: 1200px; min-height: 100svh; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); display: flex; flex-direction: column; }
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.header-identity { display: flex; align-items: center; gap: 8px; }
.brand { display: inline-flex; flex-shrink: 0; }
.brand img { border-radius: 8px; }
.brand-version { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.release-controls { margin-bottom: 12px; }
.app-tools { display: flex; align-items: center; justify-content: space-between; min-height: 24px; gap: 48px; color: var(--muted); font-size: .8rem; }
#check-update { margin: 0 0 0 auto; padding: 3px 5px; font-size: 10px; line-height: 1.3; font-weight: 400; min-height: 0; background: transparent; color: var(--muted); border: 1px solid var(--muted); border-radius: 3px; align-self: center; }
#update-banner { font-size: .85rem; margin-top: 8px; color: var(--muted); }
#update-button { padding: 8px 12px; font-size: .8rem; font-weight: 700; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-text); margin-top: 8px; }
.badge-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); font-size: 12px; }
.badge-panel p { flex: 1 1 240px; margin: 0; }
.story-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.card-loading { margin: 18px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.list-switcher { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.list-tab { min-height: 38px; padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.list-tab[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-actions .button { min-height: 40px; padding: 8px; gap: 4px; font-size: 12px; }
main { flex: 1; padding: 16px 0 32px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 20px; z-index: 10; padding: 12px 18px; background: var(--accent); color: var(--accent-text); border-radius: 8px; }
.skip-link:focus { top: 12px; }
.eyebrow { margin: 0 0 16px; color: var(--accent); font-size: 11px; line-height: 1.4; font-weight: 750; text-transform: uppercase; letter-spacing: .15em; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 6vw, 60px); font-weight: 400; line-height: 1.09; letter-spacing: -.045em; }
.welcome-panel { max-width: 660px; padding: 36px 0 28px; }
.welcome-panel h1 { font-size: clamp(48px, 8.5vw, 82px); }
.welcome-copy, .muted { margin: 24px 0 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
#session-retry { margin-top: 24px; }
.login-form { margin-top: 38px; max-width: 520px; }
.login-form label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 650; }
.password-row { display: flex; flex-wrap: wrap; gap: 10px; }
.password-row input { flex: 1 1 190px; min-width: 0; width: 100%; min-height: 50px; padding: 11px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 17px; box-shadow: var(--shadow); }
.password-row input[aria-invalid="true"] { border-color: var(--warning); }
.button { min-height: 46px; padding: 10px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 14px; border: 1px solid transparent; border-radius: 11px; font-size: 13px; font-weight: 650; white-space: nowrap; transition: background .15s ease, border-color .15s ease; }
.button-primary { background: var(--accent); color: var(--accent-text); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-quiet { padding-inline: 10px; background: transparent; border-color: var(--border); color: var(--muted); }
.button-quiet:hover:not(:disabled) { background: var(--surface-soft); color: var(--text); }
.input-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.form-message { margin: 12px 0 0; color: var(--warning); font-size: 14px; min-height: 21px; }
.connection-banner, .feed-status { margin: 0 0 24px; border: 1px solid var(--border); border-radius: 12px; padding: 13px 16px; color: var(--warning); background: var(--warning-bg); font-size: 13px; line-height: 1.6; }
.refresh-symbol { font-size: 20px; font-weight: 400; line-height: 1; }
.refresh-button[disabled] .refresh-symbol { animation: turn 1.5s linear infinite; }
.feed-status.is-loading { background: var(--accent-soft); color: var(--text); }
.feed-panel { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.feed-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.story-card { position: relative; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.story-move { position: absolute; z-index: 1; top: 12px; left: 12px; min-height: 40px; padding: 8px 12px; background: var(--surface); color: var(--accent); border-color: var(--border); box-shadow: 0 2px 10px rgb(0 0 0 / 12%); }
.story-card:not(.has-preview) .story-body { padding-top: 68px; }
.story-media { position: relative; overflow: hidden; background: var(--surface-soft); }
.story-media img, .story-media video { display: block; width: 100%; height: auto; object-fit: contain; }
.preview-toggle { position: absolute; inset: 0; width: 100%; height: 100%; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: #fff; }
.preview-play { display: grid; place-items: center; width: 76px; height: 76px; padding-left: 5px; border: 1px solid rgb(255 255 255 / 35%); border-radius: 50%; background: rgb(0 0 0 / 50%); font-size: 34px; line-height: 1; }
.is-playing .preview-play { opacity: 0; }
.is-playing .preview-toggle:focus-visible .preview-play { opacity: 1; }
.preview-duration { position: absolute; left: 12px; bottom: 12px; padding: 4px 9px; border-radius: 9px; background: rgb(0 0 0 / 65%); color: #fff; font-size: 14px; font-variant-numeric: tabular-nums; line-height: 1.5; pointer-events: none; }
.preview-sound { position: absolute; right: 12px; bottom: 12px; display: grid; place-items: center; width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 50%; background: rgb(0 0 0 / 60%); color: #fff; }
.preview-sound svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.story-body { display: flex; flex: 1; flex-direction: column; padding: 23px; }
.story-reading-time { color: var(--muted); font-size: 11px; }
.story-title { margin: 0 0 11px; font-size: 21px; line-height: 1.32; letter-spacing: -.025em; font-weight: 700; }
.story-title a { text-decoration: none; }
.story-title a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.story-summary { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.7; white-space: pre-line; }
.story-footer { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 14px; margin-top: auto; padding-top: 17px; border-top: 1px solid var(--border); font-size: 12px; }
.story-reactions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); }
.story-reaction { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.story-reaction img { width: 24px; height: 24px; object-fit: contain; }
.story-reactions-more { white-space: nowrap; }
.story-links { display: flex; align-items: center; flex-wrap: wrap; gap: 15px; }
.story-link { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--accent); font-weight: 650; text-decoration: none; }
.story-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.source-link { color: var(--muted); font-weight: 450; }
.story-delete { min-height: 36px; padding: 6px 8px; font-size: 12px; }
.story-error { margin: 10px 0 0; color: var(--warning); font-size: 12px; }
.empty-state { padding: 55px 24px 65px; text-align: center; border: 1px dashed var(--border); border-radius: 18px; }
.empty-symbol { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 13px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 26px; }
.empty-state h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 400; letter-spacing: -.03em; }
.empty-state p { max-width: 340px; margin: 12px auto 0; color: var(--muted); font-size: 14px; }
.site-footer { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 16px 26px; padding-top: 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.site-footer > p { margin: 0; }
.footer-dot { margin: 0 4px; }
.install-help { max-width: 400px; }
.install-help summary { display: flex; align-items: center; gap: 16px; min-height: 36px; font-size: 12px; cursor: pointer; list-style: none; }
.install-help summary::-webkit-details-marker { display: none; }
.install-help[open] summary { color: var(--accent); }
.install-copy { font-size: 12px; line-height: 1.7; }
.install-copy p { margin: 12px 0 0; }

.undo-popups { position: fixed; z-index: 20; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: auto; max-width: 440px; margin-inline: auto; max-height: 50svh; overflow-y: auto; pointer-events: none; }
.undo-popup { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px 10px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 28px rgb(0 0 0 / 20%); font-size: 14px; pointer-events: auto; }
.undo-popup-message { flex: 1; }
.undo-popup-countdown { position: relative; display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.undo-countdown-ring { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; transform: rotate(-90deg); }
.undo-countdown-ring circle { transition: stroke-dashoffset 50ms linear; }
.undo-popup .button { min-height: 44px; }

@keyframes turn { to { transform: rotate(360deg); } }

@media (min-width: 650px) {
  .app-shell { padding: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
  main { padding-top: 20px; padding-bottom: 40px; }
  .welcome-panel { padding-top: 52px; padding-bottom: 58px; }
  .feed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1040px) {
  .feed-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 649px) {
  .site-header { flex-wrap: wrap; }
  .list-switcher { order: 3; width: 100%; }
  .list-tab { flex: 1; }
}

@media (max-width: 370px) {
  .wide-only { display: none; }
  .password-row .button { width: 100%; }
}

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