/* ==========================================================================
   SoundMatch
   Hybrid neumorphism: soft raised/pressed shapes for controls and the amp
   calculator, flatter high-contrast product cards, teal for everything clickable.
   ========================================================================== */

:root {
    color-scheme: dark;

    /* Surfaces (neumorphism needs a mid-dark base so both shadows show) */
    --bg: #1f2227;
    --bg-deep: #1a1c21;          /* pressed-in fields */
    --card: #262a31;
    --card-hover: #2b3038;

    /* Text */
    --text: #eef0f4;
    --text-muted: #b9bfc9;
    --text-subtle: #939aa7;      /* ≥ 4.5:1 on --bg */

    /* Lines */
    --edge: #6e7480;             /* ≥ 3:1 on --bg, used for form field borders */
    --line: rgba(255, 255, 255, 0.08);

    /* Brand */
    --accent: #0bbb98;
    --accent-strong: #19d3ad;
    --accent-ink: #04201a;       /* text on --accent (≥ 6:1) */
    --accent-soft: rgba(11, 187, 152, 0.14);
    --pick: #ff7a7a;
    --pick-ink: #2b0707;

    /* Status */
    --good: #22c58b;
    --warn: #f5b041;
    --bad: #ff6b6b;

    /* Neumorphic shadows */
    --sh-dark: rgba(0, 0, 0, 0.55);
    --sh-light: rgba(255, 255, 255, 0.055);
    --raise-lg: 12px 12px 26px var(--sh-dark), -8px -8px 22px var(--sh-light);
    --raise: 7px 7px 16px var(--sh-dark), -5px -5px 13px var(--sh-light);
    --raise-sm: 4px 4px 9px var(--sh-dark), -3px -3px 8px var(--sh-light);
    --press: inset 3px 3px 7px var(--sh-dark), inset -3px -3px 7px var(--sh-light);
    --press-lg: inset 5px 5px 12px var(--sh-dark), inset -4px -4px 10px var(--sh-light);

    --radius-lg: 22px;
    --radius: 16px;
    --radius-sm: 11px;
    --sidebar-w: 280px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, sans-serif;
    --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

[hidden] {
    display: none !important;
}

html {
    scroll-padding-top: 1rem;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body.no-scroll,
body:has(dialog[open]) {
    overflow: hidden;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

a {
    color: var(--accent);
}

/* One clear focus style everywhere (keyboard users) */
:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 3px;
}

.icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 2000;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.skip-link:focus {
    top: 1rem;
}

/* ---------- Logo ---------- */
.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-mark {
    width: 34px;
    height: 34px;
    color: var(--accent);
    border-radius: 10px;
    box-shadow: var(--raise-sm);
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.logo-text span {
    color: var(--accent);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease), color 0.2s var(--ease);
}

.btn .icon {
    width: 1em;
    height: 1em;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: var(--raise-sm);
}

.btn-primary:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--press);
}

.btn-soft {
    background: var(--card);
    color: var(--text);
    box-shadow: var(--raise-sm);
}

.btn-soft:hover {
    color: var(--accent-strong);
}

.btn-soft:active {
    box-shadow: var(--press);
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    box-shadow: var(--raise-sm);
    transition: color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.icon-btn:hover {
    color: var(--accent-strong);
}

.icon-btn:active {
    box-shadow: var(--press);
}

.icon-btn-sm {
    width: 32px;
    height: 32px;
}

.text-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: none;
    background: none;
    color: var(--accent);
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.text-btn:hover {
    color: var(--accent-strong);
}

.text-btn .icon {
    width: 1em;
    height: 1em;
}

/* ---------- Layout ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg);
    box-shadow: 1px 0 0 var(--line), 8px 0 24px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 10;
    scrollbar-width: thin;
    scrollbar-color: var(--edge) transparent;
}

main {
    margin-left: var(--sidebar-w);
    padding: 2.5rem clamp(1.25rem, 3vw, 3rem) 5rem;
    min-height: 100vh;
}

main:focus {
    outline: none;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Sidebar sections only for one view */
body[data-view="calculator"] .gear-only,
body[data-view="gear"] .calc-only {
    display: none;
}

.mobile-header,
.sidebar-close-btn,
.mobile-filter-btn {
    display: none;
}

/* ---------- Sidebar ---------- */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.6rem 1.25rem 1.2rem;
}

.sidebar-section {
    padding: 1rem 1.25rem 1.25rem;
}

.sidebar-section + .sidebar-section {
    border-top: 1px solid var(--line);
}

.nav-section {
    padding-top: 0.25rem;
}

/* Segmented view switch: pressed-in track, raised active tab */
.view-switch {
    display: flex;
    gap: 0.3rem;
    padding: 0.35rem;
    border-radius: 14px;
    background: var(--bg-deep);
    box-shadow: var(--press);
}

.nav-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.5rem 0.6rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-subtle);
    font-size: 0.85rem;
    font-weight: 650;
    white-space: nowrap;
    transition: color 0.2s var(--ease), background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.nav-tab:hover {
    color: var(--text);
}

.nav-tab[aria-pressed="true"] {
    background: var(--bg);
    color: var(--accent-strong);
    box-shadow: var(--raise-sm);
}

/* Search */
.search-box {
    position: relative;
}

.search-box .icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    min-height: 46px;
    padding: 0.7rem 1rem 0.7rem 2.6rem;
    border: 1px solid var(--edge);
    border-radius: 14px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    font-size: 0.95rem;
    transition: border-color 0.2s var(--ease);
}

.search-box input::placeholder {
    color: var(--text-subtle);
}

.search-box input:focus {
    border-color: var(--accent);
}

/* Filters */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2,
.calc-guide h2 {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.reset-btn {
    padding: 0.35rem 0.85rem;
    border: none;
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    box-shadow: var(--raise-sm);
}

.reset-btn:not(:disabled):hover {
    color: var(--accent-strong);
}

.reset-btn:disabled {
    box-shadow: none;
}

.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-item label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

/* Shared select look (pressed-in field with a custom arrow) */
.filter-item select,
.calc-select {
    appearance: none;
    width: 100%;
    min-height: 44px;
    padding: 0.6rem 2.2rem 0.6rem 0.85rem;
    border: 1px solid var(--edge);
    border-radius: 12px;
    background-color: var(--bg-deep);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b9bfc9' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    box-shadow: var(--press);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s var(--ease);
}

.filter-item select:focus,
.calc-select:focus {
    border-color: var(--accent);
}

select option,
select optgroup {
    background: var(--card);
    color: var(--text);
}

select optgroup {
    color: var(--accent-strong);
    font-weight: 700;
}

/* Neumorphic toggle switch */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.switch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch-track {
    position: relative;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--bg-deep);
    border: 1px solid var(--edge);
    box-shadow: var(--press);
    transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 2px 2px 5px var(--sh-dark);
    transition: transform 0.25s var(--ease), background-color 0.25s var(--ease);
}

.switch input:checked + .switch-track {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
    transform: translateX(20px);
    background: var(--accent);
}

.switch input:focus-visible + .switch-track {
    outline: 2px solid var(--accent-strong);
    outline-offset: 3px;
}

/* Calculator guide in the sidebar */
.calc-guide {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.calc-guide h3 {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text);
}

.calc-guide ol {
    padding-left: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.calc-guide strong {
    color: var(--text);
}

.legend {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.good { background: var(--good); }
.legend-dot.warn { background: var(--warn); }
.legend-dot.bad { background: var(--bad); }

.guide-note {
    font-size: 0.78rem;
    color: var(--text-subtle);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1.25rem;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-subtle);
}

.sidebar-footer a {
    font-weight: 650;
}

/* ---------- Gear view header ---------- */
.page-header {
    max-width: 900px;
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: clamp(1.7rem, 3vw, 2.3rem);
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-header h1:focus,
.calc-title:focus,
.category h2:focus,
.calc-verdict-title:focus {
    outline: none;
}

.page-lead {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 1.02rem;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.1rem;
    margin-top: 0.9rem;
    font-size: 0.85rem;
    color: var(--text-subtle);
}

#result-count {
    color: var(--text);
    font-weight: 650;
}

.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-subtle);
    flex-shrink: 0;
}

.sync-dot.syncing {
    background: var(--warn);
    animation: pulse-dot 1s infinite;
}

.sync-dot.synced { background: var(--good); }
.sync-dot.error { background: var(--bad); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* Category jump chips (sticky) */
.category-nav {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 0.6rem;
    margin: 0 calc(-1 * clamp(1.25rem, 3vw, 3rem)) 1.75rem;
    padding: 0.85rem clamp(1.25rem, 3vw, 3rem);
    overflow-x: auto;
    background: rgba(31, 34, 39, 0.92);
    backdrop-filter: blur(10px);
    scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: var(--bg);
    box-shadow: var(--raise-sm);
    color: var(--text-muted);
    font-size: 0.83rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.category-chip:hover {
    color: var(--accent-strong);
}

.category-chip:active {
    box-shadow: var(--press);
}

.category-chip-count {
    font-size: 0.72rem;
    color: var(--text-subtle);
}

/* Loading / error / empty states */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5rem 1rem;
    color: var(--text-subtle);
    gap: 1rem;
}

.loading-spinner {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 4px solid var(--bg-deep);
    border-top-color: var(--accent);
    box-shadow: var(--raise-sm);
    animation: spin 0.9s linear infinite;
}

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

.load-error,
.no-results {
    max-width: 520px;
    margin: 3rem auto;
    padding: 2rem;
    text-align: center;
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--raise);
    color: var(--text-muted);
}

.load-error > .icon {
    width: 40px;
    height: 40px;
    color: var(--warn);
    margin: 0 auto 0.75rem;
}

.load-error h2,
.no-results h2 {
    color: var(--text);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.load-error .btn {
    margin-top: 1.25rem;
}

/* ---------- Categories + product cards ---------- */
.category {
    margin-bottom: 3rem;
    scroll-margin-top: 80px;
}

.category h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.45rem;
    font-weight: 750;
    letter-spacing: -0.01em;
    margin-bottom: 1.25rem;
}

.count-pill {
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--text-muted);
}

.items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.7rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--raise-sm);
    transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.item:hover {
    transform: translateY(-3px);
    border-color: rgba(11, 187, 152, 0.45);
    background: var(--card-hover);
}

.item-media {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}

/* Product photos are square, so "contain" shows the whole product with nothing cropped */
.item-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-image-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: var(--bg-deep);
    color: var(--text-subtle);
}

.item-image-fallback .icon {
    width: 48px;
    height: 48px;
}

.pick-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border: none;
    border-radius: 999px;
    background: var(--pick);
    color: var(--pick-ink);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s var(--ease);
}

.pick-badge:hover {
    transform: scale(1.05);
}

.pick-badge .icon {
    width: 0.9em;
    height: 0.9em;
}

.item-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    padding: 0 0.3rem 0.3rem;
}

.item-name {
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-price {
    font-size: 1.15rem;
    font-weight: 750;
    color: var(--accent);
}

.item-price-none {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-subtle);
}

.item-actions {
    display: flex;
    flex-wrap: wrap; /* safety net: never let a button stick out of the card */
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.item-actions .btn {
    padding-inline: 0.75rem;
    font-size: 0.85rem;
}

.item-actions .btn-primary {
    flex: 1 1 auto;
}

/* Keeps "View product" + the icon button on one line even on the narrowest cards */
.item-actions .btn-primary .icon {
    display: none;
}

/* Square icon button (Graph / Specs) */
.item-actions .btn-icon {
    flex: 0 0 38px;
    width: 38px;
    padding: 0;
}

.item-actions .btn-icon .icon {
    width: 1.15em;
    height: 1.15em;
}

.item-actions .btn-label {
    display: none;
}

/* ---------- Dialogs ---------- */
dialog.modal {
    margin: auto;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text);
    width: min(540px, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: visible;
}

dialog.modal-wide {
    width: min(980px, calc(100% - 2rem));
}

dialog.modal::backdrop {
    background: rgba(8, 9, 11, 0.72);
    backdrop-filter: blur(6px);
}

dialog.modal[open] {
    animation: modal-in 0.25s var(--ease);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal-content {
    position: relative;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 2rem;
    border-radius: var(--radius-lg);
    background: var(--bg);
    border: 1px solid var(--line);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.modal-content h2 {
    font-size: 1.4rem;
    line-height: 1.25;
    margin: 0 2.5rem 1rem 0;
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.modal-x {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.modal-actions:empty {
    display: none;
}

.graph {
    margin-bottom: 1.25rem;
}

.graph-link {
    display: block;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--raise-sm);
    cursor: zoom-in;
}

.graph img {
    width: 100%;
    height: auto;
}

.graph figcaption {
    margin-top: 0.55rem;
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.spec-list {
    display: grid;
    gap: 0.5rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    background: var(--bg-deep);
    box-shadow: var(--press);
}

.spec-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
}

.spec-row dt {
    color: var(--text-subtle);
}

.spec-row dd {
    text-align: right;
    font-family: var(--mono);
    font-weight: 600;
}

.modal-content .spec-note {
    margin: 1rem 0 0;
    font-size: 0.88rem;
}

/* ==========================================================================
   AMP CALCULATOR (full neumorphism)
   ========================================================================== */

.calc-container {
    max-width: 1120px;
    margin: 0 auto;
}

.calc-hero {
    text-align: center;
    padding: 1rem 0 2.5rem;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: var(--bg);
    box-shadow: var(--raise-sm);
    color: var(--accent-strong);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.calc-title {
    margin: 1.25rem auto 0.75rem;
    max-width: 760px;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.calc-subtitle {
    max-width: 620px;
    margin: 0 auto;
    color: var(--text-muted);
    font-size: 1.02rem;
}

.calc-tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1.5rem;
}

.calc-tags li {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.calc-tags .icon {
    color: var(--accent);
    width: 1em;
    height: 1em;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: 1.75rem;
    margin-bottom: 2rem;
}

.calc-panel {
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--raise-lg);
}

.calc-panel-header {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1.4rem 1.6rem 0.4rem;
}

.calc-panel-icon,
.calc-metric-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 14px;
    background: var(--bg);
    box-shadow: var(--raise-sm);
    color: var(--accent);
}

.calc-panel-icon .icon {
    width: 22px;
    height: 22px;
}

.calc-panel-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.calc-panel-header p {
    font-size: 0.82rem;
    color: var(--text-subtle);
}

.calc-panel-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.25rem 1.6rem 1.7rem;
}

.calc-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.calc-field label,
.calc-label {
    font-size: 0.85rem;
    font-weight: 650;
    color: var(--text-muted);
}

.calc-optional {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-subtle);
}

.calc-hint {
    font-size: 0.75rem;
    color: var(--text-subtle);
}

.calc-input {
    width: 100%;
    min-height: 46px;
    padding: 0.65rem 0.95rem;
    border: 1px solid var(--edge);
    border-radius: 12px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    font-size: 1rem;
    font-family: var(--mono);
    transition: border-color 0.2s var(--ease);
}

.calc-input::placeholder {
    color: var(--text-subtle);
    font-family: var(--font);
}

.calc-input:focus {
    border-color: var(--accent);
}

.calc-input[aria-invalid="true"] {
    border-color: var(--bad);
}

.calc-row {
    display: flex;
    gap: 0.6rem;
}

.calc-row > .calc-input,
.calc-row > .calc-unit-input {
    flex: 1;
    min-width: 0;
}

.calc-select-unit {
    width: auto;
    flex: 0 0 auto;
}

.calc-input-sm {
    flex: 0 0 96px !important;
    width: 96px;
}

.calc-unit-input {
    position: relative;
}

.calc-unit-input .calc-input {
    padding-right: 3.2rem;
}

.calc-unit-input > span {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: var(--text-subtle);
    pointer-events: none;
}

.calc-unit-input-sm {
    flex: 0 0 120px !important;
}

.calc-divider {
    height: 2px;
    border-radius: 2px;
    background: var(--bg-deep);
    box-shadow: 0 1px 0 var(--sh-light);
}

/* Quick-value chips: raised, pressed in when active */
.calc-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip-btn {
    padding: 0.35rem 0.75rem;
    border: none;
    border-radius: 999px;
    background: var(--bg);
    box-shadow: var(--raise-sm);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    transition: box-shadow 0.2s var(--ease), color 0.2s var(--ease);
}

.chip-btn:hover {
    color: var(--accent-strong);
}

.chip-btn[aria-pressed="true"] {
    box-shadow: var(--press);
    color: var(--accent-strong);
}

/* "Good fits" recommendations under each preset dropdown */
.fit-box {
    padding: 0.9rem 1rem 1rem;
    border-radius: var(--radius);
    background: var(--bg-deep);
    box-shadow: var(--press);
    animation: fade-in 0.3s var(--ease);
}

.fit-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.7rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.fit-title .icon {
    width: 1em;
    height: 1em;
    color: var(--accent);
}

.fit-title strong {
    color: var(--text);
}

.fit-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fit-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: 999px;
    background: var(--bg);
    box-shadow: var(--raise-sm);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    transition: box-shadow 0.2s var(--ease), color 0.2s var(--ease);
}

.fit-chip:hover {
    color: var(--accent-strong);
}

.fit-chip[aria-pressed="true"] {
    box-shadow: var(--press);
    color: var(--accent-strong);
}

.fit-db {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--good);
    white-space: nowrap;
}

.fit-more,
.fit-empty {
    font-size: 0.75rem;
    color: var(--text-subtle);
}

.fit-more {
    margin-top: 0.65rem;
}

/* Loudness slider: pressed track + raised knob */
.calc-range-row {
    align-items: center;
    gap: 1rem;
}

.calc-range {
    flex: 1;
    appearance: none;
    height: 10px;
    border-radius: 999px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    cursor: pointer;
}

.calc-range::-webkit-slider-thumb {
    appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent) 0 4px, var(--bg) 5px);
    box-shadow: 3px 3px 8px var(--sh-dark), -2px -2px 6px var(--sh-light);
}

.calc-range::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent) 0 4px, var(--bg) 5px);
    box-shadow: 3px 3px 8px var(--sh-dark), -2px -2px 6px var(--sh-light);
}

.calc-action {
    text-align: center;
    margin-bottom: 2.5rem;
}

.calc-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem 2.4rem;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 1.05rem;
    font-weight: 750;
    box-shadow: var(--raise), 0 0 28px rgba(11, 187, 152, 0.25);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}

.calc-btn:hover {
    background: var(--accent-strong);
    transform: translateY(-2px);
}

.calc-btn:active {
    transform: translateY(0);
    box-shadow: var(--press);
}

.calc-error {
    max-width: 560px;
    margin: 1.25rem auto 0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--bg-deep);
    box-shadow: var(--press);
    border-left: 3px solid var(--bad);
    text-align: left;
    color: var(--text);
    font-size: 0.88rem;
}

.calc-error ul {
    margin: 0.4rem 0 0 1.1rem;
    color: var(--text-muted);
}

/* ---------- Results ---------- */
.calc-results {
    animation: fade-in 0.4s var(--ease);
    scroll-margin-top: 1rem;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.calc-verdict {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.75rem 2rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--raise-lg);
    border-left: 4px solid var(--verdict-color, var(--good));
}

.verdict-good { --verdict-color: var(--good); }
.verdict-warn { --verdict-color: var(--warn); }
.verdict-bad { --verdict-color: var(--bad); }

.verdict-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg-deep);
    box-shadow: var(--press-lg);
    color: var(--verdict-color, var(--good));
}

.verdict-icon .icon {
    width: 34px;
    height: 34px;
}

.calc-verdict-title {
    font-size: 1.45rem;
    font-weight: 750;
    line-height: 1.25;
}

.calc-verdict-desc {
    margin-top: 0.35rem;
    color: var(--text-muted);
}

.verdict-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.chip {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--text-muted);
}

.chip-good { color: var(--good); }
.chip-warn { color: var(--warn); }
.chip-bad { color: var(--bad); }

.calc-notes {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1.2rem;
    border-radius: var(--radius);
    background: var(--bg-deep);
    box-shadow: var(--press);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.calc-notes li::before {
    content: 'ⓘ ';
    color: var(--accent);
}

.text-good { color: var(--good); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }

.calc-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.calc-metric-card {
    padding: 1.3rem 1.4rem;
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--raise);
    border: 1px solid transparent;
    transition: border-color 0.2s var(--ease);
}

.calc-metric-card.is-limit {
    border-color: rgba(245, 176, 65, 0.4);
}

.calc-metric-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.calc-metric-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.calc-metric-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}

.calc-metric-icon.voltage { color: #6ea8ff; }
.calc-metric-icon.current { color: #b18cff; }
.calc-metric-icon.power { color: #ff8fc4; }
.calc-metric-icon.damping { color: var(--accent); }

.limit-badge {
    margin-left: auto;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: rgba(245, 176, 65, 0.14);
    color: var(--warn);
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.limit-badge-muted {
    background: var(--bg-deep);
    color: var(--text-subtle);
    box-shadow: var(--press);
}

.calc-metric-rows {
    display: flex;
    flex-direction: column;
}

.calc-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--line);
}

.calc-metric-row:last-child {
    border-bottom: none;
}

.calc-metric-row dt {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.calc-mono {
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: right;
}

.calc-mono.bold {
    font-weight: 800;
}

/* VU meter: pressed track, segmented fill, tick at 0 dB (what's needed) */
.vu {
    position: relative;
    height: 14px;
    margin: 0.9rem 0 0.75rem;
    border-radius: 999px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    overflow: hidden;
}

.vu-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width 0.8s var(--ease);
    -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 9px);
    mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 9px);
}

.vu-fill.fill-good { background: linear-gradient(90deg, #178a67, var(--good)); }
.vu-fill.fill-warn { background: linear-gradient(90deg, #b87a1c, var(--warn)); }
.vu-fill.fill-bad { background: linear-gradient(90deg, #a83c3c, var(--bad)); }

.vu-mark {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 40%;
    width: 2px;
    border-radius: 2px;
    background: var(--text);
    opacity: 0.8;
}

.calc-status {
    padding: 0.35rem;
    border-radius: 10px;
    background: var(--bg-deep);
    box-shadow: var(--press);
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-good { color: var(--good); }
.status-warn { color: var(--warn); }
.status-bad { color: var(--bad); }
.status-unknown { color: var(--text-subtle); }

/* Damping */
.calc-damping {
    padding: 1.4rem 1.6rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--raise);
}

.calc-damping-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.calc-damping-header h3 {
    font-size: 1rem;
}

.calc-damping-header p {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.calc-damping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 1rem;
    align-items: center;
}

.calc-damping-cell {
    text-align: center;
}

.calc-damping-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-subtle);
    margin-bottom: 0.2rem;
}

.calc-damping-value {
    font-family: var(--mono);
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.calc-damping-rule {
    font-weight: 700;
    font-size: 0.9rem;
}

.calc-damping-verdict {
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    background: var(--bg-deep);
    box-shadow: var(--press);
    text-align: center;
}

.calc-damping-verdict p:first-child {
    font-weight: 700;
}

.calc-damping-desc {
    margin-top: 0.2rem;
    font-size: 0.8rem;
    color: var(--text-subtle);
}

/* Breakdown */
.calc-breakdown {
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--raise);
    margin-bottom: 2rem;
}

.calc-breakdown summary {
    padding: 1.1rem 1.5rem;
    font-weight: 700;
    cursor: pointer;
    list-style-position: inside;
}

.calc-breakdown summary:hover {
    color: var(--accent-strong);
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 1.25rem;
    padding: 0 1.5rem 1.5rem;
}

.breakdown-grid h4 {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.breakdown-grid pre {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-deep);
    box-shadow: var(--press);
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==========================================================================
   Footer links + privacy policy page
   ========================================================================== */
.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    margin-top: 2rem;
    padding: 1.75rem 1rem 0.5rem;
    border-top: 1px solid var(--line);
    font-size: 0.85rem;
}

.site-footer a {
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

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

.legal-header .logo {
    text-decoration: none;
}

main.legal-page {
    max-width: 820px;
    min-height: auto;
    margin: 0 auto;
    padding: 0 1rem 1rem;
}

.legal-card {
    padding: clamp(1.5rem, 4vw, 2.75rem);
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--raise-lg);
}

.legal-card h1 {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.legal-updated {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-subtle);
}

.legal-card section {
    margin-top: 2rem;
}

.legal-card h2 {
    margin-bottom: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.legal-card p,
.legal-card li {
    color: var(--text-muted);
}

.legal-card p + p,
.legal-card ul + p,
.legal-card p + ul {
    margin-top: 0.75rem;
}

.legal-card ul {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-left: 1.2rem;
}

.legal-card strong {
    color: var(--text);
}

.legal-card code {
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
    background: var(--bg-deep);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.85em;
}

.legal-footer {
    max-width: 820px;
    margin: 0 auto 2rem;
}

/* ==========================================================================
   Mobile
   ========================================================================== */
@media (max-width: 768px) {
    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.65rem 1rem;
        background: rgba(31, 34, 39, 0.95);
        backdrop-filter: blur(10px);
        box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(0, 0, 0, 0.3);
    }

    .mobile-header .logo-mark {
        width: 30px;
        height: 30px;
    }

    .mobile-header .logo-text {
        font-size: 1.1rem;
    }

    .mobile-header .view-switch {
        padding: 0.25rem;
    }

    .mobile-header .nav-tab {
        min-height: 36px;
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    /* The sidebar becomes an off-canvas filter panel */
    .sidebar {
        width: min(86vw, 330px);
        z-index: 1001;
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
    }

    .sidebar.open {
        transform: none;
        visibility: visible;
        transition: transform 0.3s var(--ease);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
    }

    .sidebar .nav-section,
    .sidebar .calc-only {
        display: none;
    }

    .sidebar-close-btn {
        display: inline-grid;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.55);
    }

    main {
        margin-left: 0;
        padding: 1.5rem 1rem 6rem;
    }

    .category-nav {
        top: 62px;
        margin: 0 -1rem 1.5rem;
        padding: 0.75rem 1rem;
    }

    .category {
        scroll-margin-top: 130px;
    }

    .mobile-filter-btn {
        position: fixed;
        right: 1rem;
        bottom: 1rem;
        z-index: 30;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.8rem 1.25rem;
        border: none;
        border-radius: 999px;
        background: var(--accent);
        color: var(--accent-ink);
        font-weight: 750;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    }

    body[data-view="calculator"] .mobile-filter-btn {
        display: none;
    }

    .modal-content {
        padding: 1.5rem 1.25rem;
    }

    .calc-panel-header,
    .calc-panel-body {
        padding-left: 1.2rem;
        padding-right: 1.2rem;
    }

    .calc-verdict {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem 1.25rem;
        border-left: none;
        border-top: 4px solid var(--verdict-color, var(--good));
    }

    .verdict-chips {
        justify-content: center;
    }
}

/* Two product columns on phones */
@media (max-width: 560px) {
    .items {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.85rem;
    }

    .item {
        padding: 0.5rem;
        gap: 0.55rem;
        border-radius: var(--radius);
    }

    .item-media {
        border-radius: var(--radius-sm);
    }

    .item-name {
        font-size: 0.88rem;
    }

    .item-price {
        font-size: 1rem;
    }

    .item-actions {
        flex-direction: column;
    }

    /* Buttons stack full width on phones, so there's room for the label again */
    .item-actions .btn-icon {
        flex-basis: auto;
        width: auto;
        padding: 0.5rem 0.6rem;
    }

    .item-actions .btn-label,
    .item-actions .btn-primary .icon {
        display: inline;
    }

    .btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }

    .pick-badge {
        top: 0.4rem;
        left: 0.4rem;
        padding: 0.25rem 0.5rem;
        font-size: 0.62rem;
    }

    .category h2 {
        font-size: 1.2rem;
    }

    .calc-unit-input-sm {
        flex-basis: 104px !important;
    }
}

@media (max-width: 400px) {
    .mobile-header .nav-tab .icon {
        display: none;
    }

    .mobile-header .logo-text {
        font-size: 1rem;
    }
}

@media (max-width: 330px) {
    .mobile-header .logo-text {
        display: none;
    }
}

/* Respect "reduce motion" */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
