:root {
    --paper: #f5f1e8;
    --card: #fffdf8;
    --ink: #1d1c1a;
    --ink-soft: #4b4842;
    --muted: #857f74;
    --line: #e6dfd2;
    --accent: #b64926;
    --accent-deep: #93371b;
    --accent-soft: #f6e3da;
    --ok: #4c7a63;
    --shadow: 0 30px 60px -42px rgba(52, 38, 20, .45);
    --radius: 20px;
    --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
    --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", Georgia, serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.7;
    padding-bottom: 132px;
    -webkit-font-smoothing: antialiased;
}

.glow {
    position: fixed;
    z-index: 0;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
}

.glow-a {
    width: 520px;
    height: 520px;
    top: -180px;
    right: -120px;
    background: rgba(182, 73, 38, .13);
}

.glow-b {
    width: 480px;
    height: 480px;
    bottom: -220px;
    left: -160px;
    background: rgba(120, 122, 90, .16);
}

.topbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1120px;
    margin: 0 auto;
    padding: 26px 28px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 9px;
    background: var(--accent);
    position: relative;
}

.brand-mark::after {
    content: "";
    position: absolute;
    left: 10px;
    top: 7px;
    border-left: 9px solid #fff8ee;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.brand-name {
    font-weight: 700;
    letter-spacing: .08em;
    font-size: 16px;
}

.brand-sub {
    font-size: 10px;
    letter-spacing: .22em;
    color: var(--muted);
    padding-top: 2px;
}

.topmeta {
    font-size: 12px;
    letter-spacing: .04em;
    color: var(--muted);
}

.shell {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 28px;
}

.hero {
    padding: 60px 0 42px;
    max-width: 720px;
}

.eyebrow {
    margin: 0 0 18px;
    font-size: 11px;
    letter-spacing: .34em;
    color: var(--accent);
    font-weight: 600;
}

.hero h1 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(38px, 5.6vw, 62px);
    line-height: 1.18;
    letter-spacing: .01em;
}

.hero h1 em {
    font-style: normal;
    color: var(--accent);
    position: relative;
    white-space: nowrap;
}

.hero h1 em::after {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    bottom: 6px;
    height: 8px;
    background: var(--accent-soft);
    z-index: -1;
    border-radius: 4px;
}

.lede {
    margin: 22px 0 0;
    max-width: 560px;
    color: var(--ink-soft);
    font-size: 14.5px;
    line-height: 1.9;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
}

.editor {
    padding: 26px 28px 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.card-head h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--ink-soft);
}

.counter {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.counter b {
    color: var(--ink);
    font-weight: 600;
}

.counter.warn b {
    color: var(--accent);
}

textarea {
    display: block;
    width: 100%;
    min-height: 196px;
    resize: vertical;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15.5px;
    line-height: 2;
    padding: 2px 0;
}

textarea::placeholder {
    color: #b3ac9e;
}

.editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    border-top: 1px dashed var(--line);
    margin-top: 12px;
    padding-top: 18px;
}

.editor-meta {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--muted);
}

.dot-live {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 4px rgba(76, 122, 99, .13);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    border: 0;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 999px;
    transition: transform .18s ease, background .18s ease, box-shadow .18s ease, color .18s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: .72;
}

.btn.primary {
    background: var(--ink);
    color: #fdf9f1;
    box-shadow: 0 16px 30px -18px rgba(29, 28, 26, .8);
}

.btn.primary:hover:not(:disabled) {
    background: var(--accent);
}

.btn.ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--line);
}

.btn.ghost:hover {
    border-color: #cdc4b4;
    color: var(--ink);
}

.btn.small {
    padding: 8px 16px;
    font-size: 12.5px;
}

.btn-icon {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.spinner {
    display: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}

.btn.loading .spinner {
    display: inline-block;
}

.btn.loading .btn-icon {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- workspace ---------- */

.workspace {
    margin-top: 26px;
    animation: rise .35s ease both;
}

.workspace-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 2px 18px;
}

.workspace-actions.hidden {
    display: none;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.progress-block {
    margin: 0 2px 16px;
}

.progress-track {
    height: 3px;
    background: #e7e0d3;
    border-radius: 99px;
    overflow: hidden;
}

.progress-track i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 99px;
    transition: width .4s ease;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 9px;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.grid {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.roles {
    padding: 22px 22px 16px;
    position: sticky;
    top: 20px;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    letter-spacing: .04em;
    background: var(--accent-soft);
    color: var(--accent-deep);
    white-space: nowrap;
}

.tag.muted {
    background: #f0ece3;
    color: var(--muted);
}

.tag.tiny {
    padding: 1px 8px;
    font-size: 10.5px;
}

.role-list {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.role {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.avatar {
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 700;
    color: hsl(var(--hue) 42% 32%);
    background: hsl(var(--hue) 58% 92%);
    border: 1px solid hsl(var(--hue) 45% 85%);
}

.role-body {
    min-width: 0;
    flex: 1;
}

.role-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.role-line b {
    font-size: 14px;
    font-weight: 600;
}

.role-gender {
    font-size: 11px;
    color: var(--muted);
}

.role-voice {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
}

.footnote {
    margin: 16px 0 4px;
    font-size: 11.5px;
    line-height: 1.75;
    color: var(--muted);
    border-top: 1px dashed var(--line);
    padding-top: 12px;
}

.footnote:empty {
    display: none;
}

.script {
    padding: 22px 24px 18px;
}

.segment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 620px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.segment {
    display: flex;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

.segment:hover {
    background: #faf6ee;
}

.segment.active {
    background: #fdf3ec;
    border-color: #efcdbd;
}

.seg-index {
    flex: none;
    width: 22px;
    padding-top: 2px;
    font-size: 11px;
    color: #bcb4a5;
    font-variant-numeric: tabular-nums;
}

.seg-body {
    min-width: 0;
    flex: 1;
}

.seg-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.speaker {
    font-size: 12px;
    font-weight: 600;
    color: hsl(var(--hue) 44% 34%);
    background: hsl(var(--hue) 56% 93%);
    border-radius: 99px;
    padding: 1px 9px;
}

.emo {
    font-size: 10.5px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 99px;
    padding: 0 8px;
}

.seg-state {
    margin-left: auto;
    font-size: 10.5px;
    letter-spacing: .04em;
    color: #b6ae9f;
}

.seg-state.working {
    color: var(--accent);
}

.seg-state.ready {
    color: var(--ok);
}

.seg-state.failed {
    color: #b03a2e;
}

.segment p {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.85;
    color: var(--ink-soft);
    word-break: break-word;
}

/* ---------- player ---------- */

.player {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 18px;
    width: auto;
    z-index: 30;
    animation: rise .3s ease both;
}

.player.hidden {
    display: none;
}

.player-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 18px;
    border-radius: 22px;
    background: rgba(255, 253, 248, .92);
    border: 1px solid var(--line);
    box-shadow: 0 24px 60px -26px rgba(58, 41, 19, .5);
    backdrop-filter: blur(14px);
}

.play-toggle {
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    background: var(--accent);
    color: #fff8ee;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease, transform .18s ease;
}

.play-toggle:hover {
    background: var(--accent-deep);
}

.play-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.player.paused .icon-pause,
.player:not(.paused) .icon-play {
    display: none;
}

.player-main {
    flex: 1;
    min-width: 0;
}

.player-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 7px;
}

.player-track {
    height: 6px;
    background: #eae3d6;
    border-radius: 99px;
    overflow: visible;
    cursor: pointer;
    position: relative;
    transition: height .15s ease;
}

.player-track:hover {
    height: 10px;
}

.player-track i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 99px;
    transition: width .1s linear;
    position: relative;
}

.player-track.seeking i {
    transition: none;
}

.player-track i::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
    transition: transform .15s ease;
}

.player-track:hover i::after,
.player-track.seeking i::after {
    transform: translateY(-50%) scale(1);
}

.player-sub {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.player-sub span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-extra {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rate-select {
    font-family: var(--sans);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    background: transparent;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #b3ac9e 50%),
                      linear-gradient(135deg, #b3ac9e 50%, transparent 50%);
    background-position: calc(100% - 10px) 14px, calc(100% - 6px) 14px;
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
    padding-right: 22px;
}

.rate-select:hover {
    border-color: #cdc4b4;
    color: var(--ink);
}

/* ---------- toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translate(-50%, 12px);
    background: rgba(29, 28, 26, .92);
    color: #fdf9f0;
    font-size: 13px;
    padding: 11px 20px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
    z-index: 50;
    max-width: min(560px, calc(100vw - 40px));
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .roles {
        position: static;
    }

    .hero {
        padding: 44px 0 32px;
    }

    .shell {
        padding: 0 18px;
    }

    .topbar {
        padding: 20px 18px 0;
    }

    .topmeta {
        display: none;
    }

    .segment-list {
        max-height: none;
    }
}

@media (max-width: 560px) {
    .editor {
        padding: 20px 18px 16px;
    }

    .editor-foot {
        align-items: stretch;
    }

    .editor-actions {
        width: 100%;
    }

    .editor-actions .btn {
        flex: 1;
    }

    .script {
        padding: 20px 16px 14px;
    }

    .player-inner {
        gap: 12px;
        padding: 12px 14px;
    }

    .player-sub {
        display: none;
    }
}

/* ---------- audiobook ---------- */

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.page-nav {
    color: var(--ink-soft);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.page-nav:hover {
    color: var(--accent);
}

.page-nav span {
    margin-left: 3px;
}

.audiobook-setup {
    padding: 8px 28px 22px;
}

.setup-section {
    padding: 22px 0;
}

.setup-section + .setup-section {
    border-top: 1px dashed var(--line);
}

.setup-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.step-no {
    padding-top: 2px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
}

.setup-heading h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .06em;
}

.setup-heading p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.book-drop {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    min-height: 128px;
    padding: 22px;
    border: 1px dashed #cfc5b5;
    border-radius: 16px;
    background: #fbf8f1;
    cursor: pointer;
    text-align: center;
    transition: border-color .18s ease, background .18s ease;
}

.book-drop:hover,
.book-drop.dragging {
    border-color: var(--accent);
    background: #fdf3ec;
}

.book-drop strong {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 14px;
    font-weight: 600;
}

.book-drop span {
    color: var(--muted);
    font-size: 12px;
}

.book-drop-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 5px;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
}

.voice-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 10px;
}

.voice-option {
    display: flex;
    align-items: stretch;
    gap: 6px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fffdf8;
    transition: border-color .18s ease, background .18s ease;
}

.voice-option.selected {
    border-color: #d8a68f;
    background: #fdf3ec;
}

.voice-select,
.voice-preview {
    border: 0;
    font-family: var(--sans);
    cursor: pointer;
}

.voice-select {
    flex: 1;
    min-width: 0;
    padding: 5px 7px;
    background: transparent;
    color: var(--ink);
    text-align: left;
}

.voice-select b,
.voice-select small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-select b {
    font-size: 13px;
    font-weight: 600;
}

.voice-select small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 10.5px;
}

.voice-preview {
    flex: none;
    align-self: center;
    padding: 6px 8px;
    border-radius: 99px;
    background: transparent;
    color: var(--accent);
    font-size: 11px;
}

.voice-preview:hover {
    background: var(--accent-soft);
}

.setup-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 18px;
    border-top: 1px dashed var(--line);
}

.selection-summary {
    color: var(--muted);
    font-size: 12px;
}

.book-overview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.book-overview-main {
    min-width: 0;
}

.book-title-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.book-title-line h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--serif);
    font-size: 20px;
}

.book-meta {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.chapters-card {
    padding: 22px 24px 18px;
}

.chapter-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 680px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: #fbf8f1;
}

.chapter-item.synthesizing {
    border-color: #efcdbd;
    background: #fdf6f0;
}

.chapter-item.ready {
    background: #f7faf5;
}

.chapter-index {
    flex: none;
    width: 30px;
    color: #b3aa9b;
    font-family: var(--serif);
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.chapter-body {
    flex: 1;
    min-width: 0;
}

.chapter-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.chapter-head b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13.5px;
    font-weight: 600;
}

.chapter-detail {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 11px;
}

.chapter-error {
    color: #b03a2e;
    overflow-wrap: anywhere;
}

.chapter-actions {
    flex: none;
    display: flex;
    gap: 6px;
}

.chapter-actions .btn {
    text-decoration: none;
}

.empty-note {
    margin: 0;
    padding: 18px 0;
    color: var(--muted);
    font-size: 12.5px;
    text-align: center;
}

@media (max-width: 900px) {
    .chapter-list {
        max-height: none;
    }
}

@media (max-width: 560px) {
    .topbar-actions {
        gap: 10px;
    }

    .audiobook-setup {
        padding: 4px 18px 18px;
    }

    .setup-foot,
    .book-overview {
        align-items: stretch;
        flex-direction: column;
    }

    .setup-foot .btn,
    .book-overview .btn {
        width: 100%;
    }

    .book-overview,
    .chapters-card {
        padding: 18px 16px;
    }

    .chapter-item {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }

    .chapter-actions {
        width: 100%;
        padding-left: 40px;
    }

    .chapter-actions .btn {
        flex: 1;
    }
}

/* ---------- home feature cards ---------- */

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.brand:hover .brand-name {
    color: var(--accent);
}

.brand-name {
    transition: color .18s ease;
}

.home-shell {
    padding-top: 20px;
}

.home-hero {
    padding: 72px 0 48px;
    text-align: center;
    margin: 0 auto;
    max-width: 640px;
}

.home-hero h1 {
    font-size: clamp(44px, 6vw, 72px);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    margin-bottom: 60px;
}

.feature-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 32px 28px 28px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.feature-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, var(--accent-soft) 0%, transparent 60%);
    opacity: 0;
    transition: opacity .22s ease;
    pointer-events: none;
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: #e0c4b6;
    box-shadow: 0 38px 70px -48px rgba(52, 38, 20, .55);
}

.feature-card:hover::before {
    opacity: 1;
}

.feature-icon {
    position: relative;
    z-index: 1;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.feature-icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.voice-icon {
    background: #fdf0e9;
    color: var(--accent);
}

.book-icon {
    background: #eef1ec;
    color: #5d7a63;
}

.shelf-icon {
    background: #f4efe6;
    color: #8b6b3f;
}

.feature-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.feature-tag {
    font-size: 10px;
    letter-spacing: .24em;
    color: var(--accent);
    font-weight: 600;
}

.feature-body h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
}

.feature-body p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.85;
    flex: 1;
}

.feature-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: .02em;
}

.feature-card:hover .feature-action {
    gap: 8px;
}

.feature-action {
    transition: gap .18s ease;
}

@media (max-width: 900px) {
    .feature-grid {
        grid-template-columns: 1fr;
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }

    .home-hero {
        padding: 48px 0 32px;
    }
}

@media (max-width: 560px) {
    .home-shell {
        padding-top: 10px;
    }

    .home-hero h1 {
        font-size: clamp(36px, 9vw, 48px);
    }
}

/* ================================================================
   THEME: voice-theme — 多角色配音（戏剧橙红）
   ================================================================ */
.voice-theme {
    --paper: #f5f1e8;
    --card: #fffdf8;
    --ink: #1d1c1a;
    --ink-soft: #4b4842;
    --muted: #857f74;
    --line: #e6dfd2;
    --accent: #b64926;
    --accent-deep: #8d3619;
    --accent-soft: #f6e3da;
    --ok: #4c7a63;
}

.voice-theme .page-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 99px;
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
}

.voice-theme .hero {
    position: relative;
    padding-left: 28px;
}
.voice-theme .hero::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
}
.voice-theme .eyebrow {
    color: var(--accent-deep);
}
.voice-theme .brand-mark {
    background: var(--accent);
}

/* ================================================================
   THEME: audiobook-theme — 整本有声书（墨绿书卷）
   ================================================================ */
.audiobook-theme {
    --paper: #eef2ed;
    --card: #fbfcfa;
    --ink: #1e2520;
    --ink-soft: #48524b;
    --muted: #7b867e;
    --line: #dde4dc;
    --accent: #4a6b52;
    --accent-deep: #344c3a;
    --accent-soft: #dde8df;
    --ok: #4a6b52;
    --shadow: 0 30px 60px -42px rgba(45, 58, 44, .38);
}

.audiobook-theme .glow-a {
    background: rgba(74, 107, 82, .12);
}
.audiobook-theme .glow-b {
    background: rgba(110, 130, 100, .12);
}

.audiobook-theme .brand-mark {
    background: var(--accent);
}
.audiobook-theme .brand-mark::after {
    border-left-color: #f0f4ee;
}

.audiobook-theme .page-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--accent);
    color: #f0f4ee;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
}

.audiobook-theme .hero {
    padding: 64px 0 38px;
    max-width: 560px;
}
.audiobook-theme .eyebrow {
    color: var(--accent-deep);
    font-size: 10.5px;
    letter-spacing: .4em;
}
.audiobook-theme .hero h1 {
    font-family: var(--serif);
    font-size: clamp(36px, 4.8vw, 54px);
    letter-spacing: .02em;
    line-height: 1.25;
}
.audiobook-theme .hero h1 em::after {
    background: var(--accent-soft);
}
.audiobook-theme .lede {
    line-height: 2;
}

.audiobook-theme .card {
    border-radius: 16px;
}
.audiobook-theme .btn.primary {
    background: var(--accent);
}
.audiobook-theme .btn.primary:hover:not(:disabled) {
    background: var(--accent-deep);
}
.audiobook-theme .tag {
    background: var(--accent-soft);
    color: var(--accent-deep);
}
.audiobook-theme .dot-live {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(74, 107, 82, .18);
}

.audiobook-theme .book-drop-icon {
    background: var(--accent-soft);
    color: var(--accent-deep);
}
.audiobook-theme .book-drop:hover,
.audiobook-theme .book-drop.dragging {
    border-color: var(--accent);
    background: #f3f7f2;
}

/* ================================================================
   THEME: bookshelf-theme — 书架边看边听（赭石家居）
   ================================================================ */
.bookshelf-theme {
    --paper: #f3ede2;
    --card: #fcf9f3;
    --ink: #2a2219;
    --ink-soft: #5a4d3d;
    --muted: #8c7e6b;
    --line: #e2d7c4;
    --accent: #a0683a;
    --accent-deep: #7d4e28;
    --accent-soft: #efe0ce;
    --ok: #6b8a5a;
    --shadow: 0 30px 60px -42px rgba(90, 65, 35, .42);
}

.bookshelf-theme .glow-a {
    background: rgba(160, 104, 58, .14);
}
.bookshelf-theme .glow-b {
    background: rgba(140, 110, 70, .14);
}

.bookshelf-theme .brand-mark {
    background: var(--accent);
}
.bookshelf-theme .brand-mark::after {
    border-left-color: #fdf6eb;
}

.bookshelf-theme .page-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 99px;
    border: 1.5px solid var(--accent);
    color: var(--accent-deep);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .1em;
}

.bookshelf-theme .library-hero {
    position: relative;
    padding: 48px 0 36px;
    max-width: 620px;
}
.bookshelf-theme .library-hero::after {
    content: "📚";
    position: absolute;
    right: -10px;
    top: 40px;
    font-size: 64px;
    opacity: .18;
    line-height: 1;
    pointer-events: none;
}
.bookshelf-theme .eyebrow {
    color: var(--accent-deep);
}
.bookshelf-theme .library-hero h1 em::after {
    background: var(--accent-soft);
}

.bookshelf-theme .library-card {
    border-radius: 18px;
}
.bookshelf-theme .book-drop-icon {
    background: var(--accent-soft);
    color: var(--accent-deep);
}
.bookshelf-theme .book-drop:hover,
.bookshelf-theme .book-drop.dragging {
    border-color: var(--accent);
    background: #faf3e8;
}

.bookshelf-theme .btn.primary {
    background: var(--accent);
    color: #fdf6eb;
}
.bookshelf-theme .btn.primary:hover:not(:disabled) {
    background: var(--accent-deep);
}
.bookshelf-theme .tag {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.bookshelf-theme .card-head h2 {
    color: var(--accent-deep);
}

.bookshelf-theme .chapter-item {
    background: #faf6ee;
}

.bookshelf-theme .book-title-line h2 {
    color: var(--ink);
}
.bookshelf-theme .voice-option.selected {
    border-color: #d9b48c;
    background: #fdf5ea;
}

/* reader page 也共享 bookshelf-theme */
.bookshelf-theme .reader-title-line h2 {
    color: var(--ink);
}

/* 响应式：移动端隐藏装饰元素 */
@media (max-width: 900px) {
    .bookshelf-theme .library-hero::after {
        display: none;
    }
    .voice-theme .hero {
        padding-left: 18px;
    }
    .voice-theme .hero::before {
        left: 6px;
    }
}

/* ================================================================
   手机端响应式优化（≤ 560px）
   ================================================================ */

@media (max-width: 560px) {
    /* ----- 顶部导航 ----- */
    .topbar {
        padding: 16px 14px 0;
        gap: 8px;
    }
    .brand-mark {
        width: 22px;
        height: 22px;
        border-radius: 7px;
    }
    .brand-mark::after {
        left: 8px;
        top: 5px;
        border-left-width: 7px;
        border-top-width: 5px;
        border-bottom-width: 5px;
    }
    .brand-name {
        font-size: 14px;
        letter-spacing: .06em;
    }
    .brand-sub {
        display: none;
    }
    .topbar-actions {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
        max-width: 62%;
    }
    .topbar-actions .page-badge {
        display: none !important;
    }
    .topbar-actions .page-nav {
        font-size: 11px;
        padding: 4px 8px;
        border-radius: 99px;
        border: 1px solid var(--line);
        background: var(--card);
    }
    .topbar-actions .page-nav span {
        display: none;
    }

    /* ----- 主容器 ----- */
    .shell {
        padding: 0 14px;
    }

    /* ----- Hero 区域 ----- */
    .home-hero {
        padding: 36px 0 24px;
    }
    .home-hero h1 {
        font-size: clamp(32px, 9vw, 42px);
    }
    .lede {
        font-size: 14px;
        line-height: 1.8;
    }
    .eyebrow {
        font-size: 10px;
        letter-spacing: .28em;
    }

    /* ----- 首页 feature 卡片 ----- */
    .feature-grid {
        gap: 14px;
    }
    .feature-card {
        padding: 24px 20px 20px;
        gap: 14px;
        border-radius: 16px;
    }
    .feature-icon {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }
    .feature-icon svg {
        width: 22px;
        height: 22px;
    }
    .feature-body h2 {
        font-size: 19px;
    }
    .feature-body p {
        font-size: 13px;
        line-height: 1.8;
    }

    /* ----- 按钮触控区 ----- */
    .btn {
        min-height: 44px;
        padding: 11px 18px;
        font-size: 13.5px;
    }
    .btn.small {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 12.5px;
    }

    /* ----- 编辑器 ----- */
    textarea {
        min-height: 160px;
        font-size: 15px;
        line-height: 1.9;
    }

    /* ----- workspace ----- */
    .segment-list {
        max-height: none;
    }
    .segment {
        gap: 10px;
        padding: 10px 12px;
    }
    .segment p {
        font-size: 14px;
        line-height: 1.8;
    }
    .seg-index {
        width: 18px;
        font-size: 10px;
    }
    .seg-state {
        margin-left: 0;
    }
    .seg-head {
        gap: 5px;
    }
    .speaker, .emo {
        font-size: 10.5px;
        padding: 0 7px;
    }

    /* ----- 卡片 ----- */
    .card,
    .library-card,
    .chapters-card,
    .book-overview {
        border-radius: 16px;
    }

    /* ----- 底部播放器 ----- */
    .player {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
    .player-inner {
        gap: 10px;
        padding: 10px 12px;
        border-radius: 18px;
    }
    .play-toggle {
        width: 42px;
        height: 42px;
    }
    .play-toggle svg {
        width: 18px;
        height: 18px;
    }
    .player-main {
        min-width: 0;
    }
    .player-title {
        font-size: 13px;
        margin-bottom: 5px;
    }
    .player-sub {
        display: none;
    }
    .player-extra {
        gap: 6px;
        flex-shrink: 0;
    }
    .player-extra .btn {
        padding: 7px 10px;
        font-size: 11px;
    }
    .rate-select {
        font-size: 11px;
        padding: 6px 10px;
        padding-right: 18px;
    }

    /* ----- toast ----- */
    .toast {
        bottom: 72px;
        font-size: 12.5px;
        padding: 10px 16px;
    }

    /* ----- 有声书 setup ----- */
    .setup-section {
        padding: 18px 0;
    }
    .setup-heading h2 {
        font-size: 13.5px;
    }
    .setup-heading p {
        font-size: 11px;
    }
    .book-drop {
        min-height: 110px;
        padding: 18px 16px;
    }
    .book-drop strong {
        font-size: 13px;
    }
    .book-drop span {
        font-size: 11px;
    }
    .book-drop-icon {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }

    /* ----- 有声书声音选择 ----- */
    .voice-picker {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .voice-option {
        padding: 8px;
    }
    .voice-select b {
        font-size: 13px;
    }
    .voice-select small {
        font-size: 10px;
    }

    /* ----- 章节列表 ----- */
    .chapter-item {
        padding: 12px;
        gap: 10px;
        flex-wrap: wrap;
    }
    .chapter-index {
        width: 24px;
        font-size: 14px;
    }
    .chapter-head b {
        font-size: 13px;
    }
    .chapter-detail {
        font-size: 10.5px;
        flex-wrap: wrap;
    }

    /* ----- 角色列表 (voice.html) ----- */
    .avatar {
        width: 32px;
        height: 32px;
        border-radius: 11px;
        font-size: 15px;
    }
    .role-line b {
        font-size: 13px;
    }
    .role-gender {
        font-size: 10.5px;
    }
    .role-voice {
        font-size: 11px;
    }
    .footnote {
        font-size: 11px;
    }

    /* ----- 隐藏发光装饰（手机节省性能） ----- */
    .glow {
        display: none;
    }
}

/* 更小屏幕（< 380px，如 iPhone SE / Android 小屏） */
@media (max-width: 380px) {
    .topbar-actions {
        max-width: 55%;
    }
    .topbar-actions .page-nav {
        font-size: 10.5px;
        padding: 3px 6px;
    }
    .home-hero h1 {
        font-size: clamp(28px, 9vw, 36px);
    }
    .feature-card {
        padding: 20px 16px 16px;
    }
    .feature-body h2 {
        font-size: 17px;
    }
    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    .brand-name {
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------- 历史生成列表（配音 / 有声书） ---------- */

.history-card {
    padding: 22px 24px 18px;
    margin: 22px 0;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbf8f1;
}

.history-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.history-main b {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-meta {
    color: var(--muted);
    font-size: 11.5px;
}

.history-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    flex: none;
}

.history-empty {
    list-style: none;
    padding: 18px 0;
    color: var(--muted);
    font-size: 12.5px;
    text-align: center;
}

.btn.ghost.danger {
    color: #b03a2e;
    border-color: #e6c9c3;
}

.btn.ghost.danger:hover:not(:disabled) {
    background: #f9e7e3;
    border-color: #d9aca2;
    color: #8f2c22;
}

@media (max-width: 560px) {
    .history-card {
        padding: 16px 16px 12px;
    }
    .history-item {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    .history-actions {
        justify-content: flex-start;
    }
}
