:root {
    --bg-color: #0f1115;
    --surface-color: #1a1d24;
    --surface-hover: #252932;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #2e3340;
    --error-color: #ef4444;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* View Management */
.view {
    display: none;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.view.active { display: flex; }

/* Typography */
h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 0.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; font-weight: 600; margin-bottom: 1rem; }
p { color: var(--text-muted); }

/* Landing Layout */
.landing-container { width: 100%; max-width: 480px; }
.landing-header { text-align: center; margin-bottom: 2.5rem; }
.selection-card {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Forms & Inputs */
.form-group { margin-bottom: 1.5rem; position: relative; }
label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-muted); }

input[type="text"], select {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
    appearance: none;
}
input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
input[type="text"]:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Type Toggle */
.type-toggle { display: flex; gap: 10px; }
.radio-label { flex: 1; cursor: pointer; }
.radio-label input { display: none; }
.toggle-btn {
    display: block;
    text-align: center;
    padding: 10px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
}
.radio-label input:checked + .toggle-btn {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Custom Icons Wrapper */
.input-wrapper, .select-wrapper { position: relative; }
.search-icon, .chevron-icon {
    position: absolute;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-icon { left: 14px; top: 50%; transform: translateY(-50%); }
.input-wrapper input { padding-left: 44px; }
.chevron-icon { right: 14px; top: 50%; transform: translateY(-50%); }

/* Searchable Dropdown */
.dropdown-container { position: relative; }
.dropdown-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    z-index: 50;
    list-style: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.dropdown-list[hidden] { display: none; }
.dropdown-list li {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.1s;
    min-height: 44px; /* Touch target size */
}
.dropdown-list li:hover, .dropdown-list li.active { background-color: var(--surface-hover); }

/* Buttons */
.primary-btn, .secondary-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 48px; /* Touch target */
}
.primary-btn { background-color: var(--primary-color); color: white; }
.primary-btn:hover:not(:disabled) { background-color: var(--primary-hover); }
.primary-btn:disabled { background-color: var(--border-color); color: var(--text-muted); cursor: not-allowed; }
.secondary-btn { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-main); margin-top: 10px; }
.secondary-btn:hover { background-color: var(--surface-hover); }

/* Loading Screen */
.loader-container, .error-container {
    max-width: 500px;
    text-align: center;
    background-color: var(--surface-color);
    padding: 3rem 2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.attempt-counter {
    display: inline-block;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}
.loading-info p { margin-bottom: 1rem; font-size: 0.95rem; }
.loading-info .subtext { font-size: 0.85rem; opacity: 0.7; font-style: italic; }

/* Error Screen */
.error-icon { width: 64px; height: 64px; color: var(--error-color); margin-bottom: 1rem; }
.error-actions { display: flex; gap: 10px; margin-top: 2rem; }

/* PhotoSwipe Custom Header UI */
.custom-pswp-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0));
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 10000;
    color: white;
}
.header-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: var(--transition);
    min-height: 44px;
}
.header-btn:hover { background: rgba(255, 255, 255, 0.2); }
.header-btn svg { width: 18px; height: 18px; }
.header-title-group { text-align: center; flex: 1; margin: 0 15px; overflow: hidden; }
.header-pub-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; margin: 0; }
.header-pub-date { font-size: 0.75rem; color: rgba(255, 255, 255, 0.7); }

/* Overrides for PhotoSwipe native UI elements so our custom header acts clean */
.pswp__top-bar { display: none !important; }

/* Responsive adjustments */
@media (max-width: 600px) {
    .header-pub-title { font-size: 0.9rem; }
    .header-btn span { display: none; } /* hide text on mobile, keep icon */
    .header-btn .page-indicator { display: inline-block; } /* except page number */
    .custom-pswp-header { padding: 0 10px; }
}