:root {
    color-scheme: dark;
    --bg: #09111d;
    --panel: #121c2a;
    --field: #0b1421;
    --line: #2c3848;
    --muted: #9aa8ba;
    --text: #f4f7fb;
    --purple: #884cff;
    --green: #42d67c;
    --accent: #914fff;
}

* { box-sizing: border-box; }
html {
    scroll-padding-bottom: 96px;
    scroll-padding-bottom: max(96px, calc(48px + env(safe-area-inset-bottom)));
}
body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 50% -15%, rgba(101, 74, 166, .16), transparent 34rem), var(--bg);
}
button, input, textarea, select { font: inherit; }
a { color: #b993ff; }
button {
    padding: 11px 17px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #7135e9, #914fff);
    cursor: pointer;
    font-weight: 750;
    transition: .15s;
}
button:hover { filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.secondary { background: #1c2736; border-color: #344052; }
input, textarea, select {
    width: 100%;
    padding: 11px 12px;
    color: #f7f9fc;
    background: var(--field);
    border: 1px solid #344052;
    border-radius: 8px;
    outline: none;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(136, 76, 255, .14);
}
label { display: block; color: #d1d9e6; font-size: 13px; }
[hidden] { display: none !important; }
.browser-flow { display: none; }

/* Home */
.home-page { background: radial-gradient(circle at 50% -10%, rgba(111, 75, 188, .2), transparent 34rem), var(--bg); }
.home-page header { min-height:72px; padding:14px 28px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid #253142; background:rgba(8,15,26,.88); }
.home-page .brand { display:flex; align-items:center; gap:12px; font-weight:800; font-size:20px; }
.home-page .mark { width:40px; height:40px; display:grid; place-items:center; border-radius:11px; background:linear-gradient(145deg,#47218e,#8c48ff); }
.home-page main { width:min(1120px,calc(100% - 32px)); margin:0 auto; padding:60px 0 120px; padding:60px 0 max(120px,calc(60px + env(safe-area-inset-bottom))); }
.home-page .hero { max-width:760px; margin:0 auto 38px; text-align:center; }
.home-page h1 { margin:0 0 16px; font-size:clamp(38px,6vw,66px); line-height:1.02; letter-spacing:-.045em; }
.home-page .hero p { margin:0 auto; max-width:680px; color:#b4c0cf; font-size:18px; line-height:1.7; }
.home-page .panel { max-width:860px; margin:0 auto; padding:28px; border:1px solid var(--line); border-radius:14px; background:linear-gradient(145deg,rgba(20,30,45,.98),rgba(13,22,34,.98)); box-shadow:0 24px 70px rgba(0,0,0,.22); }
.home-page .login-grid { display:grid; grid-template-columns:1fr 1fr; gap:26px; align-items:start; }
.home-page .feature-list { display:grid; gap:12px; color:#bec9d7; line-height:1.5; }
.home-page .feature { padding:14px; border:1px solid #2b3748; border-radius:9px; background:#0e1724; }
.home-page .read-link { color:var(--accent); text-decoration:none; font-weight:700; }
.home-page h2 { margin:0 0 10px; }
.home-page p { color:var(--muted); }
.home-page label { margin:14px 0 6px; color:#d3dbe6; }
.home-page .actions,.home-page .nav-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:20px; }
.home-page .nav-card { display:block; min-height:0; padding:15px; color:#eef2f8; text-decoration:none; border:1px solid #344154; border-radius:9px; background:#0e1825; font-weight:750; }
.home-page .nav-card:hover { border-color:var(--purple); }
.home-page #message { min-height:22px; color:#ff9a9a; }
.home-page .dashboard-head { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; }
.home-page .stats { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin:24px 0; }
.home-page .stat { padding:17px; border:1px solid #303c4e; border-radius:9px; background:#0d1623; }
.home-page .stat span { display:block; margin-bottom:7px; color:#94a3b7; font-size:12px; text-transform:uppercase; letter-spacing:.05em; }
.home-page .stat strong { font-size:18px; overflow-wrap:anywhere; }
.home-page .nav-actions { display:grid; grid-template-columns:repeat(3,1fr); }
.home-page .nav-card.primary { background:#0e1825; }
.home-page .nav-card small { display:block; margin-top:4px; color:var(--muted); font-size:12px; font-weight:400; }

/* Login */
.login-page { display:grid; place-items:center; padding:24px 24px 120px; padding:24px 24px max(120px,calc(56px + env(safe-area-inset-bottom))); }
.login-page main { width:100%; max-width:420px; padding:30px; background:linear-gradient(145deg,rgba(20,30,45,.98),rgba(13,22,34,.98)); border:1px solid var(--line); border-radius:14px; box-shadow:0 24px 70px rgba(0,0,0,.22); }
.login-page h1 { margin:0 0 8px; }
.login-page p { color:var(--muted); line-height:1.5; }
.login-page label { margin:18px 0 6px; }
.login-page .actions { display:flex; gap:10px; margin-top:22px; }
.login-page .actions button { flex:1; }
.login-page #message { min-height:24px; color:#ff8d8d; }

/* Admin */
.admin-page .topbar { min-height:70px; padding:12px 26px; display:flex; align-items:center; justify-content:space-between; gap:20px; border-bottom:1px solid #253142; background:rgba(8,15,26,.9); }
.admin-page .brand,.admin-page .nav { display:flex; align-items:center; gap:12px; }
.admin-page .mark { width:39px; height:39px; display:grid; place-items:center; border-radius:10px; background:linear-gradient(145deg,#47218e,#8c48ff); box-shadow:0 0 24px rgba(136,76,255,.3); }
.admin-page .brand h1 { margin:0; font-size:20px; }
.admin-page .nav a { color:var(--accent); text-decoration:none; font-weight:700; }
.admin-page .app { width:min(1000px,calc(100% - 32px)); margin:0 auto; padding:36px 0 120px; padding:36px 0 max(120px,calc(56px + env(safe-area-inset-bottom))); }
.admin-page .intro { margin-bottom:24px; }
.admin-page .intro h2 { margin:0 0 8px; font-size:30px; }
.admin-page .intro p { margin:0; color:var(--muted); line-height:1.6; }
.admin-page .grid { display:grid; grid-template-columns:1fr; gap:22px; }
.admin-page .card { padding:24px; border:1px solid var(--line); border-radius:12px; background:linear-gradient(145deg,rgba(20,30,45,.98),rgba(13,22,34,.98)); box-shadow:0 20px 60px rgba(0,0,0,.15); }
.admin-page .card h2 { margin:0 0 20px; font-size:19px; }
.admin-page label { margin:0 0 7px; color:#d2dbe7; }
.admin-page input { margin-bottom:16px; }
.admin-page button { width:100%; }
.admin-page .note { color:var(--muted); font-size:13px; line-height:1.55; }
.admin-page .status { min-height:20px; margin-top:12px; color:var(--green); font-size:13px; }
.admin-page .quick-links { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.admin-page .quick-link { display:block; padding:15px; color:#eef2f8; text-decoration:none; border:1px solid #344154; border-radius:9px; background:#0e1825; }
.admin-page .quick-link:hover { border-color:var(--purple); }
.admin-page .quick-link strong { display:block; margin-bottom:4px; }
.admin-page .quick-link span { color:var(--muted); font-size:12px; }

/* Writer */
.author-page { background:radial-gradient(circle at 50% -20%,rgba(86,109,153,.15),transparent 36rem),var(--bg); }
.author-page .topbar { min-height:70px; padding:12px 24px; border-bottom:1px solid #222d3c; background:rgba(8,15,26,.9); display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:20; backdrop-filter:blur(14px); }
.author-page .brand,.author-page .account { display:flex; align-items:center; gap:12px; }
.author-page .brand-mark { width:38px; height:38px; display:grid; place-items:center; border-radius:10px; background:linear-gradient(145deg,#3e227f,#873dff); box-shadow:0 0 24px rgba(130,71,245,.35); font-size:21px; }
.author-page .brand h1 { margin:0; font-size:20px; letter-spacing:-.02em; }
.author-page .account { color:#b9c3d2; font-size:14px; }
.author-page .account-name { color:#fff; font-weight:700; }
.author-page .app { max-width:1440px; margin:0 auto; padding:28px 24px 120px; padding:28px 24px max(120px,calc(56px + env(safe-area-inset-bottom))); }
.author-page .card { background:linear-gradient(145deg,rgba(19,29,43,.98),rgba(13,22,34,.98)); border:1px solid var(--line); border-radius:10px; box-shadow:0 18px 50px rgba(0,0,0,.12); }
.author-page .status-strip { min-height:96px; display:grid; grid-template-columns:1.35fr 1fr .3fr .7fr 1fr; align-items:center; margin-bottom:24px; padding:16px 18px; }
.author-page .status-cell { min-width:0; padding:0 10px; }
.author-page .status-cell + .status-cell { border-left:1px solid #354052; }
.author-page .eyebrow { display:block; margin-bottom:8px; color:#aab7ca; font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; }
.author-page .status-value { display:flex; align-items:center; gap:10px; min-height:26px; font-weight:700; }
.author-page .status-value select { margin:0; }
.author-page .status-pills { display:flex; flex-wrap:wrap; gap:8px; }
.author-page .status-login { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.author-page .pill { padding:5px 9px; border-radius:5px; color:#65e797; background:rgba(33,163,87,.23); font-size:12px; font-weight:700; }
.author-page .pill.chapter { color:#b993ff; background:rgba(116,64,208,.24); }
.author-page .pill.visibility { color:#c9d3e0; background:#293545; }
.author-page .pill.visibility.public { color:#75d9ff; background:rgba(31,138,181,.24); }
.author-page .pill.publication { color:#f2b86b; background:rgba(177,113,31,.22); }
.author-page .pill.publication.published { color:#65e797; background:rgba(33,163,87,.23); }
.author-page .layout { display:grid; grid-template-columns:330px minmax(0,1fr); gap:26px; align-items:start; }
.author-page .sidebar,.author-page .main-column { display:grid; gap:18px; }
.author-page .main-column { min-width:0; }
.author-page .side-card { padding:18px; }
.author-page .novel-state-fields { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.author-page .field-help { margin:-7px 0 14px; color:var(--muted); font-size:11px; line-height:1.4; }
.author-page #genre { min-height:154px; }
.author-page .card-title { display:flex; align-items:center; gap:10px; margin:0 0 18px; font-size:17px; }
.author-page label { margin-bottom:7px; }
.author-page input,.author-page textarea,.author-page select { margin:0 0 14px; border-radius:7px; }
.author-page textarea { line-height:1.7; resize:vertical; }
.author-page button:hover { filter:brightness(1.1); transform:translateY(-1px); }
.author-page button.outline { width:100%; color:#aa72ff; background:transparent; border-color:#8247f5; }
.author-page button.full { width:100%; }
.author-page #chapterSelect { min-height:132px; border-left:4px solid var(--purple); background:#151d2d; }
.author-page .memory { margin-top:6px; padding-top:12px; border-top:1px solid #2b3646; }
.author-page .memory-row { margin-top:8px; color:var(--muted); font-size:12px; line-height:1.45; }
.author-page .memory-row strong { color:#dce3ee; }
.author-page .reader-copy { color:#b1bdcd; font-size:13px; line-height:1.55; }
.author-page .main-editor { padding:28px; min-height:900px; }
.author-page .chapter-heading { display:flex; align-items:center; gap:12px; margin:0 0 26px; font-size:24px; letter-spacing:-.025em; }
.author-page .chapter-meta { display:grid; grid-template-columns:120px 1fr; gap:12px; }
.author-page #chapterTitle { font-size:17px; font-weight:700; }
.author-page .section-heading { display:flex; justify-content:space-between; align-items:center; gap:14px; margin:22px 0 10px; }
.author-page .section-heading h3 { margin:0; font-size:17px; }
.author-page #chapterPrompt { min-height:205px; }
.author-page #chapterOutput { min-height:540px; max-height:720px; padding:20px; font-family:inherit; font-size:15px; background:#0a1320; }
.author-page .chapter-preview-panel {
    display:flex;
    flex-direction:column;
    min-height:100%;
    padding:0;
}
.author-page .project-name-control { margin-bottom:10px; }
.author-page .chapter-preview-status {
    display:flex;
    align-items:center;
    min-height:38px;
    margin-bottom:6px;
    padding:8px 12px;
    border:1px solid #303b4c;
    border-radius:7px;
    color:#dce3ee;
    background:#11202b;
    font-size:12px;
    font-weight:800;
}
.author-page #chapterPreviewText {
    flex:0 0 1044px;
    min-height:1044px;
    max-height:1044px;
    margin:0;
    padding:14px 16px;
    border:1px solid #303b4c;
    border-radius:7px;
    overflow:auto;
    font-family:inherit;
    font-size:13px;
    line-height:1.48;
    background:#0a1320;
}
.author-page #chapterPreviewText p { margin:0 0 .55em; }
.author-page #chapterPreviewText p + p { margin-top:.1em; }
.author-page #chapterPreviewText .dialogue,
.author-page #chapterPreviewText .speech { font-style:italic; }
.author-page #chapterPreviewText h1,
.author-page #chapterPreviewText h2,
.author-page #chapterPreviewText h3 {
    margin:.85em 0 .35em;
    color:#edf2f8;
    font-size:1.08em;
    line-height:1.25;
}
.author-page #chapterPreviewText blockquote {
    margin:.55em 0;
    padding-left:.8em;
    border-left:2px solid #516074;
    color:#b9c4d4;
}
.author-page #chapterPreviewText ul,
.author-page #chapterPreviewText ol { margin:.45em 0 .6em; padding-left:1.35em; }
.author-page #chapterPreviewText li { margin:.12em 0; }
.author-page #chapterPreviewText hr { border:0; border-top:1px solid #303b4c; margin:.8em 0; }
.author-page #chapterPreviewText code {
    padding:.05em .25em;
    border-radius:4px;
    background:#162234;
    font-size:.92em;
}
.author-page .chapter-preview-controls {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin:0;
    padding:0;
    background:#102038;
    margin-top: 6px
}
.author-page .chapter-preview-controls button { min-width:118px; }
.author-page .preview-position {
    min-width:0;
    color:#c9d3e0;
    font-size:12px;
    font-weight:700;
    text-align:center;
}
.author-page .word-count { padding:6px 10px; border-radius:5px; color:#c9d3e0; background:#293545; font-size:12px; }
.author-page .editor-actions,.author-page .browser-actions { display:flex; flex-wrap:wrap; gap:12px; align-items:center; margin-top:4px; }
.author-page .saved-indicator { min-height:18px; color:var(--green); font-size:12px; }
.author-page .export-output { max-height:180px; margin-top:12px; overflow:auto; white-space:pre-wrap; color:#b8c3d2; font-size:12px; }
.author-page #novelDetails { display:none; }
.author-page #browserFlow { margin-top:22px; padding:20px; }
.author-page .project-card { margin-top:0; padding:18px 22px; }
.author-page .sidebar .project-card { padding:18px; }
.author-page .project-header { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:18px; }
.author-page .project-header h2 { margin:0; font-size:18px; }
.author-page .project-header button { padding:8px 12px; }
.author-page .project-top { display:grid; grid-template-columns:minmax(260px,.85fr) minmax(0,1.4fr); gap:24px; }
.author-page .project-grid { display:grid; grid-template-columns:1fr; gap:24px; margin-top:22px; }
.author-page .project-settings { padding-right:22px; border-right:1px solid #303b4c; }
.author-page .sidebar .project-grid { grid-template-columns:1fr; gap:14px; margin-top:18px; }
.author-page .sidebar .project-settings { padding-right:0; border-right:0; }
.author-page .sidebar .memory-summary { grid-template-columns:1fr; }
.author-page .switch-list { display:grid; gap:10px; margin:16px 0; }
.author-page .switch-row { display:flex; align-items:flex-start; gap:10px; color:#c9d3e0; font-size:13px; line-height:1.4; }
.author-page .switch-row input { width:auto; margin:2px 0 0; accent-color:var(--purple); }
.author-page .switch-row small { display:block; color:var(--muted); }
.author-page .memory-summary { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin:14px 0 18px; }
.author-page .memory-state { padding:10px; border:1px solid #303b4c; border-radius:7px; background:#0d1623; }
.author-page .memory-state span { display:block; color:var(--muted); font-size:11px; margin-bottom:4px; }
.author-page .memory-state strong { color:#dce3ef; font-size:13px; }
.author-page .memory-state strong.on { color:#65e797; }
.author-page .memory-state strong.off { color:#f2b86b; }
.author-page .canon-tabs { display:grid; gap:12px; }
.author-page .canon-document { border:1px solid #303b4c; border-radius:8px; background:#0d1623; overflow:hidden; }
.author-page .canon-document summary { padding:12px 14px; cursor:pointer; font-weight:700; color:#dce3ef; }
.author-page .canon-help { padding:0 14px 12px; color:var(--muted); font-size:12px; line-height:1.5; }
.author-page .canon-actions { display:flex; gap:8px; padding:0 14px 12px; }
.author-page .canon-actions button { padding:7px 10px; font-size:12px; }
.author-page .canon-document textarea { min-height:150px; margin:0; border:0; border-top:1px solid #303b4c; border-radius:0; }
.author-page .canon-editor { padding:14px; border:1px solid #303b4c; border-radius:8px; background:#0d1623; }
.author-page .canon-editor textarea { min-height:420px; margin-bottom:10px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:13px; }
.author-page .canon-editor-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.author-page .canon-editor-actions button { padding:8px 11px; font-size:12px; }
.author-page .canon-select-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:start; }
.author-page .canon-select-row button { padding:11px 13px; white-space:nowrap; }
.author-page .project-note { color:#9faec1; font-size:12px; line-height:1.55; }
.author-page .manual-chat-box { padding:15px; border:1px solid #57417d; border-radius:8px; background:rgba(91,52,151,.12); }
.author-page .manual-chat-box h3 { margin:0 0 8px; font-size:15px; color:#d9c7ff; }
.author-page .manual-chat-box ol { margin:8px 0 0; padding-left:20px; color:#c4cddd; font-size:13px; line-height:1.55; }
.author-page .manual-chat-box code { color:#decfff; }
.author-page .project-save-row { display:flex; flex-wrap:wrap; align-items:center; gap:14px; margin-top:18px; }
.author-page .project-save-row button { min-width:220px; }
.author-page .project-advanced[hidden] { display:none; }
.author-page .field-action { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:start; }
.author-page .field-action button { padding:11px 12px; white-space:nowrap; }
.author-page .write-chat-panel { margin-top:24px; padding-top:22px; border-top:1px solid #303b4c; }
.author-page .write-chat-panel .section-heading { align-items:center; }
.author-page .write-chat-panel .section-heading button { padding:7px 11px; font-size:12px; }
.author-page .write-chat-messages { min-height:120px; max-height:420px; margin:12px 0; padding:14px; overflow-y:auto; border:1px solid #303b4c; border-radius:8px; background:#0b1421; }
.author-page .write-chat-empty { margin:0; color:var(--muted); font-size:13px; }
.author-page .write-chat-message { max-width:88%; margin:0 0 12px; padding:11px 13px; border-radius:10px; white-space:pre-wrap; line-height:1.55; }
.author-page .write-chat-message.user { margin-left:auto; background:#40277a; }
.author-page .write-chat-message.assistant { margin-right:auto; background:#182536; border:1px solid #344052; }
.author-page .write-chat-message strong { display:block; margin-bottom:5px; font-size:11px; color:#cfc2ef; text-transform:uppercase; letter-spacing:.05em; }
.author-page .write-chat-actions { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin-top:10px; }

/* Reader */
.reader-page { color-scheme:light; --bg:#eeeae2; --card:#fffdf8; --text:#24211d; --muted:#716b63; --line:#ddd7cd; --accent:#7140da; --header:#f8f4ec; overflow-x:hidden; background:var(--bg); color:var(--text); transition:background .2s,color .2s; }
.reader-page.dark { color-scheme:dark; --bg:#09111d; --card:#121c2a; --text:#edf1f7; --muted:#a5b0bf; --line:#2d3949; --accent:#914fff; --header:#08101b; }
.reader-page .topbar { min-height:70px; padding:12px 26px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line); background:var(--header); }
.reader-page .brand { display:flex; align-items:center; gap:12px; font-weight:800; font-size:20px; }
.reader-page .brand-mark { width:39px; height:39px; display:grid; place-items:center; border-radius:10px; color:#fff; background:linear-gradient(145deg,#47218e,#8c48ff); box-shadow:0 0 24px rgba(136,76,255,.28); }
.reader-page .home-link { color:var(--accent); text-decoration:none; font-weight:700; }
.reader-page .reader-header-actions { display:flex; align-items:center; gap:18px; }
.reader-page .reader-menu { position:relative; }
.reader-page .reader-menu summary { cursor:pointer; color:var(--accent); font-weight:700; list-style:none; }
.reader-page .reader-menu summary::-webkit-details-marker { display:none; }
.reader-page .reader-menu summary::after { content:" ▾"; font-size:11px; }
.reader-page .reader-menu[open] summary::after { content:" ▴"; }
.reader-page .reader-menu-panel { position:absolute; z-index:30; top:calc(100% + 16px); right:0; width:min(420px,calc(100vw - 28px)); padding:18px; border:1px solid var(--line); border-radius:10px; background:var(--card); box-shadow:0 18px 50px rgba(0,0,0,.22); }
.reader-page .reader-menu-panel label { margin:0 0 7px; color:var(--muted); font-weight:700; }
.reader-page .reader-menu-panel select { margin-bottom:14px; color:var(--text); background:var(--card); border-color:var(--line); }
.reader-page .reader-menu-panel select:last-of-type { margin-bottom:10px; }
.reader-page #readerCatalogStatus { margin:0; color:var(--muted); font-size:12px; line-height:1.45; }
.reader-page .page { padding:28px 20px 120px; padding:28px 20px max(120px,calc(56px + env(safe-area-inset-bottom))); }
.reader-page .app { max-width:860px; margin:0 auto; }
.reader-page .header { display:flex; justify-content:space-between; align-items:flex-end; margin-bottom:18px; }
.reader-page .header h1 { margin:0 0 6px; font-size:32px; letter-spacing:-.025em; }
.reader-page .card { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:28px; box-shadow:0 18px 50px rgba(0,0,0,.12); margin-bottom:20px; }
.reader-page .chapter-toolbar { display:flex; justify-content:flex-end; gap:10px; margin-bottom:18px; }
.reader-page .chapter-nav { display:flex; justify-content:flex-start; gap:10px; margin-top:18px; }
.reader-page #chapterTitle { margin:0 0 18px; font-size:2rem; line-height:1.2; }
.reader-page .button-link { cursor:pointer; border:1px solid transparent; background:linear-gradient(135deg,#7135e9,#914fff); color:#fff; border-radius:8px; padding:11px 16px; font-weight:750; text-decoration:none; }
.reader-page button.secondary,.reader-page .button-link.secondary { background:transparent; color:var(--accent); border-color:var(--accent); }
.reader-page a { color:var(--accent); }
.reader-page #novelMeta { color:var(--muted); }
.reader-page .story-content { font-family:Georgia,"Times New Roman",serif; font-size:18px; line-height:1.62; }
.reader-page .story-content p { margin:0 0 .62em; }
.reader-page .story-content p + p { margin-top:.18em; }
.reader-page .story-content .dialogue { font-style:italic; }
.reader-page .story-content h1,.reader-page .story-content h2,.reader-page .story-content h3 { margin:1.15em 0 .45em; line-height:1.25; }
.reader-page .story-content blockquote { margin:.8em 0; padding-left:1em; border-left:3px solid var(--accent); color:var(--muted); }
.reader-page .story-content ul,.reader-page .story-content ol { margin:.55em 0 .8em; padding-left:1.5em; }
.reader-page .story-content li { margin:.2em 0; }
.reader-page .story-content hr { border:0; border-top:1px solid var(--line); margin:1.2em 0; }
.reader-page .story-content code { padding:.1em .3em; border-radius:4px; background:color-mix(in srgb,var(--text) 10%,transparent); font-size:.9em; }
.reader-page .footer-actions { max-width:860px; margin:0 auto; padding:4px 0 24px; padding:4px 0 max(24px,env(safe-area-inset-bottom)); display:flex; flex-wrap:wrap; justify-content:flex-end; gap:10px; }

/* Legacy standalone authoring page */
.legacy-page .app { max-width:980px; margin:0 auto; padding:32px; }
.legacy-page h1 { margin-bottom:8px; }
.legacy-page .card { background:linear-gradient(145deg,rgba(20,30,45,.98),rgba(13,22,34,.98)); border:1px solid var(--line); border-radius:14px; padding:24px; margin-bottom:24px; }
.legacy-page label { margin-bottom:8px; }
.legacy-page input,.legacy-page textarea { margin-bottom:12px; }
.legacy-page .outline,.legacy-page .story-output { white-space:pre-wrap; font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace; }
.legacy-page .browser-actions { display:flex; gap:8px; margin-bottom:8px; }

@media (max-width:900px) {
    .author-page .status-strip { grid-template-columns:1fr 1fr; gap:18px 0; }
    .author-page .status-cell:nth-child(3) { border-left:0; }
    .author-page .layout,.author-page .project-top,.author-page .project-grid { grid-template-columns:1fr; }
    .author-page .sidebar { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .author-page .main-editor { min-height:auto; }
    .author-page .project-settings { padding-right:0; border-right:0; border-bottom:1px solid #303b4c; padding-bottom:20px; }
}
@media (max-width:720px) {
    .home-page main { padding:36px 0 128px; padding:36px 0 max(128px,calc(64px + env(safe-area-inset-bottom))); }
    .home-page .login-grid,.home-page .stats,.home-page .nav-actions { grid-template-columns:1fr; }
    .home-page .dashboard-head { flex-direction:column; }
    .home-page .panel { padding:21px; }
    .home-page .hero { text-align:left; }
    .admin-page .topbar { align-items:flex-start; padding:14px 16px; }
    .admin-page .nav { flex-wrap:wrap; justify-content:flex-end; }
    .admin-page .quick-links { grid-template-columns:1fr; }
    .admin-page .app { padding:24px 0 128px; padding:24px 0 max(128px,calc(64px + env(safe-area-inset-bottom))); }
}
@media (max-width:620px) {
    .author-page .topbar { align-items:flex-start; padding:14px 16px; }
    .author-page .brand h1 { font-size:16px; }
    .author-page .account { flex-wrap:wrap; justify-content:flex-end; }
    .author-page .app { padding:18px 14px 128px; padding:18px 14px max(128px,calc(64px + env(safe-area-inset-bottom))); }
    .author-page .status-strip,.author-page .sidebar { grid-template-columns:1fr; }
    .author-page .status-cell { padding:14px 10px; }
    .author-page .status-cell + .status-cell { border-left:0; border-top:1px solid #354052; }
    .author-page .main-editor { padding:20px 16px; }
    .author-page .chapter-meta { grid-template-columns:1fr; }
    .author-page .novel-state-fields { grid-template-columns:1fr; }
    .author-page .chapter-heading { font-size:20px; }
    .author-page #chapterOutput { min-height:420px; }
    .reader-page .topbar { padding:12px 15px; }
    .reader-page .brand { font-size:16px; }
    .reader-page .page { padding:18px 14px 128px; padding:18px 14px max(128px,calc(64px + env(safe-area-inset-bottom))); }
    .reader-page .header { align-items:flex-start; gap:14px; }
    .reader-page .card { padding:20px 17px; }
    .reader-page .reader-header-actions { gap:12px; }
    .reader-page .reader-menu-panel {
        position:fixed;
        top:76px;
        right:12px;
        left:12px;
        width:auto;
        max-height:calc(100vh - 92px);
        max-height:calc(100dvh - 92px);
        overflow-y:auto;
        overscroll-behavior:contain;
        padding:16px;
    }
    .reader-page .reader-menu-panel select { max-width:100%; }
    .reader-page .story-content { font-size:17px; }
    .reader-page .footer-actions { justify-content:flex-start; }
    .login-page { padding:18px 14px 128px; padding:18px 14px max(128px,calc(64px + env(safe-area-inset-bottom))); }
    .legacy-page .app { padding:18px 14px 128px; padding:18px 14px max(128px,calc(64px + env(safe-area-inset-bottom))); }
}
