/* Mobile-first PoGO Search Filter Helper */
:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --accent: #0f3460;
    --highlight: #e94560;
    --text: #eee;
    --text-muted: #aaa;
    --touch-min: 44px;
    --radius: 8px;
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    color: var(--text);
    background: var(--bg);
    padding-bottom: calc(60px + var(--safe-bottom));
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Sticky output bar */
.output-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px 12px 8px;
    padding-top: calc(12px + var(--safe-top));
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
}

.output-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

#output {
    flex: 1;
    min-height: var(--touch-min);
    padding: 10px 12px;
    font-size: 14px;
    font-family: ui-monospace, monospace;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

#output::placeholder {
    color: var(--text-muted);
}

.copy-btn {
    min-width: 72px;
    min-height: var(--touch-min);
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--highlight);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.copy-btn:hover,
.copy-btn:focus-visible {
    filter: brightness(1.1);
}

.copy-btn:active {
    transform: scale(0.98);
}

.copy-feedback {
    margin: 6px 0 0;
    font-size: 14px;
    color: #7bed9f;
}

.copy-feedback[hidden] {
    display: none;
}

/* Long-press tooltip (mobile-friendly) */
.tooltip {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    max-width: min(280px, calc(100vw - 24px));
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}

.tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* Main content */
.main {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 12px;
}

.main h2 {
    font-size: 1.1rem;
    margin: 0 0 10px;
    color: var(--text-muted);
}

/* Operator row */
.operator-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.operator-label {
    font-size: 14px;
    color: var(--text-muted);
}

.operator-toggle {
    display: flex;
    gap: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--accent);
}

.op-btn {
    min-height: var(--touch-min);
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.op-btn + .op-btn {
    border-left: 1px solid var(--accent);
}

.op-btn.active {
    background: var(--accent);
    color: #fff;
}

.op-btn:hover:not(.active),
.op-btn:focus-visible:not(.active) {
    background: var(--accent);
    color: var(--text);
}

/* Prefix toggles */
.prefix-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 16px;
}

.prefix-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
}

.prefix-option input {
    width: 20px;
    height: 20px;
    accent-color: var(--highlight);
}

/* Custom term */
.custom-term {
    margin-bottom: 20px;
}

.custom-term label {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.custom-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

#custom-input {
    flex: 1;
    min-height: var(--touch-min);
    padding: 10px 12px;
    font-size: 16px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

.add-custom-btn {
    min-width: 64px;
    min-height: var(--touch-min);
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.add-custom-btn:hover,
.add-custom-btn:focus-visible {
    filter: brightness(1.15);
}

.custom-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* Selected list */
.selected-section {
    margin-bottom: 20px;
}

.selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 24px;
}

.selected-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--touch-min);
    padding: 8px 12px;
    font-size: 13px;
    font-family: ui-monospace, monospace;
    color: var(--text);
    background: var(--accent);
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.1);
}

.selected-chip .chip-term {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-chip .chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: var(--text);
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.selected-chip .chip-remove:hover,
.selected-chip .chip-remove:focus-visible {
    background: rgba(255,255,255,0.2);
}

/* Filter categories (accordion) */
.filter-categories {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.category {
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}

.category-header {
    width: 100%;
    min-height: var(--touch-min);
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    color: var(--text);
    background: var(--surface);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

.category-header:hover,
.category-header:focus-visible {
    background: var(--accent);
}

.category-header .chevron {
    font-size: 12px;
    transition: transform 0.2s;
}

.category.open .category-header .chevron {
    transform: rotate(180deg);
}

.category-body {
    display: none;
    padding: 10px 12px;
    background: var(--bg);
    border-top: 1px solid var(--accent);
}

.category.open .category-body {
    display: block;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    min-height: var(--touch-min);
    padding: 10px 14px;
    font-size: 13px;
    font-family: ui-monospace, monospace;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.filter-chip:hover,
.filter-chip:focus-visible {
    border-color: var(--highlight);
    color: var(--highlight);
}

.filter-chip.needs-value {
    border-style: dashed;
}

.filter-chip.needs-value::after {
    content: "…";
}

/* Range input modal / inline */
.range-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.range-row input {
    flex: 1;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: ui-monospace, monospace;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

.range-row button {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 14px;
    color: #fff;
    background: var(--highlight);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

/* Help section */
.help-section {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--accent);
}

.help-link {
    margin: 0 0 12px;
    font-size: 14px;
}

.help-link a {
    color: var(--highlight);
    text-decoration: none;
}

.help-link a:hover,
.help-link a:focus {
    text-decoration: underline;
}

.help-list {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.help-list li {
    margin-bottom: 8px;
}

.help-list code {
    font-size: 12px;
    padding: 2px 6px;
    background: var(--surface);
    border-radius: 4px;
}

/* Fixed bottom bar: AND/OR + Exclude so you can swap while scrolling */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 10px 12px;
    padding-bottom: calc(10px + var(--safe-bottom));
    background: var(--surface);
    border-top: 2px solid var(--accent);
}

.bottom-bar-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.bottom-bar-label {
    font-size: 14px;
    color: var(--text-muted);
}

.bottom-bar-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-family: ui-monospace, monospace;
    color: var(--text);
    cursor: pointer;
}

.bottom-bar-option input {
    width: 20px;
    height: 20px;
    accent-color: var(--highlight);
}

.bottom-bar .op-btn {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 13px;
}

@media (min-width: 480px) {
    .main {
        padding: 20px 16px;
    }
    .output-bar {
        padding: 14px 16px 10px;
        padding-top: calc(14px + var(--safe-top));
    }
    #output {
        font-size: 15px;
    }
    .bottom-bar-inner {
        padding: 0 4px;
    }
}

/* Info page (filter reference) */
.info-page {
    padding-bottom: 24px;
}

.info-header {
    padding: 16px 12px;
    padding-top: calc(16px + var(--safe-top));
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
}

.info-back {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--highlight);
    text-decoration: none;
}

.info-back:hover,
.info-back:focus {
    text-decoration: underline;
}

.info-header h1 {
    margin: 0 0 10px;
    font-size: 1.35rem;
    color: var(--text);
}

.info-intro {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.45;
}

.info-intro code {
    padding: 2px 6px;
    font-size: 13px;
    background: var(--bg);
    border-radius: 4px;
}

.info-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 12px;
}

.info-section {
    margin-bottom: 24px;
}

.info-section h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
    color: var(--highlight);
}

.info-dl {
    margin: 0;
    padding: 0;
}

.info-dl dt {
    margin-top: 12px;
    font-size: 14px;
    font-family: ui-monospace, monospace;
    color: var(--text);
}

.info-dl dt:first-child {
    margin-top: 0;
}

.info-dl dt code {
    padding: 2px 6px;
    font-size: 13px;
    background: var(--surface);
    border-radius: 4px;
}

.info-dl dd {
    margin: 4px 0 0 12px;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.4;
}

.info-dl dd code {
    font-size: 12px;
    padding: 1px 4px;
    background: var(--surface);
    border-radius: 3px;
}

.info-footer {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 12px;
    border-top: 1px solid var(--accent);
}

.info-back-btn {
    display: inline-block;
    min-height: var(--touch-min);
    padding: 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--highlight);
    text-decoration: none;
}

.info-back-btn:hover,
.info-back-btn:focus {
    text-decoration: underline;
}
