/* Area52 — Mobile-first domain browser (Light theme) */
:root {
    --bg: #ffffff;
    --surface: #f5f5f7;
    --surface-hover: #ebebed;
    --border: #e0e0e5;
    --text: #1a1a2e;
    --text-dim: #6b6b80;
    --accent: #6366f1;
    --accent-light: #eef0ff;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --premium: #d97706;
    --premium-bg: rgba(217, 119, 6, 0.1);
    --standard: #6366f1;
    --standard-bg: rgba(99, 102, 241, 0.1);
    --economy: #059669;
    --economy-bg: rgba(5, 150, 105, 0.1);
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}

header h1 span {
    color: var(--accent);
}

/* Search */
#search-bar {
    position: relative;
}

#search-bar input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 16px;
    outline: none;
    transition: all 0.2s;
}

#search-bar input::placeholder {
    color: var(--text-dim);
}

#search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg);
}

/* Mode toggle (Simple / Advanced) */
#mode-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 8px;
}

#mode-toggle span {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 500;
}

#mode-toggle span.active {
    color: var(--accent);
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    -webkit-tap-highlight-color: transparent;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Advanced filters panel */
#advanced-filters {
    display: none;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

body.mode-advanced #advanced-filters {
    display: block;
}

.adv-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.adv-row:last-child {
    margin-bottom: 0;
}

.adv-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 52px;
    flex-shrink: 0;
}

.adv-select {
    flex: 1;
    padding: 7px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b80' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.adv-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.adv-input {
    width: 60px;
    padding: 7px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    text-align: center;
}

.adv-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.adv-input-full {
    flex: 1;
    padding: 7px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.adv-input-full:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.adv-sep {
    font-size: 12px;
    color: var(--text-dim);
}

/* SLD preview */
#sld-preview {
    padding: 8px 16px 0;
    font-size: 13px;
    color: var(--text-dim);
    display: none;
}

#sld-preview .sld-term {
    font-weight: 600;
    color: var(--accent);
}

/* Type filters (All / Text / Emoji / Kanji) */
#type-filters {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.type-pill {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

.type-pill:active,
.type-pill.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Categories */
#categories {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

#categories::-webkit-scrollbar { display: none; }

.cat-pill {
    flex-shrink: 0;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.cat-pill:active,
.cat-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.cat-pill .cat-count {
    font-size: 11px;
    opacity: 0.6;
    margin-left: 3px;
}

/* Domain cards */
main {
    padding: 0;
    display: grid;
    gap: 0;
    width: 100%;
    overflow: hidden;
}

.domain-card {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
}

.domain-card:active {
    background: var(--surface);
}

.domain-card.selected {
    background: var(--accent-light);
}

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

.domain-name {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.2px;
}

.domain-name .sld-part {
    color: var(--text);
}

.domain-name .tld-part {
    color: var(--accent);
}

.domain-desc {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.domain-meta {
    display: flex;
    gap: 6px;
    margin-top: 5px;
    flex-wrap: wrap;
}

.domain-badge {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-premium { background: var(--premium-bg); color: var(--premium); }
.badge-standard { background: var(--standard-bg); color: var(--standard); }
.badge-economy { background: var(--economy-bg); color: var(--economy); }
.badge-emoji { background: var(--surface); color: var(--text-dim); }
.badge-kanji { background: var(--surface); color: var(--text-dim); }
.badge-hof { background: var(--premium-bg); color: var(--premium); }

.domain-choose {
    padding: 8px 14px;
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    min-height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.domain-choose:active,
.domain-choose.chosen {
    background: var(--accent);
    color: white;
}

/* Load more */
#load-more-wrap {
    padding: 12px 16px 24px;
    text-align: center;
}

#load-more {
    padding: 12px 32px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    max-width: 300px;
    box-shadow: var(--shadow-md);
    transition: opacity 0.2s;
}

#load-more:active {
    opacity: 0.8;
}

/* Selections bar (sticky bottom) */
#selections-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

#selections-bar span { font-size: 14px; color: var(--text-dim); font-weight: 500; }

#selections-bar button {
    padding: 10px 24px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* Overlays */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.overlay-content {
    background: var(--bg);
    width: 100%;
    max-height: 85dvh;
    border-radius: 16px 16px 0 0;
    padding: 24px 16px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--surface);
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Detail overlay */
.detail-emoji { font-size: 56px; text-align: center; margin: 12px 0; }
.detail-name { font-size: 26px; font-weight: 700; text-align: center; letter-spacing: -0.3px; }
.detail-desc { color: var(--text-dim); margin: 10px 0 16px; line-height: 1.5; text-align: center; font-size: 14px; }
.detail-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.detail-section { margin-top: 16px; }
.detail-section h3 { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; font-weight: 600; }
.detail-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-cat { padding: 5px 10px; background: var(--surface); border-radius: 8px; font-size: 13px; color: var(--text); }
.detail-choose {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

/* Selections list */
.selection-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.selection-item .domain-emoji { font-size: 22px; min-width: 32px; }
.selection-remove {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px;
}

/* Status message */
.status-msg {
    text-align: center;
    padding: 24px;
    color: var(--text-dim);
    font-size: 14px;
}

/* Bottom padding for selections bar */
body.has-selections main { padding-bottom: 80px; }
body.has-selections #load-more-wrap { padding-bottom: 80px; }

/* ========================================================================
   DESKTOP STYLES
   ======================================================================== */

@media (min-width: 768px) {
    body {
        background: var(--surface);
    }

    header {
        max-width: 1100px;
        margin: 0 auto;
        padding: 16px 24px;
        border-bottom: none;
        border-radius: 0 0 16px 16px;
        box-shadow: var(--shadow);
    }

    header h1 {
        font-size: 28px;
        margin-bottom: 12px;
    }

    #search-bar input {
        font-size: 17px;
        padding: 14px 20px;
    }

    /* Advanced filters — horizontal layout */
    #advanced-filters {
        max-width: 1100px;
        margin: 0 auto;
        padding: 12px 24px;
        display: none;
        border-bottom: none;
    }
    body.mode-advanced #advanced-filters {
        display: flex;
        gap: 16px;
        flex-wrap: wrap;
        align-items: center;
    }
    body.mode-advanced #advanced-filters .adv-row {
        margin-bottom: 0;
    }

    /* Type filter tabs */
    #type-filters {
        max-width: 1100px;
        margin: 0 auto;
        border-bottom: none;
        padding: 4px 0;
    }

    .type-pill {
        flex: none;
        padding: 10px 24px;
    }

    /* Categories — centered with wrapping */
    #categories {
        max-width: 1100px;
        margin: 0 auto;
        flex-wrap: wrap;
        justify-content: center;
        padding: 12px 24px;
        border-bottom: none;
    }

    /* Domain cards — 2-column grid */
    main {
        max-width: 1100px;
        margin: 0 auto;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1px;
        background: var(--border);
        border-radius: 12px;
        overflow: hidden;
        box-shadow: var(--shadow);
    }

    .domain-card {
        padding: 14px 20px;
        border-bottom: none;
        transition: background 0.15s;
    }

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

    .domain-name {
        font-size: 17px;
    }

    .domain-desc {
        font-size: 13px;
    }

    /* Load more */
    #load-more-wrap {
        max-width: 1100px;
        margin: 0 auto;
        padding: 20px 24px 32px;
    }

    #load-more {
        max-width: 240px;
    }

    /* Selections bar — centered */
    #selections-bar {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px 12px 0 0;
        right: auto;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    }

    /* Overlays — centered modal instead of bottom sheet */
    .overlay {
        align-items: center;
    }

    .overlay-content {
        max-width: 600px;
        max-height: 80vh;
        border-radius: 16px;
        box-shadow: 0 16px 48px rgba(0,0,0,0.15);
    }

    .detail-emoji { font-size: 64px; }
    .detail-name { font-size: 30px; }
}

@media (min-width: 1024px) {
    /* 3-column grid on wide screens */
    main {
        grid-template-columns: 1fr 1fr 1fr;
    }

    header {
        padding: 20px 32px;
    }

    header h1 {
        font-size: 32px;
    }

    #search-bar input {
        max-width: 600px;
        margin: 0 auto;
        display: block;
    }

    #mode-toggle {
        justify-content: center;
    }
}
