/* ===== DESIGN TOKENS ===== */
:root {
    --color-bg-base: #0f1117;
    --color-bg-surface: #181a20;
    --color-bg-elevated: #1e2028;
    --color-bg-hover: #252830;
    --color-bg-active: #2c2f3a;

    --color-border: #2a2d38;
    --color-border-subtle: #22252e;
    --color-border-strong: #3a3d48;

    --color-text-primary: #eaedf3;
    --color-text-secondary: #b0b5c3;
    --color-text-muted: #6e7487;
    --color-text-inverse: #0f1117;

    --color-accent: #d4a843;
    --color-accent-hover: #e4bc5e;
    --color-accent-muted: rgba(212, 168, 67, 0.15);
    --color-accent-ring: rgba(212, 168, 67, 0.3);

    --color-danger: #e5534b;
    --color-danger-hover: #f47067;
    --color-danger-muted: rgba(229, 83, 75, 0.15);

    --color-success: #3fb950;
    --color-success-muted: rgba(63, 185, 80, 0.15);

    --color-info: #58a6ff;
    --color-info-muted: rgba(88, 166, 255, 0.15);

    --color-purple: #a371f7;
    --color-purple-muted: rgba(163, 113, 247, 0.15);

    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 0.75rem;
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --space-3xl: 3rem;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-xl: 14px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3), 0 1px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.25);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    --font-mono: 'Fira Code', 'Cascadia Code', Consolas, monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.3rem;
    --text-2xl: 1.625rem;
    --text-3xl: 2rem;

    --leading-tight: 1.3;
    --leading-normal: 1.6;
    --leading-relaxed: 1.75;

    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;

    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
    --topbar-height: 56px;
}

/* ===== RESET & BASE ===== */
html {
    scroll-behavior: smooth;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    background: var(--color-bg-base);
    color: var(--color-text-primary);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Focus-visible ring for accessibility */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

::selection {
    background: var(--color-accent-muted);
    color: var(--color-text-primary);
}

/* Keep reference and campaign text copyable, while controls still behave like controls. */
button, .btn, .nav-item, .sidebar-toggle, .mobile-menu-btn {
    -webkit-user-select: none;
    user-select: none;
}

input, textarea, [contenteditable="true"], .ql-editor {
    -webkit-user-select: text;
    user-select: text;
}

/* ===== TYPOGRAPHY ===== */
a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

h1, h2, h3, h4 {
    color: var(--color-text-primary);
    margin-top: 0;
    line-height: var(--leading-tight);
    font-weight: 600;
}

h1 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h2 { font-size: var(--text-xl); letter-spacing: -0.005em; }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

.section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border-subtle);
}

.page-description {
    color: var(--color-text-secondary);
    font-size: var(--text-base);
    margin-bottom: var(--space-xl);
}

.whitespace-pre-wrap { white-space: pre-wrap; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    gap: var(--space-lg);
}

.page-header h1 {
    margin: 0;
    -webkit-user-select: text;
    user-select: text;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:focus-visible {
    box-shadow: 0 0 0 2px var(--color-bg-base), 0 0 0 4px var(--color-accent);
}

.btn-primary {
    background: var(--color-accent);
    color: var(--color-text-inverse);
    border-color: var(--color-accent);
}
.btn-primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: var(--color-text-inverse);
}

.btn-secondary {
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
    border-color: var(--color-border-strong);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}
.btn-danger:hover {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--color-accent);
    border-color: var(--color-accent);
}
.btn-outline:hover {
    background: var(--color-accent-muted);
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 0.4rem;
    width: 2rem;
    height: 2rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
    border-color: var(--color-border-strong);
}

a.card, .card[style*="cursor"] {
    cursor: pointer;
}

a.card:hover, .card[style*="cursor"]:hover {
    border-color: var(--color-accent-muted);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    text-decoration: none;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
}

/* ===== STAT CARDS (Dashboard) ===== */
.stat-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.stat-card:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-sm);
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--color-accent-muted);
    color: var(--color-accent);
}

.stat-card-body {
    min-width: 0;
}

.stat-card-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.stat-card-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-lg);
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-gold   { background: var(--color-accent-muted); color: var(--color-accent); }
.badge-blue   { background: var(--color-info-muted); color: var(--color-info); }
.badge-green  { background: var(--color-success-muted); color: var(--color-success); }
.badge-red    { background: var(--color-danger-muted); color: var(--color-danger); }
.badge-purple { background: var(--color-purple-muted); color: var(--color-purple); }
.badge-gray   { background: rgba(110, 116, 135, 0.15); color: var(--color-text-muted); }

/* ===== FORMS ===== */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label,
.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
}

input:not([type]),
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
select,
textarea,
.form-select {
    min-height: 2.35rem;
    padding: 0.55rem 0.85rem;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: var(--text-base);
    font-family: inherit;
    line-height: 1.3;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), var(--shadow-xs);
    transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:not([type]):hover,
input[type="text"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="time"]:hover,
input[type="month"]:hover,
select:hover,
textarea:hover,
.form-select:hover {
    background-color: var(--color-bg-hover);
    border-color: var(--color-border-strong);
}

input:not([type]):focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
input[type="month"]:focus,
select:focus,
textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    background-color: var(--color-bg-elevated);
    box-shadow: 0 0 0 3px var(--color-accent-ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-muted);
}

input:disabled,
select:disabled,
textarea:disabled,
.form-select:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

select,
.form-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.45rem;
    background-color: var(--color-bg-elevated);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
        linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%),
        linear-gradient(to right, var(--color-border), var(--color-border));
    background-position:
        calc(100% - 1rem) 50%,
        calc(100% - 0.7rem) 50%,
        calc(100% - 2.1rem) 50%;
    background-repeat: no-repeat;
    background-size: 0.35rem 0.35rem, 0.35rem 0.35rem, 1px 1.35rem;
}

select:focus,
.form-select:focus {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--color-accent) 50%),
        linear-gradient(135deg, var(--color-accent) 50%, transparent 50%),
        linear-gradient(to right, var(--color-border-strong), var(--color-border-strong));
}

select::-ms-expand {
    display: none;
}

select option {
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}

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

.form-inline-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.form-inline-row input:not([type]),
.form-inline-row input[type="text"],
.form-inline-row select,
.form-inline-row .form-select {
    min-width: 12rem;
}

.form-inline-row input[type="number"] {
    width: 6rem;
    min-width: 6rem;
}

.form-inline-row .btn-sm {
    min-height: 2.35rem;
    padding: 0.45rem 0.8rem;
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--color-danger);
    margin-top: var(--space-xs);
}

/* ===== TABLES ===== */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--color-border-subtle);
}

th {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: var(--color-bg-elevated);
    position: sticky;
    top: 0;
    z-index: 1;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover td {
    background: var(--color-bg-hover);
}

tbody tr:nth-child(even) td {
    background: rgba(255,255,255,0.015);
}

tbody tr:nth-child(even):hover td {
    background: var(--color-bg-hover);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== SEGMENTED CONTROL (filter pills) ===== */
.filter-group {
    display: inline-flex;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
    flex-wrap: wrap;
}

.filter-group .btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.75rem;
    font-size: var(--text-xs);
    font-weight: 600;
}

.filter-group .btn-primary {
    background: var(--color-accent);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-xs);
}

.filter-group .btn-secondary {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
}

.filter-group .btn-secondary:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

/* ===== TIMELINE (sessions) ===== */
.timeline {
    position: relative;
    padding-left: var(--space-2xl);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--color-border);
    border-radius: 1px;
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-lg);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--space-2xl) + 4px);
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-accent);
    border: 2px solid var(--color-bg-base);
}

.timeline-date {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.timeline-content {
    margin-top: 2px;
}

/* ===== QUICK-LINK CARDS ===== */
.quick-link-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-xl);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-xs);
}

.quick-link-card:hover {
    border-color: var(--color-accent-muted);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    text-decoration: none;
    color: inherit;
}

.quick-link-card .ql-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--color-bg-elevated);
    color: var(--color-accent);
    transition: background var(--transition-base);
}

.quick-link-card:hover .ql-icon {
    background: var(--color-accent-muted);
}

.quick-link-card .ql-body h3 {
    margin: 0;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text-primary);
}

.quick-link-card .ql-body p {
    margin: 2px 0 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.quick-link-card .ql-arrow {
    margin-left: auto;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.quick-link-card:hover .ql-arrow {
    transform: translateX(3px);
    color: var(--color-accent);
}

/* ===== ADMIN ===== */
.admin-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 var(--space-lg) var(--space-2xl);
}

.admin-section {
    margin-bottom: var(--space-2xl);
}

.admin-section h2 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-md);
}

.admin-count-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-md);
}

.admin-count-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.admin-count-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-accent);
    line-height: 1.2;
}

.admin-count-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.admin-link-list {
    margin: 0;
    padding-left: var(--space-xl);
    line-height: 1.8;
}

.admin-user-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-user-table th {
    background: var(--color-bg-elevated);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl) var(--space-xl);
    text-align: center;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-xl);
    background: var(--color-bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
}

.empty-state h3 {
    margin: 0 0 var(--space-sm);
    font-size: var(--text-md);
    color: var(--color-text-secondary);
}

.empty-state p {
    margin: 0 0 var(--space-xl);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    max-width: 320px;
}

/* ===== LOADING SKELETON ===== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--color-bg-elevated) 25%, var(--color-bg-hover) 50%, var(--color-bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 0.875rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
}

.skeleton-heading {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--radius-lg);
}

/* ===== CONTENT FADE-IN ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* ===== UTILITIES ===== */
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-gold { color: var(--color-accent); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-lg); }
.mt-3 { margin-top: var(--space-xl); }
.mb-0 { margin-bottom: 0; }
.mb-05 { margin-bottom: var(--space-xs); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-lg); }
.mb-3 { margin-bottom: var(--space-xl); }
.px-1 { padding-left: var(--space-sm); padding-right: var(--space-sm); }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.gap-05 { gap: var(--space-sm); }
.gap-1 { gap: var(--space-lg); }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--space-xl) 0;
    border: none;
}

mark {
    background: var(--color-accent-muted);
    color: var(--color-accent);
    padding: 0.1em 0.25em;
    border-radius: 2px;
}

/* ===== CONDITION BOX INDICATORS ===== */
.cond-box-row {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.cond-box-indicator {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1.5px solid var(--color-border-strong);
    background: var(--color-bg-elevated);
    transition: background var(--transition-fast);
}

.cond-box-indicator.filled {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

/* ===== DETAIL META ROW ===== */
.detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-lg);
}

.detail-meta-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.detail-meta-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.detail-meta-value {
    font-size: var(--text-base);
    color: var(--color-text-primary);
    font-weight: 500;
}

/* ===== ENTITY DETAIL SYSTEM ===== */
.entity-detail-shell {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    animation: fadeIn 0.25s ease forwards;
}

.entity-hero {
    position: relative;
    overflow: hidden;
    min-height: 248px;
    padding: 0;
    border-color: rgba(212, 168, 67, 0.18);
    background:
        radial-gradient(circle at top left, rgba(212, 168, 67, 0.18), transparent 36%),
        radial-gradient(circle at top right, rgba(88, 166, 255, 0.12), transparent 30%),
        linear-gradient(140deg, rgba(24, 26, 32, 0.98), rgba(13, 15, 22, 0.98));
    box-shadow: var(--shadow-md);
}

.entity-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(9, 10, 14, 0.06), rgba(9, 10, 14, 0.42)),
        linear-gradient(90deg, rgba(11, 13, 18, 0.04), rgba(11, 13, 18, 0.28));
    pointer-events: none;
}

.entity-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-xl);
    min-height: 248px;
    padding: var(--space-2xl);
}

.entity-hero-main {
    display: flex;
    gap: var(--space-xl);
    flex: 1;
    min-width: 0;
}

.entity-hero-copy {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0;
    max-width: 760px;
}

.entity-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent);
}

.entity-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -0.03em;
}

.entity-hero-summary {
    margin: 0;
    max-width: 62ch;
    font-size: var(--text-md);
    color: var(--color-text-secondary);
}

.entity-hero-summary-empty {
    color: rgba(234, 237, 243, 0.74);
}

.entity-badge-row,
.entity-meta-chips,
.entity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.entity-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-full);
    background: rgba(15, 17, 23, 0.48);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    backdrop-filter: blur(10px);
}

.entity-actions {
    align-self: flex-start;
    justify-content: flex-end;
    max-width: 320px;
}

.entity-portrait,
.entity-portrait-fallback {
    width: 120px;
    height: 120px;
    border-radius: calc(var(--radius-xl) + 2px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.entity-portrait {
    display: block;
    object-fit: cover;
    background: rgba(15, 17, 23, 0.72);
}

.entity-portrait-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 18% 20%, rgba(212, 168, 67, 0.34), transparent 30%),
        linear-gradient(145deg, rgba(33, 37, 48, 0.98), rgba(17, 19, 26, 0.98));
    color: var(--color-text-primary);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.entity-summary-link-card {
    display: block;
    color: inherit;
    text-decoration: none;
}

.entity-summary-link-card:hover {
    color: inherit;
    text-decoration: none;
}

.entity-summary-card {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    min-width: 0;
}

.entity-summary-media {
    flex-shrink: 0;
}

.entity-summary-thumb,
.entity-summary-thumb-fallback {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.entity-summary-thumb {
    display: block;
    object-fit: cover;
    background: rgba(15, 17, 23, 0.72);
}

.entity-summary-thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 18% 20%, rgba(212, 168, 67, 0.34), transparent 30%),
        linear-gradient(145deg, rgba(33, 37, 48, 0.98), rgba(17, 19, 26, 0.98));
    color: var(--color-text-primary);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.entity-summary-copy {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.entity-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md);
}

.entity-stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
        var(--color-bg-surface);
    box-shadow: var(--shadow-xs);
}

.entity-stat-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.entity-stat-value {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.1;
}

.entity-control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.entity-control-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
        var(--color-bg-surface);
}

.entity-control-card h2 {
    margin-bottom: var(--space-sm);
}

.entity-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.entity-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
    cursor: pointer;
}

.entity-checkbox-row input {
    margin-top: 0.15rem;
}

.entity-checkbox-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.entity-checkbox-title {
    color: var(--color-text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
}

.entity-checkbox-subtitle {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    line-height: 1.4;
}

.entity-dossier {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.95fr);
    gap: var(--space-lg);
    align-items: start;
}

.entity-main-column,
.entity-side-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.entity-section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.entity-section-kicker {
    margin-bottom: var(--space-xs);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.entity-section-title {
    margin: 0;
}

.entity-section-subtitle {
    margin: 0.25rem 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.entity-rich-text {
    margin: 0;
    color: var(--color-text-secondary);
    white-space: pre-wrap;
}

.entity-token-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.entity-token-list li {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.entity-link-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.entity-link-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: var(--color-bg-elevated);
    color: inherit;
    text-decoration: none;
}

.entity-link-item:hover {
    color: inherit;
    text-decoration: none;
    border-color: rgba(212, 168, 67, 0.22);
}

.entity-link-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.entity-link-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-link-copy span {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.entity-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
}

.entity-detail-block {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.entity-detail-block .detail-meta-label {
    margin-bottom: var(--space-xs);
}

.entity-brief-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
}

.entity-brief-card {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.entity-highlight-card {
    border-left: 3px solid var(--color-accent);
    background:
        linear-gradient(to right, rgba(212, 168, 67, 0.08), transparent 55%),
        var(--color-bg-surface);
}

.entity-highlight-card--purple {
    border-left-color: var(--color-purple);
    background:
        linear-gradient(to right, rgba(163, 113, 247, 0.1), transparent 55%),
        var(--color-bg-surface);
}

.entity-empty-copy {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.entity-inline-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--color-text-secondary);
}

.entity-inline-list li + li {
    margin-top: var(--space-xs);
}

/* ===== EXTRA BADGE VARIANTS ===== */
.badge-teal { background: rgba(45, 212, 191, 0.15); color: #2dd4bf; }
.badge-orange { background: rgba(251, 146, 60, 0.15); color: #fb923c; }

/* ===== EDIT FORMS (Location / Faction / Character) — Premium ===== */

/* Page wrapper — constrained width, fade-in */
.ef-page {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.25s ease forwards;
}

/* Gradient page title */
.ef-page .page-header h1 {
    background: linear-gradient(120deg, var(--color-text-primary) 55%, var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ef-page .page-header p {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin: 4px 0 0;
}

/* Outer wrapper for each section card (replaces old edit-form-card) */
.ef-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-lg);
    overflow: hidden;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.ef-card:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-md);
}

/* Gold accent left stripe */
.ef-card::before {
    display: none; /* handled per-card now */
}

/* Accent left border via a wrapper element */
.ef-card-accent {
    border-left: 3px solid var(--color-accent);
}

.ef-card-danger {
    border-left: 3px solid var(--color-danger);
    background: linear-gradient(to right, rgba(229,83,75,0.03), var(--color-bg-surface) 40%);
}

/* Card body padding */
.ef-body {
    padding: var(--space-xl) var(--space-2xl);
}

@media (max-width: 640px) {
    .ef-body { padding: var(--space-lg); }
}

/* Section header inside each card */
.ef-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border-subtle);
}

.ef-section-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent-muted);
    color: var(--color-accent);
    flex-shrink: 0;
}

.ef-card-danger .ef-section-icon {
    background: var(--color-danger-muted);
    color: var(--color-danger);
}

.ef-section-title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.ef-section-meta {
    margin-left: auto;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-weight: 600;
}

.ef-card-danger .ef-section-title {
    color: var(--color-danger);
}

/* Enhanced labels with hint support */
.ef-label {
    display: block;
    margin-bottom: var(--space-xs);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
}

.ef-label .ef-required {
    color: var(--color-danger);
    margin-left: 2px;
}

.ef-hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
    line-height: 1.45;
}

/* Tall textareas for narrative fields */
.form-group textarea.ef-tall {
    min-height: 120px;
}

/* Two-column grid for short inputs */
.ef-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

/* Three-column grid for approaches */
.ef-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

@media (max-width: 640px) {
    .ef-grid-2, .ef-grid-3 { grid-template-columns: 1fr; }
}
@media (min-width: 641px) and (max-width: 768px) {
    .ef-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Approach number inputs — centered, bold */
.ef-approach .form-group input {
    text-align: center;
    font-size: var(--text-xl);
    font-weight: 700;
    padding: 0.65rem 0.5rem;
    letter-spacing: 0.02em;
}

/* Toggle row for checkboxes (replaces bare InputCheckbox) */
.ef-toggle-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.ef-toggle-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    user-select: none;
}

.ef-toggle-row:hover {
    border-color: var(--color-border-strong);
    background: var(--color-bg-hover);
}

/* Custom toggle switch */
.ef-toggle-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 22px;
    background: var(--color-bg-active);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.ef-toggle-row input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: var(--color-text-muted);
    border-radius: var(--radius-full);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.ef-toggle-row input[type="checkbox"]:checked {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.ef-toggle-row input[type="checkbox"]:checked::after {
    transform: translateX(16px);
    background: #fff;
}

.ef-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.ef-toggle-label-main {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-primary);
}

.ef-toggle-label-sub {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    line-height: 1.35;
}

/* Portrait / image preview block */
.ef-portrait-row {
    display: flex;
    gap: var(--space-lg);
    align-items: flex-start;
}

.ef-portrait-preview {
    width: 88px;
    height: 88px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    border: 1px solid var(--color-border);
    flex-shrink: 0;
    background: var(--color-bg-elevated);
}

.ef-portrait-inputs {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.ef-uploading-indicator {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-accent);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Sticky action bar */
.ef-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-2xl);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    margin-top: var(--space-lg);
    position: sticky;
    bottom: var(--space-lg);
    z-index: 20;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ef-actions .btn-primary {
    padding: 0.6rem 1.75rem;
    box-shadow: 0 2px 10px rgba(212,168,67,0.3);
    transition: all var(--transition-fast);
}

.ef-actions .btn-primary:hover {
    box-shadow: 0 4px 18px rgba(212,168,67,0.45);
    transform: translateY(-1px);
}

/* Legacy aliases — kept so existing CharacterEdit still works */
.edit-form-card {
    padding: var(--space-xl);
    position: relative;
    overflow: hidden;
}

.edit-form-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-accent);
    border-radius: 0 2px 2px 0;
    opacity: 0.6;
    transition: opacity var(--transition-base);
}

.edit-form-card:hover::before {
    opacity: 1;
}

.edit-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border-subtle);
}

.edit-section-header h3 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.edit-section-header .section-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent-muted);
    color: var(--color-accent);
    flex-shrink: 0;
}

.edit-section-header .section-meta {
    margin-left: auto;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.edit-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-lg);
}

.edit-form-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-md);
}

.edit-mantle-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    background: var(--color-bg-elevated);
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent;
}

.edit-mantle-group {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    transition: border-color var(--transition-fast);
}

.edit-mantle-group:hover {
    border-color: var(--color-border-strong);
}

.edit-mantle-group-title {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.edit-mantle-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.edit-mantle-item:hover {
    background: var(--color-bg-hover);
}

.edit-mantle-item:last-child {
    margin-bottom: 0;
}

.edit-mantle-item input[type="checkbox"]:checked + span {
    color: var(--color-accent);
    font-weight: 600;
}

.condition-edit-list,
.stunt-edit-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.condition-edit-empty,
.stunt-edit-empty {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: var(--color-text-muted);
    background: var(--color-bg-elevated);
    font-size: var(--text-sm);
}

.condition-edit-row,
.stunt-edit-row {
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    background: var(--color-bg-elevated);
}

.condition-edit-row-head,
.stunt-edit-row-head {
    display: flex;
    align-items: end;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.condition-edit-name,
.stunt-edit-name {
    flex: 1;
}

.condition-remove-btn,
.stunt-remove-btn {
    flex-shrink: 0;
    min-height: 38px;
}

.stunt-core-toggle {
    align-self: end;
    min-height: 2.35rem;
    margin-bottom: var(--space-md);
}

.edit-form-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-top: var(--space-lg);
    position: sticky;
    bottom: var(--space-lg);
    z-index: 10;
    box-shadow: var(--shadow-md);
}

/* Legacy NPC aliases */
.npc-form-card { padding: var(--space-xl); position: relative; overflow: hidden; }
.npc-form-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--color-accent); border-radius: 0 2px 2px 0; opacity: 0.6; }
.npc-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-lg); }
.npc-approach-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-md); }
.npc-mantle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); max-height: 280px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-md); background: var(--color-bg-elevated); }
.npc-mantle-group { background: var(--color-bg-surface); border: 1px solid var(--color-border-subtle); border-radius: var(--radius-sm); padding: var(--space-sm) var(--space-md); }
.npc-mantle-group-title { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: var(--space-sm); }
.npc-mantle-item { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-xs); cursor: pointer; padding: 2px 4px; border-radius: var(--radius-sm); }
.npc-mantle-item:last-child { margin-bottom: 0; }

/* ===== BLAZOR ERROR UI ===== */
#blazor-error-ui {
    background: var(--color-danger);
    color: white;
    padding: 0.75rem;
    text-align: center;
    display: none;
}

/* ===== RESPONSIVE ===== */
/* Breakpoints: sm=640, md=768, lg=1024, xl=1280 */

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }

    .entity-hero-content {
        flex-direction: column;
        justify-content: flex-end;
        padding: var(--space-xl);
    }

    .entity-hero-main {
        flex-direction: column;
        gap: var(--space-lg);
    }

    .entity-actions {
        max-width: none;
        justify-content: flex-start;
    }

    .entity-dossier,
    .entity-detail-grid,
    .entity-brief-grid {
        grid-template-columns: 1fr;
    }

    .entity-section-head {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .edit-form-grid,
    .npc-form-grid {
        grid-template-columns: 1fr;
    }

    .edit-form-grid-3col,
    .npc-approach-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .edit-mantle-grid,
    .npc-mantle-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .entity-control-grid {
        grid-template-columns: 1fr;
    }

    .form-inline-row > input:not([type]),
    .form-inline-row > input[type="text"],
    .form-inline-row > input[type="number"],
    .form-inline-row > select,
    .form-inline-row > .form-select,
    .form-inline-row > .btn {
        width: 100%;
        min-width: 0;
    }

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

    .edit-form-grid-3col,
    .npc-approach-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== PRINT ===== */
@media print {
    .top-nav, .sidebar, .app-footer, .nav-search, .nav-actions,
    .btn, .tag-editor, .milestone-add-form, .notes-add-form,
    form, button, .sidebar-toggle, .mobile-menu-btn { display: none !important; }

    body, .app-container, .main-content, .layout-body {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0.5rem !important;
        max-width: 100% !important;
    }

    body {
        font-size: 11pt;
        line-height: 1.45;
    }

    .card {
        background: white !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        color: black !important;
    }

    a { color: black !important; text-decoration: underline !important; }
    .badge { border: 1px solid #999 !important; background: white !important; color: black !important; }

    .stress-box, .cond-box {
        background: white !important;
        border: 2px solid black !important;
    }
    .stress-box.marked, .cond-box.marked {
        background: black !important;
    }

    .text-gold, .text-muted { color: #333 !important; }
    h1, h2, h3 { color: black !important; }
    .page-header { border-bottom: 1px solid #ccc; margin-bottom: 1rem; }

    .approach-seg { border: 1px solid #999 !important; background: white !important; }
    .approach-seg.filled { background: #333 !important; }
}
