/* ═══════════════════════════════════════════════
   AI Story Time — Dark Fantasy Theme
   ═══════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────── */
:root {
    --bg-primary: #0d0f14;
    --bg-secondary: #161922;
    --bg-card: #1a1e2a;
    --bg-card-hover: #202638;
    --bg-input: #12151d;
    --border: #2a2f42;
    --border-focus: #6c5ce7;

    --text-primary: #e2e0f0;
    --text-secondary: #9994b8;
    --text-muted: #6b6588;
    --text-heading: #f0ecff;

    --accent: #6c5ce7;
    --accent-hover: #7f71f0;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --success: #00b894;
    --danger: #e84545;
    --danger-hover: #f05555;
    --warning: #fdcb6e;

    --font-body: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-heading: 'Roboto', Georgia, 'Times New Roman', serif;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    --transition: 0.2s ease;

    --nav-height: 56px;
    --max-width: 960px;
}

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--text-heading);
    line-height: 1.3;
}

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

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    display: block;
}

/* ── Utility ────────────────────────────────── */
.hidden { display: none !important; }

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ── Navigation ─────────────────────────────── */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    backdrop-filter: blur(12px);
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--text-heading);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

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

.nav-logo {
    font-size: 1.3rem;
}

.nav-links {
    display: flex;
    align-items: center;
}

.nav-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-link {
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-nav {
    background: var(--accent);
    color: #fff !important;
    font-weight: 600;
}

.btn-nav:hover {
    background: var(--accent-hover);
}

.nav-credits {
    color: var(--warning);
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
    background: rgba(253, 203, 110, 0.1);
    border-radius: var(--radius);
    font-weight: 600;
}

/* ── Main Content ───────────────────────────── */
.main-content {
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
    padding: 2rem 0;
}

/* ── Loading Spinner ────────────────────────── */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.loading-spinner::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.6rem;
}

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

/* ── Buttons ────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

/* ── Forms ──────────────────────────────────── */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.form-error {
    background: rgba(232, 69, 69, 0.1);
    border: 1px solid rgba(232, 69, 69, 0.3);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    color: var(--danger);
    font-size: 0.85rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Auth Pages ─────────────────────────────── */
.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-height) - 4rem);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Home / Hero ────────────────────────────── */
.page-home {
    padding: 3rem 0;
}

.hero {
    text-align: center;
    padding: 3rem 0 4rem;
}

.hero h1 {
    font-size: 2.8rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--accent), #a29bfe, var(--warning));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition);
}

.feature-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.feature-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Dashboard ──────────────────────────────── */
.page-dashboard {
    padding: 1.5rem 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.6rem;
}

.story-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.story-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: all var(--transition);
    cursor: pointer;
}

.story-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.story-card-info {
    flex: 1;
    min-width: 0;
}

.story-card-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-heading);
    margin-bottom: 0.3rem;
}

.story-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.story-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.story-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.story-empty p {
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-active { background: rgba(0, 184, 148, 0.15); color: var(--success); }
.badge-draft { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.badge-complete { background: rgba(108, 92, 231, 0.15); color: var(--accent); }
.badge-nsfw { background: rgba(232, 69, 69, 0.15); color: var(--danger); }

/* ── Story Play ─────────────────────────────── */
.page-story {
    padding: 1.5rem 0;
    max-width: 720px;
    margin: 0 auto;
}

.story-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.story-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.story-header-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.story-pages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.story-page {
    position: relative;
    padding-left: 2rem;
}

.story-page::before {
    content: attr(data-page);
    position: absolute;
    left: 0;
    top: 0.1rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    width: 1.4rem;
    text-align: center;
}

.story-page-content {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.story-page-content p {
    margin-bottom: 0.75rem;
}

.story-page-content p:last-child {
    margin-bottom: 0;
}

.story-page-choice {
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 0.5rem;
    font-style: italic;
}

.story-page.clickable {
    cursor: pointer;
    border-radius: var(--radius);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-right: 0.5rem;
    margin-left: -0.5rem;
    padding-left: 2.5rem;
    transition: background var(--transition);
}

.story-page.clickable:hover {
    background: rgba(108, 92, 231, 0.05);
}

/* Choices */
.story-choices {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.story-choices h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-family: var(--font-body);
    font-weight: 600;
}

.choice-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.choice-row {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}

.choice-row .choice-btn {
    flex: 1;
}

.btn-edit-choice {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 0.6rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-edit-choice:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    color: var(--accent);
}

.choice-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    line-height: 1.5;
}

.choice-btn:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.choice-btn .choice-label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.2rem;
}

.choice-btn .choice-summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.story-page-number {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.story-page-choice-made {
    font-size: 0.85rem;
    color: var(--accent);
    font-style: italic;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(108, 92, 231, 0.08);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
}

/* Page navigation */
.page-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Custom continuation */
.custom-continuation {
    margin-top: 1rem;
}

.custom-continuation textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-primary);
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition);
}

.custom-continuation textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.custom-continuation .btn {
    margin-top: 0.5rem;
}

/* Story actions bar */
.story-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Generating indicator */
.generating {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.generating::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Story Create ───────────────────────────── */
.page-story-create {
    max-width: 640px;
    margin: 0 auto;
    padding: 1.5rem 0;
}

.page-story-create h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.character-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.character-entry {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    position: relative;
}

.character-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius);
    transition: color var(--transition);
}

.character-remove:hover {
    color: var(--danger);
}

/* ── Profile ────────────────────────────────── */
.page-profile {
    max-width: 640px;
    margin: 0 auto;
    padding: 1.5rem 0;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-muted);
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info h1 {
    font-size: 1.4rem;
    margin-bottom: 0.15rem;
}

.profile-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Toast Notification ─────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 200;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 360px;
}

.toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: var(--success);
    color: #fff;
}

.toast-error {
    background: var(--danger);
    color: #fff;
}

.toast-info {
    background: var(--accent);
    color: #fff;
}

/* ── Confirm Dialog ─────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    margin-bottom: 0.75rem;
}

.modal p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ── Pagination ────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Credit History ────────────────────────── */
.page-credits {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem 0;
}

.credit-table {
    overflow-x: auto;
}

.credit-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.credit-table th,
.credit-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.credit-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.credit-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.credit-positive {
    color: var(--success);
    font-weight: 600;
}

.credit-negative {
    color: var(--danger);
    font-weight: 600;
}

/* ── NSFW Age Gate ─────────────────────────── */
.nsfw-gate {
    text-align: center;
    padding: 4rem 1rem;
    max-width: 480px;
    margin: 0 auto;
}

.nsfw-gate-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(232, 69, 69, 0.15);
    color: var(--danger);
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 1.25rem;
}

.nsfw-gate h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.nsfw-gate p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.nsfw-gate-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ── Rollback danger button ───────────────── */
.btn-danger-outline {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

.btn-danger-outline:hover:not(:disabled) {
    background: rgba(232, 69, 69, 0.1);
}

/* ── AI Prefill Section ──────────────────── */
.ai-prefill {
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: rgba(212, 175, 55, 0.04);
}

.ai-prefill-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.ai-prefill-icon {
    font-size: 1.1rem;
}

.ai-prefill-cost {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
    background: var(--bg-card);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.ai-prefill-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.ai-prefill textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 0.6rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.5rem;
    box-sizing: border-box;
}

.ai-prefill textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── Collapsible Panels ───────────────────── */
.collapsible-panel {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    background: var(--bg-card);
    border: none;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.panel-toggle:hover {
    background: var(--bg-card-hover);
}

.panel-arrow {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.panel-body {
    padding: 0.75rem 1rem 1rem;
    background: var(--bg-main);
}

/* ── Character Cards ─────────────────────── */
.char-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
}

.char-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.char-card-header strong {
    font-size: 0.92rem;
}

.char-role {
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(212, 175, 55, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.char-detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.15rem;
}

.char-detail em {
    color: var(--text-muted);
    font-style: normal;
    font-weight: 600;
    font-size: 0.78rem;
}

.char-card-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.char-card-edit {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.input-sm {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    font-family: var(--font-body);
    width: 100%;
    box-sizing: border-box;
}

.input-sm:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-xs {
    padding: 0.2rem 0.5rem !important;
    font-size: 0.75rem !important;
}

/* ── Settings Panel ──────────────────────── */
.settings-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    margin-bottom: 0.2rem;
}

.settings-label:first-child {
    margin-top: 0;
}

.settings-textarea {
    min-height: 60px;
    resize: vertical;
}

/* ── Story Images ─────────────────────────── */
.story-image-container {
    text-align: center;
    margin: 1rem 0;
}

.story-image {
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.btn-generate-image {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.cost-badge {
    font-size: 0.7rem;
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.btn-regen-image {
    margin-top: 0.4rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-regen-image:hover {
    opacity: 1;
}

.character-portrait {
    width: 72px;
    height: 96px;
    border-radius: var(--radius);
    object-fit: cover;
    float: right;
    margin: 0 0 0.5rem 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── Transitions & Animations ─────────────── */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-page {
    animation: fadeSlideIn 0.35s ease-out;
}

.story-choices {
    animation: fadeSlideIn 0.4s ease-out 0.1s both;
}

.page-nav {
    animation: fadeSlideIn 0.3s ease-out;
}

.generating {
    animation: fadeSlideIn 0.3s ease-out;
}

.nsfw-gate {
    animation: fadeSlideIn 0.4s ease-out;
}

/* ── Public Story View ─────────────────────── */
.public-story-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.public-story-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.public-story-header .story-card-meta {
    justify-content: center;
}

.public-story-cta {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 2rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: rgba(212, 175, 55, 0.04);
    animation: fadeSlideIn 0.4s ease-out;
}

.public-story-cta h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.public-story-cta p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.public-story-cta-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 640px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero-sub {
        font-size: 0.95rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .nav-inner {
        padding: 0 0.75rem;
    }

    .nav-group {
        gap: 0.1rem;
    }

    .nav-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.82rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .story-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .story-card-actions {
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
