/* 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; }

.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; }
