:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #eef2ff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d7deeb;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --danger: #dc2626;
    --success: #059669;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1120px, calc(100vw - 32px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
}

.brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.hero,
.panel,
.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.hero {
    margin: 32px 0;
    padding: 48px;
}

.hero__content {
    max-width: 760px;
}

.eyebrow {
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.15;
}

.hero__text,
.section-desc,
.auth-card__intro,
.auth-card__footnote,
.status-text,
.story-card p,
.story-content,
.empty-state {
    color: var(--muted);
}

.hero__actions,
.social-buttons,
.story-card__actions,
.reader-toolbar,
.editor-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
}

.button:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.button--secondary {
    background: var(--surface-alt);
    color: var(--primary);
    border-color: #c7d2fe;
}

.button--secondary:hover {
    background: #e0e7ff;
}

.panel,
.auth-card {
    margin: 24px 0;
    padding: 24px;
}

.panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.panel__header h1,
.panel__header h2,
.auth-card h1 {
    margin: 0 0 6px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.story-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    border-radius: 16px;
    background: linear-gradient(180deg, #fff, #f8faff);
    border: 1px solid var(--line);
}

.story-card h2,
.story-card h3 {
    margin: 0;
}

.story-card__meta {
    font-size: 0.9rem;
    color: var(--muted);
}

.auth-card {
    width: min(540px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.stack-form {
    display: grid;
    gap: 16px;
}

.stack-form__field {
    display: grid;
    gap: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    font: inherit;
    color: var(--text);
}

.form-control:focus {
    outline: 2px solid rgba(79, 70, 229, 0.18);
    border-color: var(--primary);
}

textarea.form-control {
    resize: vertical;
}

.auth-divider {
    margin: 20px 0 12px;
    text-align: center;
    color: var(--muted);
}

.flash-list {
    list-style: none;
    padding: 0;
    margin: 24px 0 0;
}

.flash {
    margin: 0 0 10px;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.flash--success {
    color: var(--success);
    border-color: rgba(5, 150, 105, 0.25);
    background: rgba(5, 150, 105, 0.08);
}

.flash--error {
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.25);
    background: rgba(220, 38, 38, 0.08);
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    margin: 24px 0 40px;
}

.panel--narrow {
    align-self: start;
}

.story-editor__textarea {
    min-height: 420px;
}

.story-detail audio {
    width: 100%;
    margin: 10px 0 24px;
}

.tts-provider-picker,
.tts-provider-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.tts-provider-picker__label {
    font-weight: 600;
}

.tts-provider-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
}

.tts-provider-option:has(input:disabled) {
    opacity: 0.55;
}

.tts-provider-meta {
    margin-top: 12px;
    margin-bottom: 8px;
}

.tts-provider-meta .status-text {
    margin: 0;
}

.story-content {
    font-size: 1.05rem;
    white-space: pre-wrap;
    line-height: 1.8;
    cursor: text;
}

.empty-state {
    display: grid;
    gap: 12px;
    justify-items: start;
    padding: 8px 0;
}

ul.errorlist {
    margin: 0;
    padding-left: 18px;
    color: var(--danger);
}

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

    .hero {
        padding: 32px 24px;
    }

    .panel__header,
    .site-header__inner {
        flex-direction: column;
        align-items: flex-start;
    }
}
