:root{
  --bg:#fffaf8;--card:#fff;--text:#312928;--muted:#7b6d69;
  --line:#eaded9;--accent:#9b3d62;--accent2:#702741;
  --shadow:0 12px 30px rgba(70,35,45,.08);--reader-size:19px
}
*{box-sizing:border-box} body{margin:0;background:var(--bg);color:var(--text);
font-family:system-ui,-apple-system,"Segoe UI",sans-serif;line-height:1.65}
a{text-decoration:none;color:inherit} button,input,select,textarea{font:inherit}
header{position:sticky;top:0;z-index:20;background:rgba(255,250,248,.96);
border-bottom:1px solid var(--line);backdrop-filter:blur(10px)}
.header-inner{width:min(1120px,calc(100% - 24px));margin:auto;min-height:64px;
display:flex;align-items:center;gap:18px}.brand{font:700 20px Georgia,serif;color:var(--accent2)}
nav{display:flex;gap:8px;flex:1;justify-content:center}nav a{padding:8px 10px;border-radius:10px;color:var(--muted)}
nav a:hover{background:#f6ece8;color:var(--accent)}.auth-slot{min-width:95px;text-align:right}
.container{width:min(1120px,calc(100% - 24px));margin:auto}.hero{text-align:center;padding:58px 0 36px}
.hero h1{font:700 clamp(34px,7vw,62px) Georgia,serif;color:var(--accent2);margin:0}
.hero p{max-width:680px;margin:16px auto;color:var(--muted)}.notice{background:#fff2f5;border:1px solid #eed3dc;
border-radius:13px;padding:13px 15px}.section{padding:24px 0 52px}.section-head{display:flex;justify-content:space-between;
align-items:end;margin-bottom:16px}.section-head h2,.page-title{font-family:Georgia,serif;color:var(--accent2)}
.grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}.card{background:var(--card);
border:1px solid var(--line);border-radius:16px;overflow:hidden;box-shadow:var(--shadow)}.cover{aspect-ratio:2/3;background:#ead9d4;
position:relative;display:block}.cover img{width:100%;height:100%;object-fit:cover}.placeholder{height:100%;display:grid;
place-items:center;text-align:center;font:700 24px Georgia,serif;color:var(--accent2);
background:linear-gradient(145deg,#f5e7e3,#dec3ca)}.badge{position:absolute;right:9px;top:9px;background:#7f233f;color:#fff;
padding:3px 7px;border-radius:999px;font-size:12px}.card-body{padding:13px}.card h3{margin:0 0 3px;line-height:1.35}
.muted{color:var(--muted)}.tags{display:flex;gap:5px;flex-wrap:wrap;margin-top:9px}.tags span{font-size:12px;
background:#f6ece8;color:var(--muted);padding:3px 7px;border-radius:999px}.meta{display:flex;justify-content:space-between;
font-size:13px;color:var(--muted);margin-top:10px}.button{display:inline-flex;align-items:center;justify-content:center;border:0;
background:var(--accent);color:#fff;border-radius:10px;padding:9px 14px;cursor:pointer}.button:hover{background:var(--accent2)}
.button.ghost{background:transparent;color:var(--accent);border:1px solid var(--line)}.button.danger{background:#a22e2e}
.field{display:grid;gap:6px}.field label{font-weight:650}.field input,.field textarea,.field select{width:100%;padding:10px 11px;
border:1px solid var(--line);border-radius:10px;background:#fff}.form{display:grid;gap:14px}.row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.auth-box,.center-card{width:min(540px,calc(100% - 24px));margin:48px auto;background:var(--card);border:1px solid var(--line);
border-radius:17px;padding:24px;box-shadow:var(--shadow)}.tabs{display:grid;grid-template-columns:1fr 1fr;gap:5px;background:#f6ece8;
padding:5px;border-radius:12px;margin-bottom:18px}.tabs button{border:0;background:transparent;padding:9px;border-radius:8px;cursor:pointer}
.tabs button.active{background:#fff;color:var(--accent)}.hidden{display:none!important}.story-detail{display:grid;grid-template-columns:230px 1fr;
gap:28px;padding:38px 0}.story-cover{aspect-ratio:2/3;border-radius:15px;overflow:hidden;background:#ead9d4;box-shadow:var(--shadow)}
.story-cover img{width:100%;height:100%;object-fit:cover}.summary{white-space:pre-wrap}.chapter-list{display:grid;gap:8px;margin-bottom:48px}
.chapter-item{display:flex;justify-content:space-between;padding:11px 13px;border:1px solid var(--line);background:#fff;border-radius:10px}
.reader{width:min(760px,calc(100% - 24px));margin:38px auto}.reader h1{text-align:center;font-family:Georgia,serif;color:var(--accent2)}
.chapter-content{font:var(--reader-size)/1.9 Georgia,"Times New Roman",serif}.chapter-content p{white-space:pre-wrap;margin:0 0 1.2em}
.reader-nav{display:flex;justify-content:space-between;gap:12px;margin:40px 0}.toolbar{position:sticky;top:64px;z-index:15;
background:rgba(255,250,248,.96);border-bottom:1px solid var(--line)}.toolbar-inner{width:min(760px,calc(100% - 24px));margin:auto;
display:flex;justify-content:space-between;align-items:center;min-height:50px}.tools{display:flex;gap:5px}.tools button{border:1px solid var(--line);
background:#fff;border-radius:8px;padding:5px 9px;cursor:pointer}.admin-layout{display:grid;grid-template-columns:220px 1fr;gap:22px;padding:28px 0 50px}
.admin-nav{display:grid;gap:7px;align-self:start;position:sticky;top:88px}.admin-nav button{border:1px solid var(--line);background:#fff;
padding:10px;border-radius:9px;text-align:left;cursor:pointer}.admin-panel{background:#fff;border:1px solid var(--line);border-radius:15px;padding:20px}
table{width:100%;border-collapse:collapse}th,td{padding:9px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}
.loading,.empty{text-align:center;padding:28px;color:var(--muted);border:1px dashed var(--line);border-radius:12px}
footer{text-align:center;color:var(--muted);border-top:1px solid var(--line);padding:30px 0}
@media(max-width:850px){.grid{grid-template-columns:repeat(3,1fr)}nav{position:fixed;left:0;right:0;bottom:0;background:#fff;
border-top:1px solid var(--line);padding:6px;z-index:30;justify-content:space-around}nav a{font-size:12px;padding:6px 3px}
body{padding-bottom:54px}.admin-layout{grid-template-columns:1fr}.admin-nav{position:static;grid-template-columns:repeat(3,1fr)}
.story-detail{grid-template-columns:180px 1fr}}
@media(max-width:600px){.grid{grid-template-columns:repeat(2,1fr);gap:11px}.story-detail{grid-template-columns:115px 1fr;gap:15px}
.story-detail .summary-block{grid-column:1/-1}.row{grid-template-columns:1fr}.reader-nav{flex-direction:column}}


/* ===== GIAO DIỆN TÙY CHỈNH MINMAANX ===== */
.brand{
  font-family:Arial,"Segoe UI",sans-serif;
  font-weight:800;
  letter-spacing:.02em;
  color:var(--accent2);
  text-transform:lowercase;
}

.header-inner{
  gap:14px;
}

.social-links{
  display:flex;
  align-items:center;
  gap:7px;
  flex:0 0 auto;
}

.social-icon{
  width:32px;
  height:32px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:transform .18s ease,box-shadow .18s ease;
}

.social-icon:hover{
  transform:translateY(-2px);
  box-shadow:0 7px 16px rgba(50,30,40,.18);
}

.social-icon img{
  width:16px;
  height:16px;
  object-fit:contain;
}

.social-icon.facebook{background:#1877f2}
.social-icon.instagram{
  background:radial-gradient(circle at 30% 105%,#fdf497 0 5%,#fdf497 5% 10%,#fd5949 36%,#d6249f 62%,#285aeb 90%);
}
.social-icon.wattpad{background:#ff500a}

.hero{
  padding:38px 0 34px;
}

.hero-banner{
  position:relative;
  width:min(880px,100%);
  aspect-ratio:16/8;
  margin:0 auto 20px;
  overflow:hidden;
  border-radius:22px;
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  background:#8fb5dc;
}

.hero-banner>img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
}

.hero-shade{
  position:absolute;
  inset:0;
  background:linear-gradient(to bottom,rgba(15,30,48,.04),rgba(12,24,40,.52));
}

.hero-banner h1{
  position:absolute;
  left:24px;
  right:24px;
  bottom:22px;
  z-index:2;
  margin:0;
  color:#fff;
  font-family:Arial,"Segoe UI",sans-serif;
  font-size:clamp(30px,6.5vw,66px);
  font-weight:900;
  line-height:1.05;
  letter-spacing:.055em;
  text-align:center;
  text-shadow:0 3px 14px rgba(0,0,0,.72);
}

.hero .notice{
  max-width:880px;
  margin:0 auto;
  font-size:16px;
}

@media(max-width:850px){
  .header-inner{gap:9px}
  .social-links{gap:5px}
  .social-icon{width:30px;height:30px}
  .social-icon img{width:15px;height:15px}
  .auth-slot{min-width:auto}
}

@media(max-width:600px){
  .brand{font-size:17px}
  .header-inner{min-height:58px}
  .social-icon{width:28px;height:28px}
  .social-icon img{width:14px;height:14px}
  .auth-slot .button{padding:7px 9px;font-size:13px}
  .hero{padding-top:24px}
  .hero-banner{border-radius:16px;aspect-ratio:16/9}
  .hero-banner h1{left:12px;right:12px;bottom:14px;font-size:clamp(25px,9vw,42px)}
}


/* ===== BẢN V3: FONT MỀM MẠI + FOOTER MỚI ===== */

.brand{
  font-family:"Dancing Script","Segoe Script","Lucida Handwriting",cursive;
  font-size:27px;
  font-weight:700;
  letter-spacing:.01em;
  text-transform:none;
  line-height:1;
}

.hero-banner h1{
  font-family:"Cormorant Garamond",Georgia,"Times New Roman",serif;
  font-size:clamp(36px,7vw,74px);
  font-weight:600;
  font-style:italic;
  letter-spacing:.035em;
  text-transform:uppercase;
}

.site-footer{
  padding:34px 18px;
  border-top:1px solid var(--line);
  text-align:center;
}

.footer-note{
  width:min(820px,100%);
  margin:0 auto;
  color:var(--muted);
  line-height:1.75;
}

.footer-note p{
  margin:3px 0;
}

@media(max-width:600px){
  .brand{
    font-size:23px;
  }

  .hero-banner h1{
    font-size:clamp(31px,10vw,48px);
    letter-spacing:.02em;
  }

  .site-footer{
    padding:28px 18px;
  }

  .footer-note{
    font-size:14px;
    line-height:1.65;
  }
}


/* ===== BẢN V4: SỬA DỨT ĐIỂM FONT TIẾNG VIỆT ===== */
.brand{
  font-family:"Dancing Script","Segoe Script","Times New Roman",cursive;
  font-size:27px;
  font-weight:700;
  letter-spacing:0;
  text-transform:none;
}

.hero-banner h1{
  left:50%;
  right:auto;
  width:max-content;
  max-width:94%;
  transform:translateX(-50%);
  white-space:nowrap;
  font-family:"Lora","Palatino Linotype","Book Antiqua","Times New Roman",serif;
  font-size:clamp(32px,5.7vw,64px);
  font-weight:600;
  font-style:italic;
  letter-spacing:.005em;
  text-transform:none;
  font-kerning:normal;
  font-variant-ligatures:normal;
}

@media(max-width:600px){
  .hero-banner h1{
    max-width:96%;
    font-size:clamp(25px,8vw,39px);
    letter-spacing:0;
  }
}


/* ===== BẢN V6: THƯ VIỆN + CHƯƠNG MỚI CẬP NHẬT ===== */
.library-section{
  padding-top:34px;
}

.latest-section{
  padding-top:8px;
}

.latest-chapter-list{
  display:grid;
  gap:10px;
}

.latest-chapter-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:14px 17px;
  border:1px solid var(--line);
  border-radius:13px;
  background:var(--card);
  box-shadow:0 6px 18px rgba(70,35,45,.045);
  transition:border-color .18s ease,transform .18s ease,box-shadow .18s ease;
}

.latest-chapter-item:hover{
  border-color:#d6a9b8;
  transform:translateY(-1px);
  box-shadow:0 9px 22px rgba(70,35,45,.08);
}

.latest-chapter-main{
  display:grid;
  gap:2px;
  min-width:0;
}

.latest-story-name{
  color:var(--accent);
  font-size:14px;
}

.latest-chapter-main strong{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.latest-chapter-date{
  flex:0 0 auto;
  color:var(--muted);
  font-size:13px;
}

@media(max-width:600px){
  .latest-chapter-item{
    align-items:flex-start;
    padding:12px 13px;
  }

  .latest-chapter-main strong{
    white-space:normal;
  }

  .latest-chapter-date{
    font-size:12px;
  }
}


/* ===== BẢN V7: TẢI ẢNH BÌA TRỰC TIẾP ===== */
.field-help{
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}

.cover-upload-preview{
  display:grid;
  justify-items:start;
  gap:10px;
  margin-top:6px;
}

.cover-upload-preview img{
  width:150px;
  aspect-ratio:2/3;
  object-fit:cover;
  border:1px solid var(--line);
  border-radius:12px;
  background:#ead9d4;
  box-shadow:var(--shadow);
}

.small-button{
  padding:7px 11px;
  font-size:13px;
}

button:disabled{
  cursor:not-allowed;
  opacity:.65;
}


/* =========================================================
   BẢN V9 — TRANG TRUYỆN VÀ CHẾ ĐỘ ĐỌC
   ========================================================= */

/* Phần giới thiệu luôn chiếm trọn chiều ngang bên dưới bìa và thông tin. */
.story-detail .summary-block{
  grid-column:1 / -1;
  width:100%;
  min-width:0;
  margin-top:10px;
}

.story-detail .summary-block h2{
  margin:0 0 14px;
}

.story-detail .summary{
  width:100%;
  max-width:none;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  font-size:17px;
  line-height:1.8;
  text-align:left;
}

/* Biến màu chỉ dùng cho trang đọc. */
body.reader-page[data-reader-theme="white"]{
  --reader-bg:#ffffff;
  --reader-text:#242424;
  --reader-muted:#746f6d;
  --reader-line:#e5e1df;
  --reader-panel:rgba(255,255,255,.84);
  --reader-accent:#8b3154;
}

body.reader-page[data-reader-theme="cream"]{
  --reader-bg:#f7f0df;
  --reader-text:#3b312a;
  --reader-muted:#7d7168;
  --reader-line:#ddd0ba;
  --reader-panel:rgba(247,240,223,.86);
  --reader-accent:#8b3154;
}

body.reader-page[data-reader-theme="dark"]{
  --reader-bg:#171717;
  --reader-text:#e8e5e2;
  --reader-muted:#aaa39d;
  --reader-line:#393939;
  --reader-panel:rgba(35,35,35,.88);
  --reader-accent:#e39ab5;
}

body.reader-page{
  background:var(--reader-bg);
  color:var(--reader-text);
  transition:background-color .2s ease,color .2s ease;
}

body.reader-page header,
body.reader-page .reader-topbar{
  background:var(--reader-panel);
  border-color:var(--reader-line);
  color:var(--reader-text);
  backdrop-filter:blur(14px);
}

body.reader-page header nav a,
body.reader-page .auth-slot,
body.reader-page .reader-topbar a{
  color:var(--reader-text);
}

body.reader-page header nav a:hover{
  background:rgba(127,127,127,.12);
  color:var(--reader-accent);
}

body.reader-page .brand,
body.reader-page .reader h1{
  color:var(--reader-accent);
}

body.reader-page .button.ghost{
  color:var(--reader-accent);
  border-color:var(--reader-line);
  background:transparent;
}

body.reader-page .button{
  background:var(--reader-accent);
}

body.reader-page .button.ghost:hover{
  background:rgba(127,127,127,.10);
}

body.reader-page .muted,
body.reader-page .reader-story-title{
  color:var(--reader-muted);
}

body.reader-page .reader-topbar{
  position:sticky;
  top:64px;
  z-index:15;
}

body.reader-page .toolbar-inner{
  width:min(920px,calc(100% - 32px));
  min-height:48px;
}

.reader{
  width:min(920px,calc(100% - 32px));
  margin:42px auto 110px;
}

.reader h1{
  margin:14px 0 30px;
  text-align:center;
  font-family:"Noto Serif","Times New Roman",serif;
  font-size:clamp(28px,4.5vw,42px);
  line-height:1.35;
}

.reader-story-title{
  margin:0;
  text-align:center;
  font-size:16px;
}

.chapter-content{
  font-family:"Times New Roman","Noto Serif",serif;
  font-size:var(--reader-size);
  line-height:1.9;
  color:var(--reader-text);
  font-kerning:normal;
  font-variant-ligatures:normal;
  text-rendering:optimizeLegibility;
}

.chapter-content p{
  margin:0 0 1.22em;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  text-align:left;
}

/* Đoạn hook nằm trước dấu ***. */
.chapter-content .chapter-hook{
  margin-bottom:1.35em;
  font-style:italic;
  text-align:left;
}

/* Dòng ngăn cách giữa hook và nội dung chính. */
.chapter-content .chapter-separator{
  margin:1.7em 0;
  text-align:left;
  letter-spacing:.12em;
}

.reader-nav{
  align-items:center;
  margin:48px 0 20px;
}

/* Nút tròn nổi góc phải dưới. */
.reader-settings{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:60;
  display:grid;
  justify-items:end;
  gap:10px;
}

.reader-settings-toggle{
  width:50px;
  height:50px;
  border:1px solid var(--reader-line);
  border-radius:50%;
  background:var(--reader-panel);
  color:var(--reader-text);
  box-shadow:0 8px 25px rgba(0,0,0,.16);
  backdrop-filter:blur(14px);
  cursor:pointer;
  font-family:Georgia,"Times New Roman",serif;
  font-size:17px;
  font-weight:700;
  transition:transform .16s ease,box-shadow .16s ease;
}

.reader-settings-toggle:hover{
  transform:translateY(-2px);
  box-shadow:0 11px 29px rgba(0,0,0,.2);
}

.reader-settings-panel{
  width:220px;
  padding:14px;
  border:1px solid var(--reader-line);
  border-radius:17px;
  background:var(--reader-panel);
  color:var(--reader-text);
  box-shadow:0 15px 38px rgba(0,0,0,.18);
  backdrop-filter:blur(16px);
}

.reader-setting-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}

.reader-setting-row + .reader-setting-row{
  margin-top:13px;
  padding-top:13px;
  border-top:1px solid var(--reader-line);
}

.reader-setting-label{
  font-size:14px;
  font-weight:650;
}

.font-size-controls,
.theme-controls{
  display:flex;
  align-items:center;
  gap:7px;
}

.font-size-controls button{
  min-width:36px;
  height:34px;
  padding:0 8px;
  border:1px solid var(--reader-line);
  border-radius:9px;
  background:transparent;
  color:var(--reader-text);
  cursor:pointer;
}

#fontSizeValue{
  min-width:24px;
  text-align:center;
  font-size:13px;
  color:var(--reader-muted);
}

.theme-swatch{
  width:28px;
  height:28px;
  padding:0;
  border:2px solid transparent;
  border-radius:50%;
  box-shadow:inset 0 0 0 1px rgba(90,75,65,.25);
  cursor:pointer;
}

.theme-swatch.active{
  outline:2px solid var(--reader-accent);
  outline-offset:2px;
}

.swatch-white{background:#ffffff}
.swatch-cream{background:#f7f0df}
.swatch-dark{background:#171717}

@media(max-width:850px){
  body.reader-page header nav{
    background:var(--reader-panel);
    border-color:var(--reader-line);
    backdrop-filter:blur(14px);
  }
}

@media(max-width:600px){
  body.reader-page .reader-topbar{
    top:58px;
  }

  body.reader-page .toolbar-inner,
  .reader{
    width:min(100% - 28px,920px);
  }

  .reader{
    margin-top:30px;
    margin-bottom:120px;
  }

  .reader h1{
    margin-bottom:24px;
  }

  .reader-settings{
    right:14px;
    bottom:72px;
  }

  .reader-settings-toggle{
    width:46px;
    height:46px;
  }

  .reader-settings-panel{
    width:210px;
  }
}
