:root {
    /* Auto Light/Dark */
    color-scheme: light dark;

    /* Light Theme (Default) */
    --bg-color: #ffffff;
    --surface-color: #ffffff;
    --surface-contrast: #f0f0f0;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border-color: #000000;
    --card-shadow-color: #000000;
    --btn-shadow-color: #000000;
    --alert-bg: #f5f5f5;
    --alert-card-bg: #fcfcfc;
    --alert-card-hover: #f0f0f0;

    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --surface-color: #2a2a2a;
    --surface-contrast: #3a3a3a;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --border-color: #ffffff;
    --card-shadow-color: #555555;
    --btn-shadow-color: #555555;
    --alert-bg: #333333;
    --alert-card-bg: #3a3a3a;
    --alert-card-hover: #4a4a4a;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    min-height: 100vh;
}

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

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
}

.toolbar-group {
    display: flex;
    gap: 12px;
}

.icon-btn,
.text-btn {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    padding: 8px 12px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
    box-shadow: 4px 4px 0px 0px var(--btn-shadow-color);
    color: var(--text-primary);
}

.icon-btn:active,
.text-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px 0px var(--btn-shadow-color);
}

.icon-btn.active {
    background: var(--surface-contrast);
}

.icon-btn.seamless {
    border: none;
    box-shadow: none;
    background: transparent;
}

.icon-btn.seamless:active {
    transform: none;
    box-shadow: none;
}


/* Main Card */
.card {
    background: var(--surface-color);
    border: 3px solid var(--border-color);
    padding: 32px;
    box-shadow: 8px 8px 0px 0px var(--card-shadow-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title h1 {
    font-size: 24px;
    font-weight: 700;
}

.refresh-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 14px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    margin-left: 36px;
    /* align with text start */
}

/* Alert Box */
.alert-box {
    background: var(--alert-bg);
    border: 1px solid var(--border-color);
    padding: 16px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 32px;
}

/* Timer Displays */
.main-counter,
.secondary-counter,
.stats-counter {
    text-align: center;
    padding: 24px 0;
}

.timer-display {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 48px;
    letter-spacing: -1px;
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.timer-display.small {
    font-size: 28px;
}

.time-unit small {
    font-size: 0.6em;
    margin-left: 2px;
}

.stat-number {
    font-family: var(--font-mono);
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
}

.timer-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.divider {
    border: none;
    border-top: 1px solid var(--text-secondary);
    margin: 8px 0;
    opacity: 0.2;
}

/* Details Section */
.details-section {
    margin-top: 24px;
}

.details-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-item label {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 4px;
}

.detail-item .value {
    font-weight: 600;
    font-size: 15px;
}

.detail-item.full-width {
    grid-column: span 2;
}

.value.mono {
    font-family: var(--font-mono);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface-color);
    padding: 24px;
    border: 3px solid var(--border-color);
    box-shadow: 12px 12px 0px 0px var(--card-shadow-color);
    max-width: 900px;
    width: 95%;
    color: var(--text-primary);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

#calendar-year-label {
    font-family: var(--font-mono);
    font-weight: 700;
}

#close-modal {
    font-size: 24px;
    padding: 0;
    width: 32px;
    height: 32px;
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    /* 7 days a week */
    grid-auto-flow: column;
    /* Fill columns (weeks) first */
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.calendar-day {
    width: 12px;
    height: 12px;
    background-color: #ebedf0;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.calendar-day:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--border-color);
    color: var(--bg-color);
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    margin-bottom: 5px;
}

.calendar-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

/* List Modal Specifics */
.list-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.count-tag {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-left: 8px;
    font-weight: 500;
}

.filters-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

.filter-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

.filter-row.actions {
    justify-content: space-between;
}

.filter-row.actions .icon-btn {
    flex: 1;
    font-size: 13px;
    box-shadow: 3px 3px 0px 0px var(--btn-shadow-color);
}

.filter-row.actions .icon-btn:active {
    box-shadow: 1px 1px 0px 0px var(--btn-shadow-color);
    transform: translate(2px, 2px);
}

.text-with-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.neo-select,
.neo-input {
    width: 100%;
    padding: 10px 12px;
    font-family: var(--font-main);
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: 0;
    background: var(--surface-color);
    box-shadow: 3px 3px 0px 0px var(--card-shadow-color);
    color: var(--text-primary);
}

.neo-select:focus,
.neo-input:focus {
    outline: none;
    box-shadow: 3px 3px 0px 0px var(--border-color);
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

#location-search {
    padding-left: 36px;
}

.alerts-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
    min-height: 200px;
}

.alert-card {
    border: 1px solid var(--surface-contrast);
    padding: 16px;
    border-left: 4px solid var(--border-color);
    background: var(--alert-card-bg);
    transition: background 0.2s;
}

.alert-card:hover {
    background: var(--alert-card-hover);
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.alert-location {
    font-weight: 700;
    font-size: 16px;
}

.alert-time-ago {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.alert-area {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.alert-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    align-items: center;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.load-more {
    text-align: center;
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--surface-contrast);
}

.load-more button {
    width: 100%;
}

/* Heatmap Modal Specifics */
.heatmap-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    height: 80vh;
    /* Fixed height for map */
}

.map-container {
    flex: 1;
    width: 100%;
    background: #ebedf0;
    border: 2px solid var(--border-color);
    box-shadow: 4px 4px 0px 0px var(--card-shadow-color);
    margin-bottom: 16px;
    z-index: 1;
    /* Ensure map is below custom controls if any */
}

.map-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--surface-color);
    padding: 8px;
    border: 2px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
}

.legend-gradient {
    width: 150px;
    height: 12px;
    background: linear-gradient(to right, blue, cyan, lime, yellow, red);
    border: 1px solid var(--border-color);
    border-radius: 2px;
}