:root {
  --primary: #FF6B00;
  --primary-light: #FF8F40;
  --primary-dark: #E55A00;
  --bg: #F5F6FA;
  --bg-card: #FFFFFF;
  --bg-input: #F0F1F5;
  --text: #1A1A2E;
  --text-2: #6B7280;
  --text-3: #9CA3AF;
  --border: #E5E7EB;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --star: #FBBF24;
  --reader-bg: #FFFFFF;
  --reader-text: #1F2937;
}
[data-theme="dark"] {
  --primary: #FF8F40;
  --primary-light: #FFB088;
  --primary-dark: #FF6B00;
  --bg: #0F172A;
  --bg-card: #1E293B;
  --bg-input: #334155;
  --text: #F1F5F9;
  --text-2: #94A3B8;
  --text-3: #64748B;
  --border: #334155;
  --shadow: 0 2px 8px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.3);
  --reader-bg: #1E293B;
  --reader-text: #E2E8F0;
}
[data-theme="sepia"] {
  --primary: #E55A00;
  --primary-light: #FF8F40;
  --bg: #F5E6D3;
  --bg-card: #FAF0E6;
  --bg-input: #EDD9C4;
  --text: #5D4037;
  --text-2: #795548;
  --text-3: #A1887F;
  --border: #D7CCC8;
  --shadow: 0 2px 8px rgba(93,64,55,0.08);
  --reader-bg: #FAF0E6;
  --reader-text: #4E342E;
}
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
body { font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; background:var(--bg); color:var(--text); min-height:100vh; overflow-x:hidden; }
a { color:var(--primary); text-decoration:none; }
img { max-width:100%; display:block; }
button, input, textarea, select { font-family:inherit; }
input, textarea, select {
  background:var(--bg-input); color:var(--text); border:1px solid var(--border);
  border-radius:var(--radius-sm); padding:12px 14px; width:100%; font-size:15px;
  outline:none; transition:border .2s;
}
input:focus, textarea:focus { border-color:var(--primary); }
textarea { resize:vertical; min-height:200px; line-height:1.8; }

/* BUTTONS */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:12px 20px; border:none; border-radius:var(--radius); font-size:15px; font-weight:600; cursor:pointer; transition:all .2s; }
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:active { background:var(--primary-dark); transform:scale(0.97); }
.btn-ghost { background:transparent; color:var(--text); border:1px solid var(--border); }
.btn-sm { padding:8px 14px; font-size:13px; border-radius:var(--radius-sm); }
.btn-icon { width:38px; height:38px; padding:0; border-radius:50%; background:transparent; border:none; color:var(--text); display:flex; align-items:center; justify-content:center; }
.btn-icon svg { width:22px; height:22px; }

/* HEADER */
.header { position:fixed; top:0; left:0; right:0; height:54px; background:var(--bg); display:flex; align-items:center; padding:0 16px; z-index:100; border-bottom:1px solid var(--border); }
.header h1 { font-size:20px; font-weight:800; color:var(--primary); letter-spacing:-0.5px; }
.header h1 span { color:var(--text); }
.header-spacer { flex:1; }
.header .btn-icon { width:36px; height:36px; }

/* BOTTOM NAV */
.bottom-nav { position:fixed; bottom:0; left:0; right:0; height:60px; background:var(--bg-card); border-top:1px solid var(--border); display:flex; z-index:100; padding-bottom:env(safe-area-inset-bottom); }
.bottom-nav a { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; color:var(--text-3); font-size:10px; font-weight:600; transition:color .2s; position:relative; }
.bottom-nav a.active { color:var(--primary); }
.bottom-nav a.active::before { content:''; position:absolute; top:-1px; width:24px; height:3px; background:var(--primary); border-radius:0 0 3px 3px; }
.bottom-nav a svg { width:22px; height:22px; }

/* PAGE */
.page { padding-top:54px; min-height:100vh; padding-bottom:76px; }
.page-narrow { max-width:480px; margin:0 auto; padding:54px 16px 76px; }

/* HOME */
.home-section { padding:12px 16px; max-width:600px; margin:0 auto; }
.section-title { font-size:17px; font-weight:700; margin-bottom:10px; display:flex; align-items:center; justify-content:space-between; }
.section-title .more { font-size:13px; color:var(--primary); font-weight:500; }
.search-bar { position:relative; margin-bottom:14px; }
.search-bar input { padding-left:42px; height:42px; border-radius:22px; font-size:14px; }
.search-icon { position:absolute; left:14px; top:50%; transform:translateY(-50%); width:18px; height:18px; color:var(--text-3); pointer-events:none; }
.genre-scroll { display:flex; gap:8px; overflow-x:auto; padding-bottom:4px; margin-bottom:14px; scrollbar-width:none; -ms-overflow-style:none; }
.genre-scroll::-webkit-scrollbar { display:none; }
.genre-chip { flex-shrink:0; padding:7px 16px; border-radius:20px; font-size:13px; font-weight:500; background:var(--bg-card); color:var(--text-2); border:1px solid var(--border); cursor:pointer; transition:all .2s; }
.genre-chip.active { background:var(--primary); color:#fff; border-color:var(--primary); }

/* BANNER */
.banner { width:100%; aspect-ratio:2.4/1; border-radius:var(--radius-lg); overflow:hidden; margin-bottom:16px; position:relative; background:linear-gradient(135deg,var(--primary),var(--primary-dark)); display:flex; align-items:flex-end; padding:16px 20px; color:#fff; }
.banner-text h2 { font-size:18px; font-weight:700; margin-bottom:2px; }
.banner-text p { font-size:12px; opacity:.85; }

/* NOVEL CARDS */
.novel-scroll { display:flex; gap:12px; overflow-x:auto; padding-bottom:4px; margin-bottom:20px; scrollbar-width:none; }
.novel-scroll::-webkit-scrollbar { display:none; }
.novel-card-sm { flex-shrink:0; width:110px; cursor:pointer; transition:transform .15s; }
.novel-card-sm:active { transform:scale(0.96); }
.cover-sm { width:110px; height:150px; border-radius:var(--radius-sm); overflow:hidden; background:var(--bg-input); position:relative; }
.cover-sm img { width:100%; height:100%; object-fit:cover; }
.cover-sm .placeholder-cover { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:28px; font-weight:800; color:var(--primary); background:linear-gradient(135deg, var(--bg-input) 0%, var(--border) 100%); }
.novel-card-sm h3 { font-size:12px; font-weight:600; margin-top:6px; line-height:1.3; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.novel-card-sm .meta { font-size:10px; color:var(--text-3); margin-top:2px; display:flex; align-items:center; gap:3px; }
.novel-card-sm .meta svg { width:10px; height:10px; }

/* NOVEL GRID */
.novel-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-bottom:20px; }
.novel-grid .novel-card-sm { width:auto; }
.novel-grid .cover-sm { width:100%; aspect-ratio:3/4.2; }

/* NOVEL CARD HORIZONTAL */
.novel-hcard { display:flex; gap:12px; padding:12px; background:var(--bg-card); border-radius:var(--radius); margin-bottom:10px; cursor:pointer; transition:transform .15s; box-shadow:var(--shadow); }
.novel-hcard:active { transform:scale(0.98); }
.cover-hcard { width:80px; height:110px; border-radius:var(--radius-sm); overflow:hidden; flex-shrink:0; background:var(--bg-input); }
.cover-hcard img { width:100%; height:100%; object-fit:cover; }
.cover-hcard .placeholder-cover { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:24px; font-weight:800; color:var(--primary); background:linear-gradient(135deg, var(--bg-input), var(--border)); }
.hcard-info { flex:1; display:flex; flex-direction:column; justify-content:space-between; min-width:0; }
.hcard-info h3 { font-size:15px; font-weight:600; line-height:1.3; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.hcard-info .meta { font-size:12px; color:var(--text-2); }
.hcard-info .genre-tag { display:inline-block; padding:2px 8px; border-radius:4px; background:var(--primary); color:#fff; font-size:10px; font-weight:600; margin-top:4px; width:fit-content; }

/* NOVEL DETAIL */
.detail-hero { display:flex; gap:16px; margin-bottom:16px; padding:16px; background:var(--bg-card); border-radius:var(--radius-lg); box-shadow:var(--shadow); }
.detail-cover { width:120px; height:170px; border-radius:var(--radius); overflow:hidden; flex-shrink:0; }
.detail-cover img { width:100%; height:100%; object-fit:cover; }
.detail-cover .placeholder-cover { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:36px; font-weight:800; color:var(--primary); background:linear-gradient(135deg, var(--bg-input), var(--border)); }
.detail-meta h2 { font-size:20px; font-weight:700; margin-bottom:4px; line-height:1.3; }
.detail-meta .author { font-size:13px; color:var(--text-2); margin-bottom:6px; }
.detail-meta .tags { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:8px; }
.detail-meta .tag { padding:3px 10px; border-radius:4px; background:var(--bg-input); font-size:11px; font-weight:500; color:var(--text-2); }
.detail-meta .stats { font-size:12px; color:var(--text-3); display:flex; gap:12px; }
.detail-desc { padding:0 16px 12px; }
.detail-desc p { font-size:14px; color:var(--text-2); line-height:1.7; }
.detail-actions { display:flex; gap:8px; padding:0 16px 16px; }
.detail-actions .btn { flex:1; }

/* CHAPTER LIST */
.ch-list { padding:0 16px; }
.ch-section-title { font-size:15px; font-weight:700; margin:16px 0 8px; }
.ch-item { display:flex; align-items:center; gap:12px; padding:14px 0; border-bottom:1px solid var(--border); cursor:pointer; }
.ch-item:active { opacity:.7; }
.ch-num { width:36px; height:36px; border-radius:50%; background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; flex-shrink:0; }
.ch-item h4 { font-size:14px; font-weight:500; flex:1; }
.ch-item .ch-meta { font-size:11px; color:var(--text-3); }

/* READER */
.reader-overlay { position:fixed; inset:0; z-index:200; background:var(--reader-bg); display:flex; flex-direction:column; }
.reader-header { height:52px; display:flex; align-items:center; padding:0 12px; background:var(--reader-bg); border-bottom:1px solid var(--border); flex-shrink:0; }
.reader-header h3 { font-size:14px; font-weight:600; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin:0 8px; }
.reader-body { flex:1; overflow-y:auto; padding:24px 20px 60px; -webkit-overflow-scrolling:touch; scroll-behavior:smooth; }
.reader-body::-webkit-scrollbar { display:none; }
.reader-body .ch-title { font-size:22px; font-weight:700; margin-bottom:20px; text-align:center; color:var(--reader-text); }
.reader-body .ch-content {
  line-height:var(--line-height, 2); font-size:var(--font-size, 16px);
  font-family:var(--font-family, 'Inter'); color:var(--reader-text);
  white-space:pre-wrap; word-break:break-word;
  letter-spacing:0.01em;
}
.reader-body .ch-content p { margin-bottom:1em; text-indent:2em; }
.reader-nav { display:flex; align-items:center; justify-content:space-between; padding:10px 16px; border-top:1px solid var(--border); background:var(--reader-bg); flex-shrink:0; }
.reader-nav button { padding:8px 16px; font-size:13px; font-weight:600; }
.reader-nav button:disabled { opacity:.25; pointer-events:none; }
.reader-progress { text-align:center; font-size:11px; color:var(--text-3); font-weight:500; }

/* SETTINGS PANEL */
.settings-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:205; opacity:0; pointer-events:none; transition:opacity .3s; }
.settings-backdrop.open { opacity:1; pointer-events:auto; }
.settings-panel { position:fixed; bottom:0; left:0; right:0; background:var(--bg-card); border-top:1px solid var(--border); border-radius:16px 16px 0 0; padding:20px 16px 32px; z-index:210; transform:translateY(100%); transition:transform .3s cubic-bezier(.4,0,.2,1); max-height:60vh; overflow-y:auto; }
.settings-panel.open { transform:translateY(0); }
.settings-panel .handle { width:40px; height:4px; border-radius:2px; background:var(--border); margin:0 auto 16px; }
.settings-panel h4 { font-size:15px; font-weight:700; margin-bottom:14px; }
.setting-row { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.setting-row label { font-size:13px; color:var(--text-2); font-weight:500; }
.ctrl-row { display:flex; align-items:center; gap:4px; }
.ctrl-btn { width:36px; height:36px; border-radius:50%; border:1px solid var(--border); background:var(--bg-input); color:var(--text); font-size:16px; font-weight:600; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:all .2s; }
.ctrl-btn:active { background:var(--primary); color:#fff; border-color:var(--primary); }
.ctrl-val { min-width:32px; text-align:center; font-size:14px; font-weight:600; }
.theme-row { display:flex; gap:8px; }
.theme-btn { width:48px; height:32px; border-radius:8px; border:2px solid var(--border); cursor:pointer; transition:all .2s; display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:600; }
.theme-btn.active { border-color:var(--primary); }
.font-opts { display:flex; gap:8px; flex-wrap:wrap; }
.font-opt { padding:6px 14px; border-radius:8px; border:1px solid var(--border); font-size:13px; cursor:pointer; transition:all .2s; background:var(--bg-input); }
.font-opt.active { border-color:var(--primary); color:var(--primary); background:var(--bg-card); }
.spacing-opts { display:flex; gap:6px; }
.spacing-opt { padding:6px 12px; border-radius:8px; border:1px solid var(--border); font-size:11px; cursor:pointer; background:var(--bg-input); font-weight:500; transition:all .2s; }
.spacing-opt.active { border-color:var(--primary); color:var(--primary); }

/* AUTH */
.auth-page { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:calc(100vh - 120px); padding:20px; }
.auth-card { width:100%; max-width:360px; }
.auth-card .logo { text-align:center; margin-bottom:24px; }
.auth-card .logo h2 { font-size:28px; font-weight:800; color:var(--primary); }
.auth-card .logo h2 span { color:var(--text); }
.auth-card .subtitle { font-size:14px; color:var(--text-2); margin-bottom:24px; text-align:center; }
.auth-card .field { margin-bottom:14px; }
.auth-card .field label { display:block; font-size:13px; font-weight:500; margin-bottom:6px; color:var(--text-2); }
.auth-card .error { color:#EF4444; font-size:13px; margin-bottom:12px; text-align:center; }
.auth-card .switch-text { text-align:center; margin-top:16px; font-size:14px; color:var(--text-2); }

/* EMPTY STATE */
.empty-state { text-align:center; padding:40px 20px; color:var(--text-3); }
.empty-state svg { width:48px; height:48px; margin:0 auto 12px; opacity:.3; color:var(--primary); }
.empty-state p { font-size:14px; }

/* TOAST */
.toast { position:fixed; bottom:80px; left:50%; transform:translateX(-50%); background:#1F2937; color:#fff; padding:10px 20px; border-radius:24px; font-size:13px; font-weight:500; z-index:300; opacity:0; transition:opacity .3s; pointer-events:none; box-shadow:var(--shadow-lg); }
.toast.show { opacity:1; }

/* LOADING */
.spinner { width:28px; height:28px; border:3px solid var(--border); border-top-color:var(--primary); border-radius:50%; animation:spin .6s linear infinite; margin:32px auto; }
@keyframes spin { to { transform:rotate(360deg); } }

/* WRITER DASHBOARD */
.writer-header { display:flex; align-items:center; justify-content:space-between; padding:12px 0; margin-bottom:8px; }
.writer-card { background:var(--bg-card); border-radius:var(--radius); padding:14px; margin-bottom:10px; box-shadow:var(--shadow); cursor:pointer; transition:transform .15s; border:1px solid var(--border); }
.writer-card:active { transform:scale(0.98); }
.writer-card h4 { font-size:15px; font-weight:600; margin-bottom:2px; }
.writer-card p { font-size:12px; color:var(--text-3); }
.writer-card .status-badge { display:inline-block; padding:2px 8px; border-radius:4px; font-size:10px; font-weight:600; margin-top:4px; }
.status-ongoing { background:#DCFCE7; color:#166534; }
.status-draft { background:#FEF3C7; color:#92400E; }
.status-completed { background:#DBEAFE; color:#1E40AF; }
[data-theme="dark"] .status-ongoing { background:#14532D; color:#86EFAC; }
[data-theme="dark"] .status-draft { background:#78350F; color:#FDE68A; }
[data-theme="dark"] .status-completed { background:#1E3A5F; color:#93C5FD; }
