/* Component CSS - Reusable UI Components */

/* ===== HEADER COMPONENT ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.app-header h1 {
    font-size: 18px;
    color: var(--text-bright);
    margin: 0;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Credits display in header */
.credits-display {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    border-radius: 4px;
    text-decoration: none;
    color: var(--accent-color);
    font-size: 13px;
    font-family: var(--font-mono);
    transition: all var(--transition-normal);
}

.credits-display:hover {
    background: rgba(var(--accent-rgb), 0.2);
    border-color: var(--accent-color);
}

.credits-display .credits-icon {
    font-size: 14px;
}

.credits-display .credits-value {
    font-weight: 600;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.home-btn {
    text-decoration: none;
    font-size: 18px;
    opacity: 0.7;
    transition: opacity var(--transition-normal);
}

.home-btn:hover { 
    opacity: 1; 
}

/* ===== CHAT/MESSAGE COMPONENTS ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    min-height: 0;
}

/* Message styles - shared between game and session zero */
.message {
    margin-bottom: var(--spacing-md);
    animation: fadeIn var(--transition-slow);
}

/* ===== MARKDOWN FORMATTING ===== */

/* Headers in markdown content */
.md-header {
    color: var(--accent-color);
    margin: 0.8em 0 0.4em 0;
    font-family: var(--font-interface);
    letter-spacing: 0.05em;
}

h3.md-header { font-size: 1.1em; }
h4.md-header { font-size: 1em; }
h5.md-header { font-size: 0.95em; }

/* Inline code */
.md-code {
    background: rgba(255, 191, 0, 0.15);
    color: var(--accent-color);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-family: var(--font-interface);
    font-size: 0.9em;
}

/* Blockquotes */
.md-quote {
    border-left: 2px solid var(--accent-color);
    margin: 0.5em 0;
    padding: 0.3em 0 0.3em 1em;
    color: var(--text-dim);
    font-style: italic;
}

/* Lists */
.md-list {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.md-list li {
    margin: 0.25em 0;
    line-height: 1.5;
}

/* Unordered list bullets */
ul.md-list {
    list-style-type: none;
}

ul.md-list li::before {
    content: "›";
    color: var(--accent-color);
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

/* Ordered list numbers */
ol.md-list {
    list-style-type: decimal;
}

ol.md-list li::marker {
    color: var(--accent-color);
}

/* Horizontal rule */
.md-hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1em 0;
}

/* Bold and italic styling (already handled by strong/em but ensure colors) */
.message strong,
.message-bubble strong,
.script-message strong {
    color: var(--accent-color);
    font-weight: 600;
}

.message em,
.message-bubble em,
.script-message em {
    color: rgba(255, 191, 0, 0.8);
    font-style: italic;
}

/* Game-style messages (left-aligned with border) */
.message.game-style {
    padding: 10px 12px;
    border-left: 3px solid transparent;
}

.message.game-style.user {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    background: rgba(0, 255, 255, 0.05);
}

.message.game-style.dm {
    color: var(--text-color);
    line-height: 1.7;
}

.message.game-style.tool {
    color: var(--text-dim);
    font-size: 13px;
    border-left-color: var(--warning-color);
    background: rgba(255, 170, 0, 0.05);
}

.message.game-style.thinking {
    color: var(--text-dim);
    font-size: 12px;
    font-style: italic;
    opacity: 0.7;
}

/* Chat-style messages (bubbles with avatars) */
.message.chat-style {
    display: flex;
    gap: 12px;
}

.message.chat-style.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.chat-style.user .message-avatar {
    background: var(--accent-color);
    color: var(--bg-color);
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    line-height: 1.5;
}

.message.chat-style.user .message-bubble {
    background: rgba(0, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.message.chat-style.system .message-bubble {
    background: rgba(0, 255, 0, 0.1);
    border-color: var(--text-color);
    font-style: italic;
}

.message.chat-style.thinking .message-bubble {
    background: rgba(255, 170, 0, 0.1);
    border-color: var(--warning-color);
    font-size: 13px;
    font-style: italic;
    opacity: 0.8;
}

.message.chat-style.tool .message-bubble {
    background: rgba(0, 255, 255, 0.05);
    border-color: var(--accent-color);
    font-size: 13px;
    opacity: 0.8;
}

/* Message tags */
.msg-prompt { 
    color: var(--accent-color); 
    margin-right: var(--spacing-sm); 
}

.tool-tag { 
    color: var(--warning-color); 
    font-weight: bold; 
    margin-right: var(--spacing-sm); 
}

.thinking-tag { 
    margin-right: 6px; 
}

/* ===== INPUT COMPONENT ===== */
.input-area {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

/* Game-style input (single line with prompt) */
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--text-color);
}

.input-prompt {
    color: var(--accent-color);
    font-size: 18px;
    font-weight: bold;
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 15px;
    padding: 10px 0;
    outline: none;
}

.input-wrapper input:disabled { 
    color: var(--text-dim); 
}

/* Chat-style input (textarea with send button) */
.chat-input-wrapper {
    display: flex;
    gap: 10px;
}

.chat-input-wrapper textarea {
    flex: 1;
    resize: none;
}

.send-btn {
    padding: 12px 20px;
    background: var(--accent-color);
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-color);
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: var(--text-bright);
}

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

.input-hints {
    margin-top: var(--spacing-sm);
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
}

/* ===== MODEL PICKER COMPONENT ===== */
.model-selector-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.model-picker {
    --model-picker-bg: rgba(0, 0, 0, 0.35);
    --model-picker-border: rgba(235, 230, 220, 0.16);
    --model-picker-input-border: rgba(235, 230, 220, 0.22);
    --model-picker-text: #ebe6dc;
    --model-picker-muted: rgba(235, 230, 220, 0.5);
    --model-picker-accent: #d4a853;
    --model-picker-option-bg: #0d0d0c;
    --model-picker-option-text: rgba(235, 230, 220, 0.9);

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 360px;
    max-width: min(100%, 520px);
    padding: 10px 12px 8px;
    border: 1px solid var(--model-picker-border);
    background: var(--model-picker-bg);
    border-radius: 8px;
    position: relative;
    z-index: 20;
}

.model-picker-trigger {
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: linear-gradient(180deg, rgba(235, 230, 220, 0.08), rgba(235, 230, 220, 0.02));
    border: 1px solid var(--model-picker-input-border);
    color: var(--model-picker-text);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.67rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 7px 10px;
    cursor: pointer;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(235, 230, 220, 0.03);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
    text-align: left;
}

.model-picker-trigger:hover {
    border-color: var(--model-picker-accent);
    box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.16);
}

.model-picker-trigger:focus {
    outline: none;
    border-color: var(--model-picker-accent);
    box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.22);
}

.model-picker-trigger-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-picker-trigger-caret {
    color: var(--model-picker-muted);
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

.model-picker.open .model-picker-trigger-caret {
    color: var(--model-picker-accent);
}

.model-picker-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.model-picker-modal[hidden] {
    display: none;
}

.model-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(3px);
}

.model-picker-dialog {
    position: relative;
    z-index: 1;
    width: min(720px, calc(100vw - 32px));
    max-height: min(80vh, 620px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--model-picker-input-border);
    background: linear-gradient(180deg, rgba(13, 13, 12, 0.95), rgba(11, 11, 10, 0.98));
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55);
}

.model-picker-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.model-picker-dialog-title {
    margin: 0;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--model-picker-text);
}

.model-picker-dialog-close {
    width: 30px;
    height: 30px;
    border: 1px solid var(--model-picker-input-border);
    border-radius: 6px;
    background: transparent;
    color: var(--model-picker-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.model-picker-dialog-close:hover {
    border-color: var(--model-picker-accent);
    color: var(--model-picker-accent);
    background: rgba(212, 168, 83, 0.08);
}

.model-picker-dialog-close:focus {
    outline: none;
    border-color: var(--model-picker-accent);
    box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.2);
}

.model-picker-dialog-subtitle {
    margin: 0;
    color: var(--model-picker-muted);
    font-size: 0.6rem;
    line-height: 1.35;
}

.model-picker-menu {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px;
    border: 1px solid var(--model-picker-input-border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.24);
    max-height: min(60vh, 460px);
    overflow-y: auto;
}

.model-picker-option {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--model-picker-option-text);
    cursor: pointer;
    padding: 10px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.model-picker-option:hover,
.model-picker-option.active {
    background: rgba(235, 230, 220, 0.05);
    border-color: rgba(235, 230, 220, 0.18);
    transform: translateY(-1px);
}

.model-picker-option.selected {
    border-color: var(--model-picker-accent);
    background: rgba(212, 168, 83, 0.08);
}

.model-picker-option-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.model-picker-option-name {
    font-size: 0.73rem;
    font-weight: 600;
}

.model-picker-option-selected-tag {
    font-size: 0.56rem;
    letter-spacing: 0.08em;
    color: var(--model-picker-accent);
    text-transform: uppercase;
    opacity: 0;
}

.model-picker-option.selected .model-picker-option-selected-tag {
    opacity: 1;
}

.model-picker-option-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.model-picker-option-stat {
    border: 1px solid var(--model-picker-border);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 0.56rem;
    color: var(--model-picker-muted);
    background: rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.model-picker-option-stat-label {
    color: var(--model-picker-accent);
    margin-right: 4px;
}

.model-picker-option-description {
    font-size: 0.59rem;
    color: var(--model-picker-muted);
    line-height: 1.35;
}

.model-picker-menu::-webkit-scrollbar {
    width: 8px;
}

.model-picker-menu::-webkit-scrollbar-thumb {
    background: rgba(235, 230, 220, 0.18);
    border-radius: 999px;
}

.model-picker-menu::-webkit-scrollbar-track {
    background: transparent;
}

body.model-picker-modal-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .model-selector-row {
        margin-top: 8px;
    }

    .model-picker {
        min-width: 0;
        width: 100%;
        max-width: none;
        padding: 8px 10px;
    }

    .model-picker-trigger {
        height: 36px;
        font-size: 0.62rem;
        padding: 6px 8px;
    }

    .model-picker-dialog {
        width: calc(100vw - 20px);
        padding: 10px;
        gap: 10px;
    }

    .model-picker-dialog-title {
        font-size: 0.68rem;
    }

    .model-picker-dialog-subtitle {
        display: none;
    }

    .model-picker-menu {
        max-height: 56vh;
    }

    .model-picker-option-name {
        font-size: 0.64rem;
    }

    .model-picker-option-description {
        display: none;
    }
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    gap: 12px;
    margin-bottom: var(--spacing-md);
    animation: fadeIn var(--transition-slow);
}

.typing-indicator .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.typing-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        background: var(--text-dim);
    }
    30% {
        transform: translateY(-8px);
        background: var(--text-color);
    }
}

/* Activity bar (game-style loading) */
.activity-bar {
    padding: 10px var(--spacing-md);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--warning-color);
    font-size: 13px;
}

.activity-spinner { 
    animation: spin 1s linear infinite; 
}

/* ===== MODAL COMPONENT ===== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.modal-icon {
    font-size: 20px;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-bright);
}

.modal-body {
    margin-bottom: var(--spacing-md);
}

.modal-body p {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 10px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions .btn {
    flex: 1;
    max-width: 150px;
}

/* Modal field display */
.modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.modal-field-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-field-value {
    color: var(--text-color);
    font-size: 13px;
    line-height: 1.4;
}

.modal-field-value.title {
    color: var(--text-bright);
    font-size: 16px;
    font-weight: bold;
}

.modal-field-value.accent {
    color: var(--accent-color);
}

.modal-elements {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.modal-element {
    padding: 4px 8px;
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 3px;
    font-size: 11px;
    color: var(--accent-color);
}

/* ===== SIDE PANEL COMPONENT ===== */
.side-panel {
    width: 350px;
    background: var(--bg-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.side-panel.hidden {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    color: var(--accent-color);
    font-size: 14px;
    font-weight: bold;
}

.panel-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
}

.panel-close:hover { 
    color: var(--error-color); 
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.panel-loading {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-dim);
}

.panel-footer {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ===== SECTION COMPONENT (for panels/sidebars) ===== */
.section {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.section-header:hover {
    background: rgba(0, 0, 0, 0.3);
}

.section-icon {
    font-size: 14px;
}

.section-header h3,
.section-header h4 {
    flex: 1;
    margin: 0;
    font-size: 13px;
    color: var(--text-color);
    font-weight: normal;
}

.section-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
}

.section-status.pending {
    background: var(--warning-color);
    color: var(--bg-color);
}

.section-status.confirmed {
    background: var(--text-color);
    color: var(--bg-color);
}

.section-count {
    font-size: 11px;
    color: var(--text-dim);
}

.section-body {
    padding: 10px 12px;
    font-size: 13px;
}

.section-body.collapsed {
    display: none;
}

/* ===== LIST ITEMS ===== */
.list-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-bottom: 6px;
}

.list-item:last-child {
    margin-bottom: 0;
}

.list-item:hover {
    background: rgba(0, 0, 0, 0.3);
}

.list-item-icon {
    font-size: 12px;
    flex-shrink: 0;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-name {
    color: var(--text-bright);
    font-size: 12px;
    font-weight: 500;
}

.list-item-desc {
    color: var(--text-dim);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== CARD COMPONENT ===== */
.card {
    display: block;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-color);
    transition: all var(--transition-normal);
    margin-bottom: 10px;
}

.card:hover {
    border-color: var(--text-color);
    background: var(--bg-secondary);
}

.card.primary {
    border-color: var(--accent-color);
}

.card.primary:hover {
    background: rgba(0, 255, 255, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.card-title {
    color: var(--text-bright);
}

.card-subtitle {
    color: var(--text-dim);
    font-size: 13px;
}

.card-body {
    color: var(--accent-color);
    font-size: 14px;
}

/* Action cards (home page) */
.action-card {
    flex: 1;
    padding: 25px;
    border: 2px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: center;
    border-radius: var(--radius-md);
}

.action-card:hover,
.action-card.active {
    border-color: var(--text-color);
    background: var(--bg-secondary);
}

.action-card.primary {
    border-color: var(--accent-color);
}

.action-card.primary:hover {
    background: rgba(0, 255, 255, 0.1);
}

.action-icon { 
    font-size: 32px; 
    display: block; 
    margin-bottom: 10px; 
}

.action-title { 
    display: block; 
    font-size: 18px; 
    color: var(--text-bright); 
    margin-bottom: 5px; 
}

.action-desc { 
    display: block; 
    font-size: 13px; 
    color: var(--text-dim); 
}

/* ===== ENTITY CROSSLINKS ===== */
.entity-link {
    color: var(--accent-color);
    cursor: pointer;
    border-bottom: 1px dotted var(--accent-color);
    transition: all var(--transition-fast);
}

.entity-link:hover {
    color: var(--text-bright);
    border-bottom-color: var(--text-bright);
}

/* ===== DICE ROLL DISPLAY ===== */
.message-roll {
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid var(--accent-color);
    border-left: 4px solid var(--accent-color);
    padding: 12px 15px;
    margin: 10px 0;
    border-radius: var(--radius-sm);
}

.roll-result {
    font-family: inherit;
}

.roll-header {
    color: var(--accent-color);
    font-size: 14px;
    font-weight: bold;
    margin-bottom: var(--spacing-sm);
}

.roll-info {
    color: var(--text-dim);
    font-size: 13px;
    margin: 3px 0;
}

.roll-dice {
    color: var(--text-bright);
    font-size: 16px;
    font-weight: bold;
    margin: var(--spacing-sm) 0;
    padding: 5px 0;
    border-top: 1px dashed var(--border-color);
    border-bottom: 1px dashed var(--border-color);
}

.roll-success {
    color: var(--text-color);
    font-size: 15px;
    font-weight: bold;
    margin-top: var(--spacing-sm);
}

.roll-failure {
    color: var(--error-color);
    font-size: 15px;
    font-weight: bold;
    margin-top: var(--spacing-sm);
}

.roll-crit-success {
    color: #ffff00;
    font-size: 16px;
    font-weight: bold;
    margin-top: var(--spacing-sm);
    text-shadow: 0 0 10px #ffff00;
    animation: critPulse 0.5s ease-in-out 3;
}

.roll-crit-fail {
    color: var(--error-color);
    font-size: 16px;
    font-weight: bold;
    margin-top: var(--spacing-sm);
    text-shadow: 0 0 10px var(--error-color);
    animation: critPulse 0.5s ease-in-out 3;
}

@keyframes critPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* ===== EDIT FORMS (Session Zero) ===== */
.edit-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
    transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
}

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

.form-row {
    display: flex;
    gap: 12px;
}

.form-group.half {
    flex: 1;
}

.form-group.third {
    flex: 1;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-color);
    text-transform: none;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
}

.form-status {
    text-align: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-top: 8px;
}

.form-status.pending {
    background: rgba(255, 170, 0, 0.1);
    color: var(--warning-color);
}

.form-status.confirmed {
    background: rgba(0, 255, 255, 0.1);
    color: var(--accent-color);
}

/* ===== CHARACTER SHEET ===== */
.character-sheet {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sheet-header {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sheet-section {
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
}

.sheet-section h4 {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-box label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.stat-box input {
    width: 100%;
    max-width: 50px;
    text-align: center;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 4px;
    color: var(--text-bright);
    font-size: 16px;
    font-weight: bold;
}

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

/* Abilities List */
.abilities-list,
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.ability-row,
.inventory-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ability-name {
    flex: 1;
    max-width: 120px;
}

.ability-desc {
    flex: 2;
}

.inventory-item {
    flex: 1;
}

.ability-row input,
.inventory-row input {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    color: var(--text-color);
    font-size: 12px;
}

.ability-row input:focus,
.inventory-row input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.remove-btn {
    background: none;
    border: none;
    color: var(--error-color);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.remove-btn:hover {
    opacity: 1;
}

.add-btn-inline {
    background: none;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-btn-inline:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.empty-list {
    color: var(--text-dim);
    font-size: 12px;
    font-style: italic;
    padding: 8px;
    text-align: center;
}

/* Mini stats display in World Bible */
.char-stats-mini {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 6px 0;
}

.stat-mini {
    font-size: 11px;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 5px;
    border-radius: 3px;
}

.char-hp-mini {
    font-size: 11px;
    color: var(--accent-color);
    margin-top: 4px;
}

.hp-label,
.ac-label {
    color: var(--text-dim);
}

/* Add buttons */
.add-btn {
    display: block;
    width: 100%;
    background: none;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 8px;
}

.add-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.add-btn-small {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
    transition: color var(--transition-fast);
}

.add-btn-small:hover {
    color: var(--accent-color);
}

/* Wider modal for character sheet */
.modal-content:has(.character-sheet) {
    max-width: 600px;
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .ability-row {
        flex-wrap: wrap;
    }
    
    .ability-name {
        max-width: none;
        flex: 1 1 100%;
    }
    
    .ability-desc {
        flex: 1 1 100%;
    }
}


/* ===== CONTEXT VIEWER ===== */
.context-viewer {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: var(--spacing-md) 0;
    font-size: 12px;
    overflow: hidden;
}

.context-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 255, 255, 0.1);
    border-bottom: 1px solid var(--border-color);
    color: var(--accent-color);
    font-weight: bold;
}

.context-header .turn-badge {
    background: var(--accent-color);
    color: var(--bg-color);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
}

.context-body {
    padding: 12px;
}

/* Memory Bars Section */
.context-section {
    margin-bottom: 12px;
}

.context-section:last-child {
    margin-bottom: 0;
}

.context-section-title {
    color: var(--text-dim);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.memory-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.memory-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.memory-bar-label {
    width: 80px;
    color: var(--text-dim);
    font-size: 11px;
    flex-shrink: 0;
}

.memory-bar-track {
    flex: 1;
    height: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.memory-bar-fill {
    height: 100%;
    background: var(--text-color);
    transition: width 0.3s ease;
}

.memory-bar-fill.accent {
    background: var(--accent-color);
}

.memory-bar-fill.warning {
    background: var(--warning-color);
}

.memory-bar-value {
    width: 50px;
    text-align: right;
    color: var(--text-dim);
    font-size: 10px;
    flex-shrink: 0;
}

/* Entity Stats */
.entity-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.entity-stat {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
}

.entity-stat-label {
    color: var(--text-dim);
}

.entity-stat-value {
    color: var(--text-bright);
    margin-left: 4px;
}

/* Entity Graph (Simple ASCII-style) */
.entity-graph {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: monospace;
    font-size: 11px;
    line-height: 1.4;
    overflow-x: auto;
}

.entity-graph-node {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    margin: 2px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.entity-graph-node:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.entity-graph-node.location {
    border-color: var(--text-color);
    color: var(--text-color);
}

.entity-graph-node.character {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.entity-graph-node.item {
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.entity-graph-node.player {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
}

.entity-graph-connector {
    color: var(--text-dim);
    margin: 0 4px;
}

/* Nearby Entities Tags */
.entity-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.entity-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.entity-tag:hover {
    border-color: var(--accent-color);
    background: rgba(0, 255, 255, 0.1);
}

.entity-tag-icon {
    font-size: 10px;
}

.entity-tag-name {
    color: var(--text-color);
}

.entity-tag-type {
    color: var(--text-dim);
    font-size: 9px;
}

/* Collapsible Sections */
.context-collapsible {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    overflow: hidden;
}

.context-collapsible summary {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    color: var(--text-dim);
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.context-collapsible summary:hover {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-color);
}

.context-collapsible summary::marker {
    color: var(--accent-color);
}

.context-collapsible-content {
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
}

.context-collapsible pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
}

/* Message list in context */
.context-messages {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.context-message {
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    font-size: 11px;
}

.context-message-role {
    color: var(--accent-color);
    font-weight: bold;
    margin-right: 6px;
}

.context-message-content {
    color: var(--text-dim);
}

/* Journal entries */
.context-journal {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.context-journal-entry {
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    border-left: 2px solid var(--border-color);
}

.context-journal-entry.high {
    border-left-color: var(--warning-color);
}

.context-journal-entry.critical {
    border-left-color: var(--error-color);
}

.context-journal-turn {
    color: var(--text-dim);
    font-size: 10px;
}

.context-journal-text {
    color: var(--text-color);
    font-size: 11px;
    margin-top: 2px;
}

/* DM Plan display */
.context-plan {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.context-plan-section {
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.context-plan-label {
    color: var(--accent-color);
    font-size: 10px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.context-plan-value {
    color: var(--text-color);
    font-size: 11px;
}

.context-plan-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.context-plan-list li {
    color: var(--text-dim);
    font-size: 11px;
    padding: 2px 0;
}

.context-plan-list li::before {
    content: "› ";
    color: var(--text-color);
}

/* Token Usage Display */
.token-usage {
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 12px;
}

.token-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.token-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.token-stat.total {
    border-left: 1px solid var(--border-color);
    padding-left: 12px;
}

.token-label {
    color: var(--text-dim);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.token-value {
    color: var(--accent-color);
    font-size: 14px;
    font-weight: bold;
    font-family: monospace;
}

.token-stat.total .token-value {
    color: var(--text-bright);
}

.token-bar {
    display: flex;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.token-bar-prompt {
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.token-bar-completion {
    background: var(--warning-color);
    transition: width 0.3s ease;
}


/* ===== LOW CREDIT WARNING BANNER ===== */
.low-credit-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--spacing-md);
    background: rgba(255, 100, 100, 0.15);
    border-bottom: 1px solid var(--error-color);
    color: var(--error-color);
    font-size: 13px;
    animation: warningPulse 2s ease-in-out infinite;
}

.low-credit-warning.hidden {
    display: none;
}

.low-credit-warning .warning-icon {
    font-size: 16px;
}

.low-credit-warning .warning-text {
    flex: 1;
}

.low-credit-warning .warning-link {
    color: var(--error-color);
    text-decoration: underline;
    font-weight: bold;
}

.low-credit-warning .warning-link:hover {
    color: var(--text-bright);
}

@keyframes warningPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== INLINE TOKEN DISPLAY (per message) ===== */
.message-token-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
    font-size: 11px;
    color: var(--text-dim);
}

.message-token-info .token-icon {
    color: var(--accent-color);
}

.message-token-info .token-total {
    color: var(--text-color);
    font-family: monospace;
}

.message-token-info .token-breakdown {
    color: var(--text-dim);
    font-size: 10px;
}

.message-token-info .token-cached {
    color: #4ade80;
    font-size: 10px;
    padding: 1px 4px;
    background: rgba(74, 222, 128, 0.1);
    border-radius: 3px;
}

.message-token-info .context-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 6px;
    color: var(--text-dim);
    font-size: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.message-token-info .context-toggle:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Historic context viewer (collapsed by default) */
.message-context-viewer {
    margin-top: 8px;
    display: none;
}

.message-context-viewer.expanded {
    display: block;
}


/* ===== BOTTOM SHEET COMPONENT ===== */
/* Neo-Scribe styled bottom sheet for mobile sidebars */

.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85vh;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bottom-sheet.open {
    transform: translateY(0);
}

/* L-bracket corners for bottom sheet - Neo-Scribe aesthetic */
.bottom-sheet::before,
.bottom-sheet::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--accent-color);
    border-style: solid;
    border-width: 0;
    pointer-events: none;
    z-index: 1;
}

.bottom-sheet::before {
    top: 8px;
    left: 8px;
    border-top-width: 1px;
    border-left-width: 1px;
}

.bottom-sheet::after {
    top: 8px;
    right: 8px;
    border-top-width: 1px;
    border-right-width: 1px;
}

/* Additional L-brackets at bottom corners using inner element */
.bottom-sheet-content::before,
.bottom-sheet-content::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--accent-color);
    border-style: solid;
    border-width: 0;
    pointer-events: none;
    z-index: 1;
}

.bottom-sheet-content::before {
    bottom: 8px;
    left: 8px;
    border-bottom-width: 1px;
    border-left-width: 1px;
}

.bottom-sheet-content::after {
    bottom: 8px;
    right: 8px;
    border-bottom-width: 1px;
    border-right-width: 1px;
}

/* Drag handle indicator */
.bottom-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 12px;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
}

.bottom-sheet-handle:active {
    cursor: grabbing;
}

.bottom-sheet-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    transition: background var(--transition-fast);
}

.bottom-sheet-handle:hover::before {
    background: var(--accent-dim);
}

/* Bottom sheet header */
.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--border-dim);
    flex-shrink: 0;
}

.bottom-sheet-title {
    color: var(--accent-color);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0;
}

.bottom-sheet-close {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.bottom-sheet-close:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Bottom sheet content area */
.bottom-sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

/* Bottom sheet overlay/backdrop */
.bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
    z-index: 99;
}

.bottom-sheet-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-sheet {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .bottom-sheet-content {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Mobile toggle button for triggering bottom sheet */
.mobile-panel-toggle {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 48px;
    height: 48px;
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    font-size: 20px;
    cursor: pointer;
    z-index: 50;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.mobile-panel-toggle:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}

/* L-bracket corners on toggle button */
.mobile-panel-toggle::before,
.mobile-panel-toggle::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-color: var(--accent-color);
    border-style: solid;
    border-width: 0;
    pointer-events: none;
    transition: border-color var(--transition-fast);
}

.mobile-panel-toggle::before {
    top: 4px;
    left: 4px;
    border-top-width: 1px;
    border-left-width: 1px;
}

.mobile-panel-toggle::after {
    bottom: 4px;
    right: 4px;
    border-bottom-width: 1px;
    border-right-width: 1px;
}

.mobile-panel-toggle:hover::before,
.mobile-panel-toggle:hover::after {
    border-color: var(--bg-color);
}

/* Show toggle button on mobile viewports */
@media (max-width: 900px) {
    .mobile-panel-toggle {
        display: flex;
    }
}

/* Adjust toggle position when input area is visible */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-panel-toggle {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
}



/* ===== MODAL RESPONSIVE STYLES ===== */
/* Property 8: Modal Responsiveness - Requirements 7.1, 7.2, 7.3, 7.4, 7.5 */

/* Tablet and below - expand modal width */
@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        margin: 5vh auto;
        padding: 20px;
    }
    
    /* Scale L-bracket corners smaller on mobile */
    .modal-content::before,
    .modal-content::after {
        width: 12px;
        height: 12px;
    }
    
    /* Ensure modal body scrolls properly */
    .modal-body {
        max-height: calc(90vh - 180px);
        overflow-y: auto;
    }
    
    /* Full-width form inputs on mobile */
    .modal-body input[type="text"],
    .modal-body input[type="email"],
    .modal-body input[type="password"],
    .modal-body input[type="number"],
    .modal-body textarea,
    .modal-body select {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Reduce modal header padding */
    .modal-header {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }
    
    .modal-header h3 {
        font-size: 14px;
    }
    
    /* Reduce modal icon size */
    .modal-icon {
        font-size: 18px;
    }
    
    /* Large modal variant also respects mobile constraints */
    .modal-content.modal-large {
        max-width: 95%;
        width: 95%;
    }
    
    /* Neo-modal variant (home page) */
    .modal-content.neo-modal {
        width: 95%;
        max-width: 95%;
    }
}

/* Very small screens - stack action buttons vertically */
@media (max-width: 400px) {
    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-actions .btn {
        width: 100%;
        max-width: none;
        justify-content: center;
    }
    
    /* Further reduce modal padding */
    .modal-content {
        padding: 16px;
    }
    
    /* Smaller L-bracket corners on very small screens */
    .modal-content::before,
    .modal-content::after {
        width: 10px;
        height: 10px;
    }
    
    /* Reduce modal body text size slightly */
    .modal-body p {
        font-size: 13px;
    }
    
    /* Stack form rows on very small screens */
    .modal-body .form-row {
        flex-direction: column;
        gap: 12px;
    }
}

/* Ensure modal backdrop covers full viewport on mobile */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-backdrop {
        position: fixed;
        inset: 0;
    }
}
