@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,400;0,700;1,100;1,400;1,700&display=swap');

:root {
    --primary: #4570ff;
    --primary-hover: #ffc400;
    --accent: #ffc400;
    --text: whitesmoke;
    --text-muted: #666;
    --text-light: #444;
    --bg: #1d1d1d;
    --bg-secondary: #1a1a1a;
    --surface: #222;
    --surface-hover: #282828;
    --border: #2e2e2e;
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.4);
    --shadow: 0 4px 12px rgb(0 0 0 / 0.3);
}

* { box-sizing: border-box; }

html, body {
    background-color: var(--bg);
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    line-height: 1.1;
    -webkit-font-smoothing: antialiased;
    color: var(--text);
    margin: 0;
    padding: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover { color: var(--accent); }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.header-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 1.5rem;
    height: 44px;
    gap: 1rem;
}

.logo {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text);
    justify-self: start;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    justify-self: center;
}

#searchBar {
    padding: 0 0.85rem;
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 10px;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    outline: none;
    height: 30px;
    width: 180px;
}

#searchBar:focus { background: var(--surface); }
#searchBar::placeholder { color: var(--text-light); }

#sortOptions,
#filterOptions {
    padding: 0 0.65rem;
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    cursor: pointer;
    outline: none;
    height: 30px;
    -webkit-appearance: none;
    appearance: none;
}

#filterOptions { border-right: 0; }

#sortOptions:hover,
#filterOptions:hover {
    background: var(--surface);
    color: var(--text);
}

#sortOptions option,
#filterOptions option {
    background: var(--bg);
    color: var(--text);
}

.control-buttons {
    display: flex;
    gap: 0;
    justify-self: end;
    border: 1px solid var(--border);
}

.control-buttons button {
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.control-buttons button:last-child { border-right: 0; }
.control-buttons button:hover { background: var(--surface); }

.control-button { box-shadow: none !important; transform: none !important; }
.control-button:active { background: var(--surface-hover) !important; }

.control-button img {
    width: 13px;
    height: 13px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.control-button:hover img { opacity: 1; transform: none; }

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem 7rem;
}

details summary {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', monospace;
    cursor: pointer;
    padding: 0.3rem 0;
    list-style: none;
    user-select: none;
    margin-bottom: 2.5rem;
}

details summary::-webkit-details-marker { display: none; }
details summary::before { content: '+ '; color: var(--primary); }
details[open] summary::before { content: '- '; color: var(--accent); }

#zoneCount {
    margin: 0 0 2rem;
    font-size: 9px;
    color: var(--text-light);
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#zoneCount::before { content: '//'; color: var(--primary); }

#container,
#featuredZones {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 3rem 2rem;
    background: transparent;
}

.zone-item {
    background: transparent;
    border: 0;
    overflow: visible;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.zone-item:hover { transform: none; box-shadow: none; }
.zone-item::before { display: none; }

.zone-item-img-wrap {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    position: relative;
    background: var(--surface);
}

.zone-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s, transform 0.4s cubic-bezier(0.4,0,0.2,1);
    filter: none;
    background: var(--surface);
}

.zone-item:hover img {
    opacity: 0.85;
    transform: scale(1.03);
    filter: none;
}

.zone-item button {
    background: transparent;
    color: var(--text-muted);
    border: 0;
    padding: 0.6rem 0 0;
    cursor: pointer;
    font-weight: 400;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    font-family: 'IBM Plex Mono', monospace;
    transition: color 0.15s;
    min-height: unset;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.5;
}

.zone-item:hover button { color: var(--primary); }

#zoneViewer {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.zone-header {
    background: var(--bg-secondary);
    color: var(--text);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    border-bottom: 1px solid var(--border);
}

.zone-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#zoneName {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: 'IBM Plex Mono', monospace;
    margin: 0;
    line-height: 1;
    color: var(--text);
}

#zoneId { display: none; }

#zoneAuthor {
    font-size: 10px;
    color: var(--primary);
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

#zoneAuthor:hover { color: var(--accent); }

.info-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--text-light);
    transition: color 0.15s;
}

.info-button:hover { color: var(--primary); transform: none; background: transparent; }
.info-button:active { transform: none; }
.info-button svg { display: block; }

.zone-controls {
    display: flex;
    border: 1px solid var(--border);
}

.zone-controls button {
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0 0.9rem;
    height: 30px;
    cursor: pointer;
    font-size: 10px;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    font-weight: 400;
    transition: color 0.15s, background 0.15s;
}

.zone-controls button:last-child { border-right: 0; }
.zone-controls button:hover { background: var(--surface); color: var(--primary); transform: none; box-shadow: none; }

#zoneFrame { flex-grow: 1; border: none; width: 100%; height: 100%; }

#popupOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}

.popup {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 460px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.popup-header {
    background: var(--bg-secondary);
    color: var(--text);
    padding: 0.75rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

#popupTitle {
    margin: 0;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: 'IBM Plex Mono', monospace;
}

#popupClose {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    font-family: 'IBM Plex Mono', monospace;
    line-height: 1;
    margin-left: auto;
}

#popupClose:hover { color: var(--accent); background: var(--surface-hover); transform: none; }

#popupBody {
    padding: 1.5rem;
    overflow-y: auto;
    color: var(--text);
    font-size: 11px;
    line-height: 1.6;
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    letter-spacing: -0.01em;
}

#popupBody input[type="text"],
#popupBody input[type="file"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 11px;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.15s;
}

#popupBody input[type="text"]:focus,
#popupBody input[type="file"]:focus {
    border-color: var(--primary);
    box-shadow: none;
    transform: none;
}

.settings-button {
    background: var(--primary);
    color: var(--bg);
    border: 0;
    padding: 0.6rem 1.25rem;
    font-size: 10px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s;
    min-width: 200px;
    width: 100%;
    text-align: center;
}

.settings-button:hover { background: var(--accent); color: var(--bg); transform: none; box-shadow: none; }
.settings-button:active { opacity: 0.85; }

footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 0 1.5rem;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-links {
    display: flex;
    justify-content: center;
}

.footer-links a {
    color: var(--text-light);
    font-size: 9px;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: color 0.15s;
    padding: 0.3rem 0.9rem;
    border-right: 1px solid var(--border);
}

.footer-links a:first-child { border-left: 1px solid var(--border); }
.footer-links a:hover { color: var(--accent); }

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

::selection { background: var(--primary); color: var(--bg); }

@media (max-width: 900px) {
    .header-content {
        grid-template-columns: auto 1fr auto;
        padding: 0 1rem;
    }

    .search-container { justify-self: stretch; }
    #searchBar { width: 100%; flex: 1; }
}

@media (max-width: 768px) {
    .header-content {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        height: auto;
        padding: 0.6rem 1rem;
        gap: 0.5rem;
    }

    .search-container {
        grid-column: 1 / -1;
        justify-self: stretch;
    }

    .control-buttons { justify-self: end; }

    main { padding: 2rem 1rem 6rem; }

    #container,
    #featuredZones {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 2rem 1.25rem;
    }

    .zone-header {
        padding: 0.6rem 1rem;
        height: auto;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .zone-controls { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    #container,
    #featuredZones {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem 1rem;
    }
}