/* Unseen Stories - editorial magazine theme. No external requests. */
:root {
  --bg: #ffffff; --bg-alt: #f6f4ef; --text: #1b1b1b; --muted: #5f5f5f;
  --line: #e3e0d8; --accent: #9b1c31; --accent-text: #ffffff; --link: #8a1a2c;
  --ok: #17663a; --ok-bg: #e4f4ea; --warn: #8a5a00; --warn-bg: #fdf1d6; --bad: #a11d1d; --bad-bg: #fde8e8;
  --gray-bg: #ececec; --focus: #1a5fd0;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px; --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131315; --bg-alt: #1c1c1f; --text: #e8e6e1; --muted: #a2a09a;
    --line: #2e2e33; --accent: #e0566b; --accent-text: #131315; --link: #f08797;
    --ok: #6fd69a; --ok-bg: #163524; --warn: #f0c36a; --warn-bg: #3a2c0c; --bad: #ff8a8a; --bad-bg: #3d1818;
    --gray-bg: #2a2a2e; --focus: #7ab0ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #131315; --bg-alt: #1c1c1f; --text: #e8e6e1; --muted: #a2a09a;
    --line: #2e2e33; --accent: #e0566b; --accent-text: #131315; --link: #f08797;
    --ok: #6fd69a; --ok-bg: #163524; --warn: #f0c36a; --warn-bg: #3a2c0c; --bad: #ff8a8a; --bad-bg: #3d1818;
    --gray-bg: #2a2a2e; --focus: #7ab0ff; color-scheme: dark;
}
:root[data-theme="light"] {
    --bg: #ffffff; --bg-alt: #f6f4ef; --text: #1b1b1b; --muted: #5f5f5f;
    --line: #e3e0d8; --accent: #9b1c31; --accent-text: #ffffff; --link: #8a1a2c;
    --ok: #17663a; --ok-bg: #e4f4ea; --warn: #8a5a00; --warn-bg: #fdf1d6; --bad: #a11d1d; --bad-bg: #fde8e8;
    --gray-bg: #ececec; --focus: #1a5fd0; color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--sans); min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1 0 auto; width: 100%; padding-top: 24px; padding-bottom: 48px; }
.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw + .5rem, 2.6rem); }
h2 { font-size: clamp(1.3rem, 2vw + .6rem, 1.7rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
section { margin-bottom: 40px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.skip {
  position: absolute; left: 8px; top: 8px; z-index: 100; padding: 10px 14px;
  background: var(--accent); color: var(--accent-text); border-radius: var(--radius);
  transform: translateY(-200%); text-decoration: none; font-weight: 600;
}
.skip:focus { transform: none; }

/* header */
.top { border-bottom: 3px double var(--line); background: var(--bg); position: relative; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-top: 10px; padding-bottom: 10px; }
.brand {
  font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--text);
  text-decoration: none; letter-spacing: -.02em; min-height: 44px; display: inline-flex; align-items: center;
}
.top nav {
  display: flex; gap: 2px; order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; white-space: nowrap; border-top: 1px solid var(--line); margin-top: 4px;
}
.top nav a, .acct a:not(.btn) {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--text); text-decoration: none; font-size: .95rem; font-weight: 500;
}
.top nav a:hover, .acct a:not(.btn):hover { color: var(--link); text-decoration: underline; }
.search { flex: 1 1 160px; order: 2; margin-left: auto; max-width: 320px; }
.search input {
  width: 100%; min-height: 44px; padding: 0 14px; font: inherit; color: var(--text);
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 22px;
}
.acct { display: flex; align-items: center; gap: 4px; order: 1; margin-left: auto; }
.acct form { margin: 0; }
@media (min-width: 900px) {
  .top nav { order: 0; width: auto; border: 0; margin: 0; overflow: visible; flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
  .search { order: 0; flex: 0 1 240px; margin-left: 0; }
  .acct { order: 0; margin-left: 0; }
}

/* buttons */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 20px; font: 600 .95rem var(--sans); cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 2px solid var(--accent);
  border-radius: var(--radius); text-decoration: none; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: .88rem; }
.btn.ghost { background: transparent; color: var(--link); border-color: var(--accent); }
.btn.ghost:hover { background: var(--bg-alt); filter: none; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--bg); }
.btn.ghost.danger { background: transparent; color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link {
  background: none; border: 0; padding: 0 12px; min-height: 44px; font: inherit; font-size: .95rem;
  color: var(--link); text-decoration: underline; cursor: pointer;
}
.link:hover { text-decoration-thickness: 2px; }

/* flash */
.flash {
  padding: 12px 16px; margin: 0 0 20px; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--text); border-left: 4px solid var(--warn);
}
.flash.err { background: var(--bad-bg); border-left-color: var(--bad); }

/* layout helpers */
.row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.row h1, .row h2 { margin: 0; }
.muted { color: var(--muted); }
.meta { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.meta a { color: inherit; }

.grid3, .grid4 { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid3, .grid4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid3 { grid-template-columns: repeat(3, 1fr); } .grid4 { grid-template-columns: repeat(4, 1fr); } }

.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 16px; min-height: 44px;
  background: var(--bg-alt); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.tile strong { font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; }
.tile:hover strong { color: var(--link); text-decoration: underline; }

.card { display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none; }
.card img, .card .ph {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-alt);
}
.card .ph {
  display: flex; align-items: center; justify-content: center;
  font: 700 4rem var(--serif); color: var(--accent);
  background: linear-gradient(135deg, var(--bg-alt), var(--line));
}
.card strong { font-family: var(--serif); font-size: 1.1rem; line-height: 1.3; }
.card:hover strong { color: var(--link); text-decoration: underline; }
.card .meta { margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 22px; background: var(--bg-alt);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.chips a:hover { border-color: var(--accent); color: var(--link); }
.chips small { color: var(--muted); font-size: .8rem; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 32px 0 0; flex-wrap: wrap; }
.pager a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; font-weight: 600;
}
.pager a:hover { border-color: var(--accent); background: var(--bg-alt); }
.pager span { color: var(--muted); }

/* story page */
.storyhead { display: grid; gap: 24px; grid-template-columns: 1fr; margin-bottom: 32px; align-items: start; }
.storyhead .cover { width: 100%; max-width: 240px; }
.storyhead .cover img, .storyhead .cover .ph { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.storyhead .cover .ph {
  display: flex; align-items: center; justify-content: center; font: 700 5rem var(--serif); color: var(--accent);
  background: linear-gradient(135deg, var(--bg-alt), var(--line));
}
.storyhead .info { min-width: 0; }
.storyhead .btn { margin: 4px 8px 4px 0; }
@media (min-width: 640px) { .storyhead { grid-template-columns: 240px minmax(0, 1fr); } }
.actions-row { display: flex; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 16px; }
.crumbs a { color: var(--muted); }
.lead { font-family: var(--serif); font-size: 1.15rem; line-height: 1.6; color: var(--text); white-space: pre-line; }

.partlist { list-style: none; margin: 0 0 32px; padding: 0; border-top: 1px solid var(--line); }
.partlist li { border-bottom: 1px solid var(--line); }
.partlist a { display: flex; gap: 14px; align-items: center; min-height: 48px; padding: 8px 4px; color: var(--text); text-decoration: none; font-family: var(--serif); font-size: 1.05rem; }
.partlist a span { font: 600 .8rem var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); min-width: 64px; }
.partlist a:hover { background: var(--bg-alt); color: var(--link); }

/* reader */
.reader { max-width: 68ch; margin: 0 auto; }
.reader h1 { margin-bottom: .3em; }
.reader .body { font-family: var(--serif); font-size: 18px; line-height: 1.75; margin-top: 24px; hyphens: auto; overflow-wrap: break-word; }
.reader .body p { margin: 0 0 1.2em; }
@media (min-width: 700px) { .reader .body { font-size: 19px; } }
.reader .pager { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 20px; }

/* iOS install prompt. It remains hidden unless app.js detects an iOS browser. */
.ios-app-prompt { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 12px; }
.ios-app-prompt[hidden] { display: none; }
.ios-app-scrim { position: absolute; inset: 0; background: rgb(10 7 12 / .7); backdrop-filter: blur(8px); }
.ios-app-card {
  --ios-pink: #e50048;
  position: relative; width: min(100%, 560px); max-height: min(94svh, 760px); margin: 0 auto;
  overflow: auto; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid rgb(255 255 255 / .78); border-radius: 28px;
  background:
    radial-gradient(circle at 92% 8%, rgb(255 222 232 / .9), transparent 32%),
    radial-gradient(circle at 4% 92%, rgb(255 190 210 / .8), transparent 32%),
    linear-gradient(145deg, #fff 0%, #fff9fb 56%, #ffe8f0 100%);
  color: #1c0710; box-shadow: 0 24px 80px rgb(0 0 0 / .38), inset 0 0 32px rgb(255 255 255 / .8);
}
.ios-app-card:focus { outline: none; }
.ios-app-close {
  position: absolute; top: 14px; right: 14px; z-index: 2; width: 48px; height: 48px; padding: 0;
  border: 0; border-radius: 50%; background: rgb(255 240 245 / .9); color: #290b15; cursor: pointer;
  font: 300 2rem/1 var(--sans); box-shadow: inset 0 0 0 1px rgb(229 0 72 / .04);
}
.ios-app-brand { display: flex; align-items: center; gap: 12px; min-height: 58px; padding-right: 58px; }
.ios-app-icon { width: 58px; height: 58px; border-radius: 15px; object-fit: cover; box-shadow: 0 8px 20px rgb(83 0 34 / .24); }
.ios-app-brand span { display: grid; gap: 1px; }
.ios-app-brand strong { color: #70001e; font-size: clamp(1.55rem, 6vw, 2rem); line-height: 1; letter-spacing: -.04em; }
.ios-app-brand small { color: #76656b; font-size: .68rem; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.ios-app-main { display: grid; grid-template-columns: minmax(118px, .82fr) minmax(0, 1.18fr); gap: 18px; align-items: center; margin-top: 18px; }
.ios-app-poster { position: relative; display: block; color: #fff; text-decoration: none; }
.ios-app-poster img {
  display: block; width: 100%; aspect-ratio: 3 / 4.35; object-fit: cover; border-radius: 22px;
  border: 3px solid #fff; box-shadow: 0 12px 30px rgb(112 0 35 / .25), 0 0 0 1px rgb(229 0 72 / .18);
}
.ios-app-play { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; width: 56px; height: 56px; padding-left: 4px; transform: translate(-50%, -50%); border: 3px solid #fff; border-radius: 50%; background: rgb(17 7 12 / .32); font-size: 1.35rem; box-shadow: 0 4px 18px rgb(0 0 0 / .28); }
.ios-app-offer { min-width: 0; }
.ios-app-offer h2 { margin: 0 0 14px; font-size: clamp(1.7rem, 7.3vw, 2.8rem); line-height: .98; letter-spacing: -.055em; }
.ios-app-offer h2 em { display: block; margin-top: 5px; color: var(--ios-pink); font-style: italic; }
.ios-app-offer p { margin: 0; color: #625158; font-size: clamp(.88rem, 3.7vw, 1.05rem); line-height: 1.28; }
.ios-app-offer p strong { color: #5e001c; font-style: italic; }
.ios-app-benefits { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0 16px; }
.ios-app-benefits span { padding: 0 8px; color: #2c171e; font-size: clamp(.68rem, 3vw, .85rem); line-height: 1.15; text-align: center; }
.ios-app-benefits span + span { border-left: 1px solid rgb(121 68 85 / .2); }
.ios-app-benefits b { display: grid; place-items: center; width: 46px; height: 30px; margin: 0 auto 4px; border-radius: 18px; background: #ffe5ee; color: var(--ios-pink); font-size: 1.2rem; }
.ios-app-install { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; width: 100%; min-height: 74px; padding: 10px 16px; border: 2px solid #ffb0c7; border-radius: 24px; background: linear-gradient(135deg, #ef1554, #c9003f); color: #fff; text-decoration: none; box-shadow: 0 12px 26px rgb(191 0 55 / .28), inset 0 1px rgb(255 255 255 / .35); }
.ios-app-install:hover, .ios-app-install:focus-visible { color: #fff; filter: brightness(1.05); transform: translateY(-1px); }
.ios-app-install strong { font-size: clamp(1.18rem, 5.2vw, 1.55rem); line-height: 1.02; }
.ios-app-install strong small { font: inherit; }
.ios-app-apple { padding-right: 14px; border-right: 1px solid rgb(255 255 255 / .5); font-size: 2.5rem; line-height: 1; }
.ios-app-arrow { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--ios-pink); font-size: 1.4rem; }
.ios-app-continue { display: block; width: 100%; margin-top: 12px; padding: 8px; border: 0; background: transparent; color: #8d1538; cursor: pointer; font: italic 500 1rem var(--sans); text-decoration: underline; text-underline-offset: 4px; }
body.ios-app-prompt-open { overflow: hidden; }
@media (max-width: 370px) {
  .ios-app-prompt { padding: 7px; }
  .ios-app-card { padding: 14px 13px calc(14px + env(safe-area-inset-bottom)); border-radius: 22px; }
  .ios-app-main { grid-template-columns: 112px minmax(0, 1fr); gap: 12px; margin-top: 13px; }
  .ios-app-benefits { margin: 13px 0 11px; }
  .ios-app-install { min-height: 66px; border-radius: 20px; }
  .ios-app-apple { font-size: 2rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .ios-app-card { animation: ios-app-rise .28s cubic-bezier(.2,.8,.2,1); }
  @keyframes ios-app-rise { from { transform: translateY(18px) scale(.97); opacity: 0; } }
}

.narrow { max-width: 440px; margin: 0 auto; }
.narrow h1 { margin-bottom: .6em; }

/* forms */
.form { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.form label, label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: 400 1rem var(--sans); color: var(--text);
  background: var(--bg); border: 1px solid var(--muted); border-radius: var(--radius);
}
textarea { min-height: 160px; line-height: 1.6; resize: vertical; font-family: var(--serif); }
input[type=file] { font: inherit; padding: 8px 0; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.form .hint, .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

/* footer */
.foot { border-top: 3px double var(--line); background: var(--bg-alt); padding: 20px 0; color: var(--muted); font-size: .9rem; flex-shrink: 0; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; }
.foot a { color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }
.foot a:hover { color: var(--link); }
.foot span { margin-right: auto; }

/* admin */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 24px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--bg-alt); white-space: nowrap; }
tbody tr:hover { background: var(--bg-alt); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions form { margin: 0; display: inline-flex; gap: 6px; align-items: center; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: .78rem; font-weight: 700;
  background: var(--gray-bg); color: var(--text); white-space: nowrap;
}
.badge.draft { background: var(--gray-bg); color: var(--muted); }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.published { background: var(--ok-bg); color: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* public additions */
[hidden] { display: none !important; }
.hero { margin-bottom: 32px; }
.lead-sm { font-family: var(--serif); font-size: 1.15rem; color: var(--muted); max-width: 60ch; }
.continue { margin: 0 0 16px; }
.continue a { font-weight: 600; }
.legal { max-width: 70ch; margin: 0 auto; }
.legal h2 { margin-top: 1.6em; }
.badge { vertical-align: middle; }
.reader .tools { display: flex; gap: 8px; margin-top: 8px; }
.reader { --step: 0; }
.reader[data-fs="1"] { --step: 2; }
.reader[data-fs="2"] { --step: 4; }
.reader[data-fs="3"] { --step: 6; }
.reader[data-fs="4"] { --step: 8; }
.reader .body { font-size: calc(18px + var(--step) * 1px); }
@media (min-width: 700px) { .reader .body { font-size: calc(19px + var(--step) * 1px); } }
.reader .caught { text-align: center; margin-top: 16px; }

/* ---- /comic/{slug}/chapter/{n}: full-page images, vertical scroll ---- */
.comicpages { display: flex; flex-direction: column; align-items: center; gap: 0; margin: 16px auto; max-width: 900px; }
.comicpages img { display: block; width: 100%; height: auto; }
