* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #1a1a2e;
    color: #e0e0e0;
    font-family: 'Segoe UI', sans-serif;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    width: 100%;
    padding: 12px 20px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    z-index: 10;
}

header h1 { font-size: 1.1rem; color: #e94560; }

#sidebarToggle {
    background: none;
    border: 1px solid #0f3460;
    border-radius: 8px;
    color: #888;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}
#sidebarToggle:hover { border-color: #e94560; color: #e94560; }

.header-title {
    flex: 1;
    font-size: 0.9rem;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rpg-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #888;
    border: 1px solid #0f3460;
    border-radius: 10px;
    padding: 4px 10px;
    cursor: pointer;
    user-select: none;
}
.rpg-toggle input { accent-color: #e94560; }
.rpg-toggle:hover { border-color: #e94560; color: #e94560; }

.app-body { display: flex; flex: 1; overflow: hidden; }

.sidebar {
    width: 260px;
    background: #16213e;
    border-right: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease, opacity 0.25s ease;
    overflow: hidden;
}
.sidebar.collapsed { width: 0; opacity: 0; pointer-events: none; }

.sidebar-header {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #0f3460;
}
.sidebar-header span {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#newChatBtn {
    background: #e94560;
    border: none;
    border-radius: 8px;
    color: white;
    padding: 5px 12px;
    font-size: 0.8rem;
    cursor: pointer;
}
#newChatBtn:hover { background: #c73652; }

.session-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
}
.session-item:hover { background: #1a1a2e; }
.session-item.active { background: #1a1a2e; border-left-color: #e94560; }
.session-item .s-title { flex: 1; font-size: 0.82rem; color: #ccc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .s-companion { flex: 1; font-size: 0.72rem; color: #777; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .s-meta { font-size: 0.7rem; color: #555; }
.session-item .s-del { background: none; border: none; color: #555; cursor: pointer; opacity: 0; }
.session-item:hover .s-del { opacity: 1; }
.session-item .s-del:hover { color: #e94560; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.persona-bar {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    border-bottom: 1px solid #0f3460;
}

.system-blob {
    border-bottom: 1px solid #0f3460;
    background: #11162a;
    padding: 8px 16px;
}
.system-blob-header {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: space-between;
    color: #888;
    font-size: 0.8rem;
    margin-bottom: 6px;
}
.system-blob-header span { flex: 1; }
.system-blob-header button {
    background: transparent;
    border: 1px solid #0f3460;
    border-radius: 8px;
    color: #888;
    padding: 4px 10px;
    cursor: pointer;
}
.system-blob-header button:hover { border-color: #e94560; color: #e94560; }
#systemBlobRefresh { font-size: 1rem; padding: 2px 8px; }
#systemBlobRefresh.spinning { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.blob-changed { background: rgba(255, 200, 50, 0.15); border-radius: 3px; transition: background 2s ease; }
.blob-context-warn { color: #e9a045; }

.rp-dialogue { color: #e94560; }
.rp-action { font-style: italic; color: #a8a8b8; }

.rp-choice {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(155, 127, 212, 0.15);
    border: 1px solid rgba(155, 127, 212, 0.35);
}
.rp-choice-tag {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9b7fd4;
    font-weight: 600;
}
.rp-choice-label { color: #d4c8f0; }

.dice-user-override {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
}
.dice-user-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
    opacity: 0.9;
}
.dice-user-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    line-height: 1.45;
}
.dice-intent-struck {
    text-decoration: line-through;
    opacity: 0.55;
    color: #888;
}
.dice-intent-arrow { color: #9b7fd4; font-weight: bold; }
.dice-intent-resolved { color: #c8e6c9; font-style: italic; }
.message.user.has-dice-override .bubble { border-color: rgba(155, 127, 212, 0.4); }

.quest-panel-actions {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid #333;
}
.quest-panel-actions button {
    flex: 1;
    font-size: 0.75rem;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #444;
    background: #2a2a3e;
    color: #ccc;
    cursor: pointer;
}
.quest-panel-actions button:hover:not(:disabled) { background: #3a3a52; }
.quest-panel-actions button:disabled { opacity: 0.4; cursor: default; }
.quest-panel-actions .quest-btn-done:hover:not(:disabled) { border-color: #2ecc71; color: #2ecc71; }
.quest-panel-actions .quest-btn-fail:hover:not(:disabled) { border-color: #e74c3c; color: #e74c3c; }

.format-btn {
    margin-top: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    border: 1px solid #444;
    border-radius: 4px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    align-self: flex-start;
}
.format-btn:hover { background: #4a90d9; color: white; border-color: #4a90d9; }
.system-blob-content {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
    color: #aaa;
    max-height: 140px;
    overflow: auto;
    margin: 0;
}

.persona-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}
.persona-card:hover { border-color: #e94560; }
.persona-card.active { border-color: #e94560; background: #1f1535; }
.persona-card .emoji { font-size: 1.2rem; }
.persona-card .pname { font-size: 0.7rem; color: #ccc; }
.persona-card .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #0f3460;
}
.persona-card .del-btn {
    position: absolute; top: -5px; right: -5px;
    width: 14px; height: 14px;
    background: #e94560; border: none; border-radius: 50%;
    color: white; font-size: 0.55rem; cursor: pointer;
    display: none;
}
.persona-card .edit-btn {
    position: absolute; top: -5px; left: -5px;
    width: 16px; height: 16px;
    background: #0f3460; border: 1px solid #e94560; border-radius: 50%;
    color: white; font-size: 0.55rem; cursor: pointer;
    display: none; align-items: center; justify-content: center;
}
.persona-card:hover .del-btn { display: flex; align-items: center; justify-content: center; }
.persona-card:hover .edit-btn { display: flex; }

.persona-add, .card-import-btn {
    display: flex; flex-direction: column; align-items: center;
    padding: 6px 12px;
    background: transparent;
    border: 1px dashed #0f3460; border-radius: 10px;
    cursor: pointer; color: #555; font-size: 0.7rem;
    flex-shrink: 0;
}
.persona-add:hover, .card-import-btn:hover { border-color: #e94560; color: #e94560; }

.messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.message { display: flex; flex-direction: column; max-width: 75%; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.bubble {
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.bubble.typing-active::after { content: '▋'; animation: blink 0.7s infinite; color: #e94560; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.message.user .bubble { background: #0f3460; border-bottom-right-radius: 4px; }
.message.assistant .bubble { background: #16213e; border: 1px solid #0f3460; border-bottom-left-radius: 4px; }

.label { font-size: 0.7rem; color: #888; margin-bottom: 4px; padding: 0 4px; }
.message.user .label { text-align: right; }

.image-prompt-block {
    margin-top: 8px; padding: 8px 12px;
    background: #1a1a2e;
    border: 1px dashed #e94560;
    border-radius: 8px;
    font-size: 0.8rem; color: #e94560;
}
.image-prompt-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.image-prompt-block .prompt-text { display: block; color: #aaa; margin-top: 4px; font-style: italic; white-space: pre-wrap; }

.copy-prompt-btn, .gen-image-btn {
    background: #0f3460;
    border: 1px solid #e94560;
    border-radius: 6px;
    color: #e94560;
    font-size: 0.7rem;
    padding: 2px 8px;
    cursor: pointer;
}
.copy-prompt-btn:hover, .gen-image-btn:hover { background: #e94560; color: white; }

.translate-btn {
    align-self: flex-end;
    background: #0f3460;
    border: 1px solid #4a90d9;
    border-radius: 6px;
    color: #4a90d9;
    font-size: 0.7rem;
    padding: 2px 8px;
    cursor: pointer;
    margin-top: 4px;
}
.translate-btn:hover { background: #4a90d9; color: white; }
.translate-btn:disabled { opacity: 0.5; cursor: default; }

.chat-image-wrap { margin-top: 8px; }
.chat-image-label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.chat-image { max-width: 100%; border-radius: 8px; border: 1px solid #0f3460; display: block; }
.image-prompt-blocks .image-prompt-block + .image-prompt-block { margin-top: 8px; }

.image-generating {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px dashed #533483;
    background: rgba(15, 52, 96, 0.45);
    color: #bbb;
    font-size: 0.9em;
}
.image-generating-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #0f3460;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: image-spin 0.75s linear infinite;
    flex-shrink: 0;
}
@keyframes image-spin { to { transform: rotate(360deg); } }

.gen-image-btn:disabled { opacity: 0.6; cursor: wait; }
.image-error { margin-top: 6px; font-size: 0.75rem; color: #888; }

.choice-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}
.choice-section-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.choice-section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #c9a227;
    margin-bottom: 4px;
}
.choice-section-label-generic {
    color: #888;
}
.choice-section-plot {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(201, 162, 39, 0.45);
    background: rgba(201, 162, 39, 0.08);
}
.choice-beat-teaser {
    font-size: 0.75rem;
    color: #b8a888;
    font-style: italic;
    line-height: 1.35;
    margin-bottom: 6px;
    white-space: pre-wrap;
}
.choice-btn {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 10px;
    color: #ccc;
    font-size: 0.8rem;
    padding: 6px 10px;
    cursor: pointer;
}
.choice-btn-plot {
    border-color: rgba(201, 162, 39, 0.55);
    background: rgba(201, 162, 39, 0.12);
    color: #e8d5a3;
}
.choice-btn:hover {
    border-color: #e94560;
    color: #e94560;
}
.choice-btn-plot:hover {
    border-color: #c9a227;
    color: #f0e0b0;
    background: rgba(201, 162, 39, 0.2);
}

.choice-row-new-arc {
    margin-top: 12px;
}
.new-arc-roll {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(233, 69, 96, 0.45);
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.12), rgba(201, 162, 39, 0.1));
}
.new-arc-roll-header {
    font-size: 1rem;
    font-weight: 600;
    color: #f5d0d8;
    margin-bottom: 6px;
}
.new-arc-roll-hint {
    font-size: 0.78rem;
    color: #b8b0c8;
    line-height: 1.4;
    margin-bottom: 12px;
}
.new-arc-roll-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(15, 52, 96, 0.9);
}
.new-arc-half {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 72px;
    padding: 12px 10px;
    border: none;
    background: #16213e;
    color: #ddd;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.new-arc-half-user {
    border-right: 1px solid rgba(15, 52, 96, 0.9);
}
.new-arc-half:hover {
    background: rgba(233, 69, 96, 0.22);
    color: #fff;
}
.new-arc-half-icon {
    font-size: 1.25rem;
    line-height: 1;
}
.new-arc-half-title {
    font-size: 0.92rem;
    font-weight: 600;
}
.new-arc-half-sub {
    font-size: 0.72rem;
    color: #9aa3b8;
}
.new-arc-half:hover .new-arc-half-sub {
    color: #e8edf7;
}


.typing {
    align-self: flex-start;
    display: flex; gap: 4px;
    padding: 12px 16px;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 16px;
}
.typing span { width: 6px; height: 6px; background: #888; border-radius: 50%; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.input-area {
    display: flex; gap: 10px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid #0f3460;
}

textarea {
    flex: 1;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    color: #e0e0e0;
    font-size: 0.95rem;
    padding: 10px 14px;
    resize: none; outline: none;
    font-family: inherit;
    max-height: 120px;
}
textarea:focus { border-color: #e94560; }

#sendBtn {
    background: #e94560; border: none;
    border-radius: 12px; color: white;
    padding: 0 20px; cursor: pointer;
}
#sendBtn:disabled { background: #555; cursor: not-allowed; }

#clearBtn {
    background: transparent;
    border: 1px solid #0f3460;
    border-radius: 12px; color: #888;
    padding: 0 14px; cursor: pointer;
}
#clearBtn:hover { border-color: #e94560; color: #e94560; }

.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100; align-items: center; justify-content: center;
    padding: 16px;
    overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
    background: #16213e; border: 1px solid #0f3460;
    border-radius: 16px; padding: 24px;
    width: 100%; max-width: 440px;
    max-height: calc(100vh - 32px);
    display: flex; flex-direction: column; gap: 12px;
    margin: auto;
}
.modal-wizard { max-width: 480px; }
.modal-wizard-header { flex-shrink: 0; }
.modal-wizard-header h2 { margin-bottom: 8px; }
.modal-wizard-body {
    flex: 1; min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}
.modal-wizard-footer {
    flex-shrink: 0;
    margin-top: 4px;
}
.wizard-steps {
    display: flex; align-items: center; justify-content: center;
    gap: 0; margin-bottom: 4px;
}
.wizard-step-dot {
    width: 28px; height: 28px; border-radius: 50%;
    background: #1a1a2e; border: 1px solid #0f3460;
    color: #666; font-size: 0.75rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.wizard-step-dot.active { border-color: #e94560; color: #e94560; background: #1f0a14; }
.wizard-step-dot.done { border-color: #9b7fd4; color: #9b7fd4; }
.wizard-step-line { width: 40px; height: 1px; background: #0f3460; }
.wizard-page { display: none; flex-direction: column; gap: 12px; }
.wizard-page.active { display: flex; }
.wizard-page-title { font-size: 0.85rem; color: #9b7fd4; margin: 0 0 4px; }
.wizard-hint { font-size: 0.8rem; color: #666; margin: -4px 0 4px; }
.selected-genres-label { font-size: 0.8rem; color: #e94560; margin-top: 4px; }
.wizard-nav { display: flex; gap: 8px; }
.wizard-nav-btn {
    padding: 8px 18px; border-radius: 8px; border: none; cursor: pointer;
    background: #0f3460; color: #ccc;
}
.wizard-nav-btn:hover { color: #e0e0e0; }
.wizard-nav-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.modal h2 { font-size: 1.1rem; color: #e94560; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: #888; }
.modal input, .modal textarea, .modal select {
    background: #1a1a2e; border: 1px solid #0f3460;
    border-radius: 8px; color: #e0e0e0;
    padding: 8px 10px; outline: none; font-family: inherit;
}
.modal select { cursor: pointer; }
.modal select[size] { min-height: 80px; }
.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.modal-wizard-footer { justify-content: space-between; align-items: center; }
.modal-buttons button { padding: 8px 18px; border-radius: 8px; border: none; cursor: pointer; }
#modalCancel, #cardModalCancel { background: #0f3460; color: #aaa; }
#modalSave, #cardModalImport { background: #e94560; color: white; }

.empty-state {
    flex: 1; display: flex;
    align-items: center; justify-content: center;
    color: #444; flex-direction: column; gap: 8px;
}
.empty-state .big { font-size: 2.5rem; }
.hidden { display: none !important; }

/* Narrator message bubble */
.message.narrator { align-self: center; max-width: 80%; }
.message.narrator .label { color: #9b7fd4; font-size: 0.75rem; margin-bottom: 4px; }
.message.narrator .bubble {
    background: #1a1230;
    border: 1px solid #4a2d8a;
    border-left: 3px solid #9b7fd4;
    border-radius: 12px;
    padding: 10px 14px;
    color: #ccc;
    font-size: 0.9rem;
}

/* Dice block inside narrator bubble */
.dice-block {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #0f0a1e;
    font-size: 0.8rem;
    width: fit-content;
}
.dice-icon { font-size: 1.1rem; }
.dice-roll { font-size: 1.3rem; font-weight: bold; }
.dice-outcome { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.outcome-crit-fail { border: 1px solid #c0392b; }
.outcome-crit-fail .dice-roll { color: #e74c3c; }
.outcome-crit-fail .dice-outcome { color: #e74c3c; }
.outcome-fail { border: 1px solid #555; }
.outcome-fail .dice-roll { color: #aaa; }
.outcome-fail .dice-outcome { color: #888; }
.outcome-success { border: 1px solid #27ae60; }
.outcome-success .dice-roll { color: #2ecc71; }
.outcome-success .dice-outcome { color: #2ecc71; }
.outcome-crit-success { border: 1px solid #f39c12; }
.outcome-crit-success .dice-roll { color: #f1c40f; }
.outcome-crit-success .dice-outcome { color: #f1c40f; }
.narrator-text { white-space: pre-wrap; line-height: 1.5; }

.narrator-activity-hint {
    margin-top: 6px;
    font-size: 0.72rem;
    color: #9b7fd4;
    opacity: 0.9;
    line-height: 1.35;
}

/* Affinity display in header */
.affinity-display {
    font-size: 0.8rem; padding: 4px 10px;
    border: 1px solid #0f3460; border-radius: 10px;
    color: #aaa; white-space: nowrap;
}
.affinity-display.affinity-high { border-color: #e94560; color: #e94560; }
.affinity-display.affinity-low { border-color: #555; color: #666; }

.stats-display {
    font-size: 0.72rem;
    padding: 4px 8px;
    border: 1px solid #0f3460;
    border-radius: 10px;
    color: #9b9bb8;
    white-space: nowrap;
}
.stats-display.stats-warn { border-color: #e9a045; color: #e9a045; }
.stats-display.stats-critical { border-color: #e74c3c; color: #e74c3c; }

.rpg-debug-panel {
    margin-top: 12px;
    padding: 10px;
    border: 1px dashed #3a3a52;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
}
.rpg-debug-panel summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: #9b7fd4;
}
.rpg-debug-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 10px 0;
}
.rpg-debug-grid label {
    font-size: 0.78rem;
    color: #aaa;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rpg-debug-grid input {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    color: #e0e0e0;
    padding: 6px 8px;
}
.rpg-debug-apply {
    background: #3a3a52;
    border: 1px solid #9b7fd4;
    border-radius: 8px;
    color: #e0e0e0;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.8rem;
}
.rpg-debug-apply:hover { background: #4a4a62; }
.rpg-debug-status {
    margin-left: 8px;
    font-size: 0.75rem;
    color: #2ecc71;
}

.context-editor-modal { max-width: 640px; }
.context-editor-body label {
    display: block;
    font-size: 0.78rem;
    color: #aaa;
    margin-bottom: 10px;
}
.context-editor-body textarea,
.context-editor-body input[type="number"] {
    width: 100%;
    margin-top: 4px;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    color: #e0e0e0;
    padding: 8px 10px;
    font-family: Consolas, 'Segoe UI', monospace;
    font-size: 0.78rem;
    resize: vertical;
}
.context-editor-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
#contextEditorOpen {
    background: transparent;
    border: 1px solid #0f3460;
    border-radius: 8px;
    color: #888;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.9rem;
}
#contextEditorOpen:hover { border-color: #9b7fd4; color: #9b7fd4; }

/* Quest panel in sidebar */
.quest-panel {
    border-top: 1px solid #0f3460;
    padding: 10px 14px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: min(42vh, 280px);
    min-height: 0;
}
#questList {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.quest-panel-header {
    font-size: 0.75rem; color: #888;
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.quest-panel-arc-header {
    font-size: 0.72rem;
    color: #c9a227;
    margin-bottom: 6px;
    line-height: 1.35;
}
.quest-panel-arc-header.hidden { display: none; }
.quest-panel-hint {
    font-size: 0.68rem;
    color: #555;
    margin: 0 0 6px;
    line-height: 1.3;
}
.quest-item {
    font-size: 0.8rem; padding: 4px 6px;
    color: #bbb; line-height: 1.4;
    border-bottom: 1px solid #0f3460;
    cursor: pointer;
    user-select: none;
}
.quest-item.quest-selected {
    background: rgba(233, 69, 96, 0.12);
    border-radius: 4px;
}
.quest-item:last-child { border-bottom: none; }
.quest-done { color: #555; text-decoration: line-through; }
.quest-failed { color: #c0392b; }

/* Genre modal grid */
.genre-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin: 4px 0;
}
.genre-btn {
    background: #1a1a2e; border: 1px solid #0f3460;
    border-radius: 8px; color: #ccc;
    padding: 10px 8px; cursor: pointer;
    font-size: 0.85rem; text-align: center;
    transition: all 0.15s;
}
.genre-btn:hover { border-color: #9b7fd4; color: #e0e0e0; }
.genre-btn.selected { border-color: #e94560; color: #e94560; background: #1f0a14; }

/* RPG settings checkboxes */
.rpg-settings-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px; margin: 4px 0;
}
.rpg-settings-grid label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.8rem; color: #aaa; cursor: pointer;
    flex-direction: row;
}
.rpg-settings-grid input[type=checkbox] { accent-color: #e94560; }

.header-icon-btn {
    background: transparent; border: 1px solid #0f3460;
    border-radius: 10px; color: #aaa; padding: 4px 10px;
    cursor: pointer; font-size: 1rem;
}
.header-icon-btn:hover { border-color: #e94560; color: #e94560; }
.rpg-badge {
    font-size: 0.7rem; padding: 3px 8px;
    border: 1px solid #9b7fd4; border-radius: 8px;
    color: #9b7fd4; text-transform: uppercase;
    letter-spacing: 0.05em;
}
.persona-pick-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}
.persona-pick-card {
    background: #1a1a2e; border: 1px solid #0f3460;
    border-radius: 10px; padding: 10px 8px;
    cursor: pointer; text-align: center;
    font-size: 0.8rem; color: #ccc;
    transition: all 0.15s;
}
.persona-pick-card:hover { border-color: #9b7fd4; }
.persona-pick-card.selected { border-color: #e94560; color: #e94560; background: #1f0a14; }
.persona-pick-card .emoji { font-size: 1.5rem; display: block; margin-bottom: 4px; }
.rpg-mode-option {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.9rem; color: #ccc; cursor: pointer;
    flex-direction: row !important;
    padding: 8px 0;
}
.hint-text {
    font-size: 0.8rem;
    color: #888;
    margin: 0 0 8px;
}
.chat-settings-meta {
    margin-top: 12px; padding: 10px;
    background: #1a1a2e; border-radius: 8px;
    font-size: 0.8rem; color: #888; line-height: 1.5;
}
.session-item .s-preview {
    font-size: 0.75rem; color: #666;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px;
}
.session-item .s-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.session-item .s-badge {
    font-size: 0.65rem; padding: 1px 5px;
    border: 1px solid #9b7fd4; border-radius: 4px;
    color: #9b7fd4;
}
.session-item .s-date { font-size: 0.7rem; color: #555; margin-left: auto; }
.session-item .s-title[contenteditable] {
    outline: none; border-bottom: 1px dashed #e94560;
}
.message-actions {
    display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap;
    position: relative;
    z-index: 2;
}
.message-actions button {
    background: #0f3460; border: none; border-radius: 6px;
    color: #aaa; font-size: 0.7rem; padding: 3px 8px; cursor: pointer;
}
.message-actions button:hover { color: #e94560; }
.message .bubble-edit {
    width: 100%; min-height: 60px;
    background: #1a1a2e; border: 1px solid #e94560;
    border-radius: 8px; color: #e0e0e0; padding: 8px;
    font-family: inherit; resize: vertical;
}
