/* StoryAddict — sleek, futuristic e-reader. Cool graphite, electric accent,
   crisp modern type. Kindle-clean reading surface. */
:root {
  --bg: #0a0c11;
  --bg-2: #0d1017;
  --panel: #12161e;
  --panel-2: #1a1f2a;
  --ink: #f3f6fb;
  --ink-soft: #cdd5e2;      /* long-form reading text */
  --muted: #8b95a7;
  --muted-2: #5a6576;
  --accent: #5b8cff;
  --accent-2: #9b6bff;
  --accent-soft: #a8c2ff;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --up: #58d6a0;
  --down: #ff7a8a;
  --grad: linear-gradient(135deg, #5b8cff, #9b6bff);
  --glow: 0 8px 30px rgba(91, 140, 255, 0.30);
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, Inter, system-ui, sans-serif;
  --reading: 'Charter', 'Cambria', 'Georgia', serif;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(1100px 620px at 82% -12%, rgba(91, 140, 255, 0.10), transparent 60%),
    radial-gradient(900px 560px at 8% 8%, rgba(155, 107, 255, 0.07), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 22px; }
a { color: inherit; text-decoration: none; }
em { font-style: italic; }

/* header */
.top { border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  background: rgba(10, 12, 17, 0.72); backdrop-filter: blur(14px); }
.top-inner { display: flex; align-items: center; gap: 14px; height: 60px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark { width: 28px; height: 28px; border-radius: 9px; background: var(--grad); display: grid; place-items: center;
  box-shadow: var(--glow); flex: none; }
.brand .mark svg { width: 17px; height: 17px; color: #fff; }
.brand-name { font-size: 19px; font-weight: 750; letter-spacing: -0.01em; }
.brand-name .lit { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.spacer { flex: 1; }

/* buttons */
.btn { font-family: var(--sans); font-size: 14px; font-weight: 650; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; transition: transform .06s ease, background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--grad); color: #fff; border: none; font-weight: 700; box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { font-size: 15.5px; padding: 15px 28px; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* hero */
.hero { text-align: center; padding: 78px 22px 40px; }
.hero-mark { width: 52px; height: 52px; border-radius: 15px; background: var(--grad); display: grid; place-items: center;
  margin: 0 auto 22px; box-shadow: var(--glow); }
.hero-mark svg { width: 30px; height: 30px; color: #fff; }
.hero h1 { font-weight: 780; font-size: clamp(34px, 6vw, 60px); line-height: 1.08; letter-spacing: -0.03em; margin-bottom: 36px; padding-bottom: 4px; }
.hero h1 .lit { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.lede { max-width: 600px; margin: 22px auto 30px; color: var(--muted); font-size: 18px; line-height: 1.6; }

.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 58px auto 0; max-width: 880px; text-align: left; }
.how-step { background: linear-gradient(180deg, rgba(255,255,255,.02), transparent), var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.how-step .n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: rgba(91,140,255,.14); border: 1px solid rgba(91,140,255,.3); color: var(--accent-soft); font-weight: 700; font-size: 13px; margin-bottom: 13px; }
.how-step b { display: block; font-size: 16px; margin-bottom: 5px; font-weight: 700; }
.how-step span { color: var(--muted); font-size: 13.5px; line-height: 1.55; }

/* footer */
.foot { border-top: 1px solid var(--line); margin-top: auto; padding: 20px 0; }
.foot .wrap { color: var(--muted-2); font-size: 12.5px; }
.foot-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.foot-tag { flex: 1; min-width: 220px; }
.foot-mint { display: inline-flex; align-items: center; gap: 7px; color: var(--muted-2); font-size: 12px; opacity: .72; transition: opacity .15s; white-space: nowrap; }
.foot-mint[hidden] { display: none; }
.foot-mint:hover { opacity: 1; }
.foot-mint img { height: 15px; width: auto; display: block; }
@media (max-width: 620px) { .foot-inner { justify-content: center; text-align: center; } .foot-tag { flex-basis: 100%; } }

/* utility */
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--line-2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* compose */
.compose { max-width: 720px; padding: 44px 22px 72px; }
.c-head h1 { font-weight: 780; font-size: clamp(28px, 4.5vw, 40px); letter-spacing: -0.02em; }
.c-head p { color: var(--muted); margin: 10px 0 30px; font-size: 15.5px; max-width: 520px; }
.field { display: block; margin-bottom: 24px; }
.flabel { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 11px; }
.field.big textarea { width: 100%; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px;
  color: var(--ink); font-family: var(--reading); font-size: 19px; line-height: 1.5; padding: 16px 17px; resize: vertical; min-height: 96px; }
.field.big textarea::placeholder { color: var(--muted-2); }
.field.big textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.16); }
.fhint { display: block; text-align: right; color: var(--muted-2); font-size: 12px; margin-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ink-soft);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 15px; cursor: pointer; transition: all .13s; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--glow); }
.chips.small .chip { padding: 8px 13px; font-size: 13.5px; }
.chip.len { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 16px; }
.chip.len small { font-weight: 500; font-size: 11.5px; opacity: .7; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

.dials { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 30px; margin: 30px 0 8px; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.dial-top { margin-bottom: 8px; }
.dial-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.dial input[type=range] { width: 100%; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 3px; background: var(--panel-2); outline: none; }
.dial input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--grad); cursor: pointer; border: 3px solid var(--panel); box-shadow: 0 0 10px rgba(91,140,255,.5); }
.dial input[type=range]::-moz-range-thumb { width: 17px; height: 17px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 3px solid var(--panel); }
.dial-ends { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted-2); font-size: 11.5px; }

.c-actions { margin-top: 30px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.c-note { color: var(--muted); font-size: 13px; }

/* reader — Kindle-clean */
.reader { padding-bottom: 90px; }
.r-bar { max-width: 700px; display: flex; align-items: center; justify-content: space-between; padding-top: 18px; padding-bottom: 6px; }
.r-exit { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.r-exit:hover { color: var(--accent-soft); }
.r-meter { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; font-variant-numeric: tabular-nums; }
.r-meter .m-spent { color: var(--accent-soft); font-weight: 700; }
.r-meter .m-dot { color: var(--muted-2); }
.r-bar-right { display: flex; align-items: center; gap: 11px; }
.r-dl { font-size: 12.5px; font-weight: 600; color: var(--muted); background: transparent; border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 13px; cursor: pointer; transition: border-color .15s, color .15s; }
.r-dl:hover { border-color: var(--accent); color: var(--accent-soft); }

.r-page { max-width: 700px; padding-top: 26px; transition: opacity .28s ease, transform .28s ease; }
.r-page.leaving { opacity: 0; transform: translateY(-6px); }
.r-loading { color: var(--muted); padding: 64px 0; text-align: center; font-size: 16px; }

.r-head { margin-bottom: 24px; }
.r-booktitle { font-weight: 760; font-size: clamp(23px, 4vw, 31px); letter-spacing: -0.02em; line-height: 1.15; }
.r-sub { color: var(--muted); font-size: 12px; margin-top: 8px; text-transform: uppercase; letter-spacing: 0.09em; }
.r-sample { color: var(--accent-soft); text-transform: none; letter-spacing: 0; }

.page-prose { font-family: var(--reading); font-size: 20px; line-height: 1.8; color: var(--ink-soft); text-align: justify; hyphens: auto; }
.page-prose p { margin: 0 0 1.15em; }
.page-prose.enter { animation: pageIn .42s cubic-bezier(.2, .7, .2, 1); }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.r-nav { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 46px; padding-top: 22px; border-top: 1px solid var(--line); }
.r-turn { font-family: var(--sans); font-size: 15px; font-weight: 700; cursor: pointer; border-radius: 11px; padding: 13px 20px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); transition: transform .06s, border-color .15s, filter .15s; }
.r-turn:hover:not(:disabled) { border-color: var(--accent); }
.r-turn:active:not(:disabled) { transform: translateY(1px); }
.r-turn:disabled { opacity: .3; cursor: default; }
.r-turn.ghost { background: transparent; min-width: 46px; }
.r-turn.primary { background: var(--grad); color: #fff; border: none; box-shadow: var(--glow); }
.r-turn.primary:hover { filter: brightness(1.07); }
.r-turn .r-price { opacity: .8; font-weight: 600; font-size: 13px; }
.r-pageno { color: var(--muted-2); font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; }

.r-end { text-align: center; padding: 44px 0 10px; }
.r-end-rule { width: 54px; height: 2px; background: var(--grad); border-radius: 2px; margin: 0 auto 26px; }
.r-end-title { font-weight: 780; font-size: 30px; letter-spacing: -0.01em; }
.r-end-sub { color: var(--muted); margin: 8px 0 26px; }
.r-end-again { margin-top: 16px; }
.r-end-again a { color: var(--accent-soft); font-size: 14px; font-weight: 600; }

/* wrap-up off-ramp card */
.wrap-card { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 70;
  background: rgba(6, 8, 12, 0.66); backdrop-filter: blur(6px); opacity: 0; transition: opacity .25s; }
.wrap-card.show { opacity: 1; }
.wc-inner { max-width: 420px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px; padding: 30px 28px; text-align: center;
  box-shadow: var(--shadow); transform: translateY(14px) scale(.98); transition: transform .28s cubic-bezier(.2, .7, .2, 1); }
.wrap-card.show .wc-inner { transform: none; }
.wc-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; margin: 0 auto 14px; box-shadow: var(--glow); }
.wc-mark svg { width: 20px; height: 20px; color: #fff; }
.wc-title { font-size: 22px; font-weight: 750; margin-bottom: 10px; letter-spacing: -0.01em; }
.wc-inner p { color: var(--ink-soft); font-size: 15px; line-height: 1.6; margin-bottom: 22px; }
.wc-inner b { color: var(--accent-soft); }
.wc-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* top-up */
.pay-methods { display: flex; gap: 10px; margin-bottom: 14px; }
.pm { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 14px 15px; cursor: pointer; transition: border-color .13s, transform .06s; color: var(--ink); }
.pm:hover { border-color: var(--accent); }
.pm:active { transform: translateY(1px); }
.pm b { font-size: 15px; font-weight: 700; }
.pm span { font-size: 11.5px; color: var(--muted); }
.topup-amts { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.topup-amts button { flex: 1; min-width: 66px; font-size: 15px; font-weight: 700; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 11px; padding: 12px 0; cursor: pointer; transition: border-color .13s, transform .06s; }
.topup-amts button:hover:not(:disabled) { border-color: var(--accent); }
.topup-amts button:active:not(:disabled) { transform: translateY(1px); }
.topup-amts button:disabled { opacity: .5; cursor: default; }
.tu-status { min-height: 18px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.tu-custom { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.tu-cur { font-family: var(--mono, monospace); font-size: 17px; color: var(--muted); }
#tuCustom { flex: 1; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 11px; color: var(--ink); font-size: 17px; font-weight: 700; padding: 12px 14px; -moz-appearance: textfield; }
#tuCustom::-webkit-outer-spin-button, #tuCustom::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#tuCustom:focus { outline: none; border-color: var(--accent); }
.tu-go { background: var(--grad); color: #fff; border: none; border-radius: 11px; font-weight: 700; font-size: 14px; padding: 12px 18px; cursor: pointer; }
.tu-go:disabled { opacity: .5; cursor: default; }
.tu-code-link { display: block; margin: 12px auto 0; background: none; border: none; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.tu-code-link:hover { color: var(--accent-soft); }
#tuCode { flex: 1; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 11px; color: var(--ink); font-size: 16px; font-weight: 700; padding: 12px 14px; }
#tuCode:focus { outline: none; border-color: var(--accent); }

/* per-page paywall */
.paywall { text-align: center; padding: 44px 0 10px; max-width: 460px; margin: 0 auto; }
.pw-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; margin: 0 auto 16px; box-shadow: var(--glow); }
.pw-mark svg { width: 22px; height: 22px; color: #fff; }
.pw-title { font-size: 24px; font-weight: 760; letter-spacing: -0.01em; margin-bottom: 8px; }
.paywall p { color: var(--ink-soft); font-size: 15.5px; line-height: 1.6; margin-bottom: 12px; }
.paywall b { color: var(--accent-soft); }
.pw-price { font-size: 15px; font-weight: 700; color: var(--accent-soft); margin-bottom: 6px; }
.pw-bal { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.pw-back { margin-top: 16px; }
.pw-back a { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.pw-back a:hover { color: var(--accent-soft); }

/* admin */
.admin { max-width: 720px; padding: 40px 22px 72px; }
.admin h1 { font-weight: 780; font-size: clamp(26px, 4vw, 34px); letter-spacing: -0.02em; }
.admin-sub { color: var(--muted); margin-top: 8px; font-size: 15px; }
.admin-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.admin-new { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.admin-new input[type=text], .admin-new #ncCode { flex: 1; min-width: 160px; }
.admin-new input { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; color: var(--ink); font-size: 15px; font-weight: 600; padding: 11px 13px; }
.admin-new input:focus { outline: none; border-color: var(--accent); }
.admin-new label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.admin-new label input { width: 90px; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 22px; font-size: 14px; }
.admin-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; padding: 0 10px 10px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ac-code { font-family: var(--mono, monospace); font-weight: 700; letter-spacing: 0.05em; color: var(--accent-soft); }
.ac-on { color: var(--up); font-size: 12px; font-weight: 700; }
.ac-off { color: var(--muted-2); font-size: 12px; }
.ac-btns { text-align: right; white-space: nowrap; }
.ac-mini { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink); font-size: 12px; font-weight: 600; padding: 6px 10px; margin-left: 6px; cursor: pointer; }
.ac-mini:hover { border-color: var(--accent); }
.admin-foot { color: var(--muted); font-size: 13px; margin-top: 24px; line-height: 1.6; }
.admin-foot code { font-family: var(--mono, monospace); color: var(--accent-soft); background: var(--panel); padding: 2px 6px; border-radius: 5px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 26px; translate: -50% 20px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink); padding: 12px 18px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s; z-index: 80; max-width: 90vw; }
#toast.show { opacity: 1; translate: -50% 0; }
#toast.err { border-color: var(--down); }

@media (max-width: 720px) {
  .how, .dials, .grid2 { grid-template-columns: 1fr; }
  .hero { padding-top: 54px; }
  .page-prose { font-size: 19px; text-align: left; }
}
