:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f8f9fc;
    --text: #182033;
    --muted: #737b8e;
    --muted-2: #99a0af;
    --line: #e7eaf1;
    --line-strong: #dce1eb;
    --primary: #6657ee;
    --primary-dark: #5142db;
    --primary-soft: #f1efff;
    --navy: #121628;
    --navy-2: #1a1f37;
    --success: #16966e;
    --success-soft: #eaf8f3;
    --danger: #c84b4b;
    --danger-soft: #fff1f1;
    --warning: #b97716;
    --shadow-sm: 0 8px 28px rgba(26, 33, 52, .06);
    --shadow: 0 18px 55px rgba(26, 33, 52, .10);
    --shadow-lg: 0 28px 80px rgba(23, 29, 48, .16);
    --radius: 18px;
    --radius-lg: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 100% 0%, rgba(115, 91, 244, .09), transparent 28%),
        linear-gradient(180deg, #f8f9fc 0%, var(--bg) 100%);
    min-width: 320px;
}
body.sidebar-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { display: block; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4, strong { font-family: "Manrope", "DM Sans", sans-serif; }

/* ---------- Global shell ---------- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 24px 18px 18px;
    color: #fff;
    background:
        radial-gradient(circle at 30% 0%, rgba(119, 101, 255, .18), transparent 25%),
        linear-gradient(180deg, #171b31 0%, #101323 100%);
    border-right: 1px solid rgba(255,255,255,.05);
    box-shadow: 14px 0 45px rgba(14, 18, 34, .06);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(145deg, #8b7aff, #5b4be5);
    box-shadow: 0 12px 28px rgba(99, 81, 236, .30), inset 0 1px 0 rgba(255,255,255,.2);
    font: 800 19px/1 "Manrope", sans-serif;
}
.brand-copy { min-width: 0; }
.brand-copy strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.brand-copy small { display: block; margin-top: 2px; color: #949bb7; font-size: 10px; }
.sidebar-close { display: none; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; background: rgba(255,255,255,.06); color: #fff; font-size: 23px; cursor: pointer; }
.sidebar-label { padding: 0 11px 9px; color: #6f7797; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .16em; }
.sidebar-label.second { margin-top: 27px; }
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 46px;
    padding: 9px 12px;
    border-radius: 12px;
    color: #b6bdd5;
    font-size: 12px;
    font-weight: 700;
    transition: .2s ease;
}
.sidebar-nav a::before { content: ""; position: absolute; left: -18px; width: 3px; height: 0; border-radius: 4px; background: #8b7cff; transition: .2s ease; }
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.055); transform: translateX(2px); }
.sidebar-nav a.active { color: #fff; background: linear-gradient(90deg, rgba(112,95,238,.22), rgba(255,255,255,.045)); }
.sidebar-nav a.active::before { height: 24px; }
.nav-icon { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #aaa4ff; background: rgba(255,255,255,.055); }
.nav-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-nav a.active .nav-icon { color: #fff; background: linear-gradient(145deg, #7161f2, #5d4de4); box-shadow: 0 8px 18px rgba(87, 70, 221, .28); }
.engine-card { margin: 0 4px; padding: 15px; border: 1px solid rgba(255,255,255,.07); border-radius: 15px; background: rgba(255,255,255,.035); }
.engine-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.engine-orb { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: #c4bdff; background: rgba(121,104,246,.14); }
.engine-card-head > div { min-width: 0; display: grid; gap: 2px; }
.engine-card strong { font-size: 11px; }
.engine-status { color: #9ba3bd; font-size: 9px; }
.engine-status i, .status-live i, .auth-kicker i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #39d39a; box-shadow: 0 0 0 4px rgba(57,211,154,.08); margin-right: 5px; }
.engine-card small { display: block; color: #7f879f; font-size: 9px; line-height: 1.55; }
.sidebar-note { margin-top: auto; padding: 14px; display: flex; gap: 10px; border: 1px solid rgba(255,255,255,.07); border-radius: 14px; background: rgba(255,255,255,.03); }
.spark { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #bdb6ff; background: rgba(119,103,240,.12); }
.sidebar-note strong { display: block; margin: 1px 0 4px; font-size: 10px; }
.sidebar-note span { display: block; color: #838ba5; font-size: 9px; line-height: 1.5; }
.sidebar-user { margin-top: 12px; padding: 11px; display: flex; align-items: center; gap: 9px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user .user-avatar { color: #fff; background: rgba(116,98,242,.26); }
.sidebar-user > div { min-width: 0; }
.sidebar-user strong { display: block; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { display: block; margin-top: 2px; color: #7f879f; font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-overlay { display: none; }

.main { min-width: 0; padding: 28px 32px 64px; }
.page-content { max-width: 1560px; margin: 0 auto; }
.topbar { max-width: 1560px; margin: 0 auto 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.eyebrow { color: #9097a7; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.topbar h1 { margin: 4px 0 0; font-size: 29px; line-height: 1.1; letter-spacing: -.035em; }
.mobile-menu-button { display: none; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); cursor: pointer; }
.mobile-menu-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.date-chip { height: 43px; padding: 0 12px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.86); color: #71798a; font-size: 10px; font-weight: 600; }
.date-chip svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.profile-menu { position: relative; }
.profile-trigger { min-width: 184px; height: 43px; padding: 5px 8px 5px 6px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; transition: .2s; }
.profile-trigger:hover { border-color: #d8d3ff; box-shadow: 0 8px 22px rgba(43, 50, 72, .06); }
.user-avatar { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #5144cf; background: var(--primary-soft); font-size: 11px; font-weight: 800; }
.profile-copy { min-width: 0; flex: 1; text-align: left; }
.profile-copy strong { display: block; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-copy small { display: block; margin-top: 1px; color: #989ead; font-size: 8px; }
.chevron { width: 14px; height: 14px; fill: none; stroke: #8e95a4; stroke-width: 1.8; transition: .2s; }
.profile-menu.open .chevron { transform: rotate(180deg); }
.profile-dropdown { position: absolute; right: 0; top: calc(100% + 8px); z-index: 90; width: 220px; padding: 7px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateY(-6px); transition: .18s; }
.profile-menu.open .profile-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.profile-dropdown-head { padding: 10px; margin-bottom: 5px; border-bottom: 1px solid var(--line); }
.profile-dropdown-head strong, .profile-dropdown-head span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-dropdown-head strong { font-size: 11px; }
.profile-dropdown-head span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.profile-dropdown a, .profile-dropdown button { width: 100%; display: block; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: #5e6678; text-align: left; font-size: 10px; cursor: pointer; }
.profile-dropdown a:hover { background: #f5f5fb; color: var(--primary-dark); }
.profile-dropdown button:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Buttons / alerts ---------- */
.btn { min-height: 42px; padding: 10px 15px; border: 1px solid transparent; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font-size: 11px; font-weight: 800; line-height: 1; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .7; cursor: wait; transform: none; }
.btn-primary { color: #fff; background: linear-gradient(135deg, #6c5cf2, #5a4be3); box-shadow: 0 9px 22px rgba(92, 74, 225, .22); }
.btn-primary:hover { background: linear-gradient(135deg, #5f50e8, #4d3ed2); box-shadow: 0 12px 25px rgba(92, 74, 225, .28); }
.btn-secondary { color: #50586a; background: #fff; border-color: var(--line-strong); }
.btn-secondary:hover { border-color: #ccc6fb; color: var(--primary-dark); }
.btn-white { color: #5547d8; background: #fff; box-shadow: 0 10px 25px rgba(36, 29, 111, .14); }
.btn-ghost { color: #fff; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.24); }
.btn.full { width: 100%; }
.btn-icon { font-size: 15px; line-height: 0; }
.button-loader { display: none; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .65s linear infinite; }
[data-loading-form].is-loading .button-loader { display: inline-block; }
[data-loading-form].is-loading .button-arrow { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { position: relative; max-width: 1560px; margin: 0 auto 18px; padding: 12px 40px 12px 13px; display: flex; align-items: flex-start; gap: 10px; border-radius: 13px; font-size: 11px; line-height: 1.55; transition: .25s; }
.alert ul { margin: 5px 0 0; padding-left: 17px; }
.alert-icon { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; font-weight: 800; }
.alert.success { color: #14694f; background: #effaf6; border: 1px solid #d2eee4; }
.alert.success .alert-icon { background: #d9f3ea; }
.alert.error { color: #9e3939; background: #fff3f3; border: 1px solid #f0d2d2; }
.alert.error .alert-icon { background: #f6dddd; }
.alert-close { position: absolute; right: 9px; top: 8px; width: 27px; height: 27px; border: 0; background: transparent; color: currentColor; opacity: .6; cursor: pointer; font-size: 18px; }
.alert.is-hiding { opacity: 0; transform: translateY(-7px); }

/* ---------- Dashboard ---------- */
.hero-banner { position: relative; overflow: hidden; min-height: 275px; margin-bottom: 18px; padding: 38px 42px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(250px, .75fr); border-radius: 25px; color: #fff; background: linear-gradient(120deg, #4c43cf 0%, #6655ea 50%, #9268f4 100%); box-shadow: 0 22px 60px rgba(91, 72, 235, .20); }
.hero-banner::before, .hero-banner::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.09); }
.hero-banner::before { width: 380px; height: 380px; right: -130px; top: -160px; box-shadow: 0 0 0 60px rgba(255,255,255,.025), 0 0 0 120px rgba(255,255,255,.018); }
.hero-banner::after { width: 200px; height: 200px; left: 42%; bottom: -160px; box-shadow: 0 0 0 55px rgba(255,255,255,.025); }
.hero-copy { position: relative; z-index: 2; max-width: 720px; }
.hero-kicker { display: inline-flex; padding: 7px 10px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; background: rgba(255,255,255,.09); font-size: 10px; font-weight: 700; }
.hero-copy h2 { max-width: 650px; margin: 16px 0 13px; font-size: clamp(30px, 3.2vw, 43px); line-height: 1.08; letter-spacing: -.04em; }
.hero-copy p { max-width: 650px; margin-bottom: 0; color: #e8e6ff; font-size: 12px; line-height: 1.7; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.hero-visual { position: relative; z-index: 2; min-height: 190px; }
.book-mockup { position: absolute; width: 132px; height: 182px; right: 60px; top: 8px; border-radius: 9px 18px 18px 9px; transform: rotate(7deg); box-shadow: 0 25px 45px rgba(40,22,102,.34); }
.book-back { right: 92px; top: 14px; background: #352c91; transform: rotate(-8deg); }
.book-front { padding: 24px 18px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; color: #3b347b; background: linear-gradient(160deg, #fff, #e8e3ff); }
.book-front::before { content: ""; position: absolute; inset: 0; border-left: 8px solid rgba(78,61,164,.15); border-radius: inherit; }
.book-front span { font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.book-front strong { font-size: 23px; line-height: 1; }
.book-front small { margin-top: 8px; color: #766da7; font-size: 7px; }
.floating-badge { position: absolute; padding: 8px 11px; border-radius: 10px; color: #4a4098; background: #fff; box-shadow: 0 10px 24px rgba(39,25,100,.2); font-size: 8px; font-weight: 800; }
.badge-one { right: 18px; top: 28px; }
.badge-two { right: 178px; bottom: 20px; }
.stats-grid { margin-bottom: 18px; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.stat-card { min-width: 0; padding: 18px; display: flex; align-items: center; gap: 13px; border: 1px solid rgba(228,231,240,.9); border-radius: 16px; background: rgba(255,255,255,.92); box-shadow: var(--shadow-sm); }
.stat-card > div:last-child { min-width: 0; flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: end; }
.stat-card span { color: var(--muted); font-size: 10px; font-weight: 700; }
.stat-card strong { grid-column: 2; grid-row: 1 / 3; font-size: 26px; }
.stat-card small { grid-column: 1; color: var(--muted-2); font-size: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; font-weight: 900; }
.stat-icon.violet { color: #6558e9; background: #f0edff; }
.stat-icon.blue { color: #3784d4; background: #eaf4ff; }
.stat-icon.green { color: #1a9b6d; background: #eaf8f2; }

/* ---------- Panels / cards ---------- */
.panel { padding: 22px; border: 1px solid rgba(229,232,240,.96); border-radius: var(--radius); background: rgba(255,255,255,.95); box-shadow: var(--shadow-sm); }
.panel-head { margin-bottom: 19px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-head h2 { margin: 4px 0 5px; font-size: 20px; letter-spacing: -.025em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.text-link { color: #6155df; font-size: 10px; font-weight: 800; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }
.book-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #fff; transition: .2s ease; }
.book-card:hover { transform: translateY(-3px); border-color: #d9d3ff; box-shadow: 0 15px 35px rgba(37, 44, 64, .10); }
.book-card-cover { position: relative; overflow: hidden; height: 118px; padding: 17px; display: flex; align-items: flex-end; gap: 12px; color: #fff; background: linear-gradient(135deg, #282d4a, #5148a7); }
.book-card-cover::after { content: ""; position: absolute; width: 125px; height: 125px; right: -30px; top: -40px; border-radius: 50%; background: rgba(255,255,255,.07); box-shadow: 0 0 0 34px rgba(255,255,255,.025); }
.book-card-cover > span:first-child { width: 39px; height: 52px; display: grid; place-items: center; flex: 0 0 auto; z-index: 2; border-radius: 5px 9px 9px 5px; background: linear-gradient(150deg, #8e79ff, #6656f0); box-shadow: 0 10px 18px rgba(0,0,0,.2); font-size: 21px; font-weight: 800; }
.book-card-cover > div { min-width: 0; z-index: 2; }
.book-card-cover small { display: block; color: #c3c6e0; font-size: 7px; text-transform: uppercase; letter-spacing: .09em; }
.book-card-cover strong { display: block; margin-top: 3px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-status { position: absolute; z-index: 3; right: 12px; top: 12px; padding: 5px 7px; border-radius: 999px; background: rgba(255,255,255,.12); backdrop-filter: blur(8px); font-size: 7px; font-weight: 800; text-transform: uppercase; }
.book-card-body { padding: 14px; }
.book-card-body p { min-height: 32px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill { max-width: 100%; padding: 5px 8px; display: inline-flex; border-radius: 999px; color: #574ad1; background: var(--primary-soft); font-size: 8px; font-weight: 800; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pill.light { color: #6e7584; background: #f1f3f7; }
.book-progress { height: 5px; margin: 12px 0 8px; overflow: hidden; border-radius: 999px; background: #edf0f5; }
.book-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7060f4, #a276ff); }
.book-meta { display: flex; justify-content: space-between; gap: 10px; color: #7e8594; font-size: 8px; }
.book-meta b { color: #5d4fda; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-icon { width: 46px; height: 46px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 14px; color: #6558df; background: #f0edff; font-size: 17px; }
.empty h3 { margin-bottom: 6px; color: var(--text); font-size: 17px; }
.empty p { max-width: 500px; margin: 0 auto 16px; font-size: 10px; line-height: 1.6; }

/* ---------- Library ---------- */
.library-hero { margin-bottom: 16px; padding: 24px 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid #e8e7f5; border-radius: 18px; background: linear-gradient(135deg, #fff, #f8f6ff); box-shadow: var(--shadow-sm); }
.library-hero h2 { margin: 5px 0 6px; font-size: 23px; letter-spacing: -.03em; }
.library-hero p { margin: 0; color: var(--muted); font-size: 10px; }
.library-panel { padding-top: 16px; }
.library-toolbar { margin-bottom: 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-box { position: relative; flex: 1; max-width: 430px; }
.search-box svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: #9299a8; stroke-width: 1.8; stroke-linecap: round; }
.search-box input { width: 100%; height: 42px; padding: 0 13px 0 37px; border: 1px solid var(--line-strong); border-radius: 11px; outline: none; background: #fbfcfe; color: var(--text); font-size: 10px; transition: .2s; }
.search-box input:focus { border-color: #8879f5; background: #fff; box-shadow: 0 0 0 4px rgba(111, 94, 237, .08); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chips button { min-height: 35px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #737b8d; font-size: 9px; font-weight: 800; cursor: pointer; }
.filter-chips button.active, .filter-chips button:hover { color: #5749d7; border-color: #d9d3ff; background: #f4f2ff; }
.search-empty { padding: 45px 15px; text-align: center; color: var(--muted); }
.search-empty h3 { margin-bottom: 4px; color: var(--text); font-size: 16px; }
.search-empty p { font-size: 10px; }
.pagination-simple { margin-top: 20px; padding-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.pagination-simple a, .pagination-simple .disabled { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-weight: 700; }
.pagination-simple a:hover { color: var(--primary-dark); border-color: #d5cff9; }
.pagination-simple .disabled { opacity: .45; }

/* ---------- Forms ---------- */
.create-layout { display: grid; grid-template-columns: 285px minmax(0,1fr); gap: 18px; align-items: start; }
.create-guide { position: sticky; top: 20px; overflow: hidden; padding: 26px; border-radius: 19px; color: #fff; background: linear-gradient(160deg, #1e233d, #15192e 70%); box-shadow: var(--shadow); }
.create-guide::after { content: ""; position: absolute; width: 180px; height: 180px; right: -90px; top: -85px; border-radius: 50%; background: rgba(118,98,244,.12); box-shadow: 0 0 0 35px rgba(118,98,244,.045); }
.guide-badge { position: relative; z-index: 2; display: inline-flex; padding: 6px 9px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; color: #b9b2ff; background: rgba(119,102,241,.09); font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.create-guide h2 { position: relative; z-index: 2; margin: 17px 0 10px; font-size: 25px; line-height: 1.16; letter-spacing: -.035em; }
.create-guide > p { position: relative; z-index: 2; color: #a4abc3; font-size: 10px; line-height: 1.65; }
.step-list { margin-top: 27px; display: grid; gap: 4px; }
.step { position: relative; display: flex; align-items: center; gap: 11px; min-height: 54px; padding: 7px 9px; border-radius: 12px; color: #848ca6; }
.step > span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.08); border-radius: 9px; background: rgba(255,255,255,.04); font-size: 9px; font-weight: 800; }
.step strong { display: block; margin-bottom: 2px; font-size: 10px; }
.step small { display: block; font-size: 8px; }
.step.active { color: #fff; background: rgba(117,101,239,.12); }
.step.active > span { color: #fff; border-color: transparent; background: linear-gradient(145deg, #7565f1, #5b4ade); }
.step.active-soft { color: #c6caDA; }
.step.active-soft > span { color: #bdb5ff; border-color: rgba(128,109,246,.25); background: rgba(117,101,239,.08); }
.guide-tip { margin-top: 24px; padding: 13px; display: flex; gap: 9px; border: 1px solid rgba(255,255,255,.07); border-radius: 13px; background: rgba(255,255,255,.035); }
.guide-tip > span { flex: 0 0 auto; }
.guide-tip strong { display: block; margin-bottom: 3px; font-size: 9px; }
.guide-tip p { margin: 0; color: #858da7; font-size: 8px; line-height: 1.5; }
.form-panel { padding: 26px; }
.form-section-head { display: flex; align-items: center; gap: 13px; margin-bottom: 17px; }
.section-number { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: #5e50d9; background: var(--primary-soft); font-size: 11px; font-weight: 800; }
.form-section-head h2 { margin: 3px 0 4px; font-size: 21px; }
.form-section-head p { margin: 0; color: var(--muted); font-size: 9px; }
.form-completion { margin-left: auto; min-width: 58px; text-align: right; }
.form-completion span { display: block; color: #5c4edc; font-size: 15px; font-weight: 800; }
.form-completion small { color: var(--muted-2); font-size: 8px; }
.form-progress-track { height: 4px; margin: 0 0 24px; overflow: hidden; border-radius: 999px; background: #f0f1f6; }
.form-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6e5ef0, #9b74fa); transition: width .25s; }
.field-group-title { margin: 22px 0 12px; padding-bottom: 9px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.field-group-title:first-of-type { margin-top: 0; }
.field-group-title span { color: #384052; font-size: 10px; font-weight: 800; }
.field-group-title small { color: var(--muted-2); font-size: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid.compact { gap: 11px; }
.span-2 { grid-column: span 2; }
.form-field { display: block; min-width: 0; }
.field-label, .form-grid > label:not(.form-field) { color: #475064; font-size: 9px; font-weight: 800; }
.field-label { display: block; margin-bottom: 7px; }
.field-label b { color: #8c6df3; }
.form-field input, .form-field select, .form-field textarea, .form-grid > label input, .form-grid > label select, .form-grid > label textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: #fbfcfe;
    font-size: 10px;
    transition: .18s;
}
.form-field input, .form-field select, .form-grid > label input, .form-grid > label select { height: 43px; padding: 0 12px; }
.form-field textarea, .form-grid > label textarea { min-height: 100px; padding: 11px 12px; resize: vertical; line-height: 1.55; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .form-grid > label input:focus, .form-grid > label select:focus, .form-grid > label textarea:focus { border-color: #8272ef; background: #fff; box-shadow: 0 0 0 4px rgba(105,87,232,.08); }
.form-field input::placeholder, .form-field textarea::placeholder { color: #b0b6c2; }
.field-hint { display: block; margin-top: 6px; color: #9299a8; font-size: 8px; line-height: 1.45; }
.actions { margin-top: 18px; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.actions.no-margin { margin: 0; }
.form-actions { margin-top: 26px; padding-top: 17px; border-top: 1px solid var(--line); }
.sticky-actions { position: sticky; bottom: 0; z-index: 8; margin-left: -26px; margin-right: -26px; margin-bottom: -26px; padding: 14px 26px; border-radius: 0 0 var(--radius) var(--radius); background: rgba(255,255,255,.93); backdrop-filter: blur(12px); }
.settings-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 18px; align-items: start; }
.settings-summary { position: sticky; top: 18px; text-align: center; }
.settings-book-cover { width: 104px; height: 140px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 8px 15px 15px 8px; color: #fff; background: linear-gradient(145deg, #302d69, #6955e1); box-shadow: 0 18px 30px rgba(63,50,145,.22); font-size: 37px; font-weight: 800; }
.settings-summary h2 { margin: 12px 0 6px; font-size: 18px; }
.settings-summary > p { color: var(--muted); font-size: 9px; line-height: 1.55; }
.summary-list { margin: 18px 0; padding: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; }
.summary-list > div { padding: 9px 0; display: flex; justify-content: space-between; gap: 10px; }
.summary-list span { color: var(--muted); font-size: 8px; }
.summary-list strong { max-width: 58%; font-size: 8px; text-align: right; }

/* ---------- Book editor ---------- */
.project-header { margin-bottom: 14px; padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid #e8e7f2; border-radius: 19px; background: linear-gradient(135deg, #fff, #f8f7ff); box-shadow: var(--shadow-sm); }
.project-title-wrap { min-width: 0; display: flex; align-items: center; gap: 14px; }
.project-avatar { width: 57px; height: 72px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px 12px 12px 7px; color: #fff; background: linear-gradient(145deg, #3b377a, #6956dc); box-shadow: 0 12px 25px rgba(70,57,157,.20); font-size: 21px; font-weight: 800; }
.project-title-content { min-width: 0; }
.project-title-content .tags { margin-bottom: 7px; }
.project-header h2 { margin: 0 0 5px; font-size: 22px; letter-spacing: -.03em; }
.project-header p { margin: 0; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-actions { flex: 0 0 auto; }
.mini-stats { margin-bottom: 14px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.mini-stats > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.92); box-shadow: 0 7px 22px rgba(34,41,61,.045); }
.mini-stats span, .mini-stats small { display: block; }
.mini-stats > div > span { margin-bottom: 5px; color: var(--muted); font-size: 8px; font-weight: 700; }
.mini-stats strong { display: block; font-size: 17px; }
.mini-stats small { margin-top: 2px; color: var(--muted-2); font-size: 7px; }
.status-text.status-completed { color: var(--success); }
.status-text.status-writing { color: #5d51da; }
.status-text.status-review { color: var(--warning); }
.workspace { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 14px; align-items: start; }
.structure-panel { position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: var(--shadow-sm); }
.workspace-title { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.workspace-title h2 { margin: 4px 0 4px; font-size: 17px; }
.workspace-title p { margin: 0; color: var(--muted); font-size: 8px; }
.structure-scroll { max-height: calc(100vh - 130px); overflow: auto; padding: 10px 12px 16px; scrollbar-width: thin; scrollbar-color: #dadde7 transparent; }
.section-group { margin: 15px 0 7px; display: flex; align-items: center; gap: 8px; color: #636b7c; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.section-group span { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 7px; color: #6254dc; background: #f0edff; font-size: 7px; }
.section-item { min-height: 36px; margin: 3px 0; padding: 5px 5px 5px 9px; display: flex; align-items: center; justify-content: space-between; gap: 7px; border-radius: 9px; color: #535b6c; background: transparent; font-size: 9px; transition: .18s; }
.section-item:hover { background: #f8f8fc; }
.section-item.level-1 { margin-left: 12px; }
.section-item.level-2 { margin-left: 24px; }
.section-item-title { min-width: 0; display: flex; align-items: center; gap: 7px; }
.section-item-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: #c5cad4; }
.status-dot.completed { background: #2bb27e; box-shadow: 0 0 0 3px rgba(43,178,126,.08); }
.status-dot.writing, .status-dot.generated { background: #7565ed; box-shadow: 0 0 0 3px rgba(117,101,237,.08); }
.section-item form { flex: 0 0 auto; }
.section-generate { width: 27px; height: 27px; padding: 0; display: grid; place-items: center; border: 1px solid #e2defb; border-radius: 8px; color: #6254dc; background: #f6f4ff; cursor: pointer; }
.section-generate:hover { color: #fff; border-color: transparent; background: #6657ea; }
.section-generate .button-loader { width: 11px; height: 11px; }
.section-item form.is-loading .section-generate > span { display: none; }
.section-item form.is-loading .button-loader { display: inline-block; }
.empty-small { margin: 8px 3px; padding: 18px 12px; text-align: center; border: 1px dashed #dbdce5; border-radius: 11px; background: #fafafd; color: var(--muted); }
.empty-small > span { width: 29px; height: 29px; margin: 0 auto 7px; display: grid; place-items: center; border-radius: 9px; color: #6759df; background: #efedff; }
.empty-small strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 9px; }
.empty-small p { margin: 0; font-size: 8px; }
.editor-panel { min-width: 0; display: grid; gap: 14px; }
.generator-bar { padding: 12px 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.generator-bar > div:first-child { display: flex; align-items: center; gap: 9px; min-width: 0; }
.generator-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: #6253d9; background: var(--primary-soft); }
.generator-bar strong, .generator-bar span { display: block; }
.generator-bar strong { font-size: 10px; }
.generator-bar div > div > span { margin-top: 2px; color: var(--muted); font-size: 8px; }
.generator-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.generator-actions form { margin: 0; }
.editor-card { overflow: hidden; border: 1px solid #e2e4eb; border-radius: 17px; background: #fff; box-shadow: var(--shadow-sm); }
.paper-toolbar { min-height: 42px; padding: 0 14px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid #eceef3; background: #f7f8fb; color: #8a91a0; font-size: 8px; }
.paper-toolbar > span:last-child { justify-self: end; }
.dot { width: 7px; height: 7px; display: inline-block; margin-right: 4px; border-radius: 50%; }
.dot.red { background: #ff766f; }.dot.yellow { background: #f8c45a; }.dot.green { background: #65c98f; }
.paper-content { min-height: 480px; padding: clamp(30px, 5vw, 68px); background: linear-gradient(90deg, #fafafa 0, #fff 9%, #fff 91%, #fafafa 100%); }
.paper-title-block { max-width: 750px; margin: 0 auto 38px; text-align: center; }
.paper-title-block h2 { margin: 7px 0 10px; font-size: clamp(26px, 3vw, 40px); line-height: 1.12; letter-spacing: -.04em; }
.lead { margin: 0; color: #757c8b; font-size: 11px; line-height: 1.65; }
.manuscript { max-width: 790px; margin: 0 auto; padding: 30px 0; border-top: 1px solid #eceef2; }
.manuscript-head { margin-bottom: 15px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.manuscript-head h3 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.manuscript-head span { flex: 0 0 auto; color: #9aa0ad; font-size: 8px; }
.manuscript .content { color: #3e4554; font-family: Georgia, "Times New Roman", serif; font-size: 14px; line-height: 1.85; white-space: pre-wrap; }
.manuscript-empty { padding: 60px 20px; }
.reference-box { margin-top: 0; }
.secure-badge { padding: 7px 9px; border: 1px solid #d9eee6; border-radius: 999px; color: #177355; background: #eff9f5; font-size: 8px; font-weight: 800; white-space: nowrap; }
.reference-list { margin-top: 18px; border-top: 1px solid var(--line); }
.reference-item { min-height: 54px; padding: 10px 2px; display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.reference-item > div { min-width: 0; }
.reference-item strong { display: block; font-size: 9px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reference-item div span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.ref-type { padding: 5px 7px; border-radius: 999px; color: #5e53ce; background: #f2f0ff; font-size: 7px; font-weight: 800; }
.link-danger { padding: 5px 7px; border: 0; border-radius: 7px; color: #b94a4a; background: transparent; font-size: 8px; cursor: pointer; }
.link-danger:hover { background: var(--danger-soft); }

/* ---------- Login ---------- */
.auth-body { min-height: 100vh; overflow-x: hidden; background: #eef1f7; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.12fr) minmax(420px,.88fr); }
.auth-showcase { position: relative; overflow: hidden; min-height: 100vh; padding: 42px clamp(38px, 5vw, 76px); display: flex; flex-direction: column; color: #fff; background: linear-gradient(150deg, #171b31 0%, #222748 55%, #302b65 100%); }
.auth-showcase::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 75% 25%, rgba(127,103,255,.22), transparent 22%), linear-gradient(120deg, transparent 65%, rgba(255,255,255,.02)); }
.auth-showcase-bg span { position: absolute; border: 1px solid rgba(255,255,255,.055); border-radius: 50%; }
.auth-showcase-bg span:nth-child(1) { width: 460px; height: 460px; right: -190px; top: -160px; box-shadow: 0 0 0 75px rgba(255,255,255,.018), 0 0 0 150px rgba(255,255,255,.012); }
.auth-showcase-bg span:nth-child(2) { width: 260px; height: 260px; left: -120px; bottom: 50px; box-shadow: 0 0 0 60px rgba(107,88,231,.035); }
.auth-showcase-bg span:nth-child(3) { width: 70px; height: 70px; right: 25%; bottom: 16%; background: rgba(116,96,239,.08); }
.auth-brand { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 12px; align-self: flex-start; }
.auth-brand > span:last-child strong { display: block; font-size: 16px; }
.auth-brand > span:last-child small { display: block; margin-top: 2px; color: #9aa2bd; font-size: 9px; }
.auth-copy { position: relative; z-index: 2; width: 100%; max-width: 760px; margin: auto 0; padding: 55px 0; }
.auth-kicker { display: inline-flex; align-items: center; padding: 7px 10px; border: 1px solid rgba(255,255,255,.10); border-radius: 999px; color: #c8c5ff; background: rgba(255,255,255,.05); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.auth-copy h1 { max-width: 740px; margin: 22px 0 19px; font-size: clamp(43px, 5.2vw, 72px); line-height: 1.01; letter-spacing: -.055em; }
.auth-copy > p { max-width: 620px; margin-bottom: 0; color: #b8bfd3; font-size: 14px; line-height: 1.75; }
.auth-feature-grid { margin-top: 34px; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.auth-feature-grid > div { min-height: 126px; padding: 16px; border: 1px solid rgba(255,255,255,.075); border-radius: 15px; background: rgba(255,255,255,.045); backdrop-filter: blur(8px); }
.auth-feature-grid span { display: block; margin-bottom: 17px; color: #978eff; font-size: 9px; font-weight: 800; }
.auth-feature-grid strong { display: block; margin-bottom: 5px; font-size: 11px; }
.auth-feature-grid small { display: block; color: #969db5; font-size: 9px; line-height: 1.5; }
.auth-showcase-footer { position: relative; z-index: 2; padding-top: 17px; display: flex; justify-content: space-between; gap: 15px; border-top: 1px solid rgba(255,255,255,.075); color: #78819e; font-size: 8px; }
.status-live { color: #9ea5ba; }
.auth-form-side { min-height: 100vh; padding: 38px; display: grid; place-items: center; align-content: center; background: linear-gradient(180deg, #f7f8fb, #edf0f6); }
.auth-mobile-brand { display: none; }
.login-card { width: min(100%, 475px); padding: 38px; border: 1px solid #e5e8f0; border-radius: 23px; background: #fff; box-shadow: var(--shadow-lg); }
.login-heading { margin-bottom: 27px; display: flex; align-items: flex-start; gap: 13px; }
.login-icon { width: 45px; height: 45px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #715ff1, #5543d7); box-shadow: 0 10px 22px rgba(88,70,219,.22); }
.login-heading h2 { margin: 4px 0 6px; font-size: 25px; letter-spacing: -.035em; }
.login-heading p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.login-form { display: grid; gap: 17px; }
.auth-input-wrap { position: relative; }
.auth-input-wrap input { width: 100%; height: 50px; padding: 0 48px 0 42px; border: 1px solid #dce1eb; border-radius: 12px; outline: none; background: #fbfcfe; color: var(--text); font-size: 11px; transition: .2s; }
.auth-input-wrap input:focus { border-color: #8172ef; background: #fff; box-shadow: 0 0 0 4px rgba(105,87,232,.09); }
.auth-input-icon { position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: #8d95a5; }
.auth-input-icon svg, .password-toggle svg, .secure-note svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle { position: absolute; right: 9px; top: 50%; width: 34px; height: 34px; transform: translateY(-50%); display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #7869e8; cursor: pointer; }
.password-toggle:hover { background: #f2f0ff; }
.password-toggle svg { width: 17px; height: 17px; }
.login-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.remember-row { display: flex; align-items: center; gap: 7px; color: #606879; font-size: 9px; cursor: pointer; }
.remember-row input { width: 15px; height: 15px; accent-color: #6253df; }
.secure-note { display: inline-flex; align-items: center; gap: 5px; color: #8b92a1; font-size: 8px; }
.secure-note svg { width: 13px; height: 13px; }
.login-submit { width: 100%; min-height: 50px; justify-content: space-between; padding: 0 17px; font-size: 11px; }
.login-security { margin-top: 22px; padding: 12px; display: flex; gap: 9px; border: 1px solid #edf0f4; border-radius: 12px; background: #fafbfc; }
.login-security > span { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: #147858; background: #e8f7f1; font-size: 10px; font-weight: 800; }
.login-security strong { display: block; margin-bottom: 2px; color: #505869; font-size: 9px; }
.login-security small { display: block; color: #9399a7; font-size: 8px; line-height: 1.45; }
.login-footer { margin-top: 15px; color: #9aa0ad; font-size: 8px; text-align: center; }

/* ---------- Assistant ---------- */
.assistant-launcher { position: fixed; right: 24px; bottom: 22px; z-index: 90; padding: 9px 13px 9px 9px; display: flex; align-items: center; gap: 9px; border: 0; border-radius: 17px; color: #fff; background: linear-gradient(135deg, #5d50e8, #765ffc); box-shadow: 0 18px 48px rgba(73,59,202,.32); cursor: pointer; transition: .2s; }
.assistant-launcher:hover { transform: translateY(-2px); }
.assistant-launcher.hidden { opacity: 0; pointer-events: none; transform: translateY(10px); }
.assistant-launcher-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.15); }
.assistant-launcher-copy { display: grid; gap: 2px; text-align: left; }
.assistant-launcher-copy strong { font-size: 10px; }.assistant-launcher-copy small { color: #e2dfff; font-size: 8px; }
.assistant-launcher-dot { width: 7px; height: 7px; border-radius: 50%; background: #49e2a7; box-shadow: 0 0 0 4px rgba(73,226,167,.12); }
.assistant-panel { position: fixed; right: 22px; bottom: 20px; z-index: 100; width: min(390px, calc(100vw - 28px)); height: min(650px, calc(100vh - 40px)); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #e5e8f1; border-radius: 21px; background: #fff; box-shadow: 0 28px 90px rgba(25,29,52,.24); opacity: 0; pointer-events: none; transform: translateY(18px) scale(.97); transform-origin: bottom right; transition: .2s; }
.assistant-panel.open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.assistant-header { padding: 14px 15px; display: flex; align-items: center; gap: 9px; color: #fff; background: linear-gradient(135deg, #171a31, #292d50); }
.assistant-avatar { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; background: linear-gradient(135deg,#7767ff,#a27aff); }
.assistant-header > div:nth-child(2) { display: grid; gap: 2px; }.assistant-header strong { font-size: 10px; }.assistant-header small { color: #b9bfd5; font-size: 8px; }
.assistant-header small span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: #43d69c; }
.assistant-close { margin-left: auto; width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.1); border-radius: 9px; color: #fff; background: rgba(255,255,255,.06); font-size: 19px; cursor: pointer; }
.assistant-context { padding: 9px 14px; display: grid; gap: 2px; border-bottom: 1px solid #edf0f5; background: #fafbfe; }
.assistant-context span { color: #9298a8; font-size: 7px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }.assistant-context strong { font-size: 9px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.assistant-quick { padding: 9px 11px; display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid #edf0f5; }
.assistant-quick button { padding: 7px 9px; border: 1px solid #e3e5ef; border-radius: 999px; color: #5b6071; background: #fff; font-size: 8px; font-weight: 750; white-space: nowrap; cursor: pointer; }
.assistant-quick button:hover { color: #5548d6; border-color: #cfc9ff; background: #f7f5ff; }
.assistant-messages { flex: 1; overflow-y: auto; padding: 14px; background: linear-gradient(180deg,#fbfcff,#f7f8fc); scroll-behavior: smooth; }
.assistant-welcome { margin-bottom: 11px; display: flex; align-items: flex-start; gap: 8px; }
.assistant-mini-avatar { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: #5c50dd; background: #ebe8ff; }
.assistant-welcome > div:last-child { padding: 10px; border: 1px solid #e8eaf1; border-radius: 5px 13px 13px 13px; background: #fff; }
.assistant-welcome strong { font-size: 9px; }.assistant-welcome p { margin: 4px 0 0; color: #6f7687; font-size: 9px; line-height: 1.55; }
.assistant-message { max-width: 88%; margin: 8px 0; display: flex; flex-direction: column; }.assistant-message.user { margin-left: auto; align-items: flex-end; }.assistant-message.assistant { margin-right: auto; align-items: flex-start; }
.assistant-message-bubble { padding: 9px 11px; border-radius: 13px; font-size: 9.5px; line-height: 1.6; }.assistant-message.user .assistant-message-bubble { color: #fff; background: linear-gradient(135deg,#6256ee,#7665fa); border-bottom-right-radius: 4px; }.assistant-message.assistant .assistant-message-bubble { color: #343a4a; border: 1px solid #e7eaf1; border-bottom-left-radius: 4px; background: #fff; }
.assistant-message small { margin-top: 3px; padding: 0 3px; color: #a0a5b2; font-size: 7px; }
.assistant-typing { width: 52px; padding: 9px 11px; display: flex; gap: 4px; border: 1px solid #e7eaf1; border-radius: 4px 13px 13px 13px; background: #fff; }.assistant-typing span { width: 5px; height: 5px; border-radius: 50%; background: #8e94a5; animation: assistantPulse 1s infinite alternate; }.assistant-typing span:nth-child(2){animation-delay:.2s}.assistant-typing span:nth-child(3){animation-delay:.4s}@keyframes assistantPulse{to{opacity:.25;transform:translateY(-2px)}}
.assistant-form { margin: 0; padding: 9px 10px; display: flex; align-items: flex-end; gap: 7px; border-top: 1px solid #e8ebf2; background: #fff; }.assistant-form textarea { min-height: 41px; max-height: 110px; flex: 1; padding: 10px 11px; resize: none; border: 1px solid #dde1eb; border-radius: 11px; outline: none; background: #fafbfe; font-size: 9px; line-height: 1.45; }.assistant-form textarea:focus { border-color: #8175f5; box-shadow: 0 0 0 3px rgba(98,84,239,.08); background: #fff; }.assistant-form button { width: 41px; height: 41px; border: 0; border-radius: 11px; color: #fff; background: linear-gradient(135deg,#6256ee,#7867ff); cursor: pointer; }.assistant-form button:disabled { opacity: .5; cursor: not-allowed; }.assistant-disclaimer { padding: 0 10px 9px; color: #a0a5b1; background: #fff; text-align: center; font-size: 7px; }

/* ---------- Responsive ---------- */
@media (max-width: 1260px) {
    .book-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .workspace { grid-template-columns: 270px minmax(0,1fr); }
    .top-create span:not(.btn-icon) { display: none; }
    .top-create { width: 43px; padding: 0; }
}

@media (max-width: 1050px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: 0; top: 0; width: 278px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 22px 0 65px rgba(12,16,30,.25); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-close { display: grid; place-items: center; }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 45; display: block; background: rgba(12,16,28,.48); backdrop-filter: blur(2px); opacity: 0; visibility: hidden; transition: .2s; }
    body.sidebar-open .sidebar-overlay { opacity: 1; visibility: visible; }
    .main { padding: 22px 24px 56px; }
    .mobile-menu-button { display: grid; }
    .profile-trigger { min-width: 0; }
    .profile-copy { display: none; }
    .profile-trigger .chevron { display: none; }
    .hero-banner { grid-template-columns: 1fr 280px; }
    .create-layout, .settings-layout { grid-template-columns: 1fr; }
    .create-guide, .settings-summary { position: relative; top: auto; }
    .create-guide { display: grid; grid-template-columns: minmax(0,1fr) minmax(280px,.9fr); gap: 18px 28px; align-items: start; }
    .create-guide .step-list { grid-column: 2; grid-row: 1 / 5; margin-top: 0; }
    .guide-tip { grid-column: 1; }
    .settings-summary { display: grid; grid-template-columns: 100px 1fr; gap: 0 18px; text-align: left; }
    .settings-book-cover { grid-row: 1 / 5; width: 90px; height: 122px; margin: 0; }
    .settings-summary > .pill { align-self: end; justify-self: start; }.settings-summary h2 { margin-top: 8px; }.settings-summary > p { margin-bottom: 0; }
    .settings-summary .summary-list, .settings-summary .btn { grid-column: 1 / -1; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-showcase { min-height: 470px; padding: 34px; }
    .auth-copy { padding: 48px 0 30px; }
    .auth-copy h1 { max-width: 800px; font-size: 48px; }
    .auth-form-side { min-height: auto; padding: 36px 24px 48px; }
}

@media (max-width: 820px) {
    .main { padding: 18px 16px 48px; }
    .topbar { align-items: flex-start; }
    .date-chip { display: none; }
    .topbar h1 { font-size: 24px; }
    .hero-banner { min-height: auto; padding: 30px; grid-template-columns: 1fr; }
    .hero-visual { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card > div:last-child { grid-template-columns: 1fr auto; }
    .library-hero { align-items: flex-start; }
    .library-toolbar { align-items: stretch; flex-direction: column; }
    .search-box { max-width: none; }
    .book-grid { grid-template-columns: 1fr 1fr; }
    .workspace { grid-template-columns: 1fr; }
    .structure-panel { position: relative; top: auto; max-height: none; }
    .structure-scroll { max-height: 440px; }
    .project-header { align-items: flex-start; flex-direction: column; }
    .project-actions { width: 100%; }
    .project-actions .btn, .project-actions form { flex: 1; }
    .project-actions form .btn { width: 100%; }
    .mini-stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .paper-content { padding: 32px 24px; }
    .create-guide { display: block; }
    .create-guide .step-list, .guide-tip { grid-column: auto; grid-row: auto; }
    .auth-showcase { min-height: 420px; }
    .auth-feature-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
    .topbar { gap: 10px; }
    .top-actions { gap: 6px; }
    .mobile-menu-button, .profile-trigger, .top-create { width: 40px; height: 40px; min-height: 40px; }
    .profile-trigger { padding: 4px; }
    .profile-trigger .user-avatar { width: 30px; height: 30px; }
    .topbar-title { gap: 9px; }
    .topbar .eyebrow { display: none; }
    .topbar h1 { margin: 0; font-size: 21px; }
    .profile-dropdown { position: fixed; right: 12px; top: 64px; }
    .hero-banner { padding: 25px 22px; border-radius: 19px; }
    .hero-copy h2 { font-size: 29px; }
    .hero-actions .btn { flex: 1; }
    .book-grid { grid-template-columns: 1fr; }
    .panel { padding: 18px; }
    .panel-head, .library-hero { flex-direction: column; }
    .library-hero .btn { width: 100%; }
    .filter-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; }
    .filter-chips button { flex: 0 0 auto; }
    .pagination-simple { flex-wrap: wrap; justify-content: center; }
    .pagination-simple > span:nth-child(2) { order: -1; width: 100%; text-align: center; }
    .form-panel { padding: 19px; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .form-section-head { align-items: flex-start; }
    .form-completion { display: none; }
    .sticky-actions { margin-left: -19px; margin-right: -19px; margin-bottom: -19px; padding: 12px 19px; }
    .form-actions .btn { flex: 1; }
    .settings-summary { display: block; text-align: center; }
    .settings-book-cover { margin: 0 auto 15px; }
    .summary-list { text-align: left; }
    .project-title-wrap { align-items: flex-start; }
    .project-avatar { width: 48px; height: 62px; }
    .project-header h2 { font-size: 19px; }
    .project-actions { flex-direction: column; }
    .project-actions .btn, .project-actions form { width: 100%; }
    .mini-stats { gap: 7px; }
    .mini-stats > div { padding: 12px; }
    .generator-bar { align-items: stretch; flex-direction: column; }
    .generator-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .generator-actions .btn { width: 100%; }
    .paper-toolbar { grid-template-columns: auto 1fr; }
    .paper-toolbar > span:nth-child(2) { text-align: center; }
    .paper-toolbar > span:last-child { display: none; }
    .paper-content { padding: 26px 18px; }
    .manuscript .content { font-size: 13px; }
    .panel-head .secure-badge { align-self: flex-start; }
    .reference-item { grid-template-columns: minmax(0,1fr) auto; }
    .reference-item form { grid-column: 2; }
    .auth-showcase { display: none; }
    .auth-form-side { min-height: 100vh; padding: 24px 16px; align-content: center; }
    .auth-mobile-brand { width: min(100%, 465px); margin: 0 auto 16px; display: flex; align-items: center; gap: 10px; color: #293149; font-size: 12px; }
    .auth-mobile-brand .brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 16px; }
    .login-card { padding: 27px 20px; border-radius: 19px; box-shadow: 0 18px 50px rgba(31,37,58,.10); }
    .login-heading h2 { font-size: 22px; }
    .login-heading p { font-size: 9px; }
    .assistant-launcher { right: 13px; bottom: 13px; }
    .assistant-launcher-copy { display: none; }
    .assistant-panel { right: 7px; bottom: 7px; width: calc(100vw - 14px); height: calc(100vh - 14px); border-radius: 17px; }
}


/* ---------- Book writing targets & print specifications ---------- */
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.input-suffix { position: relative; display: flex; align-items: stretch; }
.input-suffix input { width: 100%; padding-right: 58px; }
.input-suffix > span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 9px; font-weight: 800; pointer-events: none; }
.word-target-field { padding: 15px; border: 1px solid #ececf5; border-radius: 14px; background: linear-gradient(180deg, #fff, #fbfbff); }
.word-target-field .field-hint { min-height: 28px; }
.conditional-fields { min-width: 0; }
.conditional-fields[hidden] { display: none !important; }
.nested-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: end; }
.margin-grid { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 13px; border: 1px dashed #dcd9f7; border-radius: 14px; background: #faf9ff; }
.book-spec-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.book-spec-stats > div { min-width: 0; }
.book-spec-stats strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-item-title { min-width: 0; flex-wrap: wrap; }
.section-item-title > span:nth-child(2) { min-width: 0; flex: 1 1 120px; }
.section-word-target { flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; color: #685be2; background: #f0eeff; font-size: 7px; font-weight: 800; white-space: nowrap; }
.paper-content { min-height: calc(min(100%, 850px) * var(--book-page-ratio, 1.42)); padding: var(--book-pad-top, 44px) var(--book-pad-right, 44px) var(--book-pad-bottom, 44px) var(--book-pad-left, 44px); font-family: var(--book-font-family, "Noto Sans"), serif; font-size: var(--book-font-size, 11pt); }
.paper-content .manuscript .content { font-family: inherit; font-size: inherit; }
.paper-content .manuscript .content, .paper-content .lead { line-height: 1.7; }
.book-card-wrap { position: relative; min-width: 0; }
.book-card-wrap .book-card { height: 100%; }
.book-spec-line { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin: 10px 0 12px; }
.book-spec-line span { padding: 4px 7px; border: 1px solid #ececf3; border-radius: 999px; color: #777e8f; background: #fafbfe; font-size: 8px; font-weight: 700; }
.draft-delete-form { position: absolute; right: 12px; bottom: 12px; z-index: 4; }
.draft-delete-button { min-height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 9px; border: 1px solid #f0caca; border-radius: 9px; color: #b93e48; background: rgba(255, 248, 248, .96); box-shadow: 0 5px 16px rgba(173, 50, 59, .08); font-size: 8px; font-weight: 800; cursor: pointer; transition: .18s ease; }
.draft-delete-button:hover { border-color: #e9aeb3; color: #9e2732; background: #fff1f2; transform: translateY(-1px); }
.draft-delete-button svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.draft-delete-form.is-loading .draft-delete-button > svg, .draft-delete-form.is-loading .draft-delete-button > span { display: none; }
.draft-delete-form .button-loader { display: none; }
.draft-delete-form.is-loading .button-loader { display: inline-block; }
.book-card-wrap:has(.draft-delete-form) .book-card-body { padding-bottom: 48px; }

@media (max-width: 1260px) {
    .book-spec-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .form-grid-3 { grid-template-columns: 1fr; }
    .margin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .nested-grid, .margin-grid { grid-template-columns: 1fr; }
    .book-spec-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .draft-delete-form { right: 10px; bottom: 10px; }
}

/* Keep AI action loaders hidden until the related form is submitted. */
.generator-bar .button-loader { display: none; }
.generator-bar form.is-loading .button-loader { display: inline-block; }

/* ---------- Medium typography for Create Book form ---------- */
/* Scoped to .create-layout so the editor, library, and login keep their existing scale. */
.create-layout .form-section-head p {
    font-size: 11px;
    line-height: 1.55;
}

.create-layout .form-completion small {
    font-size: 10px;
}

.create-layout .field-group-title span {
    font-size: 13px;
    line-height: 1.4;
}

.create-layout .field-group-title small {
    font-size: 10.5px;
    line-height: 1.45;
}

.create-layout .field-label,
.create-layout .form-grid > label:not(.form-field) {
    font-size: 12px;
    line-height: 1.4;
}

.create-layout .form-field input,
.create-layout .form-field select,
.create-layout .form-field textarea,
.create-layout .form-grid > label input,
.create-layout .form-grid > label select,
.create-layout .form-grid > label textarea {
    font-size: 13px;
}

.create-layout .form-field input,
.create-layout .form-field select,
.create-layout .form-grid > label input,
.create-layout .form-grid > label select {
    height: 47px;
    padding-right: 14px;
    padding-left: 14px;
}

.create-layout .form-field textarea,
.create-layout .form-grid > label textarea {
    min-height: 112px;
    padding: 13px 14px;
    line-height: 1.65;
}

.create-layout .field-hint {
    margin-top: 7px;
    font-size: 10.5px;
    line-height: 1.55;
}

.create-layout .input-suffix > span {
    font-size: 10.5px;
}

.create-layout .create-guide > p {
    font-size: 11.5px;
    line-height: 1.7;
}

.create-layout .step strong {
    font-size: 11px;
}

.create-layout .step small {
    font-size: 9.5px;
    line-height: 1.45;
}

.create-layout .guide-tip strong {
    font-size: 10.5px;
}

.create-layout .guide-tip p {
    font-size: 9.5px;
    line-height: 1.6;
}

@media (max-width: 640px) {
    .create-layout .field-group-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .create-layout .form-field input,
    .create-layout .form-field select,
    .create-layout .form-field textarea {
        font-size: 13px;
    }
}


/* ---------- Medium typography for Book Editor ---------- */
/* Scoped to the editor page so Dashboard, Library, Create, and Login stay unchanged. */
.book-editor-page .project-title-content .pill {
    padding: 6px 9px;
    font-size: 10px;
}

.book-editor-page .project-header p {
    font-size: 12px;
    line-height: 1.5;
}

.book-editor-page .project-actions .btn,
.book-editor-page .generator-actions .btn,
.book-editor-page .reference-box .btn {
    font-size: 12px;
}

.book-editor-page .mini-stats > div {
    padding: 15px 16px;
}

.book-editor-page .mini-stats > div > span {
    font-size: 10.5px;
    line-height: 1.4;
}

.book-editor-page .mini-stats strong {
    font-size: 18px;
    line-height: 1.35;
}

.book-editor-page .mini-stats small {
    margin-top: 4px;
    font-size: 9.5px;
    line-height: 1.4;
}

.book-editor-page .workspace {
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 16px;
}

.book-editor-page .workspace-title {
    padding: 20px 19px 16px;
}

.book-editor-page .workspace-title .eyebrow,
.book-editor-page .paper-title-block .eyebrow,
.book-editor-page .reference-box .eyebrow {
    font-size: 10px;
}

.book-editor-page .workspace-title h2 {
    font-size: 20px;
}

.book-editor-page .workspace-title p {
    font-size: 11px;
    line-height: 1.55;
}

.book-editor-page .structure-scroll {
    padding: 11px 13px 18px;
}

.book-editor-page .section-group {
    margin-top: 17px;
    margin-bottom: 9px;
    font-size: 11px;
    line-height: 1.4;
}

.book-editor-page .section-group span {
    width: 27px;
    height: 27px;
    font-size: 9px;
}

.book-editor-page .section-item {
    min-height: 44px;
    margin: 4px 0;
    padding: 7px 6px 7px 10px;
    gap: 8px;
    font-size: 11.5px;
    line-height: 1.4;
}

.book-editor-page .section-item-title {
    gap: 8px;
}

.book-editor-page .section-item-title > span:nth-child(2) {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.book-editor-page .status-dot {
    width: 7px;
    height: 7px;
}

.book-editor-page .section-word-target {
    padding: 3px 7px;
    font-size: 9px;
}

.book-editor-page .section-generate {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.book-editor-page .empty-small strong {
    font-size: 11px;
}

.book-editor-page .empty-small p {
    font-size: 10px;
    line-height: 1.5;
}

.book-editor-page .generator-bar {
    padding: 14px 15px;
}

.book-editor-page .generator-icon {
    width: 38px;
    height: 38px;
    font-size: 15px;
}

.book-editor-page .generator-bar strong {
    font-size: 12px;
}

.book-editor-page .generator-bar div > div > span {
    font-size: 10.5px;
    line-height: 1.45;
}

.book-editor-page .paper-toolbar {
    min-height: 46px;
    padding-right: 16px;
    padding-left: 16px;
    font-size: 10px;
}

.book-editor-page .paper-content {
    font-size: calc(var(--book-font-size, 11pt) * 1.08);
}

.book-editor-page .paper-title-block .lead {
    font-size: 13px;
    line-height: 1.7;
}

.book-editor-page .manuscript {
    padding-top: 34px;
    padding-bottom: 34px;
}

.book-editor-page .manuscript-head h3 {
    font-size: 21px;
    line-height: 1.35;
}

.book-editor-page .manuscript-head span {
    font-size: 10.5px;
}

.book-editor-page .paper-content .manuscript .content {
    font-size: inherit;
    line-height: 1.8;
}

.book-editor-page .reference-box .panel-head h2 {
    font-size: 22px;
}

.book-editor-page .reference-box .panel-head p {
    font-size: 11px;
    line-height: 1.6;
}

.book-editor-page .secure-badge {
    padding: 8px 10px;
    font-size: 10px;
}

.book-editor-page .reference-box .field-label,
.book-editor-page .reference-box .form-grid > label:not(.form-field) {
    font-size: 12px;
    line-height: 1.4;
}

.book-editor-page .reference-box .form-field input,
.book-editor-page .reference-box .form-field select,
.book-editor-page .reference-box .form-field textarea,
.book-editor-page .reference-box .form-grid > label input,
.book-editor-page .reference-box .form-grid > label select,
.book-editor-page .reference-box .form-grid > label textarea {
    font-size: 13px;
}

.book-editor-page .reference-box .form-field input,
.book-editor-page .reference-box .form-field select,
.book-editor-page .reference-box .form-grid > label input,
.book-editor-page .reference-box .form-grid > label select {
    height: 47px;
    padding-right: 14px;
    padding-left: 14px;
}

.book-editor-page .reference-item {
    min-height: 62px;
}

.book-editor-page .reference-item strong {
    font-size: 11.5px;
}

.book-editor-page .reference-item div span {
    font-size: 10px;
}

.book-editor-page .ref-type,
.book-editor-page .link-danger {
    font-size: 9.5px;
}

@media (max-width: 1280px) {
    .book-editor-page .workspace {
        grid-template-columns: 310px minmax(0, 1fr);
    }
}

@media (max-width: 980px) {
    .book-editor-page .workspace {
        grid-template-columns: 1fr;
    }

    .book-editor-page .structure-panel {
        position: static;
        max-height: none;
    }

    .book-editor-page .structure-scroll {
        max-height: 520px;
    }
}

@media (max-width: 640px) {
    .book-editor-page .project-title-content .pill {
        font-size: 9px;
    }

    .book-editor-page .mini-stats > div > span {
        font-size: 9.5px;
    }

    .book-editor-page .mini-stats strong {
        font-size: 16px;
    }

    .book-editor-page .section-item {
        font-size: 11px;
    }

    .book-editor-page .paper-content {
        font-size: calc(var(--book-font-size, 11pt) * 1.02);
    }

    .book-editor-page .manuscript-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .book-editor-page .manuscript-head h3 {
        font-size: 19px;
    }

    .book-editor-page .reference-box .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* ---------- Medium typography for Dashboard and Book Library ---------- */
/* Scoped per page so Create, Editor, Auth, and Settings retain their own scale. */
.dashboard-page,
.library-page {
    font-size: 13px;
}

.dashboard-page .eyebrow,
.library-page .eyebrow {
    font-size: 10.5px;
    line-height: 1.4;
}

/* Dashboard hero */
.dashboard-page .hero-kicker {
    padding: 8px 12px;
    font-size: 11.5px;
}

.dashboard-page .hero-copy p {
    font-size: 13px;
    line-height: 1.75;
}

.dashboard-page .hero-actions .btn {
    min-height: 44px;
    padding-right: 17px;
    padding-left: 17px;
    font-size: 12px;
}

.dashboard-page .book-front span {
    font-size: 9.5px;
}

.dashboard-page .book-front small,
.dashboard-page .floating-badge {
    font-size: 9.5px;
}

/* Dashboard statistic cards */
.dashboard-page .stat-card {
    min-height: 92px;
    padding: 20px;
    gap: 15px;
}

.dashboard-page .stat-icon {
    width: 46px;
    height: 46px;
    font-size: 17px;
}

.dashboard-page .stat-card span {
    font-size: 12px;
}

.dashboard-page .stat-card strong {
    font-size: 28px;
}

.dashboard-page .stat-card small {
    font-size: 10.5px;
    line-height: 1.45;
}

/* Shared panel headings */
.dashboard-page .panel-head h2,
.library-page .panel-head h2 {
    font-size: 22px;
}

.dashboard-page .panel-head p,
.library-page .panel-head p {
    font-size: 11.5px;
    line-height: 1.6;
}

.dashboard-page .text-link {
    font-size: 11.5px;
}

/* Library hero and controls */
.library-page .library-hero h2 {
    font-size: 25px;
}

.library-page .library-hero p {
    font-size: 12px;
    line-height: 1.6;
}

.library-page .library-hero .btn {
    min-height: 44px;
    padding-right: 16px;
    padding-left: 16px;
    font-size: 12px;
}

.library-page .search-box input {
    height: 46px;
    padding-left: 41px;
    font-size: 12.5px;
}

.library-page .search-box svg {
    left: 14px;
    width: 17px;
    height: 17px;
}

.library-page .filter-chips button {
    min-height: 39px;
    padding-right: 14px;
    padding-left: 14px;
    font-size: 11px;
}

/* Book cards on Dashboard and Book Library */
.dashboard-page .book-card-cover,
.library-page .book-card-cover {
    height: 130px;
    padding: 19px;
}

.dashboard-page .book-card-cover > span:first-child,
.library-page .book-card-cover > span:first-child {
    width: 43px;
    height: 57px;
    font-size: 23px;
}

.dashboard-page .book-card-cover small,
.library-page .book-card-cover small {
    font-size: 9px;
    line-height: 1.4;
}

.dashboard-page .book-card-cover strong,
.library-page .book-card-cover strong {
    margin-top: 4px;
    font-size: 16px;
    line-height: 1.35;
}

.library-page .cover-status {
    padding: 6px 9px;
    font-size: 9px;
}

.dashboard-page .book-card-body,
.library-page .book-card-body {
    padding: 17px;
}

.dashboard-page .pill,
.library-page .pill {
    padding: 6px 9px;
    font-size: 10px;
}

.dashboard-page .book-card-body p,
.library-page .book-card-body p {
    min-height: 42px;
    font-size: 12px;
    line-height: 1.65;
}

.library-page .book-spec-line span {
    padding: 5px 8px;
    font-size: 9.5px;
}

.dashboard-page .book-meta,
.library-page .book-meta {
    font-size: 10.5px;
    line-height: 1.45;
}

.library-page .draft-delete-button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 10px;
}

.library-page .draft-delete-button svg {
    width: 14px;
    height: 14px;
}

.library-page .book-card-wrap:has(.draft-delete-form) .book-card-body {
    padding-bottom: 54px;
}

/* Empty states and pagination */
.dashboard-page .empty h3,
.library-page .empty h3,
.library-page .search-empty h3 {
    font-size: 19px;
}

.dashboard-page .empty p,
.library-page .empty p,
.library-page .search-empty p {
    font-size: 11.5px;
    line-height: 1.65;
}

.library-page .pagination-simple {
    font-size: 11px;
}

.library-page .pagination-simple a,
.library-page .pagination-simple .disabled {
    padding: 9px 12px;
}

@media (max-width: 820px) {
    .dashboard-page .stat-card small {
        white-space: normal;
    }

    .dashboard-page .book-card-cover,
    .library-page .book-card-cover {
        height: 124px;
    }
}

@media (max-width: 640px) {
    .dashboard-page .hero-copy p {
        font-size: 12.5px;
    }

    .dashboard-page .stat-card {
        min-height: 86px;
        padding: 17px;
    }

    .dashboard-page .stat-card strong {
        font-size: 25px;
    }

    .library-page .library-hero h2 {
        font-size: 23px;
    }

    .library-page .filter-chips button {
        font-size: 10.5px;
    }

    .dashboard-page .book-card-cover strong,
    .library-page .book-card-cover strong {
        font-size: 15px;
    }

    .dashboard-page .book-card-body p,
    .library-page .book-card-body p {
        min-height: 0;
    }
}


/* Medium shell typography only while Dashboard or Book Library is open. */
body.dashboard-medium-page .sidebar-label,
body.library-medium-page .sidebar-label {
    font-size: 10px;
}

body.dashboard-medium-page .sidebar-nav a,
body.library-medium-page .sidebar-nav a {
    font-size: 13px;
}

body.dashboard-medium-page .engine-card strong,
body.library-medium-page .engine-card strong,
body.dashboard-medium-page .sidebar-note strong,
body.library-medium-page .sidebar-note strong,
body.dashboard-medium-page .sidebar-user strong,
body.library-medium-page .sidebar-user strong {
    font-size: 11.5px;
}

body.dashboard-medium-page .engine-status,
body.library-medium-page .engine-status,
body.dashboard-medium-page .engine-card small,
body.library-medium-page .engine-card small,
body.dashboard-medium-page .sidebar-note span,
body.library-medium-page .sidebar-note span {
    font-size: 10px;
    line-height: 1.55;
}

body.dashboard-medium-page .sidebar-user small,
body.library-medium-page .sidebar-user small {
    font-size: 9px;
}

body.dashboard-medium-page .topbar .eyebrow,
body.library-medium-page .topbar .eyebrow {
    font-size: 10px;
}

body.dashboard-medium-page .date-chip,
body.library-medium-page .date-chip,
body.dashboard-medium-page .profile-copy strong,
body.library-medium-page .profile-copy strong {
    font-size: 11px;
}

body.dashboard-medium-page .profile-copy small,
body.library-medium-page .profile-copy small {
    font-size: 9px;
}

body.dashboard-medium-page .top-create,
body.library-medium-page .top-create {
    font-size: 11.5px;
}

/* =========================================================
   PROFESSIONAL FRONTEND V2
   Dashboard, Library, Create Wizard, and Manuscript Editor
   ========================================================= */

:root {
    --v2-primary: #6254e8;
    --v2-primary-dark: #4d40cf;
    --v2-primary-soft: #efedff;
    --v2-ink: #101828;
    --v2-muted: #667085;
    --v2-line: #e4e7ec;
    --v2-bg: #f5f6fa;
    --v2-success: #12b76a;
    --v2-warning: #f79009;
    --v2-danger: #d92d20;
    --editor-zoom: 1;
}

/* Dashboard V2 */
.dashboard-page-v2 { display: grid; gap: 20px; }
.hero-banner-v2 {
    min-height: 320px;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(330px, .75fr);
    align-items: center;
    gap: 42px;
    padding: 42px;
    border-radius: 26px;
    overflow: hidden;
    background:
        radial-gradient(circle at 78% 5%, rgba(255,255,255,.18), transparent 27%),
        linear-gradient(135deg, #332c79 0%, #5848dc 58%, #765cf0 100%);
    box-shadow: 0 24px 58px rgba(63, 50, 161, .22);
}
.hero-banner-v2 .hero-copy { max-width: 760px; }
.hero-banner-v2 .hero-kicker { font-size: 13px; letter-spacing: .1em; }
.hero-banner-v2 h2 { max-width: 760px; font-size: clamp(30px, 3vw, 48px); line-height: 1.09; letter-spacing: -.045em; }
.hero-banner-v2 p { max-width: 680px; font-size: 16px; line-height: 1.75; }
.hero-banner-v2 .btn { min-height: 46px; padding-inline: 19px; font-size: 14px; }
.hero-workflow-card {
    padding: 22px;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 20px;
    background: rgba(18, 15, 52, .34);
    color: #fff;
    backdrop-filter: blur(14px);
    box-shadow: inset 0 1px rgba(255,255,255,.12);
}
.hero-workflow-card > span { display: block; margin-bottom: 14px; color: #d8d3ff; font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.workflow-line { display: grid; grid-template-columns: 34px 1fr 20px; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid rgba(255,255,255,.12); }
.workflow-line b { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.13); font-size: 12px; }
.workflow-line strong { display: block; font-size: 13px; }
.workflow-line small { display: block; margin-top: 2px; color: #c8c4ea; font-size: 11px; }
.workflow-line i { color: #b8ffdb; font-style: normal; font-weight: 800; }
.stats-grid-v2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-grid-v2 .stat-card { min-height: 118px; padding: 22px; }
.stats-grid-v2 .stat-card span { font-size: 13px; }
.stats-grid-v2 .stat-card strong { font-size: 29px; }
.stats-grid-v2 .stat-card small { font-size: 11px; }
.stat-icon.amber { background: #fff4e5; color: #dc6803; }
.dashboard-insight-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 20px; }
.dashboard-insight-grid .panel { margin: 0; padding: 24px; }
.compact-head { margin-bottom: 18px; }
.compact-head h2 { font-size: 20px; }
.compact-head p { font-size: 13px; }
.status-progress-list { display: grid; gap: 17px; }
.status-progress-row > div:first-child { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 9px; margin-bottom: 7px; }
.status-progress-row strong { color: var(--v2-ink); font-size: 13px; }
.status-progress-row b { color: var(--v2-muted); font-size: 13px; }
.status-progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #f0f1f5; }
.status-progress-track span { display: block; height: 100%; min-width: 4px; border-radius: inherit; background: #98a2b3; }
.status-progress-track span.draft { background: #98a2b3; }
.status-progress-track span.outline { background: #7f70f5; }
.status-progress-track span.writing { background: #2e90fa; }
.status-progress-track span.completed { background: #12b76a; }
.recent-activity-list { display: grid; }
.recent-activity-list > a { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 12px 0; color: inherit; border-top: 1px solid #eff1f5; text-decoration: none; }
.recent-activity-list > a:first-child { border-top: 0; }
.activity-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--v2-primary-soft); color: var(--v2-primary); font-size: 12px; font-weight: 800; }
.recent-activity-list strong { display: block; overflow: hidden; color: var(--v2-ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.recent-activity-list small { display: block; margin-top: 3px; color: var(--v2-muted); font-size: 11px; }
.recent-activity-list time { color: #98a2b3; font-size: 10px; white-space: nowrap; }
.empty-activity { display: flex; gap: 10px; align-items: center; min-height: 130px; justify-content: center; color: var(--v2-muted); font-size: 13px; }
.dashboard-quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dashboard-quick-actions > a { display: grid; grid-template-columns: 44px 1fr auto; gap: 13px; align-items: center; min-height: 88px; padding: 17px; color: inherit; border: 1px solid var(--v2-line); border-radius: 17px; background: #fff; text-decoration: none; box-shadow: 0 10px 25px rgba(16,24,40,.05); transition: .2s ease; }
.dashboard-quick-actions > a:hover { transform: translateY(-2px); border-color: #cfc9ff; box-shadow: 0 16px 32px rgba(81,63,192,.11); }
.dashboard-quick-actions > a > span { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: var(--v2-primary-soft); color: var(--v2-primary); font-size: 20px; }
.dashboard-quick-actions strong { display: block; color: var(--v2-ink); font-size: 14px; }
.dashboard-quick-actions small { display: block; margin-top: 3px; color: var(--v2-muted); font-size: 11px; }
.dashboard-quick-actions b { color: var(--v2-primary); }
.dashboard-project-panel { margin: 0; }
.dashboard-book-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-book-card .book-card-cover { min-height: 145px; }

/* Library V2 */
.library-page-v2 { display: grid; gap: 16px; }
.library-hero-v2 { margin: 0; padding: 25px 28px; border: 1px solid var(--v2-line); border-radius: 21px; background: linear-gradient(130deg, #fff, #f8f7ff); box-shadow: 0 12px 32px rgba(16,24,40,.055); }
.library-hero-v2 h2 { font-size: 27px; }
.library-hero-v2 p { font-size: 14px; }
.library-summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.library-summary-strip > div { display: flex; align-items: center; justify-content: space-between; padding: 15px 17px; border: 1px solid var(--v2-line); border-radius: 14px; background: #fff; }
.library-summary-strip span { color: var(--v2-muted); font-size: 12px; }
.library-summary-strip strong { color: var(--v2-ink); font-size: 18px; }
.library-panel-v2 { margin: 0; padding: 22px; }
.library-toolbar-v2 { align-items: center; }
.library-toolbar-actions { display: flex; align-items: center; gap: 12px; }
.view-switcher { display: inline-grid; grid-template-columns: repeat(2, 36px); gap: 4px; padding: 4px; border: 1px solid var(--v2-line); border-radius: 11px; background: #f8f9fb; }
.view-switcher button { width: 36px; height: 34px; border: 0; border-radius: 8px; color: #667085; background: transparent; cursor: pointer; font-size: 17px; }
.view-switcher button.active { color: var(--v2-primary); background: #fff; box-shadow: 0 2px 8px rgba(16,24,40,.08); }
.library-result-meta { display: flex; justify-content: space-between; align-items: center; padding: 8px 1px 16px; color: var(--v2-muted); }
.library-result-meta span { font-size: 12px; font-weight: 700; }
.library-result-meta small { font-size: 11px; }
.library-grid-v2 { gap: 18px; }
.book-card-wrap-v2 { position: relative; display: grid; border-radius: 19px; }
.book-card-v2 { height: 100%; }
.book-card-v2 .book-list-heading { display: none; }
.book-card-actions { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border: 1px solid var(--v2-line); border-top: 0; border-radius: 0 0 16px 16px; background: #fff; }
.book-card-actions a, .book-card-actions button { min-height: 31px; padding: 7px 9px; border: 0; border-radius: 8px; color: #586174; background: #f7f8fa; font-family: inherit; font-size: 10px; font-weight: 700; text-decoration: none; cursor: pointer; }
.book-card-actions form { margin-left: auto; }
.book-card-actions form button { color: var(--v2-danger); background: #fff1f1; }
.library-grid-v2[data-view="list"] { display: grid; grid-template-columns: 1fr; gap: 10px; }
.library-grid-v2[data-view="list"] .book-card-wrap-v2 { grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; border: 1px solid var(--v2-line); border-radius: 15px; background: #fff; box-shadow: 0 6px 17px rgba(16,24,40,.04); }
.library-grid-v2[data-view="list"] .book-card-v2 { display: grid; grid-template-columns: minmax(0, 1fr); border: 0; border-radius: 15px 0 0 15px; box-shadow: none; }
.library-grid-v2[data-view="list"] .book-card-cover { display: none; }
.library-grid-v2[data-view="list"] .book-card-body { display: grid; grid-template-columns: minmax(240px, 1.4fr) minmax(180px, .8fr) minmax(190px, .8fr) minmax(150px, .6fr); gap: 18px; align-items: center; min-height: 98px; padding: 16px 18px; }
.library-grid-v2[data-view="list"] .book-list-heading { display: block; }
.library-grid-v2[data-view="list"] .book-list-heading h3 { margin: 5px 0 0; overflow: hidden; color: var(--v2-ink); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.library-grid-v2[data-view="list"] .book-list-heading > span { display: none; }
.library-grid-v2[data-view="list"] .book-card-body > p { margin: 0; font-size: 12px; line-height: 1.45; }
.library-grid-v2[data-view="list"] .book-spec-line { margin: 0; }
.library-grid-v2[data-view="list"] .book-progress { margin: 0 0 5px; }
.library-grid-v2[data-view="list"] .book-meta { grid-column: 4; }
.library-grid-v2[data-view="list"] .book-card-actions { flex-direction: column; align-items: stretch; justify-content: center; width: 115px; padding: 10px; border: 0; border-left: 1px solid var(--v2-line); border-radius: 0 15px 15px 0; }
.library-grid-v2[data-view="list"] .book-card-actions form { width: 100%; margin: 0; }
.library-grid-v2[data-view="list"] .book-card-actions a, .library-grid-v2[data-view="list"] .book-card-actions button { display: block; width: 100%; text-align: center; }

/* Create Wizard V2 */
.create-layout-v2 { align-items: start; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; }
.create-guide-v2 { position: sticky; top: 18px; min-height: calc(100vh - 118px); padding: 28px; }
.create-guide-v2 h2 { font-size: 27px; line-height: 1.18; }
.create-guide-v2 > p { font-size: 13px; line-height: 1.7; }
.wizard-step-list { gap: 7px; }
.wizard-step-list .step { width: 100%; border: 0; color: inherit; text-align: left; cursor: pointer; }
.wizard-step-list .step:disabled { cursor: not-allowed; opacity: .48; }
.wizard-step-list .step.active { background: rgba(109, 91, 239, .22); }
.wizard-step-list .step.complete > span { background: #12b76a; }
.wizard-step-list .step strong { font-size: 13px; }
.wizard-step-list .step small { font-size: 10px; }
.guide-progress-card { margin-top: 20px; padding: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; background: rgba(255,255,255,.055); }
.guide-progress-card > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guide-progress-card span { color: #a9afc9; font-size: 10px; }
.guide-progress-card strong { color: #fff; font-size: 10px; }
.guide-progress-track { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.guide-progress-track span { display: block; width: 25%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8175ff, #b6abff); transition: width .25s ease; }
.wizard-form-panel { min-width: 0; padding: 28px 30px 0; }
.wizard-form-head { position: sticky; z-index: 4; top: 0; margin: -28px -30px 0; padding: 26px 30px 20px; border-radius: 19px 19px 0 0; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.wizard-form-head h2 { font-size: 23px; }
.wizard-step-panel { min-height: 560px; padding: 22px 0 30px; animation: wizardPanelIn .24s ease; }
@keyframes wizardPanelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.wizard-panel-heading { display: flex; align-items: flex-start; gap: 13px; padding: 15px 17px; border: 1px solid #e8e6ff; border-radius: 14px; background: #faf9ff; }
.wizard-panel-heading > span { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: var(--v2-primary); background: var(--v2-primary-soft); font-size: 11px; font-weight: 800; }
.wizard-panel-heading h3 { margin: 0; color: var(--v2-ink); font-size: 16px; }
.wizard-panel-heading p { margin: 4px 0 0; color: var(--v2-muted); font-size: 12px; }
.target-preview-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 16px 18px; border: 1px solid #dcd8ff; border-radius: 14px; background: linear-gradient(135deg, #f7f5ff, #fff); }
.target-preview-card span { display: block; color: var(--v2-muted); font-size: 11px; }
.target-preview-card strong { display: block; margin-top: 4px; color: var(--v2-primary-dark); font-size: 20px; }
.target-preview-card p { max-width: 520px; margin: 0; color: var(--v2-muted); font-size: 11px; line-height: 1.6; }
.wizard-summary { margin-top: 22px; padding: 18px; border: 1px solid #dedaff; border-radius: 15px; background: #faf9ff; }
.wizard-summary-head { display: flex; gap: 10px; align-items: center; }
.wizard-summary-head > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--v2-primary); }
.wizard-summary-head strong { display: block; color: var(--v2-ink); font-size: 14px; }
.wizard-summary-head p { margin: 2px 0 0; color: var(--v2-muted); font-size: 11px; }
.wizard-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.wizard-summary-grid > div { padding: 12px; border: 1px solid #e6e3f7; border-radius: 11px; background: #fff; }
.wizard-summary-grid span { display: block; color: var(--v2-muted); font-size: 10px; }
.wizard-summary-grid strong { display: block; margin-top: 4px; color: var(--v2-ink); font-size: 12px; }
.wizard-actions { position: sticky; z-index: 5; bottom: 0; margin: 0 -30px; padding: 15px 30px; background: rgba(255,255,255,.97); backdrop-filter: blur(12px); }
.wizard-actions .btn { min-height: 43px; font-size: 12px; }

/* Manuscript Editor V2 */
.book-editor-v2 { display: grid; gap: 14px; }
.editor-project-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 19px 22px; border: 1px solid var(--v2-line); border-radius: 20px; background: linear-gradient(120deg, #fff, #faf9ff); box-shadow: 0 10px 28px rgba(16,24,40,.055); }
.editor-project-identity { display: flex; align-items: center; min-width: 0; gap: 15px; }
.editor-project-identity h2 { margin: 7px 0 3px; overflow: hidden; color: var(--v2-ink); font-size: 23px; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.editor-project-identity p { margin: 0; overflow: hidden; color: var(--v2-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.editor-project-actions { display: flex; gap: 9px; flex: 0 0 auto; }
.editor-project-actions form { margin: 0; }
.editor-overview-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.editor-overview-cards > div { padding: 13px 15px; border: 1px solid var(--v2-line); border-radius: 13px; background: #fff; }
.editor-overview-cards span { display: block; color: var(--v2-muted); font-size: 10px; }
.editor-overview-cards strong { display: block; margin-top: 4px; color: var(--v2-ink); font-size: 16px; }
.editor-overview-cards small { display: block; margin-top: 2px; overflow: hidden; color: #98a2b3; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.editor-mobile-switcher { display: none; }
.editor-studio { display: grid; grid-template-columns: 300px minmax(500px, 1fr) 270px; min-height: 720px; overflow: hidden; border: 1px solid var(--v2-line); border-radius: 19px; background: #fff; box-shadow: 0 15px 40px rgba(16,24,40,.07); }
.editor-sidebar-panel { min-width: 0; background: #fbfcfe; }
.editor-structure-panel { display: flex; flex-direction: column; border-right: 1px solid var(--v2-line); }
.editor-ai-panel { padding: 17px; border-left: 1px solid var(--v2-line); }
.editor-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px; border-bottom: 1px solid var(--v2-line); }
.editor-ai-panel .editor-panel-head { margin: -17px -17px 16px; }
.editor-panel-head h3 { margin: 4px 0 0; color: var(--v2-ink); font-size: 17px; }
.mobile-panel-close { display: none; border: 0; background: transparent; color: #667085; font-size: 24px; cursor: pointer; }
.structure-search-v2 { display: flex; align-items: center; gap: 8px; margin: 13px 14px 8px; padding: 0 11px; height: 39px; border: 1px solid var(--v2-line); border-radius: 11px; background: #fff; }
.structure-search-v2 svg { width: 16px; fill: none; stroke: #98a2b3; stroke-width: 1.8; }
.structure-search-v2 input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--v2-ink); background: transparent; font: inherit; font-size: 11px; }
.editor-structure-scroll { flex: 1; min-height: 0; padding: 0 9px 10px; overflow-y: auto; }
.editor-structure-group { border-top: 1px solid #eceef3; }
.editor-structure-group:first-child { border-top: 0; }
.structure-group-title { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 12px 5px 8px; border: 0; color: #667085; background: transparent; font: inherit; font-size: 10px; font-weight: 800; text-transform: uppercase; cursor: pointer; }
.structure-group-title span { display: flex; align-items: center; gap: 8px; }
.structure-group-title b { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; color: var(--v2-primary); background: var(--v2-primary-soft); font-size: 8px; }
.structure-group-title i { font-style: normal; transition: .18s; }
.editor-structure-group.collapsed .structure-group-content { display: none; }
.editor-structure-group.collapsed .structure-group-title i { transform: rotate(180deg); }
.editor-section-item { display: grid; grid-template-columns: minmax(0, 1fr) 32px; align-items: center; gap: 3px; margin: 2px 0; border-radius: 9px; }
.editor-section-item.level-2 { margin-left: 12px; }
.editor-section-item.level-3 { margin-left: 25px; }
.editor-section-select { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px; border: 0; border-radius: 9px; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.editor-section-select:hover { background: #f1f2f7; }
.editor-section-select.active { background: #eeecff; box-shadow: inset 0 0 0 1px #dcd7ff; }
.editor-section-copy { min-width: 0; display: grid; gap: 3px; }
.editor-section-copy strong { overflow: hidden; color: #344054; font-size: 10.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.editor-section-copy small { color: #98a2b3; font-size: 8.5px; }
.editor-section-generate { margin: 0; }
.editor-section-generate button { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #dedaff; border-radius: 8px; color: var(--v2-primary); background: #fff; cursor: pointer; }
.editor-section-generate button:hover { color: #fff; background: var(--v2-primary); }
.status-dot.edited { background: #2e90fa; box-shadow: 0 0 0 3px #eaf4ff; }
.structure-footer-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; padding: 11px; border-top: 1px solid var(--v2-line); background: #fff; }
.structure-footer-actions .btn { width: 100%; min-height: 36px; padding: 8px; font-size: 10px; }
.editor-document-panel { min-width: 0; display: flex; flex-direction: column; background: #f4f5f8; }
.document-topbar { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 14px; border-bottom: 1px solid var(--v2-line); background: #fff; }
.document-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 10px; background: #f3f4f7; }
.document-tabs button { min-width: 74px; padding: 7px 11px; border: 0; border-radius: 7px; color: #667085; background: transparent; font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; }
.document-tabs button.active { color: var(--v2-primary); background: #fff; box-shadow: 0 2px 7px rgba(16,24,40,.08); }
.document-save-state { display: flex; align-items: center; gap: 6px; color: #667085; }
.document-save-state > span { width: 7px; height: 7px; border-radius: 50%; background: #12b76a; }
.document-save-state strong { font-size: 10px; }
.document-save-state small { font-size: 9px; }
.document-save-state[data-state="saving"] > span { background: #f79009; animation: savePulse 1s infinite; }
.document-save-state[data-state="dirty"] > span { background: #98a2b3; }
.document-save-state[data-state="error"] > span { background: #f04438; }
.document-save-state[data-state="error"] { color: #b42318; }
@keyframes savePulse { 50% { opacity: .35; } }
.document-toolbar { min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 7px 14px; border-bottom: 1px solid var(--v2-line); background: #fff; }
.document-toolbar-group { display: flex; gap: 3px; padding-right: 9px; border-right: 1px solid var(--v2-line); }
.document-toolbar button:not(.btn) { min-width: 32px; height: 31px; padding: 0 8px; border: 0; border-radius: 7px; color: #596174; background: #f6f7f9; font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; }
.document-toolbar button:hover:not(.btn) { color: var(--v2-primary); background: var(--v2-primary-soft); }
.zoom-control { margin-left: auto; align-items: center; }
.zoom-control span { min-width: 40px; color: #667085; font-size: 9px; text-align: center; }
.btn-small { min-height: 31px; padding: 7px 12px; font-size: 10px; }
.document-meta-bar { display: flex; align-items: center; gap: 12px; padding: 10px 15px; border-bottom: 1px solid var(--v2-line); background: #fff; }
.document-meta-bar input { min-width: 0; flex: 1; padding: 4px 0; border: 0; outline: 0; color: var(--v2-ink); background: transparent; font: 700 14px/1.3 'Manrope', sans-serif; }
.document-meta-bar > div { display: flex; gap: 7px; align-items: center; }
.document-meta-bar span { padding: 4px 7px; border-radius: 6px; color: #667085; background: #f5f6f8; font-size: 8.5px; white-space: nowrap; }
.document-canvas-wrap { flex: 1; min-height: 0; padding: 25px; overflow: auto; }
.document-page { width: min(100%, 820px); min-height: 630px; margin: 0 auto; padding: calc(var(--book-pad-top) * var(--editor-zoom)) calc(var(--book-pad-right) * var(--editor-zoom)) calc(var(--book-pad-bottom) * var(--editor-zoom)) calc(var(--book-pad-left) * var(--editor-zoom)); border: 1px solid #e7e8ec; border-radius: 3px; background: #fff; box-shadow: 0 13px 32px rgba(16,24,40,.11); transform-origin: top center; }
.document-page textarea { width: 100%; min-height: 540px; resize: none; border: 0; outline: 0; color: #1d2939; background: transparent; font-family: var(--book-font-family), Georgia, serif; font-size: calc(var(--book-font-size) * var(--editor-zoom)); line-height: 1.75; white-space: pre-wrap; }
.document-preview-page article { font-family: var(--book-font-family), Georgia, serif; font-size: calc(var(--book-font-size) * var(--editor-zoom)); }
.document-preview-page h1 { margin: 18px 0 26px; color: #101828; font-size: 2em; line-height: 1.18; }
.document-preview-content { color: #1d2939; line-height: 1.8; white-space: pre-wrap; }
.document-statusbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 51px; padding: 10px 15px; border-top: 1px solid var(--v2-line); background: #fff; }
.document-statusbar > div { width: min(360px, 55%); }
.document-statusbar span { color: #667085; font-size: 9px; }
.section-target-track { height: 5px; margin-top: 6px; overflow: hidden; border-radius: 999px; background: #eef0f4; }
.section-target-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6254e8, #9b8dff); transition: width .25s ease; }
.ai-section-card { padding: 14px; border: 1px solid #ddd9ff; border-radius: 13px; background: linear-gradient(140deg, #f6f4ff, #fff); }
.ai-section-card > span { color: #7f70e9; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.ai-section-card strong { display: block; margin-top: 7px; color: var(--v2-ink); font-size: 13px; line-height: 1.4; }
.ai-section-card p { margin: 5px 0 10px; color: var(--v2-muted); font-size: 9px; line-height: 1.5; }
.ai-target-progress { height: 6px; overflow: hidden; border-radius: 999px; background: #e9e6ff; }
.ai-target-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--v2-primary); }
.btn-block { width: 100%; justify-content: center; margin-top: 11px; }
.ai-tool-list { display: grid; gap: 7px; margin-top: 14px; }
.ai-tool-list button { display: grid; grid-template-columns: 34px 1fr; gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--v2-line); border-radius: 11px; color: inherit; background: #fff; text-align: left; cursor: pointer; }
.ai-tool-list button:hover { border-color: #cfc9ff; background: #faf9ff; }
.ai-tool-list button > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--v2-primary); background: var(--v2-primary-soft); font-size: 14px; }
.ai-tool-list strong { display: block; color: var(--v2-ink); font-size: 10.5px; }
.ai-tool-list small { display: block; margin-top: 2px; color: var(--v2-muted); font-size: 8.5px; }
.ai-context-note { margin-top: 14px; padding: 12px; border-radius: 11px; background: #f2f4f7; }
.ai-context-note strong { display: block; color: #344054; font-size: 10px; }
.ai-context-note p { margin: 4px 0 0; color: #667085; font-size: 8.5px; line-height: 1.5; }
.reference-box-v2 { margin: 0; overflow: hidden; }
.reference-box-v2 > summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 19px 22px; cursor: pointer; list-style: none; }
.reference-box-v2 > summary::-webkit-details-marker { display: none; }
.reference-box-v2 > summary h2 { margin: 4px 0 2px; font-size: 18px; }
.reference-box-v2 > summary p { margin: 0; color: var(--v2-muted); font-size: 11px; }
.reference-box-v2 > summary > span { padding: 7px 10px; border-radius: 8px; color: var(--v2-primary); background: var(--v2-primary-soft); font-size: 10px; font-weight: 800; }
.reference-box-content { padding: 0 22px 22px; border-top: 1px solid var(--v2-line); }

@media (max-width: 1500px) {
    .editor-studio { grid-template-columns: 275px minmax(460px, 1fr) 245px; }
    .dashboard-book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
    .hero-banner-v2 { grid-template-columns: 1fr; }
    .hero-workflow-card { display: none; }
    .stats-grid-v2 { grid-template-columns: repeat(2, 1fr); }
    .dashboard-insight-grid { grid-template-columns: 1fr; }
    .dashboard-quick-actions { grid-template-columns: 1fr; }
    .library-toolbar-v2 { align-items: stretch; flex-direction: column; }
    .library-toolbar-actions { justify-content: space-between; }
    .library-grid-v2[data-view="list"] .book-card-body { grid-template-columns: minmax(230px, 1.2fr) minmax(170px, .8fr) minmax(150px, .6fr); }
    .library-grid-v2[data-view="list"] .book-card-body > p { display: none; }
    .library-grid-v2[data-view="list"] .book-meta { grid-column: 3; }
    .create-layout-v2 { grid-template-columns: 260px minmax(0, 1fr); }
    .editor-mobile-switcher { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px; border: 1px solid var(--v2-line); border-radius: 12px; background: #fff; }
    .editor-mobile-switcher button { padding: 9px; border: 0; border-radius: 8px; color: #667085; background: transparent; font: inherit; font-size: 10px; font-weight: 700; }
    .editor-mobile-switcher button.active { color: var(--v2-primary); background: var(--v2-primary-soft); }
    .editor-studio { position: relative; display: block; min-height: 700px; overflow: visible; }
    .editor-document-panel { min-height: 700px; border-radius: 18px; overflow: hidden; }
    .editor-sidebar-panel { position: fixed; z-index: 100; top: 0; bottom: 0; width: min(360px, 88vw); transition: transform .25s ease; box-shadow: 0 0 42px rgba(16,24,40,.22); }
    .editor-structure-panel { left: 0; transform: translateX(-105%); }
    .editor-ai-panel { right: 0; padding: 17px; transform: translateX(105%); }
    .book-editor-v2.show-structure .editor-structure-panel { transform: translateX(0); }
    .book-editor-v2.show-assistant .editor-ai-panel { transform: translateX(0); }
    .mobile-panel-close { display: block; }
}

@media (max-width: 900px) {
    .hero-banner-v2 { min-height: auto; padding: 29px; }
    .hero-banner-v2 h2 { font-size: 32px; }
    .library-summary-strip { grid-template-columns: repeat(2, 1fr); }
    .library-toolbar-actions { align-items: flex-start; flex-direction: column; }
    .filter-chips { width: 100%; overflow-x: auto; }
    .library-grid-v2[data-view="list"] .book-card-wrap-v2 { grid-template-columns: 1fr; }
    .library-grid-v2[data-view="list"] .book-card-body { grid-template-columns: 1fr 1fr; }
    .library-grid-v2[data-view="list"] .book-meta { grid-column: auto; }
    .library-grid-v2[data-view="list"] .book-card-actions { width: auto; flex-direction: row; border: 0; border-top: 1px solid var(--v2-line); border-radius: 0 0 15px 15px; }
    .create-layout-v2 { display: block; }
    .create-guide-v2 { position: static; min-height: 0; margin-bottom: 14px; padding: 22px; }
    .create-guide-v2 > h2, .create-guide-v2 > p, .create-guide-v2 .guide-tip { display: none; }
    .wizard-step-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .wizard-step-list .step { display: grid; justify-items: center; gap: 4px; padding: 8px 4px; text-align: center; }
    .wizard-step-list .step > div small { display: none; }
    .wizard-step-list .step strong { font-size: 9px; }
    .guide-progress-card { margin-top: 12px; }
    .editor-project-header { align-items: flex-start; flex-direction: column; }
    .editor-project-actions { width: 100%; }
    .editor-project-actions .btn, .editor-project-actions form { flex: 1; }
    .editor-project-actions form .btn { width: 100%; }
    .editor-overview-cards { grid-template-columns: repeat(2, 1fr); }
    .document-statusbar { align-items: flex-start; flex-direction: column; }
    .document-statusbar > div { width: 100%; }
}

@media (max-width: 650px) {
    .dashboard-page-v2 { gap: 13px; }
    .hero-banner-v2 { padding: 23px 20px; border-radius: 20px; }
    .hero-banner-v2 h2 { font-size: 27px; }
    .hero-banner-v2 p { font-size: 13px; }
    .hero-banner-v2 .hero-actions { align-items: stretch; flex-direction: column; }
    .stats-grid-v2 { grid-template-columns: 1fr 1fr; gap: 9px; }
    .stats-grid-v2 .stat-card { min-height: 100px; padding: 14px; }
    .stats-grid-v2 .stat-card strong { font-size: 22px; }
    .stats-grid-v2 .stat-icon { display: none; }
    .dashboard-insight-grid .panel { padding: 18px; }
    .dashboard-book-grid { grid-template-columns: 1fr; }
    .library-hero-v2 { align-items: flex-start; flex-direction: column; padding: 20px; }
    .library-summary-strip { grid-template-columns: 1fr 1fr; gap: 8px; }
    .library-summary-strip > div { padding: 12px; }
    .library-summary-strip span { font-size: 10px; }
    .library-panel-v2 { padding: 14px; }
    .library-result-meta small { display: none; }
    .library-grid-v2[data-view="list"] .book-card-body { display: block; min-height: 0; }
    .library-grid-v2[data-view="list"] .book-card-body .tags, .library-grid-v2[data-view="list"] .book-card-body .book-spec-line { margin-top: 10px; }
    .library-grid-v2[data-view="list"] .book-card-actions { flex-wrap: wrap; }
    .wizard-form-panel { padding: 19px 17px 0; }
    .wizard-form-head { margin: -19px -17px 0; padding: 20px 17px 16px; }
    .wizard-step-list .step strong { display: none; }
    .wizard-step-list .step > span { width: 31px; height: 31px; }
    .wizard-summary-grid { grid-template-columns: 1fr; }
    .target-preview-card { align-items: flex-start; flex-direction: column; }
    .wizard-actions { margin: 0 -17px; padding: 12px 17px; }
    .wizard-actions .btn { flex: 1; padding-inline: 10px; }
    .editor-project-header { padding: 16px; }
    .editor-project-identity { align-items: flex-start; }
    .editor-project-identity .project-avatar { width: 44px; height: 55px; }
    .editor-project-identity h2 { font-size: 18px; }
    .editor-project-actions { flex-direction: column; }
    .editor-overview-cards { grid-template-columns: 1fr 1fr; }
    .editor-overview-cards > div { padding: 11px; }
    .editor-mobile-switcher button { font-size: 9px; }
    .document-topbar, .document-toolbar, .document-meta-bar { padding-inline: 10px; }
    .document-toolbar-group:first-child button:nth-child(3) { display: none; }
    .document-canvas-wrap { padding: 12px; }
    .document-page { min-height: 560px; padding: 35px 25px; }
    .document-page textarea { min-height: 490px; }
    .document-meta-bar { align-items: flex-start; flex-direction: column; }
    .document-meta-bar input { width: 100%; }
    .document-statusbar > span:last-child { display: none; }
    .reference-box-v2 > summary { padding: 16px; }
    .reference-box-content { padding: 0 16px 16px; }
}

/* Book structure hierarchy: BAB is visually stronger than subbab and child subbab. */
.book-editor-v2-page .editor-section-item.type-chapter .editor-section-copy strong {
    color: #1d2939;
    font-weight: 800;
    letter-spacing: .01em;
}

.book-editor-v2-page .editor-section-item.type-subchapter .editor-section-copy strong {
    font-weight: 650;
}

.book-editor-v2-page .editor-section-item.type-child_subchapter .editor-section-copy strong {
    font-weight: 550;
}


/* Structure numbering labels: BAB 1, A, A.1 are displayed separately from titles. */
.book-editor-v2-page .editor-section-heading {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
}

.book-editor-v2-page .section-number-label {
    flex: 0 0 auto;
    color: #344054;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.35;
}

.book-editor-v2-page .editor-section-heading .section-title-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-editor-v2-page .editor-section-item.type-chapter .section-number-label,
.book-editor-v2-page .editor-section-item.type-chapter .section-title-text {
    color: #101828;
    font-weight: 800;
}

.book-editor-v2-page .editor-section-item.type-subchapter .section-number-label {
    color: #475467;
    font-weight: 750;
}

.book-editor-v2-page .editor-section-item.type-child_subchapter .section-number-label {
    color: #667085;
    font-weight: 700;
}
