:root {
  color-scheme: light;
  --ink: #25324a;
  --muted: #667482;
  --paper: #fffdf7;
  font-family: Nunito, "Trebuchet MS", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
.app-shell { max-width: 1040px; margin: auto; padding: 0 28px; }
.topbar { height: 68px; display: flex; align-items: center; border-bottom: 1px solid #ece8df; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 18px; font-weight: 900; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: #efe8ff; font-size: 19px; }
.hero { position: relative; display: flex; align-items: center; gap: 22px; min-height: 150px; margin: 24px 0 26px; padding: 24px 28px; border-radius: 22px; background: #f1ebff; overflow: hidden; }
.hero:after { content: "✦  ✦  ✧"; position: absolute; right: 205px; top: 19px; color: #d7c9fa; font-size: 15px; letter-spacing: 12px; }
.hero>div { flex: 1; }
.eyebrow { margin: 0 0 4px; color: #7358b0; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.hero h1 { margin: 0; font-size: clamp(25px,4vw,37px); line-height: 1.12; letter-spacing: -1px; font-weight: 900; }
.hero-desc { margin: 7px 0 0; color: #5d687b; font-size: 14px; font-weight: 600; }
.hero-book { font-size: 57px; line-height: 1; transform: rotate(-8deg); filter: drop-shadow(0 4px 0 #d6cafa); }
.surprise-btn { position: relative; z-index: 1; flex: none; border: 0; border-radius: 999px; background: #ffcf67; color: #553c08; padding: 12px 17px; font: 900 13px Nunito,sans-serif; box-shadow: 0 3px 0 #e7b64e; cursor: pointer; }
.surprise-btn:hover { transform: translateY(-1px); }
.browse { padding-bottom: 42px; }
.browse h2 { margin: 0 0 12px; font-size: 20px; font-weight: 900; }
.filters { display: flex; gap: 9px; margin-bottom: 15px; }
.searchbox { height: 43px; max-width: 390px; display: flex; align-items: center; gap: 8px; flex: 1; padding: 0 13px; background: white; border: 2px solid #eee9e1; border-radius: 13px; }
.searchbox:focus-within { border-color: #c9b5fa; }
.searchbox span { color: #7358b0; font-size: 22px; }
.searchbox input { width: 100%; border: 0; outline: 0; background: transparent; font: 700 14px Nunito,sans-serif; color: var(--ink); }
.searchbox input::placeholder { color: #98a1aa; }
select { height: 43px; max-width: 190px; border: 2px solid #eee9e1; border-radius: 13px; background: white; padding: 0 12px; font: 800 13px Nunito,sans-serif; color: #4b5564; }
.story-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.story-card { --tile: #fff0d6; display: grid; grid-template-columns: 1fr; gap: 0; align-items: start; align-content: start; min-width: 0; padding: 10px; border: 2px solid transparent; border-radius: 20px; background: var(--tile); cursor: pointer; transition: transform .15s,box-shadow .15s; }
.story-card:nth-child(4n+2) { --tile: #e8f4e7; }
.story-card:nth-child(4n+3) { --tile: #e8f1ff; }
.story-card:nth-child(4n) { --tile: #ffebf0; }
.story-card:hover,.story-card:focus { transform: translateY(-2px); box-shadow: 0 7px 17px #34425b15; outline: 3px solid #d2c2f5; }
.cover-box { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 4/3; overflow: hidden; border-radius: 15px; background: #ffffff9c; }
.cover-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { font-size: 56px; }
.card-copy { min-width: 0; padding: 11px 4px 3px; }
.card-number { display: inline-block; margin-bottom: 5px; color: #727b88; font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.story-card h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.2; font-weight: 900; }
.card-meta { display: inline-block; padding: 3px 9px; border-radius: 99px; background: #ffffffb5; color: #58636f; font-size: 10px; font-weight: 800; }
.loading,.empty { grid-column: 1/-1; padding: 24px 0; text-align: center; color: var(--muted); font-size: 14px; font-weight: 700; }
.story-dialog { border: 0; border-radius: 20px; padding: 0; max-width: 760px; width: calc(100% - 24px); max-height: 92vh; background: white; color: var(--ink); box-shadow: 0 16px 60px #18243b35; }
.story-dialog::backdrop { background: #27344c99; }
dialog[open] { display: block; }
.close { position: sticky; top: 10px; float: right; margin: 11px 12px -42px 0; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #fff3d8; color: #634d1f; font-size: 21px; cursor: pointer; }
.story-inner { max-height: 92vh; overflow: auto; padding: 30px 38px 36px; }
.story-kicker { color: #7358b0; font-size: 12px; font-weight: 900; }
.story-title { margin: 7px 0 15px; font-size: 32px; line-height: 1.12; font-weight: 900; }
.story-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tool-btn { border: 0; border-radius: 999px; background: #eee8ff; padding: 9px 14px; color: #563e94; font: 900 13px Nunito,sans-serif; cursor: pointer; }
.tool-btn:hover,.tool-btn.active { background: #ded2ff; }
.speed-label { display: flex; align-items: center; gap: 6px; color: #58636f; font-size: 12px; font-weight: 900; }
.story-tools select { height: 36px; font-size: 12px; }
.story-text { color: #354052; font: 600 18px/1.75 Nunito,Georgia,serif; }
.story-text p { margin: 0 0 14px; }
.word { cursor: pointer; border-radius: 4px; }
.word:hover,.word:focus { background: #fff0b8; outline: 0; }
.inline-picture { margin: 12px 0 19px; }
.inline-picture img { display: block; width: 100%; max-height: 310px; object-fit: cover; border-radius: 16px; background: #f1ecff; }
.moral { margin-top: 14px; padding: 13px 16px; border-radius: 13px; background: #e8f4e7; color: #4d684d; font-size: 15px; font-weight: 700; }
.moral b { display: block; margin-bottom: 3px; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.story-loading { text-align: center; padding: 40px 12px; color: #697487; font-size: 15px; font-weight: 800; }
.story-loading .loader { display: block; margin-bottom: 10px; color: #805dca; font-size: 28px; animation: spin 2.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.story-error { color: #9c3f39; background: #fff0ed; padding: 12px 14px; border-radius: 11px; font-size: 14px; font-weight: 700; }
@media(max-width:720px) {
  .app-shell { padding: 0 16px; }
  .topbar { height: 60px; }
  .brand { font-size: 16px; }
  .hero { min-height: 132px; margin: 16px 0 20px; padding: 18px; gap: 10px; border-radius: 18px; }
  .hero:after { display: none; }
  .hero-book { font-size: 43px; }
  .surprise-btn { position: absolute; right: 14px; bottom: 12px; padding: 9px 13px; font-size: 12px; }
  .hero>div { padding-right: 72px; padding-bottom: 24px; }
  .hero h1 { font-size: 26px; }
  .hero-desc { font-size: 12px; }
  .eyebrow { font-size: 9px; }
  .browse h2 { font-size: 18px; }
  .filters { gap: 6px; }
  .searchbox { height: 41px; min-width: 0; }
  .searchbox input { font-size: 12px; }
  select { height: 41px; max-width: 145px; padding: 0 8px; font-size: 11px; }
  .story-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; }
  .story-card { min-height: 0; padding: 8px; border-radius: 16px; }
  .story-card h3 { font-size: 14px; }
  .card-copy { padding: 9px 3px 3px; }
  .card-number { font-size: 9px; }
  .card-meta { font-size: 9px; }
  .cover-box { border-radius: 12px; }
  .cover-placeholder { font-size: 40px; }
  .story-inner { padding: 25px 19px 28px; }
  .story-title { font-size: 27px; }
  .story-text { font-size: 17px; line-height: 1.7; }
  .inline-picture img { max-height: 235px; }
}
@media(max-width:380px) {
  .story-grid { grid-template-columns: 1fr; }
  .story-card h3 { font-size: 16px; }
  .cover-placeholder { font-size: 50px; }
}
