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

:root {
    --bg-color: #f5e6c8;
    --surface-color: #ede0c8;
    --primary-color: #8b2500;
    --secondary-color: #d4c4a0;
    --text-color: #1a1a1a;
    --text-muted: #6b5b47;
    /* New entity-type based colors */
    --period-color: #5c4e36;
    --state-color: #7b2d8e;
    --religion-color: #1a8a6c;
    --culture-color: #5b4fc7;
    --event-color: #8b2500;
    /* Legacy colors for backwards compat */
    --people-color: #8b2500;
    --political-color: #c47d10;
    --technology-color: #2a7ab5;
    --civilizations-color: #7b2d8e;
    --science-color: #b86b1a;
    --era-european-color: #5b4fc7;
    --era-chinese-color: #c45a80;
    --books-color: #228b56;
}

body {
    font-family: 'Courier New', Courier, 'Georgia', serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

.app-container {
    max-width: 100%;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.controls {
    background: var(--surface-color);
    padding: 15px 20px;
    border-radius: 2px;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.search-section {
    flex: 0 0 auto;
}

#searchInput {
    padding: 8px 15px;
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.85rem;
    width: 180px;
    outline: none;
    transition: border-color 0.2s, width 0.2s;
}

#searchInput:focus {
    border-color: var(--primary-color);
    width: 220px;
}

#searchInput::placeholder {
    color: var(--text-muted);
}

.filter-section h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--secondary-color);
    background: transparent;
    color: var(--text-color);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.filter-btn:hover {
    background: var(--secondary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* New entity-type filter buttons */
.filter-btn[data-category="period"].active { background: var(--period-color); border-color: var(--period-color); }
.filter-btn[data-category="state"].active { background: var(--state-color); border-color: var(--state-color); }
.filter-btn[data-category="religion"].active { background: var(--religion-color); border-color: var(--religion-color); }
.filter-btn[data-category="culture"].active { background: var(--culture-color); border-color: var(--culture-color); }
.filter-btn[data-category="event"].active { background: var(--event-color); border-color: var(--event-color); }
/* Legacy filter buttons for backwards compat */
.filter-btn[data-category="people"].active { background: var(--people-color); border-color: var(--people-color); }
.filter-btn[data-category="political"].active { background: var(--political-color); border-color: var(--political-color); }
.filter-btn[data-category="technology"].active { background: var(--technology-color); border-color: var(--technology-color); }
.filter-btn[data-category="civilizations"].active { background: var(--civilizations-color); border-color: var(--civilizations-color); }
.filter-btn[data-category="science"].active { background: var(--science-color); border-color: var(--science-color); }
.filter-btn[data-category="books"].active { background: var(--books-color); border-color: var(--books-color); }

.scale-toggle {
    display: flex;
    align-items: center;
}

.scale-toggle label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

.scale-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-controls button {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--secondary-color);
    color: var(--text-color);
    border-radius: 2px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.zoom-controls button:hover {
    background: var(--primary-color);
}

.zoom-controls button:last-child {
    width: auto;
    padding: 0 10px;
    font-size: 0.75rem;
}

#zoomSlider {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    background: var(--secondary-color);
    border-radius: 2px;
    outline: none;
}

#zoomSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.data-controls {
    display: flex;
    gap: 5px;
}

.data-controls button {
    padding: 6px 10px;
    border: 1px solid var(--secondary-color);
    background: transparent;
    color: var(--text-color);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.data-controls button:hover {
    background: var(--secondary-color);
}

/* User filter dropdown */
.user-filter-dropdown {
    position: relative;
}

.user-filter-btn {
    padding: 6px 10px;
    border: 1px solid var(--secondary-color);
    background: transparent;
    color: var(--text-color);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.user-filter-btn:hover {
    background: var(--secondary-color);
}

.user-filter-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface-color);
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    padding: 8px;
    z-index: 100;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.user-filter-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 0.8rem;
    color: var(--text-color);
    cursor: pointer;
}

.user-filter-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Join event button */
.join-event-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--culture-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 10px;
    transition: opacity 0.2s;
}

.join-event-btn:hover {
    opacity: 0.9;
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 6px 15px;
    background: var(--secondary-color);
    border-radius: 2px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
    padding: 8px 15px;
    background: var(--surface-color);
    border-radius: 2px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* New entity-type legend colors */
.legend-color.period { background: var(--period-color); }
.legend-color.state { background: var(--state-color); }
.legend-color.religion { background: var(--religion-color); }
.legend-color.culture { background: var(--culture-color); }
.legend-color.event { background: var(--event-color); }
/* Legacy legend colors */
.legend-color.people { background: var(--people-color); }
.legend-color.political { background: var(--political-color); }
.legend-color.technology { background: var(--technology-color); }
.legend-color.civilizations { background: var(--civilizations-color); }
.legend-color.era-european { background: var(--era-european-color); }
.legend-color.era-chinese { background: var(--era-chinese-color); }
.legend-color.science { background: var(--science-color); }
.legend-color.books { background: var(--books-color); }

/* Sub-tag system */
.tag-filter-bar {
    display: flex;
    gap: 6px;
    padding: 6px 15px;
    background: var(--surface-color);
    border-radius: 2px;
    margin-bottom: 8px;
    overflow-x: auto;
    white-space: nowrap;
}

.tag-filter-btn {
    padding: 4px 10px;
    border: 1px solid var(--secondary-color);
    background: transparent;
    color: var(--text-muted);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.tag-filter-btn:hover {
    background: var(--secondary-color);
    color: var(--text-color);
}

.tag-filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.tag-filter-icon {
    font-weight: 700;
}

.tag-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tag-checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px 6px;
    background: var(--bg-color);
    border-radius: 2px;
    border: 1px solid var(--secondary-color);
    transition: all 0.2s;
}

.tag-checkbox-label:hover {
    border-color: var(--primary-color);
}

.tag-checkbox-label input[type="checkbox"] {
    width: 12px;
    height: 12px;
    cursor: pointer;
}

.tag-checkbox-icon {
    font-weight: 700;
    font-size: 0.7rem;
}

.tag-chip {
    display: inline-block;
    padding: 2px 8px;
    background: var(--secondary-color);
    border-radius: 2px;
    font-size: 0.7rem;
    color: var(--text-color);
    margin-right: 4px;
    margin-bottom: 4px;
}

.event-tags-section {
    padding: 8px 0;
    margin-bottom: 5px;
}

.event-tags-section h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.event-tags-display {
    margin-bottom: 8px;
}

.tag-checkboxes-edit {
    margin-bottom: 0;
}

.no-tags {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.event-tag-icon {
    position: absolute;
    right: 2px;
    top: 1px;
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
    line-height: 1;
}

.timeline-container {
    background: var(--surface-color);
    border-radius: 2px;
    padding: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    cursor: grab;
}

.timeline-scale {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface-color);
    height: 40px;
    border-bottom: 2px solid var(--secondary-color);
    overflow: hidden;
    margin-left: 0;
    padding-left: 135px;
    border-radius: 2px 2px 0 0;
}

.scale-markers {
    position: relative;
    height: 100%;
    margin-left: 0;
}

.scale-marker {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    text-align: center;
}

.scale-marker::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 1px;
    height: 12px;
    background: var(--text-muted);
}

.scale-marker span {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    white-space: nowrap;
}

.scale-marker.major span {
    font-size: 0.75rem;
    color: var(--text-color);
    font-weight: bold;
}

.scale-marker.major::before {
    height: 20px;
    width: 2px;
    background: var(--text-color);
}

.timeline-content {
    position: relative;
}

/* Region-based layout */
.region-section {
    display: flex;
    border-bottom: 1px solid var(--secondary-color);
    min-height: 100px;
}

.region-section:last-child {
    border-bottom: none;
}

.region-label {
    position: sticky;
    left: 0;
    width: 120px;
    min-width: 120px;
    padding: 10px;
    background: var(--surface-color);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    border-right: 1px solid var(--secondary-color);
    z-index: 5;
    display: flex;
    align-items: flex-start;
}

.region-timeline {
    position: relative;
    flex: 1;
    min-height: 100px;
}

/* Timeline events */
.timeline-event {
    position: absolute;
    height: 26px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    padding: 0 6px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    min-width: 8px;
    z-index: 1;
}

.timeline-event:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 100;
}

.timeline-event[draggable="true"] {
    cursor: grab;
}

.timeline-event[draggable="true"]:active {
    cursor: grabbing;
}

.region-timeline.drag-over {
    background: rgba(139, 37, 0, 0.1);
}

/* Row guides shown during drag */
.row-guide {
    position: absolute;
    left: 0;
    right: 0;
    height: 32px;
    border-top: 2px dashed rgba(139, 37, 0, 0.3);
    pointer-events: none;
}

.event-label {
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Flag-style events for narrow/point events */
.timeline-event.flag-event {
    overflow: visible;
    background: transparent !important;
    height: 26px;
    padding: 0;
    min-width: 0;
    width: 2px !important;
    border-radius: 0;
    z-index: 2;
}

.timeline-event.flag-event:hover {
    transform: none;
    box-shadow: none;
    z-index: 100;
}

.timeline-event.flag-event:hover .flag-label {
    background: var(--bg-color);
}

/* When gap is too small, fully hide the label including border */
.flag-label.label-hidden {
    visibility: hidden;
}

/* On hover, reveal clipped flag labels as floating tooltip */
.timeline-event.flag-event:hover .flag-label.label-clipped {
    max-width: none !important;
    visibility: visible !important;
    background: #fff;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: 1px solid var(--secondary-color);
    border-radius: 3px;
    padding: 4px 8px;
    white-space: nowrap;
}

.flag-dot {
    position: absolute;
    bottom: 0;
    left: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--flag-color);
}

.flag-stem {
    position: absolute;
    bottom: 7px;
    left: 0;
    width: 2px;
    height: 12px;
    background: var(--flag-color);
}

.flag-label {
    position: absolute;
    bottom: 17px;
    left: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.65rem;
    color: var(--text-color);
    text-shadow: none;
    padding: 2px 6px;
    border-radius: 2px;
    background: transparent;
    border-left: 3px solid var(--flag-color);
    cursor: pointer;
    pointer-events: auto;
}

/* Narrow bar events: time-spanning but too small for internal text */
.timeline-event.narrow-bar-event {
    overflow: visible;
    min-width: 4px;
    z-index: 2;
}

.narrow-bar-label {
    position: absolute;
    top: 50%;
    left: calc(100% + 4px);
    transform: translateY(-50%);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.65rem;
    color: var(--text-color);
    text-shadow: none;
    padding: 2px 6px;
    border-radius: 2px;
    background: transparent;
    border-left: 3px solid var(--flag-color);
    cursor: pointer;
    pointer-events: auto;
}

/* When gap is too small, fully hide the label including border */
.narrow-bar-label.label-hidden {
    visibility: hidden;
}

/* On hover, show full label text above the bar as a floating tooltip */
.timeline-event.narrow-bar-event:hover .narrow-bar-label.label-clipped {
    max-width: none !important;
    visibility: visible !important;
    /* Reposition above the bar to avoid overlapping adjacent events */
    top: auto !important;
    bottom: calc(100% + 2px) !important;
    left: 0 !important;
    transform: none !important;
    background: #fff;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: 1px solid var(--secondary-color);
    border-radius: 3px;
    padding: 4px 8px;
    white-space: nowrap;
}

.timeline-event.narrow-bar-event:hover .narrow-bar-label {
    background: var(--bg-color);
}

/* Event colors by entity type (new knowledge map system) */
.timeline-event.period { background: var(--period-color); opacity: 0.85; }
.timeline-event.state { background: var(--state-color); }
.timeline-event.religion { background: var(--religion-color); }
.timeline-event.culture { background: var(--culture-color); }
.timeline-event.event { background: var(--event-color); }

/* Legacy event colors for backwards compat */
.timeline-event.people { background: var(--people-color); }
.timeline-event.political { background: var(--political-color); }
.timeline-event.technology { background: var(--technology-color); }
.timeline-event.civilizations { background: var(--civilizations-color); }
.timeline-event.science { background: var(--science-color); }
.timeline-event.books { background: var(--books-color); }

/* Era colors - distinct for European and Chinese */
.timeline-event.era-european {
    background: var(--era-european-color);
    border: none;
}

.timeline-event.era-chinese {
    background: var(--era-chinese-color);
    border: none;
}

/* Era styling - make them stand out as background bars */
.timeline-event.era {
    height: 24px;
    opacity: 0.85;
    border-radius: 2px;
}

.timeline-event.era .event-label {
    font-size: 0.6rem;
    font-weight: 600;
}

/* Period events (long duration) */
.timeline-event.period {
    opacity: 0.95;
}

/* Event Detail Panel */
.event-detail-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--surface-color);
    padding: 25px;
    overflow-y: auto;
    transition: right 0.3s;
    box-shadow: -5px 0 20px rgba(0,0,0,0.3);
    z-index: 1000;
}

.event-detail-panel.open {
    right: 0;
}

.close-panel {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Event Edit Fields */
.event-edit-fields {
    margin-bottom: 15px;
}

.event-edit-fields label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.event-edit-fields input[type="text"],
.event-edit-fields input[type="number"],
.event-edit-fields select,
.event-edit-fields textarea {
    width: 100%;
    padding: 8px 10px;
    margin-top: 4px;
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
}

.event-edit-fields textarea {
    resize: vertical;
    min-height: 60px;
}

.event-edit-fields input[type="text"]:first-child {
    font-size: 1.1rem;
    font-weight: 600;
}

.event-year-row {
    display: flex;
    gap: 10px;
}

.event-year-row label {
    flex: 1;
}

.event-edit-fields .save-edits-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 5px;
    transition: opacity 0.2s;
}

.event-edit-fields .save-edits-btn:hover {
    opacity: 0.9;
}

.category-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-color-preview {
    width: 20px;
    height: 20px;
    border-radius: 2px;
    flex-shrink: 0;
}

#eventCategorySelect {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.85rem;
}

/* Region Section */
.event-region-section {
    margin-bottom: 15px;
    font-size: 0.85rem;
}

.event-region-section label {
    color: var(--text-muted);
    margin-right: 8px;
}

#eventRegion {
    color: var(--text-color);
    text-transform: capitalize;
}

/* Added By Label */
.event-added-by {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 6px 0;
    margin-bottom: 5px;
    font-style: italic;
}

/* Change Name Button */
.change-name-btn {
    padding: 6px 10px;
    border: 1px solid var(--secondary-color);
    background: transparent;
    color: var(--text-muted);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.change-name-btn:hover {
    background: var(--secondary-color);
    color: var(--text-color);
}

/* Danger Zone */
.event-danger-zone {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--secondary-color);
}

.delete-event-btn {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid #e74c3c;
    border-radius: 2px;
    color: #e74c3c;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-event-btn:hover {
    background: #e74c3c;
    color: white;
}

.event-notes, .event-references {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--secondary-color);
}

.event-notes h4, .event-references h4 {
    margin-bottom: 10px;
    font-size: 0.9rem;
}

#notesInput {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    background: var(--bg-color);
    color: var(--text-color);
    resize: vertical;
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

#saveNotes {
    padding: 8px 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 2px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
}

#referencesList {
    list-style: none;
    margin-bottom: 10px;
}

#referencesList li {
    padding: 8px;
    background: var(--bg-color);
    border-radius: 2px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

#referencesList .ref-info {
    flex: 1;
}

#referencesList .ref-title {
    font-weight: 500;
}

#referencesList .ref-type {
    font-size: 0.75rem;
    color: var(--text-muted);
}

#referencesList .ref-status {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 2px;
    background: var(--secondary-color);
}

#referencesList .ref-status.completed {
    background: var(--religion-color);
}

#referencesList .ref-status.in-progress {
    background: var(--political-color);
}

#addReference {
    padding: 8px 16px;
    background: transparent;
    border: 1px dashed var(--text-muted);
    border-radius: 2px;
    color: var(--text-muted);
    cursor: pointer;
    width: 100%;
    font-size: 0.85rem;
}

#addReference:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Modals */
.add-event-modal, .add-reference-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.add-event-modal.open, .add-reference-modal.open {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    padding: 25px;
    border-radius: 2px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.modal-content label {
    display: block;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.85rem;
}

.modal-content textarea {
    height: 70px;
    resize: vertical;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

.modal-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.85rem;
}

.modal-buttons button[type="button"] {
    background: var(--secondary-color);
    color: var(--text-color);
}

.modal-buttons button[type="submit"] {
    background: var(--primary-color);
    color: white;
}

/* Add Event Button */
.add-event-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    padding: 12px 20px;
    background: var(--primary-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 37, 0, 0.4);
    transition: transform 0.2s;
    z-index: 500;
}

.add-event-btn:hover {
    transform: scale(1.05);
}

/* ========================================
   VIEW TABS
   ======================================== */
.view-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.view-tab {
    padding: 10px 30px;
    background: var(--secondary-color);
    border: 2px solid var(--secondary-color);
    color: var(--text-color);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.view-tab:hover {
    background: var(--surface-color);
    border-color: var(--primary-color);
}

.view-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* View Content Containers */
.view-content {
    display: none;
}

.view-content.active {
    display: block;
}

/* ========================================
   MAP VIEW
   ======================================== */
.map-view {
    height: calc(100vh - 150px);
    display: none;
    flex-direction: column;
}

.map-view.active {
    display: flex;
}

.map-controls {
    background: var(--surface-color);
    padding: 15px 20px;
    border-radius: 2px;
    margin-bottom: 15px;
}

.map-time-control {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.map-nav-btn, .map-play-btn {
    padding: 8px 16px;
    border: none;
    background: var(--secondary-color);
    color: var(--text-color);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.map-nav-btn:hover, .map-play-btn:hover {
    background: var(--primary-color);
}

.map-play-btn {
    min-width: 80px;
    background: var(--primary-color);
}

.map-year-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    min-width: 150px;
    text-align: center;
}

.map-slider {
    flex: 1;
    min-width: 200px;
    height: 8px;
    -webkit-appearance: none;
    background: var(--secondary-color);
    border-radius: 2px;
    outline: none;
}

.map-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.map-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.map-speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.map-speed-control select {
    padding: 5px 10px;
    background: var(--bg-color);
    border: 1px solid var(--secondary-color);
    color: var(--text-color);
    border-radius: 2px;
}

.map-scale-toggle {
    display: flex;
    align-items: center;
}

.map-scale-toggle label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.map-scale-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Map Main Area */
.map-main {
    flex: 1;
    display: flex;
    gap: 15px;
    min-height: 0;
}

.map-sidebar {
    width: 220px;
    background: var(--surface-color);
    border-radius: 2px;
    padding: 15px;
    overflow-y: auto;
}

.map-sidebar h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.empire-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empire-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-color);
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.8rem;
}

.empire-list-item:hover {
    background: var(--secondary-color);
}

.empire-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.empire-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-empires {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 20px;
}

/* Map Container */
.map-container {
    flex: 1;
    border-radius: 2px;
    overflow: hidden;
    background: #72AED5;
    height: 100%;
}

/* Leaflet customizations */
.leaflet-container {
    background: #72AED5;
    font-family: inherit;
}

.empire-tooltip {
    background: var(--surface-color);
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    color: var(--text-color);
    font-size: 0.85rem;
    padding: 5px 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.empire-tooltip::before {
    display: none;
}

/* Empire Detail Modal */
.empire-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.empire-detail-modal.open {
    display: flex;
}

.empire-modal-content {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 2px;
    width: 100%;
    max-width: 450px;
    position: relative;
}

.empire-modal-content h2 {
    margin-bottom: 10px;
    padding-right: 30px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

.empire-dates {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.empire-description {
    line-height: 1.6;
    margin-bottom: 20px;
    color: var(--text-muted);
}

.empire-actions {
    display: flex;
    gap: 10px;
}

.add-to-timeline-btn {
    flex: 1;
    padding: 12px 20px;
    background: var(--primary-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.add-to-timeline-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.add-to-timeline-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
}

.save-edits-btn {
    flex: 1;
    padding: 12px 20px;
    background: var(--religion-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.save-edits-btn:hover {
    opacity: 0.9;
}

/* Empire Edit Form */
.empire-edit-form {
    margin-bottom: 15px;
}

.empire-edit-form label {
    display: block;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.empire-edit-form input,
.empire-edit-form select,
.empire-edit-form textarea {
    width: 100%;
    padding: 8px 10px;
    margin-top: 4px;
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
}

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

.empire-edit-form .form-row {
    display: flex;
    gap: 10px;
}

.empire-edit-form .form-row label {
    flex: 1;
}

/* Map Container Wrapper (for loading overlay) */
.map-container-wrapper {
    flex: 1;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
}

.map-container-wrapper .map-container {
    height: 100%;
    width: 100%;
}

/* Map Loading Indicator */
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 230, 200, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 1000;
    color: var(--text-color);
    font-size: 0.9rem;
}

.map-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--secondary-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: map-spin 0.8s linear infinite;
}

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

/* GeoJSON Info Section */
.geo-info-section {
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 2px;
}

.geo-info-item {
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.geo-info-item .geo-label {
    color: var(--text-color);
    font-weight: 500;
}

/* Create Entity Button */
.create-entity-btn {
    flex: 1;
    padding: 12px 20px;
    background: var(--state-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.create-entity-btn:hover {
    opacity: 0.9;
}

/* Linked empire names in sidebar */
.empire-name.linked {
    color: var(--primary-color);
    font-weight: 500;
}

/* Map Toast */
.map-toast {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 2px;
    z-index: 3000;
    transition: opacity 0.3s;
}

/* ========================================
   QUIZ VIEW
   ======================================== */
.quiz-view {
    padding: 0;
}

.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-header {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 2px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.quiz-settings {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.quiz-difficulty, .quiz-source, .quiz-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.quiz-difficulty select,
.quiz-source select,
.quiz-count select {
    padding: 6px 10px;
    background: var(--bg-color);
    border: 1px solid var(--secondary-color);
    color: var(--text-color);
    border-radius: 2px;
    font-size: 0.85rem;
}

.quiz-start-btn {
    padding: 10px 24px;
    background: var(--primary-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
    font-weight: 500;
}

.quiz-start-btn:hover {
    opacity: 0.9;
}

.quiz-score {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 1.3rem;
    font-weight: 600;
}

.score-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-right: 4px;
}

.score-value {
    color: var(--religion-color);
}

.score-divider {
    color: var(--text-muted);
}

.score-total {
    color: var(--text-muted);
}

.quiz-progress {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--secondary-color);
    border-radius: 2px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}

.quiz-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.quiz-welcome {
    background: var(--surface-color);
    padding: 40px;
    border-radius: 2px;
    text-align: center;
    margin-bottom: 15px;
}

.quiz-welcome h2 {
    margin-bottom: 10px;
}

.quiz-welcome p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 500px;
    margin: 0 auto 20px;
    line-height: 1.5;
}

.quiz-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
    font-size: 0.85rem;
}

.quiz-stat {
    text-align: center;
}

.quiz-stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    display: block;
}

.quiz-stat-label {
    color: var(--text-muted);
}

.quiz-question-card {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 2px;
    margin-bottom: 15px;
}

.quiz-question-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.quiz-question-text {
    font-size: 1.2rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-answer-btn {
    padding: 14px 20px;
    background: var(--bg-color);
    border: 2px solid var(--secondary-color);
    color: var(--text-color);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    transition: all 0.2s;
    line-height: 1.4;
}

.quiz-answer-btn:hover:not(.answered) {
    border-color: var(--primary-color);
    background: rgba(139, 37, 0, 0.1);
}

.quiz-answer-btn.correct {
    border-color: var(--religion-color);
    background: rgba(26, 138, 108, 0.15);
    color: var(--religion-color);
}

.quiz-answer-btn.incorrect {
    border-color: var(--primary-color);
    background: rgba(139, 37, 0, 0.15);
    color: var(--primary-color);
}

.quiz-answer-btn.answered {
    cursor: default;
    opacity: 0.7;
}

.quiz-answer-btn.correct.answered,
.quiz-answer-btn.incorrect.answered {
    opacity: 1;
}

.quiz-answer-btn:disabled {
    cursor: default;
    pointer-events: none;
}

.quiz-feedback {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--secondary-color);
}

.quiz-feedback p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 15px;
    color: var(--text-muted);
}

.quiz-next-btn {
    padding: 10px 24px;
    background: var(--secondary-color);
    border: none;
    border-radius: 2px;
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.quiz-next-btn:hover {
    background: var(--primary-color);
}

.quiz-results {
    background: var(--surface-color);
    padding: 40px;
    border-radius: 2px;
    text-align: center;
    margin-bottom: 15px;
}

.quiz-results h2 {
    margin-bottom: 20px;
}

.quiz-results-score {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.quiz-results-score .result-percent {
    color: var(--primary-color);
}

.quiz-results-score.excellent .result-percent { color: var(--religion-color); }
.quiz-results-score.good .result-percent { color: #c47d10; }
.quiz-results-score.poor .result-percent { color: var(--primary-color); }

.quiz-results-breakdown {
    margin: 20px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.quiz-history {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 2px;
}

.quiz-history h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.quiz-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-color);
    border-radius: 2px;
    font-size: 0.85rem;
}

.quiz-history-date {
    color: var(--text-muted);
}

.quiz-history-score {
    font-weight: 600;
}

.quiz-history-score.excellent { color: var(--religion-color); }
.quiz-history-score.good { color: #c47d10; }
.quiz-history-score.poor { color: var(--primary-color); }

.no-quiz-history {
    color: var(--text-muted);
    text-align: center;
    padding: 15px;
    font-size: 0.85rem;
}

/* ========================================
   TAKEAWAYS VIEW
   ======================================== */
.takeaways-view {
    padding: 0;
}

.takeaways-container {
    max-width: 800px;
    margin: 0 auto;
}

.takeaways-header {
    margin-bottom: 20px;
}

.takeaways-header h2 {
    margin-bottom: 5px;
}

.takeaways-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.takeaway-editor {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 2px;
    margin-bottom: 20px;
}

.takeaway-editor textarea {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-color);
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.5;
}

.takeaway-editor textarea:focus {
    border-color: var(--primary-color);
}

.takeaway-editor textarea::placeholder {
    color: var(--text-muted);
}

.takeaway-editor-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.takeaway-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.takeaway-tags label {
    color: var(--text-muted);
}

.takeaway-tags select {
    padding: 6px 10px;
    background: var(--bg-color);
    border: 1px solid var(--secondary-color);
    color: var(--text-color);
    border-radius: 2px;
    font-size: 0.85rem;
    max-width: 250px;
}

.takeaway-add-btn {
    padding: 10px 24px;
    background: var(--primary-color);
    border: none;
    border-radius: 2px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
    font-weight: 500;
}

.takeaway-add-btn:hover {
    opacity: 0.9;
}

.takeaways-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.takeaway-item {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 2px;
    border-left: 4px solid var(--primary-color);
    position: relative;
}

.takeaway-item .takeaway-text {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 10px;
    white-space: pre-wrap;
}

.takeaway-item .takeaway-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.takeaway-entity-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--secondary-color);
    border-radius: 2px;
    font-size: 0.75rem;
    color: var(--text-color);
}

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

.takeaway-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 2px;
    transition: all 0.2s;
}

.takeaway-actions button:hover {
    color: var(--text-color);
    background: var(--secondary-color);
}

.takeaway-actions .delete-takeaway:hover {
    color: var(--primary-color);
}

.takeaway-edit-area {
    width: 100%;
    padding: 10px;
    background: var(--bg-color);
    border: 1px solid var(--secondary-color);
    border-radius: 2px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 10px;
    line-height: 1.5;
}

.takeaway-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.takeaway-edit-actions button {
    padding: 6px 16px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.85rem;
}

.takeaway-save-btn {
    background: var(--primary-color);
    color: white;
}

.takeaway-cancel-btn {
    background: var(--secondary-color);
    color: var(--text-color);
}

.no-takeaways {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--surface-color);
    border-radius: 2px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .event-detail-panel {
        width: 100%;
        right: -100%;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .region-label {
        width: 80px;
        min-width: 80px;
        font-size: 0.65rem;
    }

    /* Map responsive */
    .map-main {
        flex-direction: column;
    }

    .map-sidebar {
        width: 100%;
        max-height: 150px;
    }

    .map-time-control {
        flex-direction: column;
        align-items: stretch;
    }

    .map-year-display {
        order: -1;
    }

    .view-tabs {
        gap: 5px;
    }

    .view-tab {
        padding: 8px 20px;
        font-size: 0.8rem;
    }

    /* Quiz responsive */
    .quiz-header {
        flex-direction: column;
    }

    .quiz-settings {
        flex-direction: column;
        align-items: stretch;
    }

    .quiz-welcome {
        padding: 25px;
    }

    .quiz-stats {
        flex-direction: column;
        gap: 15px;
    }

    /* Takeaways responsive */
    .takeaway-editor-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .takeaway-tags select {
        max-width: 100%;
    }

    .empire-card {
        flex-direction: column;
        gap: 10px;
    }

    .empire-rank {
        min-width: auto;
    }

    .empire-actions-col {
        align-self: stretch;
    }

    .empire-actions-col button {
        width: 100%;
    }
}

/* ========================================
   EMPIRES VIEW
   ======================================== */
.empires-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.empires-header {
    text-align: center;
    margin-bottom: 30px;
}

.empires-header h2 {
    font-size: 1.6rem;
    color: var(--text-color);
    margin-bottom: 8px;
}

.empires-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.empires-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empire-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: var(--surface-color);
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    padding: 16px;
    transition: box-shadow 0.2s;
}

.empire-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.empire-card.linked {
    border-left: 4px solid var(--state-color);
}

.empire-card.unlinked {
    border-left: 4px solid var(--text-muted);
}

.empire-rank {
    min-width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    background: var(--bg-color);
    border-radius: 50%;
    flex-shrink: 0;
}

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

.empire-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.empire-name {
    font-size: 1.1rem;
    color: var(--text-color);
    margin: 0;
}

.empire-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.linked-badge {
    background: var(--state-color);
    color: white;
}

.unlinked-badge {
    background: var(--secondary-color);
    color: var(--text-muted);
}

.empire-dates-line {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.empire-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 6px;
}

.empire-stat {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.stat-value {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empire-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.3;
}

.empire-actions-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
}

.empire-create-btn {
    background: var(--state-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.empire-create-btn:hover {
    opacity: 0.85;
}

.empire-view-btn {
    background: transparent;
    color: var(--state-color);
    border: 1px solid var(--state-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.empire-view-btn:hover {
    background: var(--state-color);
    color: white;
}

.empires-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
    pointer-events: none;
}

.empires-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.highlight-flash {
    animation: flash-highlight 2s ease-out;
}

@keyframes flash-highlight {
    0%, 30% { outline: 3px solid var(--state-color); outline-offset: 2px; }
    100% { outline: 3px solid transparent; outline-offset: 2px; }
}
