:root {
   --primary: #111111;
   --primary-hover: #000000;
   --primary-light: rgba(0,0,0,0.08);
   --primary-lighter: rgba(0,0,0,0.04);
   --accent: #444444;
   --accent-light: rgba(68,68,68,0.12);
   --success: #333333;
   --warning: #555555;
   --text: #111111;
   --text-muted: #666666;
   --text-light: #999999;
   --bg: #f5f5f5;
   --bg-secondary: #eeeeee;
   --surface: #ffffff;
   --surface-hover: #f0f0f0;
   --border: #dddddd;
   --border-light: #eeeeee;
   --glass: rgba(255,255,255,0.85);
   --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.06);
   --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.10), 0 1px 2px -1px rgb(0 0 0 / 0.08);
   --shadow: 0 4px 12px -1px rgb(0 0 0 / 0.12), 0 2px 4px -2px rgb(0 0 0 / 0.08);
   --shadow-lg: 0 10px 24px -3px rgb(0 0 0 / 0.14), 0 4px 8px -4px rgb(0 0 0 / 0.10);
   --shadow-xl: 0 20px 40px -5px rgb(0 0 0 / 0.18), 0 8px 16px -6px rgb(0 0 0 / 0.12);
   --shadow-glow: 0 0 20px rgba(0,0,0,0.15);
   --radius: 10px;
   --radius-sm: 6px;
   --radius-lg: 14px;
   --radius-xl: 20px;
   --gradient-primary: linear-gradient(135deg, #111111 0%, #333333 100%);
   --gradient-surface: linear-gradient(135deg, #ffffff 0%, #f8f8f8 100%);
}

.dark-mode {
   --primary: #f0f0f0;
   --primary-hover: #ffffff;
   --primary-light: rgba(255,255,255,0.10);
   --primary-lighter: rgba(255,255,255,0.05);
   --accent: #aaaaaa;
   --accent-light: rgba(170,170,170,0.12);
   --success: #cccccc;
   --warning: #aaaaaa;
   --text: #f0f0f0;
   --text-muted: #aaaaaa;
   --text-light: #777777;
   --bg: #111111;
   --bg-secondary: #1a1a1a;
   --surface: #1e1e1e;
   --surface-hover: #2a2a2a;
   --border: #2e2e2e;
   --border-light: #3a3a3a;
   --glass: rgba(30,30,30,0.85);
   --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.4);
   --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.5);
   --shadow: 0 4px 12px -1px rgb(0 0 0 / 0.5);
   --shadow-lg: 0 10px 24px -3px rgb(0 0 0 / 0.6);
   --shadow-xl: 0 20px 40px -5px rgb(0 0 0 / 0.7);
   --shadow-glow: 0 0 20px rgba(255,255,255,0.08);
   --gradient-primary: linear-gradient(135deg, #1e1e1e 0%, #2e2e2e 100%);
   --gradient-surface: linear-gradient(135deg, #1e1e1e 0%, #252525 100%);
}

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

body {
   font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
   line-height: 1.6;
   background: var(--bg);
   color: var(--text);
   transition: background 0.3s ease, color 0.3s ease;
   -webkit-font-smoothing: antialiased;
}

/* ── AUTH OVERLAY ────────────────────────────────────────────── */
#authOverlay {
   position: fixed;
   inset: 0;
   background: #111111;
   z-index: 9999;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 1rem;
}

.auth-box {
   background: #ffffff;
   border-radius: 18px;
   width: 100%;
   max-width: 420px;
   overflow: hidden;
   box-shadow: 0 32px 80px rgba(0,0,0,0.45);
   animation: authAppear 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes authAppear {
   from { transform: translateY(30px) scale(0.96); opacity: 0; }
   to   { transform: translateY(0) scale(1); opacity: 1; }
}

.auth-brand {
   background: #111111;
   padding: 2rem 2rem 1.5rem;
   text-align: center;
}

.auth-brand-name {
   font-family: 'Bebas Neue', sans-serif;
   font-size: 2.6rem;
   letter-spacing: 0.04em;
   color: #ffffff;
   line-height: 1;
}

.auth-brand-sub {
   font-size: 12px;
   color: rgba(255,255,255,0.45);
   font-weight: 500;
   letter-spacing: 0.12em;
   text-transform: uppercase;
   margin-top: 0.35rem;
}

.auth-tabs {
   display: flex;
   border-bottom: 1px solid #e8e8e8;
   background: #fafafa;
}

.auth-tab {
   flex: 1;
   padding: 1rem;
   background: none;
   border: none;
   cursor: pointer;
   font-family: 'DM Sans', sans-serif;
   font-size: 14px;
   font-weight: 600;
   color: #999999;
   transition: all 0.2s ease;
   border-bottom: 2px solid transparent;
   margin-bottom: -1px;
}

.auth-tab.active {
   color: #111111;
   border-bottom-color: #111111;
   background: #ffffff;
}

.auth-form-wrap {
   padding: 2rem;
}

.auth-panel { display: none; }
.auth-panel.active { display: block; }

.auth-field {
   margin-bottom: 1rem;
}

.auth-field label {
   display: block;
   font-size: 12px;
   font-weight: 700;
   letter-spacing: 0.08em;
   text-transform: uppercase;
   color: #555555;
   margin-bottom: 0.4rem;
}

.auth-field input {
   width: 100%;
   padding: 0.8rem 1rem;
   border: 1.5px solid #e0e0e0;
   border-radius: 8px;
   font-family: 'DM Sans', sans-serif;
   font-size: 15px;
   color: #111111;
   background: #ffffff;
   outline: none;
   transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-field input:focus {
   border-color: #111111;
   box-shadow: 0 0 0 3px rgba(0,0,0,0.08);
}

.auth-error {
   background: #fff0f0;
   border: 1px solid #ffcccc;
   color: #cc0000;
   border-radius: 8px;
   padding: 0.65rem 1rem;
   font-size: 13px;
   font-weight: 500;
   margin-bottom: 1rem;
   display: none;
}

.auth-btn {
   width: 100%;
   padding: 0.9rem;
   background: #111111;
   color: #ffffff;
   border: none;
   border-radius: 8px;
   font-family: 'DM Sans', sans-serif;
   font-size: 15px;
   font-weight: 700;
   cursor: pointer;
   letter-spacing: 0.02em;
   transition: background 0.2s ease, transform 0.15s ease;
   margin-top: 0.5rem;
}

.auth-btn:hover { background: #333333; transform: translateY(-1px); }
.auth-btn:active { transform: translateY(0); }

.auth-footer-note {
   text-align: center;
   font-size: 12px;
   color: #aaaaaa;
   margin-top: 1.25rem;
}

/* ── HEADER ──────────────────────────────────────────────────── */
header {
   background: var(--gradient-primary);
   color: white;
   position: sticky;
   top: 0;
   z-index: 100;
   box-shadow: var(--shadow-lg);
}

.header-content {
   max-width: 1200px;
   margin: 0 auto;
   padding: 1rem 1.25rem;
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 1.25rem;
}

.logo {
   font-family: 'Bebas Neue', sans-serif;
   font-size: 2rem;
   letter-spacing: 0.06em;
   color: #ffffff;
   white-space: nowrap;
   line-height: 1;
}

.logo span {
   color: rgba(255,255,255,0.45);
   font-size: 0.6em;
   letter-spacing: 0.14em;
   display: block;
   font-family: 'DM Sans', sans-serif;
   font-weight: 500;
   text-transform: uppercase;
}

.search-container {
   display: flex;
   flex: 1;
   max-width: 480px;
   gap: 0.6rem;
}

#searchBar {
   flex: 1;
   padding: 0.75rem 1rem;
   border: 1.5px solid rgba(255,255,255,0.2);
   border-radius: var(--radius);
   background: rgba(255,255,255,0.1);

   color: white;
   font-family: 'DM Sans', sans-serif;
   font-size: 14px;
   outline: none;
   transition: all 0.25s ease;
}

#searchBar::placeholder { color: rgba(255,255,255,0.5); }
#searchBar:focus {
   background: rgba(255,255,255,0.18);
   border-color: rgba(255,255,255,0.5);
}

#sortOptions {
   padding: 0.75rem 0.9rem;
   border: 1.5px solid rgba(255,255,255,0.2);
   border-radius: var(--radius);
   background: rgba(255,255,255,0.1);
   color: rgba(255,255,255,0.85);
   font-family: 'DM Sans', sans-serif;
   font-size: 14px;
   cursor: pointer;
   outline: none;
   transition: all 0.25s ease;
}

#sortOptions:hover { background: rgba(255,255,255,0.18); }

#sortOptions option {
   background: #222;
   color: #fff;
}

.control-buttons { display: flex; gap: 0.5rem; align-items: center; }

#settings {
   background: rgba(255,255,255,0.12);
   border: 1.5px solid rgba(255,255,255,0.22);
   color: white;
   font-family: 'DM Sans', sans-serif;
   font-size: 13px;
   font-weight: 600;
   cursor: pointer;
   padding: 0.65rem 1.1rem;
   border-radius: var(--radius);
   transition: all 0.25s ease;
   letter-spacing: 0.02em;
}

#settings:hover { background: rgba(255,255,255,0.22); }

#userBadge {
   display: flex;
   align-items: center;
   gap: 0.5rem;
   background: rgba(255,255,255,0.1);
   border: 1.5px solid rgba(255,255,255,0.2);
   border-radius: var(--radius);
   padding: 0.5rem 0.9rem;
   font-size: 13px;
   font-weight: 600;
   color: rgba(255,255,255,0.85);
   cursor: pointer;
   transition: all 0.2s ease;
}

#userBadge:hover { background: rgba(255,255,255,0.18); }

#userBadge .avatar {
   width: 26px;
   height: 26px;
   border-radius: 50%;
   background: rgba(255,255,255,0.25);
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 12px;
   font-weight: 700;
   color: white;
   flex-shrink: 0;
}

/* ── MAIN ────────────────────────────────────────────────────── */
main {
   max-width: 1200px;
   margin: 0 auto;
   padding: 2rem 1.25rem 7rem;
}

details summary {
   font-family: 'Bebas Neue', sans-serif;
   font-size: 1.5rem;
   letter-spacing: 0.06em;
   cursor: pointer;
   color: var(--text);
   padding: 0.25rem 0;
   list-style: none;
   display: flex;
   align-items: center;
   gap: 0.5rem;
   user-select: none;
}

details summary::after {
   content: '↓';
   font-family: 'DM Sans', sans-serif;
   font-size: 0.9rem;
   color: var(--text-muted);
   transition: transform 0.2s ease;
}

details[open] summary::after { transform: rotate(180deg); }

details summary::-webkit-details-marker { display: none; }

.section-divider {
   height: 1px;
   background: var(--border);
   margin: 1.5rem 0;
}

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

/* ── ZONE CARD ───────────────────────────────────────────────── */
.zone-item {
   background: var(--surface);
   border: 1px solid var(--border);
   border-radius: var(--radius-lg);
   overflow: hidden;
   cursor: pointer;
   transition: transform 0.15s ease, box-shadow 0.15s ease;
   display: flex;
   flex-direction: column;
   box-shadow: var(--shadow-xs);
}

.zone-item:hover {
   transform: translateY(-3px);
   box-shadow: var(--shadow);
}

.zone-item img {
   width: 100%;
   aspect-ratio: 1;
   object-fit: cover;
   display: block;
   background: var(--border-light);
}

.zone-item button {
   background: transparent;
   color: var(--text);
   border: 0;
   padding: 1rem 0.9rem;
   cursor: pointer;
   font-family: 'DM Sans', sans-serif;
   font-weight: 600;
   font-size: 13px;
   line-height: 1.4;
   text-align: center;
   transition: color 0.2s ease;
   min-height: 62px;
   display: flex;
   align-items: center;
   justify-content: center;
}

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

/* ── ZONE VIEWER ─────────────────────────────────────────────── */
#zoneViewer {
   position: fixed;
   inset: 0;
   background: var(--bg);
   z-index: 1000;
   display: none;
   flex-direction: column;
   animation: slideInUp 0.28s cubic-bezier(0.4,0,0.2,1);
}

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

.zone-header {
   background: var(--gradient-primary);
   color: white;
   padding: 0.85rem 1.25rem;
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 1rem;
   box-shadow: var(--shadow);
}

.zone-title { flex: 1; min-width: 0; }

#zoneName {
   font-family: 'Bebas Neue', sans-serif;
   font-size: 1.4rem;
   letter-spacing: 0.05em;
   line-height: 1.2;
}

#zoneId { display: none; }

#zoneAuthor {
   font-size: 12px;
   color: rgba(255,255,255,0.6);
   text-decoration: none;
   font-weight: 500;
   transition: color 0.2s ease;
}

#zoneAuthor:hover { color: white; }

.zone-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.zone-controls button {
   background: rgba(255,255,255,0.1);
   border: 1px solid rgba(255,255,255,0.25);
   color: white;
   padding: 0.5rem 0.9rem;
   border-radius: var(--radius);
   cursor: pointer;
   font-family: 'DM Sans', sans-serif;
   font-size: 13px;
   font-weight: 600;
   transition: all 0.2s ease;
}

.zone-controls button:hover {
   background: rgba(255,255,255,0.22);
   transform: translateY(-1px);
}

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

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

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.popup {
   background: var(--surface);
   border-radius: var(--radius-lg);
   box-shadow: var(--shadow-xl);
   width: 100%;
   max-width: 500px;
   max-height: 80vh;
   overflow: hidden;
   display: flex;
   flex-direction: column;
   border: 1px solid var(--border);
   animation: popupIn 0.25s cubic-bezier(0.4,0,0.2,1);
}

@keyframes popupIn {
   from { transform: scale(0.92) translateY(16px); opacity: 0; }
   to   { transform: scale(1) translateY(0); opacity: 1; }
}

.popup-header {
   background: var(--gradient-primary);
   color: white;
   padding: 1.1rem 1.5rem;
   display: flex;
   justify-content: space-between;
   align-items: center;
}

#popupTitle {
   font-family: 'Bebas Neue', sans-serif;
   font-size: 1.4rem;
   letter-spacing: 0.05em;
}

#popupClose {
   background: rgba(255,255,255,0.12);
   border: 1px solid rgba(255,255,255,0.22);
   color: white;
   font-size: 1.1rem;
   cursor: pointer;
   padding: 0.4rem;
   border-radius: 6px;
   transition: all 0.2s ease;
   width: 32px;
   height: 32px;
   display: flex;
   align-items: center;
   justify-content: center;
   line-height: 1;
}

#popupClose:hover { background: rgba(255,255,255,0.22); }

#popupBody {
   padding: 1.5rem;
   overflow-y: auto;
   color: var(--text);
   font-family: 'DM Sans', sans-serif;
}

#popupBody input[type="text"],
#popupBody input[type="file"] {
   width: 100%;
   padding: 0.8rem 1rem;
   margin-bottom: 1rem;
   border: 1.5px solid var(--border);
   border-radius: var(--radius);
   background: var(--bg-secondary);
   color: var(--text);
   font-family: 'DM Sans', sans-serif;
   font-size: 14px;
   transition: all 0.2s ease;
   outline: none;
}

#popupBody input[type="text"]:focus {
   border-color: var(--primary);
   box-shadow: 0 0 0 3px var(--primary-light);
}

#settings-button {
   width: 100%;
   padding: 0.8rem 1rem;
   background: var(--gradient-primary);
   color: white;
   border: 0;
   border-radius: var(--radius);
   cursor: pointer;
   font-family: 'DM Sans', sans-serif;
   font-size: 14px;
   font-weight: 700;
   margin-bottom: 0.75rem;
   transition: all 0.2s ease;
   letter-spacing: 0.03em;
}

#settings-button:hover { opacity: 0.88; transform: translateY(-1px); }

/* ── FOOTER ──────────────────────────────────────────────────── */
footer {
   background: var(--surface);
   border-top: 1px solid var(--border);
   padding: 1rem 1.25rem;
   text-align: center;
   position: fixed;
   bottom: 0;
   left: 0;
   width: 100%;
   z-index: 100;
}

.footer-links {
   display: flex;
   justify-content: center;
   gap: 0.25rem;
   flex-wrap: wrap;
}

.footer-links a {
   color: var(--text-muted);
   text-decoration: none;
   font-weight: 600;
   font-size: 13px;
   transition: all 0.2s ease;
   padding: 0.4rem 0.8rem;
   border-radius: var(--radius);
   letter-spacing: 0.02em;
}

.footer-links a:hover {
   color: var(--text);
   background: var(--primary-light);
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
   .header-content { flex-wrap: wrap; padding: 0.9rem 1rem; gap: 0.75rem; }
   .search-container { width: 100%; max-width: none; order: 2; }
   .logo span { display: none; }
   #container, #featuredZones { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 1rem; }
}

@media (max-width: 480px) {
   #container, #featuredZones { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 0.85rem; }
}
