/* --------------------------------------------------
   Zombicide 2nd Edition - Card Creator UI (Light)
   Crisp studio styling, denser controls, responsive preview
-------------------------------------------------- */

:root {
    --page-bg: #f5f7fb;
    --panel: #ffffff;
    --panel-strong: #f8fafc;
    --surface: #eef2f7;
    --border: #d9e2ec;
    --border-strong: #c6d3e0;
    --text: #1f2937;
    --muted: #5b6575;
    --subtle: #94a3b8;
    --accent: #1f7ae0;
    --accent-warm: #f1636a;
    --shadow-soft: 0 20px 50px rgba(15, 23, 42, 0.08);
    --shadow-strong: 0 30px 80px rgba(15, 23, 42, 0.12);
    --radius-lg: 16px;
    --radius-sm: 10px;
}

@font-face {
    font-family: 'Piklet Caps';
    src: url('assets/fonts/piklet-caps-clean.otf') format('opentype');
    font-display: block;
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'Devil Dog';
    src: url('assets/fonts/DEVIL_DOG.TTF') format('truetype');
    font-display: swap;
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Monster Movie';
    src: url('assets/fonts/MONSTERMOVIESOBLIQUEJNL.TTF') format('truetype');
    font-display: swap;
    font-weight: 400;
    font-style: oblique;
}

@font-face {
    font-family: 'Titling Gothic';
    src: url('assets/fonts/TITLINGGOTHICFBCOMP-MEDIUM.TTF') format('truetype');
    font-display: swap;
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Tablet Gothic Zombie';
    src: url('assets/fonts/TabletGothicNarrowW02Zombie.ttf') format('truetype');
    font-display: swap;
    font-weight: 400;
    font-style: normal;
}

/* Alias family to match older inline font names used in JS */
@font-face {
    font-family: 'TabletGothicNarrowW02Zombie';
    src: url('assets/fonts/TabletGothicNarrowW02Zombie.ttf') format('truetype');
    font-display: swap;
    font-weight: 400;
    font-style: normal;
}

/* Preferred desc font (exact file name provided) */
@font-face {
    font-family: 'Tablet Gothic Narrow W02 SmBd';
    src: url('assets/fonts/TABLET GOTHIC NARROW W02 SMBD.TTF') format('truetype');
    font-display: swap;
    font-weight: 600;
    font-style: normal;
}

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

body {
    font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: radial-gradient(120% 120% at 8% 12%, rgba(31, 122, 224, 0.08), transparent 38%),
                radial-gradient(140% 120% at 80% 0%, rgba(241, 99, 106, 0.08), transparent 44%),
                var(--page-bg);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

header {
    position: relative;
    background: linear-gradient(180deg, #ffffff 0%, #f5f7fb 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px 22px 80px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 20px;
}

.eyebrow {
    font-size: 0.8rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--subtle);
    margin-bottom: 6px;
}

header h1 {
    font-family: 'Piklet Caps', 'Bebas Neue', 'Segoe UI', sans-serif;
    letter-spacing: 0.04em;
    font-size: clamp(1.9rem, 1vw + 1.8rem, 2.6rem);
    color: var(--text);
    margin: 0;
}

.current-card-display {
    flex: 1;
}

.current-card-type {
    font-size: 0.85rem;
    color: var(--accent);
    margin: 4px 0 0 0;
    font-weight: 600;
}

#wuxyLogo:hover {
    opacity: 0.7;
    transform: translateY(-1px);
}

.main-content {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    align-items: start;
}

.control-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}

#dynamicControls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

/* Shared label styling for inline section headers */
.section-label {
    display: block;
    margin-bottom: 0;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

/* Standardize grid blocks in control panel/card-specific UI */
.control-panel [style*="grid-template-columns"] {
    gap: 8px !important;
    margin-bottom: 12px !important;
    margin-top: 0 !important;
}

/* Ensure stacked back-only sections keep consistent spacing */
.back-only {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-panel .panel-section h2,
.control-panel .section-header h2 {
    display: none;
}

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}

.help-text {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

.help-text.inline {
    margin-left: auto;
    font-size: 0.8rem;
}

.micro-hint {
    color: var(--subtle);
    font-size: 0.78rem;
    line-height: 1.3;
}

.inline-color {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-file {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scale-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scale-row label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

.scale-row input[type="range"] {
    flex: 1;
}

.color-picker-group.inline {
    background: transparent;
    border: none;
    padding: 0;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--text);
}

.micro-hint.inline {
    margin-left: auto;
}

.panel-section input[type="text"],
.panel-section input[type="number"],
.skill-input,
.editor-number {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.panel-section input[type="text"]:focus,
.panel-section input[type="number"]:focus,
.skill-input:focus,
.editor-number:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(31, 122, 224, 0.15);
    background: #f7f9fd;
}

.panel-section input[type="text"]::placeholder,
.skill-input::placeholder {
    color: var(--subtle);
}

.panel-section input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.88rem;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.panel-section input[type="file"]::file-selector-button {
    padding: 7px 10px;
    border: none;
    background: var(--accent);
    color: #ffffff;
    border-radius: 7px;
    font-weight: 700;
    cursor: pointer;
    margin-right: 10px;
}

.color-picker-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.color-picker-group input[type="color"] {
    width: 44px;
    height: 38px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-picker-group span {
    font-family: 'Courier New', monospace;
    background: #ffffff;
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    border: 1px solid var(--border);
    text-align: center;
}

.name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.name-row input[type="text"] {
    margin: 0;
    flex: 1 1 auto;
}

.name-color {
    flex: 0 0 48px;
    width: 48px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

#skillsList {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skill-item {
    display: grid;
    grid-template-columns: 6px 1fr;
    gap: 8px;
    align-items: center;
}

.skill-swatch {
    width: 6px;
    align-self: stretch;
    border-radius: 4px;
    display: block;
}

.skill-color {
    width: 1px;
    height: 1px;
    border: 0;
    padding: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    cursor: pointer;
}

/* Icon Carousel Styles */
.icon-carousel-container {
    display: flex;
    align-items: center;
    gap: 0px;
    padding: 5px 0; /* Added padding for better touch target. Padding is 5px for all sides and */
}

.icon-carousel {
    display: flex;
    gap: var(--carousel-gap, 10px);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pinch-zoom;
    cursor: grab;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    flex: 1;
    padding: 5px 0;
}

.icon-carousel.dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}

.icon-carousel::-webkit-scrollbar {
    height: 6px;
}

.icon-carousel::-webkit-scrollbar-track {
    background: transparent;
}

.icon-carousel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.icon-carousel::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.icon-carousel-item {
    flex-shrink: 0;
    width: var(--carousel-button-size, 70px);
    height: var(--carousel-button-size, 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: var(--carousel-border-width, 2px) solid var(--border);
    border-radius: var(--carousel-border-radius, 10px);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
    position: relative;
    overflow: hidden;
}

.icon-carousel-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.icon-carousel-item.active {
    border-color: var(--accent);
    background: linear-gradient(135deg, #e8f4f8 0%, #f0f8ff 100%);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.icon-carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.icon-carousel-item .no-icon-indicator {
    font-size: 24px;
    color: #999;
    font-weight: bold;
    user-select: none;
}

.carousel-nav {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: bold;
    color: var(--text);
    padding: 0;
}

.carousel-nav:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.carousel-nav:active {
    transform: scale(0.95);
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-nav:disabled:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    transform: none;
}

.selected-icon-label {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0px;
    font-weight: 500;
}

.selected-icon-label span {
    color: var(--accent);
    font-weight: 600;
}

/* Card View Toggle */
.card-view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding: 4px;
    background: var(--surface);
    border-radius: 8px;
}

.view-tab {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-tab:hover {
    border-color: var(--accent);
    background: var(--panel-strong);
}

.view-tab.active {
    background: linear-gradient(135deg, #2b88ef, #1f7ae0);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(31, 122, 224, 0.25);
}

/* Back Card Text Inputs */
.back-header-input,
.back-text-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    margin-top: 0px;
}

.back-text-input {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

.back-header-input:focus,
.back-text-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(31, 122, 224, 0.15);
    background: #f7f9fd;
}

.btn {
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.94rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
    letter-spacing: 0.01em;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #2b88ef, #1f7ae0);
    color: #ffffff;
    box-shadow: 0 12px 28px rgba(31, 122, 224, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(31, 122, 224, 0.3);
}

.btn-secondary {
    background: #ffffff;
    border-color: var(--border-strong);
    color: var(--text);
}

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

.upload-btn {
    width: 100%;
}

.export-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.canvas-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-strong);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.canvas-header {
    width: 100%;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.canvas-container h2 {
    font-family: 'Piklet Caps', 'Segoe UI', sans-serif;
    letter-spacing: 0.05em;
    font-size: 1.25rem;
}

.canvas-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.canvas-frame {
    width: 100%;
    display: flex;
    justify-content: center;
}

#cardCanvas {
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.15);
    width: auto;
    height: calc(100vh - 140px);
    max-width: 100%;
    max-height: calc(100vh - 140px);
    aspect-ratio: 1218 / 1079;
    object-fit: contain;
    background: #ffffff;
    cursor: crosshair;
    /* HiDPI scaling is handled in JavaScript */
}

.canvas-info {
    color: var(--muted);
    font-size: 0.9rem;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: #ffffff;
    display: inline-block;
    position: relative;
    vertical-align: middle;
}

input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: transparent;
    box-shadow: 0 0 0 2px rgba(31, 122, 224, 0.2);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.editor-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.editor-control.compact {
    margin-top: 2px;
}

.editor-control label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.editor-number {
    width: 72px;
    text-align: center;
    font-weight: 700;
}

.editor-control input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 8px;
    background: var(--surface);
    outline: none;
    cursor: pointer;
    border: 1px solid var(--border);
}

.editor-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 1px solid #1670d8;
    box-shadow: 0 6px 16px rgba(31, 122, 224, 0.25);
}

.editor-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 1px solid #1670d8;
    box-shadow: 0 6px 16px rgba(31, 122, 224, 0.25);
}

.control-panel::-webkit-scrollbar {
    width: 10px;
}

.control-panel::-webkit-scrollbar-track {
    background: var(--panel);
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    color: var(--text);
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    letter-spacing: 0.08em;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .control-panel {
        max-height: none;
    }

    .export-buttons {
        grid-template-columns: 1fr;
    }

    #cardCanvas {
        max-height: calc(100vh - 260px);
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    header {
        padding: 18px;
    }

    .control-panel,
    .canvas-container {
        padding: 14px;
    }
}

/* Era and Card Type Selector */
.era-card-selector {
    background: var(--panel-strong);
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
}

.selector-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.selector-row:last-child {
    margin-bottom: 0;
}

.selector-row label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    min-width: 80px;
}

.era-select,
.card-type-select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.era-select:focus,
.card-type-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(31, 122, 224, 0.15);
}

.era-select:disabled,
.card-type-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.card-type-select option.unimplemented-option {
    color: #999999;
    font-style: italic;
}

.placeholder-message {
    text-align: center;
    padding: 20px;
    color: var(--muted);
}

/* Status message animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========================================
   BURGER MENU STYLES
   ======================================== */

/* Burger Menu Button */
.burger-menu-btn {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(31, 122, 224, 0.25);
    z-index: 10;
}

.burger-menu-btn:hover {
    background: #1670d8;
    box-shadow: 0 6px 16px rgba(31, 122, 224, 0.35);
    transform: translateY(-50%) scale(1.05);
}

.burger-menu-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.burger-line {
    width: 18px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.burger-menu-btn.active .burger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.burger-menu-btn.active .burger-line:nth-child(2) {
    opacity: 0;
}

.burger-menu-btn.active .burger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Burger Menu Overlay */
.burger-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.burger-menu-overlay.active {
    display: flex;
    opacity: 1;
}

.burger-menu-content {
    background: white;
    width: 100%;
    max-width: 340px;
    height: 100%;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    animation: slideInFromLeft 0.3s ease;
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.burger-menu-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel-strong);
}

.burger-menu-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--text);
    font-family: 'Piklet Caps', 'Bebas Neue', 'Segoe UI', sans-serif;
    letter-spacing: 0.05em;
}

.close-burger-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 28px;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-burger-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.burger-menu-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
}

/* Era Group */
.era-group {
    margin-bottom: 12px;
}

.era-header {
    padding: 10px 12px;
    background: var(--accent);
    color: white;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    user-select: none;
}

.era-header:hover {
    background: #1670d8;
    transform: translateX(2px);
}

.era-header .era-icon {
    font-size: 1.05rem;
    transition: transform 0.3s ease;
}

.era-header.expanded .era-icon {
    transform: rotate(90deg);
}

.era-cards {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0;
}

.era-cards.expanded {
    max-height: 460px;
    padding: 6px 0;
}

/* Card Type Item */
.card-type-item {
    padding: 10px 14px 10px 22px;
    margin: 3px 0;
    background: var(--panel);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-type-item:hover {
    background: var(--panel-strong);
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-type-item.active {
    background: linear-gradient(135deg, #e8f4f8 0%, #f0f8ff 100%);
    border-left-color: var(--accent);
    box-shadow: 0 2px 12px rgba(31, 122, 224, 0.2);
}

.card-type-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--surface);
}

.card-type-item.disabled:hover {
    transform: none;
    box-shadow: none;
    background: var(--surface);
}

.card-type-name {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

.card-type-item.disabled .card-type-name {
    color: var(--muted);
}

.card-type-badge {
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.card-type-item.disabled .card-type-badge {
    background: var(--border);
    color: var(--subtle);
}

/* ==================== Grammar Checker Styles ==================== */

/* Grammar Check Button */
#checkGrammarBtn {
    min-height: 40px;
}

#grammarBtnSpinner {
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Error Badge System */
.field-with-badge {
    position: relative;
    display: block;
    width: 100%;
}

.grammar-error-badge {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    background: #f44336;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.grammar-error-badge:hover {
    background: #d32f2f;
    transform: translateY(-50%) scale(1.15);
}

.grammar-success-badge {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    background: #4caf50;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .grammar-error-badge,
    .grammar-success-badge {
        width: 24px;
        height: 24px;
        font-size: 12px;
        right: -10px;
    }
}

/* ==================== Grammar Correction Modal ==================== */

.grammar-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grammar-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.grammar-modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.grammar-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.grammar-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.grammar-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.grammar-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.grammar-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.grammar-correction-item {
    padding: 16px;
    margin-bottom: 12px;
    background: #f9f9f9;
    border-left: 4px solid #f44336;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.grammar-correction-item.spelling {
    border-left-color: #f44336;
}

.grammar-correction-item.grammar {
    border-left-color: #ff9800;
}

.correction-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
}

.correction-type.spelling {
    background: #f44336;
}

.correction-type.grammar {
    background: #ff9800;
}

.correction-text {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.correction-text .original-text {
    color: #f44336;
    text-decoration: line-through;
    font-weight: 500;
}

.correction-text .suggestion-text {
    color: #4caf50;
    font-weight: 600;
}

.correction-actions {
    display: flex;
    gap: 8px;
}

.correction-actions button {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.apply-correction-btn {
    background: #4caf50;
    color: white;
}

.apply-correction-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.deny-correction-btn {
    background: #f0f0f0;
    color: #666;
}

.deny-correction-btn:hover {
    background: #e0e0e0;
}

.correction-applied {
    opacity: 0.5;
    pointer-events: none;
}

.correction-applied .correction-actions {
    display: none;
}

.correction-applied::after {
    content: "✓ Applied";
    display: block;
    margin-top: 8px;
    color: #4caf50;
    font-weight: 600;
    font-size: 12px;
}

.grammar-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.grammar-modal-footer button {
    padding: 10px 20px;
}

.no-corrections-message {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

/* Force-hide global controls we don't expose in the UI */
.force-hidden {
    display: none !important;
}
