/* Palette, radii, controls and product containment follow Timur's Collections
   design system (prodx-apps-collections, pdx-239 and subsequent updates). */
:root {
    --bg: #fafafa;
    --fg: #0a0a0a;
    --card: #fff;
    --border: #e5e5e5;
    --border-strong: #d4d4d4;
    --primary: #ff3900;
    --primary-hover: #e63300;
    --primary-tint: #fff1ed;
    --primary-tint-fg: #cc2e00;
    --muted: #f5f5f5;
    --muted-fg: #595959;
    --radius: 8px;
    --radius-md: 6px;
    --shadow: 0 1px 2px rgb(0 0 0 / 3%);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-family: var(--font-sans);
    color: var(--fg);
    background: var(--bg);
    font-synthesis: none;
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'ss01' 1, 'cv11' 1;
}

.topbar {
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 28px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--fg);
    text-decoration: none;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    line-height: 1;
}

.brand img { display: block; }
.divider { width: 1px; height: 22px; background: var(--border); }
.app-name { color: var(--muted-fg); font-weight: 500; }

.tag {
    margin-left: auto;
    padding: 3px 8px;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted-fg);
    font-size: 11px;
    font-weight: 600;
}

main { max-width: 1600px; margin: 0 auto; padding: 28px; }
.intro { margin-bottom: 20px; }
h1 { margin: 0 0 5px; font-size: 26px; font-weight: 600; letter-spacing: -.035em; }
.lede { margin: 0; color: var(--muted-fg); font-size: 13px; }

.search-card {
    margin-bottom: 16px;
    padding: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.search-controls { display: flex; align-items: stretch; gap: 10px; }

.searchbox {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color 120ms, box-shadow 120ms;
}

.search-icon { width: 17px; height: 17px; flex: none; color: var(--muted-fg); }

input[type="search"] {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--fg);
    font: inherit;
}

input::placeholder { color: #737373; opacity: 1; }
.searchbox:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(255 57 0 / 10%); }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary-tint-fg); outline-offset: 3px; }

#search-button, #login-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--primary-tint-fg);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* The darker Collections accent keeps the small button label readable. */
#search-button:hover:not(:disabled), #login-button:hover:not(:disabled) { background: #b82900; }
#search-button:disabled, #login-button:disabled { background: var(--muted); color: #8a8a8a; cursor: not-allowed; }

.suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    color: var(--muted-fg);
    font-size: 12px;
}

.suggestions > span { margin-right: 4px; }

.suggestions button {
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    color: var(--muted-fg);
    font-size: 12px;
    font-weight: 500;
}

.suggestions button:hover { background: var(--primary-tint); border-color: #ffe4da; color: var(--primary-tint-fg); }

.search-filters { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.filters-heading { display: flex; align-items: center; gap: 12px; }
.filters-heading h2 { margin: 0; font-size: 13px; font-weight: 600; }
#clear-filters { padding: 2px 6px; border: 0; background: transparent; color: var(--primary-tint-fg); }
#filters-hint { margin: 6px 0; color: var(--muted-fg); font-size: 12px; }
#filter-options { display: flex; flex-wrap: wrap; gap: 12px 24px; max-height: 240px; overflow-y: auto; }
.filter-group { min-width: 0; margin: 0; padding: 4px 0; border: 0; flex: 1 1 180px; }
.filter-group legend { padding: 0; font-size: 12px; font-weight: 600; }
.filter-option { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 0; font-weight: 400; cursor: pointer; overflow-wrap: anywhere; }
.filter-option input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--primary-tint-fg); }
.filter-option input:focus-visible { outline: 2px solid var(--primary-tint-fg); outline-offset: 2px; }
.auto-filter-badge { color: var(--primary-tint-fg); font-size: 10px; }

.notice {
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    background: #fffbeb;
    color: #92400e;
    overflow-wrap: anywhere;
}

.notice.connected { display: none; }
.comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; }

.panel {
    min-width: 0;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-head {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
}

.panel-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.panel-icon { width: 18px; height: 18px; flex: none; color: var(--muted-fg); font-size: 22px; line-height: 18px; }
.ai .panel-icon { color: var(--primary); }
h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }

.panel-label {
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--muted);
    color: var(--muted-fg);
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.ai .panel-label { background: var(--primary-tint); color: var(--primary-tint-fg); }

.timing {
    flex: none;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted-fg);
    font: 11px var(--font-mono);
    white-space: nowrap;
}

.summary {
    min-height: 38px;
    padding: 9px 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted-fg);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.results { padding: 0 16px 16px; }

.empty {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--muted);
    color: var(--muted-fg);
    font-size: 25px;
}

.ai .empty-icon { background: var(--primary-tint); border-color: #ffe4da; color: var(--primary-tint-fg); }
.empty h3 { margin: 0; font-size: 14px; font-weight: 600; }
.empty p { max-width: 360px; margin: 0; color: var(--muted-fg); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.empty.error .empty-icon { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.empty.error h3 { color: #b91c1c; }
.group { margin-top: 16px; }
.group + .group { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.keyword-label { margin-top: 10px; font-weight: 600; color: var(--fg); }
.keyword-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.keyword-list li { padding: 3px 9px; border: 1px solid #ffe4da; border-radius: var(--radius-md); background: var(--primary-tint); color: var(--primary-tint-fg); overflow-wrap: anywhere; max-width: 100%; }

.group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.group-heading h3 { margin: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.group-heading span { flex: none; color: var(--muted-fg); font: 10px var(--font-mono); }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.product {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
}

.product-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    padding: 10px;
    overflow: hidden;
    background: var(--card);
}

.product-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.placeholder { color: #8a8a8a; font-size: 24px; }
.product h4 { margin: 10px 0 5px; font-size: 12px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.product p { margin: 0 0 4px; color: var(--muted-fg); font-size: 11px; overflow-wrap: anywhere; }
.product .price { margin-top: 8px; color: var(--fg); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.loading { min-height: 300px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted-fg); font-size: 12px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }

footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 0 0;
    color: var(--muted-fg);
    font-size: 10px;
    line-height: 1.7;
}

footer > span { white-space: nowrap; font-weight: 600; }
footer p { margin: 0; text-align: right; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
    .searchbox { transition: none; }
}

@media (max-width: 1100px) and (min-width: 761px) {
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .topbar { padding: 12px 16px; gap: 14px; }
    main { padding: 20px 16px; }
    h1 { font-size: 23px; }
    .search-card { padding: 16px; }
    .search-controls { flex-direction: column; }
    input { font-size: 16px; }
    #search-button { min-height: 40px; }
    .comparison { grid-template-columns: 1fr; }
    footer { flex-direction: column; gap: 6px; }
    footer p { text-align: left; }
}

@media (max-width: 440px) {
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panel-label { display: none; }
    .product { padding: 8px; }
    .product-image { padding: 6px; }
}

.diagnostics { border-bottom: 1px solid var(--border, #e5e5e5); padding: 12px 16px; font-size: 12px; }
.diagnostics summary { cursor: pointer; font-weight: 600; }
.diagnostics summary:focus-visible { outline: 2px solid #cc2e00; outline-offset: 4px; }
.diagnostics h3 { font-size: 13px; margin: 18px 0 8px; }
.diagnostics p { line-height: 1.6; color: #595959; }
.diagnostics-table { overflow-x: auto; max-height: 320px; }
.diagnostics table { border-collapse: collapse; width: 100%; }
.diagnostics th, .diagnostics td { text-align: left; padding: 8px; border-bottom: 1px solid #e5e5e5; vertical-align: top; }
.diagnostics th { background: #fafafa; position: sticky; top: 0; }
.diagnostics td { overflow-wrap: anywhere; min-width: 60px; }

.diagnostics-request { width: 100%; min-height: 10rem; font-family: monospace; font-size: 12px; resize: vertical; }

.login-container { max-width: 490px; margin: 64px auto; }
.login-card { display: grid; gap: 16px; }
.login-card h1, .login-card p { margin: 0; }
.login-card input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.login-card button { padding: 12px 20px; }
#signed-in-user { font-size: 13px; }
#logout-button { padding: 6px 12px; font-size: 13px; }
