/* ==========================================================================
   Headstock — design system ("Nocturne", blue)
   Light: soft grays, white panels, black for actions, a navy glass side panel.
   Dark: near-black with blue glows, glass surfaces, blue for actions.
   All text/background pairs meet WCAG 2.2 AA (4.5:1 body, 3:1 large text and UI).
   ========================================================================== */

:root {
  --bg: #eceef3;
  --bg-elev: rgba(244, 245, 248, 0.86);
  --surface: #ffffff;
  --surface-2: #f2f3f6;
  --surface-3: #e4e6eb;
  --text: #08090b;          /* 19.8:1 on surface */
  --text-2: #565a62;        /* 6.9:1 on surface, 6.1:1 on bg */
  --text-3: #686c75;        /* 5.4:1 on surface */
  --line: #e4e6eb;          /* decorative dividers */
  --line-strong: #858a93;   /* input borders: 3.5:1 on surface (1.4.11) */
  --accent: #08090b;        /* main action: black pill */
  --accent-hover: #26282d;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefb;
  --accent-soft-ink: #1a4fae; /* 6.6:1 on accent-soft */
  --link: #1a56c4;          /* 6.1:1 on surface */
  --ok: #146c34;   --ok-soft: #e5f4ea;
  --warn: #1a4fae; --warn-soft: #e6eefb; /* notices and "due soon": the brand blue, no orange */
  --bad: #c0262d;  --bad-soft: #fbe8e8;
  --info: #1a56c4; --info-soft: #e6eefb;
  --focus: #1d5fd1;
  /* Brand: the navy side panel, its accents and the photo labels */
  --brand-1: #0b1d3a; --brand-2: #050e1f; --brand-glow: #1c3f78;
  --brand-acc: #7cb4ff; --brand-acc-ink: #04173a; --brand-label: #1f4f9c; --brand-deep: #1d5fd1;
  --side-bg: radial-gradient(420px 320px at 0% 0%, var(--brand-glow) 0%, transparent 70%), linear-gradient(180deg, var(--brand-1), var(--brand-2));
  --side-active-bg: #f1f6fb; --side-active-ink: #0b1d3a; --side-active-icon: var(--brand-deep);
  --side-color: var(--brand-2); /* solid base under the gradient: keeps text readable and measurable */
  /* Header: no watermark in light mode; a plain plus on the Add pill */
  --wm: transparent; --add-disc: transparent; --add-plus: currentColor;
  --seg-on-bg: #08090b; --seg-on-ink: #ffffff;
  --page-bg: radial-gradient(1000px 700px at 80% 0%, #f7f8fb 0%, transparent 60%), linear-gradient(180deg, #eceef3, #e3e6ec);
  --shadow-1: 0 1px 2px rgba(0,0,0,.05);
  --shadow-2: 0 16px 34px -22px rgba(20,24,34,.45), 0 1px 2px rgba(0,0,0,.04);
  --shadow-3: 0 40px 90px -30px rgba(20,24,34,.45);
  --radius-s: 14px;
  --radius: 18px;
  --radius-l: 28px;
  --sidebar: 264px;
  /* Type scale: every size in the app comes from these six (print reports use points).
     Page titles and the large count numeral are display sizes above this scale. */
  --fs-xs: 13px;   /* small labels: photo tags, counts, chart axis, table headers */
  --fs-sm: 14px;   /* supporting text: hints, card details, field labels, chips */
  --fs-md: 16px;   /* body text, buttons, form fields (16px stops iPhone zoom on focus) */
  --fs-lg: 18px;   /* small headings */
  --fs-xl: 20px;   /* section, window and panel titles */
  --fs-2xl: 28px;  /* large figures and sign-in title; page titles scale up from here */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #020306;
    --bg-elev: rgba(5, 8, 14, 0.84);
    --surface: #0b0f17;
    --surface-2: #131926;
    --surface-3: #1c2433;
    --text: #eef3fb;
    --text-2: #a8b0be;
    --text-3: #8f99ab;
    --line: #1b2230;
    --line-strong: #5f6c82;
    --accent: #7cb4ff;
    --accent-hover: #9ac5ff;
    --accent-ink: #04173a;
    --accent-soft: #14284a;
    --accent-soft-ink: #a9cbff;
    --link: #8fc0ff;
    --ok: #4ade80;   --ok-soft: #0f2a19;
    --warn: #7cb4ff; --warn-soft: #14284a;
    --bad: #ff7b7b;  --bad-soft: #351314;
    --info: #7cb4ff; --info-soft: #10213a;
    --focus: #7cb4ff;
    --side-bg: linear-gradient(180deg, rgb(241 246 251 / .025), rgb(241 246 251 / .01)); --side-color: transparent;
    --side-active-bg: linear-gradient(180deg, rgb(28 63 120 / .8), rgb(28 63 120 / .5)); --side-active-ink: #eef3fb; --side-active-icon: #7cb4ff;
    --wm: rgb(124 180 255 / .05); --add-disc: #04173a; --add-plus: #7cb4ff;
    --seg-on-bg: #1c3f78; --seg-on-ink: #7cb4ff;
    --page-bg: radial-gradient(900px 600px at 18% 0%, #0f2140 0%, transparent 60%), radial-gradient(900px 700px at 100% 100%, #0c1a33 0%, transparent 60%), #020306;
    --shadow-1: 0 1px 2px rgba(0,0,0,.5);
    --shadow-2: 0 18px 40px -24px rgba(0,0,0,.9);
    --shadow-3: 0 40px 90px -30px rgba(0,0,0,.95), 0 0 120px -40px rgba(28,63,120,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #020306;
  --bg-elev: rgba(5, 8, 14, 0.84);
  --surface: #0b0f17;
  --surface-2: #131926;
  --surface-3: #1c2433;
  --text: #eef3fb;
  --text-2: #a8b0be;
  --text-3: #8f99ab;
  --line: #1b2230;
  --line-strong: #5f6c82;
  --accent: #7cb4ff;
  --accent-hover: #9ac5ff;
  --accent-ink: #04173a;
  --accent-soft: #14284a;
  --accent-soft-ink: #a9cbff;
  --link: #8fc0ff;
  --ok: #4ade80;   --ok-soft: #0f2a19;
  --warn: #7cb4ff; --warn-soft: #14284a;
  --bad: #ff7b7b;  --bad-soft: #351314;
  --info: #7cb4ff; --info-soft: #10213a;
  --focus: #7cb4ff;
  --side-bg: linear-gradient(180deg, rgb(241 246 251 / .025), rgb(241 246 251 / .01)); --side-color: transparent;
  --side-active-bg: linear-gradient(180deg, rgb(28 63 120 / .8), rgb(28 63 120 / .5)); --side-active-ink: #eef3fb; --side-active-icon: #7cb4ff;
  --wm: rgb(124 180 255 / .05); --add-disc: #04173a; --add-plus: #7cb4ff;
  --seg-on-bg: #1c3f78; --seg-on-ink: #7cb4ff;
  --page-bg: radial-gradient(900px 600px at 18% 0%, #0f2140 0%, transparent 60%), radial-gradient(900px 700px at 100% 100%, #0c1a33 0%, transparent 60%), #020306;
  --shadow-1: 0 1px 2px rgba(0,0,0,.5);
  --shadow-2: 0 18px 40px -24px rgba(0,0,0,.9);
  --shadow-3: 0 40px 90px -30px rgba(0,0,0,.95), 0 0 120px -40px rgba(28,63,120,.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: var(--page-bg); background-attachment: fixed;
  color: var(--text);
  font: 400 var(--fs-md)/1.5 var(--font);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
p { margin: 0; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--link); }
[hidden] { display: none !important; }
.noscript { padding: 24px; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.vh {
  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: 12px; top: -60px; z-index: 1000;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px;
  background: var(--bg-elev);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.02em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 500;
  transition: background .15s var(--ease);
}
.nav-link:hover { background: var(--surface-2); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 600; }
.nav-link .count { margin-left: auto; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.nav-link[aria-current="page"] .count { background: transparent; color: inherit; }
.nav-link .count.alert { background: var(--warn-soft); color: var(--warn); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.privacy-pill {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--text-2); line-height: 1.4;
}
.privacy-pill strong { color: var(--text); display: block; font-size: var(--fs-xs); }
.privacy-pill .icon { color: var(--ok); margin-top: 1px; }

.main { min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 96px; }
.page { max-width: 1240px; margin: 0 auto; animation: page-in .35s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabbar { display: none; }
/* Desktop has no top bar: the search sits in the side panel under the logo. Phones show it (below). */
.topbar {
  display: none; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
  /* Lines up with the page content, which is centered at up to 1240px. */
  padding: 12px max(clamp(16px, 4vw, 48px), calc((100% - 1240px) / 2));
  background: var(--bg-elev);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand, .topbar-end { display: none; }
.global-search { flex: 1 1 auto; max-width: 560px; }
.global-search .input { padding-right: 44px; }
.global-search .search-clear { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
.global-search .search-clear[hidden] { display: none; }
.global-search .search-clear .icon { position: static; transform: none; color: var(--text-2); pointer-events: auto; }
.global-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.side-search { margin: 0 0 14px; }
.side-search .global-search { max-width: none; }

@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }
  /* Native apps keep room for the bottom tab bar. */
  [data-platform="native"] .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  /* Phones: brand, search button and menu; the search button opens the field on its own row. */
  .topbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; }
  .topbar .brand { display: flex; padding: 0; font-size: var(--fs-lg); }
  .topbar-end { display: flex; align-items: center; gap: 4px; }
  .global-search { display: none; order: 3; flex-basis: 100%; max-width: none; }
  .topbar.searching .global-search { display: block; }
  .topbar.searching .search-toggle { background: var(--surface-2); }
  .tabbar {
    display: none; grid-auto-flow: column; grid-auto-columns: 1fr; /* one column per tab, however many there are */
    position: fixed; inset: auto 0 0 0; z-index: 30;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg-elev);
    backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
    border-top: 1px solid var(--line);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 50px; border-radius: 10px;
    font-size: 11px; font-weight: 600; color: var(--text-2); text-decoration: none;
  }
  .tab[aria-current="page"] { color: var(--accent); }
  .tab .icon { width: 24px; height: 24px; }
  /* Six tabs on the narrowest phones (320px): slightly smaller labels so "Instruments" fits. */
  @media (max-width: 359px) { .tab { font-size: 10px; letter-spacing: -0.01em; } }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 24px; }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.h1 { font-size: clamp(28px, 4vw, 38px); font-weight: 700; letter-spacing: -0.03em; }
.h1:focus { outline: none; }
.h2 { font-size: var(--fs-xl); font-weight: 700; }
.h3 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
.sub { color: var(--text-2); margin-top: 6px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: var(--fs-md); text-decoration: none; white-space: nowrap;
  transition: background .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--accent); padding: 0 12px; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1a0000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { color: #1a0000; } }
.btn-danger-ghost { background: transparent; color: var(--bad); }
.btn-danger-ghost:hover { background: var(--bad-soft); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--fs-sm); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 999px;
  background: transparent; border: 0; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-soft-ink); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.label .req { color: var(--bad); }
.hint { font-size: var(--fs-sm); color: var(--text-2); }
.error-text { font-size: var(--fs-sm); color: var(--bad); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--bad); }
.input-wrap { position: relative; }
.input-wrap .input { padding-left: 40px; }
.input-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); pointer-events: none; }
.mono { font-family: var(--mono); letter-spacing: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-grid .span-all { grid-column: 1 / -1; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
.fieldset { padding: 20px 0; border-top: 1px solid var(--line); }
.fieldset:first-of-type { border-top: 0; padding-top: 4px; }
.fieldset legend { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; margin-bottom: 14px; float: left; width: 100%; }
.fieldset legend + * { clear: both; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; }
/* A checkbox that sits beside a text field lines up with that field's box, not its label. */
.field-inline { justify-content: flex-end; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
.stay .hint { margin: -6px 0 4px 34px; }

.error-summary {
  border: 2px solid var(--bad); background: var(--bad-soft); color: var(--text);
  border-radius: var(--radius-s); padding: 12px 14px; margin-bottom: 16px;
}
.error-summary h3 { font-size: var(--fs-md); color: var(--bad); margin-bottom: 4px; }
.error-summary ul { margin: 0; padding-left: 18px; }
.error-summary a { color: var(--text); font-weight: 600; }

/* ---------- Toolbar / chips ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: var(--fs-sm); cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg .icon-btn { width: 38px; height: 38px; }
.seg .icon-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-l); overflow: hidden;
  box-shadow: var(--shadow-1); border: 1px solid var(--line);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.card:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.media { position: relative; aspect-ratio: 4 / 5; background: var(--surface-2); overflow: hidden; }
.media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 2px; }
.card-title { font-weight: 650; font-size: var(--fs-md); letter-spacing: -0.01em; }
.card-meta { color: var(--text-2); font-size: var(--fs-sm); }
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.delta { font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); } .delta.flat { color: var(--text-2); }
/* Status on a photo: a solid dark pill so it reads on any image, with a colored dot per status. */
:is(.media, .hero-media) > .badge { position: absolute; top: 12px; left: 12px; z-index: 2; background: rgb(0 0 0 / .72); color: #fff; border-color: rgb(255 255 255 / .18); }
:is(.media, .hero-media) .badge.ok .dot { background: #4ade80; } :is(.media, .hero-media) .badge.warn .dot { background: #7cb4ff; }
:is(.media, .hero-media) .badge.bad .dot { background: #ff7b7b; } :is(.media, .hero-media) .badge.info .dot { background: #7cb3ff; }
:is(.media, .hero-media) .badge.muted .dot { background: #c4c4c4; }
@media (forced-colors: active) { :is(.media, .hero-media) > .badge { background: Canvas; color: CanvasText; border-color: CanvasText; } :is(.media, .hero-media) .badge .dot { background: CanvasText; } }

/* No photo yet: dashed outline with a gray silhouette, like the "Add photo" tile. */
.placeholder { width: 100%; height: 100%; display: grid; place-items: center; background: var(--surface); border: 2px dashed var(--line-strong); border-radius: inherit; }
.media:has(> .placeholder), .gallery-main:has(> .placeholder) { position: relative; background: var(--surface); }
.media > .placeholder, .gallery-main > .placeholder { position: absolute; inset: 12px; width: auto; height: auto; border-radius: 16px; }
.placeholder svg { width: 46%; max-height: 86%; height: auto; }
.placeholder .ph-b { fill: var(--surface-3); }
.placeholder .ph-d { fill: var(--surface); }
.placeholder .ph-s { fill: none; stroke: var(--surface); }
.list-row .thumb .placeholder { border-width: 1.5px; border-radius: 12px; }
.list-row .thumb .placeholder svg { width: 52%; }
/* Pedal and amp drawings are wider than an instrument, so they get more room. */
.placeholder.ph-pedal svg { width: 40%; }
.placeholder.ph-amp svg { width: 68%; }
.list-row .thumb .placeholder.ph-pedal svg { width: 46%; }
.list-row .thumb .placeholder.ph-amp svg { width: 78%; }

.list { background: var(--surface); border-radius: var(--radius-l); border: 1px solid var(--line); overflow: hidden; }
.list-row {
  position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 10px 16px; border-top: 1px solid var(--line); min-height: 72px;
}
.list-row:first-child { border-top: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row:focus-within { box-shadow: inset 0 0 0 3px var(--focus); }
.list-row .thumb { width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.list-row .thumb img, .list-row .thumb .placeholder { width: 100%; height: 100%; object-fit: cover; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 650; padding: 3px 9px; border-radius: 999px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.muted { background: var(--surface-2); color: var(--text-2); border-color: transparent; }

/* ---------- Panels / grouped lists ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; box-shadow: var(--shadow-1); }
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1080px) { .cols { grid-template-columns: 1fr; } }

.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 20px; margin: 0; }
.dl > div { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.dl dt { font-size: var(--fs-xs); color: var(--text-2); font-weight: 500; }
.dl dd { margin: 2px 0 0; font-weight: 550; overflow-wrap: anywhere; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .meta { color: var(--text-2); font-size: var(--fs-sm); }
.empty-inline { color: var(--text-2); padding: 8px 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px 20px; box-shadow: var(--shadow-1); }
.kpi .k { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; }
.kpi .v { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: var(--fs-xs); margin-top: 2px; }

/* ---------- Detail hero ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 12px -8px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; margin-bottom: 28px; align-items: start; }
@media (max-width: 899px) { .hero { grid-template-columns: 1fr; gap: 20px; } }
.gallery-main { aspect-ratio: 4 / 5; border-radius: var(--radius-l); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-2); }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
button.gallery-main { display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in; position: relative; }
button.gallery-main:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.zoom-hint { position: absolute; right: 12px; bottom: 12px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 999px; background: rgb(0 0 0 / .55); color: #fff; opacity: .85; transition: opacity .2s; }
button.gallery-main:hover .zoom-hint { opacity: 1; }

/* Photo carousel */
.carousel { display: grid; gap: 8px; }
.carousel-head { display: flex; align-items: center; justify-content: space-between; }
.carousel-head .label { margin: 0; }
.carousel-btns { display: flex; gap: 4px; }
.carousel-nav:disabled { opacity: .35; cursor: default; }
.carousel-track { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 8px; scrollbar-width: thin; }
.carousel-track > div { flex: none; scroll-snap-align: start; }
.thumb-btn { flex: none; width: 88px; height: 88px; padding: 0; border-radius: 14px; overflow: hidden; border: 2px solid transparent; background: var(--surface-2); cursor: pointer; }
.thumb-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.thumb-btn.add-tile { display: grid; place-items: center; align-content: center; gap: 4px; border: 2px dashed var(--line-strong); background: var(--surface); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; }
.thumb-btn.add-tile:hover { color: var(--text); border-color: var(--text-2); }

/* Full-screen viewer */
dialog.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: rgb(0 0 0 / .94); color: #fff; }
dialog.lightbox { overflow: hidden; } dialog.lightbox > * { flex-shrink: 1; } /* full-screen viewer: fits the screen, never scrolls */
dialog.lightbox::backdrop { background: rgb(0 0 0 / .94); }
.lb-figure { margin: 0; width: 100%; height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; padding: 56px 72px 16px; box-sizing: border-box; }
.lb-figure img { max-width: 100%; max-height: calc(100dvh - 120px); object-fit: contain; border-radius: 6px; user-select: none; -webkit-user-drag: none; }
.lb-caption { color: #d4d4d8; font-size: var(--fs-sm); padding-top: 12px; }
.lb-btn { position: absolute; width: 48px; height: 48px; border-radius: 999px; border: 0; display: grid; place-items: center; background: rgb(255 255 255 / .14); color: #fff; cursor: pointer; }
.lb-btn:hover { background: rgb(255 255 255 / .24); }
.lb-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
@media (max-width: 599px) { .lb-figure { padding: 60px 8px 12px; } .lb-prev, .lb-next { top: auto; bottom: 12px; transform: none; } .thumb-btn { width: 72px; height: 72px; } }
@media (forced-colors: active) { .lb-btn, .zoom-hint { border: 1px solid CanvasText; } }
.thumb-btn[aria-current="true"] { border-color: var(--accent); }
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; }
.hero-info { display: flex; flex-direction: column; gap: 16px; }
.hero-title { font-size: clamp(28px, 4vw, 40px); font-weight: 750; letter-spacing: -0.035em; line-height: 1.08; }
.hero-sub { color: var(--text-2); font-size: var(--fs-lg); }
.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .k { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; }
.stat .v { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.serial { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.serial code { font-family: var(--mono); font-size: var(--fs-md); font-weight: 600; background: var(--surface-2); padding: 6px 10px; border-radius: 8px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart-box { width: 100%; }
.chart .axis-text { fill: var(--text-2); font-size: var(--fs-xs); font-family: var(--font); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .12; }
.chart .ref { stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend .sw { width: 16px; height: 3px; border-radius: 2px; background: var(--accent); }
.legend .sw.ref { background: none; border-top: 2px dashed var(--text-3); height: 0; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: var(--fs-sm); }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-row .n { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; min-width: 2ch; text-align: right; }
details.data-table { margin-top: 12px; font-size: var(--fs-sm); }
details.data-table summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--text-2); font-weight: 600; font-size: var(--fs-xs); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Empty / banners ---------- */
.empty { text-align: center; padding: 64px 24px; background: var(--surface); border-radius: var(--radius-l); border: 1px dashed var(--line-strong); }
.empty .art { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 22px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-soft-ink); }
.empty .art .icon { width: 40px; height: 40px; }
.empty p { color: var(--text-2); max-width: 46ch; margin: 8px auto 20px; }
.empty .actions { justify-content: center; }
.banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 20px; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--text); }
.banner.warn > .icon { color: var(--warn); }
.banner.bad { background: var(--bad-soft); }
.banner.bad > .icon { color: var(--bad); }
.banner .grow { flex: 1 1 200px; }
/* The icon stays beside the text; a short message fills the rest of the line instead of wrapping under the icon. */
.banner > .icon { flex: none; }
.banner-text { flex: 1 1 0; min-width: 0; }

/* ---------- Lock screen ---------- */
.lock {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--info) 16%, transparent), transparent 60%),
    var(--bg);
}
.lock-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 28px; padding: 36px 32px; box-shadow: var(--shadow-3); border: 1px solid var(--line); animation: page-in .45s var(--ease); }
@media (max-width: 480px) { .lock-card { padding: 28px 20px; } }
.lock-logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 18px; box-shadow: var(--shadow-2); }
.lock-card h1 { text-align: center; font-size: var(--fs-2xl); font-weight: 750; }
.lock-card .sub { text-align: center; margin-bottom: 24px; }
.lock-card form { display: flex; flex-direction: column; gap: 16px; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > div { height: 100%; width: 0; border-radius: 999px; transition: width .25s var(--ease), background .25s; }
.meter-label { font-size: var(--fs-xs); color: var(--text-2); }
.features { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; font-size: var(--fs-sm); color: var(--text-2); }
.features li { display: flex; gap: 10px; align-items: flex-start; }
.features .icon { color: var(--ok); width: 18px; height: 18px; margin-top: 1px; }

/* ---------- Dialogs ---------- */
/* Every form window is the same centered modal, on phones too. The whole window
   scrolls as one: the title row (with Close) stays at the top, and the buttons
   sit at the end of the form instead of in a pinned bar. */
dialog {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  border-radius: 24px; box-shadow: var(--shadow-3);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  overflow-y: auto; overscroll-behavior: contain;
}
dialog::backdrop { background: rgba(0, 0, 0, .42); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog[open] { animation: dlg-in .28s var(--ease); display: flex; flex-direction: column; }
dialog > * { flex-shrink: 0; } /* sections keep their height; the window scrolls instead */
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 3; background: var(--surface); }
.dlg-head h2 { font-size: var(--fs-xl); }
.dlg-body { padding: 20px 24px; position: relative; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (max-width: 600px) {
  dialog { max-height: calc(100dvh - 32px); }
  .dlg-body { padding: 18px 18px; }
}

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.photo-tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile .tile-actions { position: absolute; inset: auto 4px 4px 4px; display: flex; justify-content: space-between; }
.photo-tile .icon-btn { width: 36px; height: 36px; background: rgba(0,0,0,.62); color: #fff; }
.photo-tile .icon-btn:hover { background: rgba(0,0,0,.8); }
.photo-tile .cover-tag { position: absolute; top: 6px; left: 6px; display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 650; padding: 3px 9px 3px 7px; border-radius: 999px; background: rgb(0 0 0 / .72); color: #fff; }
.photo-tile .cover-tag .icon { width: 14px; height: 14px; color: #7cb4ff; fill: currentColor; }
/* "Make cover" on every other photo: a clear text button, the same size as the labels. */
.photo-tile .tile-btn { min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px; background: rgb(0 0 0 / .72); color: #fff; font-size: var(--fs-xs); font-weight: 650; cursor: pointer; }
.photo-tile .tile-btn:hover { background: rgb(0 0 0 / .85); }
.photo-tile .tile-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (forced-colors: active) { .photo-tile .tile-btn, .photo-tile .cover-tag { border: 1px solid CanvasText; } }
.add-photo {
  aspect-ratio: 1; border-radius: 12px; border: 2px dashed var(--line-strong);
  display: grid; place-items: center; text-align: center; cursor: pointer; color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 600; background: transparent; padding: 6px;
}
.add-photo:hover { background: var(--surface-2); color: var(--text); }
.add-photo:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (max-width: 899px) { [data-platform="native"] .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); } }
.toast { display: flex; gap: 10px; align-items: center; background: var(--text); color: var(--surface); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: var(--fs-sm); box-shadow: var(--shadow-3); animation: dlg-in .3s var(--ease); max-width: calc(100vw - 32px); }

/* ---------- Settings ---------- */
.settings { display: grid; gap: 20px; max-width: 760px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.panel-head + .setting { border-top: 0; padding-top: 0; }
.setting .txt { flex: 1 1 260px; }
.setting .txt p { color: var(--text-2); font-size: var(--fs-sm); margin-top: 2px; }
.setting .select { width: auto; min-width: 160px; }

.report-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); grid-auto-rows: 1fr; gap: 20px; }
/* The grid gap does the spacing; the stacked-panel margin would offset every card after the first. */
.report-list > .panel + .panel { margin-top: 0; }
.report-card { display: flex; flex-direction: column; gap: 10px; }
.report-card .art { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-soft-ink); }
.report-card p { color: var(--text-2); font-size: var(--fs-sm); flex: 1; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
}
@media (forced-colors: active) {
  .btn, .chip, .card, .panel, .kpi, .stat { border: 1px solid CanvasText; }
  .nav-link[aria-current="page"], .tab[aria-current="page"] { outline: 2px solid Highlight; }
}

/* ---------- Print (insurance & stolen reports) ---------- */
.print-root { display: none; }
@media print {
  @page { margin: 16mm 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .app, .toasts, .skip-link { display: none !important; }
  .print-root { display: block !important; }
  .rpt h1 { font-size: 22pt; margin-bottom: 4pt; }
  .rpt .rpt-meta { color: #333; margin-bottom: 14pt; font-size: 10pt; }
  .rpt .rpt-summary { display: flex; gap: 24pt; margin-bottom: 16pt; padding: 10pt 12pt; border: 1px solid #999; border-radius: 6pt; }
  .rpt .rpt-summary div { font-size: 10pt; color: #333; }
  .rpt .rpt-summary strong { display: block; font-size: 15pt; color: #000; }
  .rpt .item { display: grid; grid-template-columns: 110pt 1fr; gap: 12pt; padding: 10pt 0; border-top: 1px solid #bbb; break-inside: avoid; }
  .rpt .item img { width: 110pt; height: 130pt; object-fit: cover; border-radius: 4pt; }
  .rpt .item .noimg { width: 110pt; height: 130pt; border: 1px dashed #999; border-radius: 4pt; display: grid; place-items: center; color: #555; font-size: 9pt; }
  .rpt .item h2 { font-size: 13pt; margin-bottom: 4pt; }
  .rpt table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  .rpt td { padding: 2pt 6pt 2pt 0; vertical-align: top; }
  .rpt td:first-child { color: #444; width: 32%; }
  .rpt .stolen-banner { font-size: 30pt; font-weight: 800; letter-spacing: .04em; border: 4pt solid #000; padding: 8pt 12pt; text-align: center; margin-bottom: 12pt; }
  .rpt .stolen-photos { display: flex; flex-wrap: wrap; gap: 8pt; margin: 10pt 0; }
  .rpt .stolen-photos img { width: 160pt; height: 190pt; object-fit: cover; border-radius: 4pt; }
  .rpt .serial-big { font-family: ui-monospace, Menlo, monospace; font-size: 18pt; font-weight: 700; }
  .rpt .blank { border-bottom: 1px solid #000; display: inline-block; min-width: 220pt; height: 14pt; }
  .rpt .foot { margin-top: 18pt; font-size: 8.5pt; color: #444; }
}

/* ---------- Additions ---------- */
.col { min-width: 0; display: flex; flex-direction: column; }
.stretch { color: inherit; text-decoration: none; }
.stretch::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.stretch:hover { text-decoration: underline; text-underline-offset: 3px; }
.stretch:focus-visible { outline: none; }
.linklike { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 600; text-align: left; min-height: 24px; }
.dlg-form { display: flex; flex-direction: column; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.photo-wrap { margin-top: 12px; }
.card-meta .badge { margin-left: 6px; }
.hero-info .chips { margin: 0; }
.rows a, .panel a:not(.btn) { color: var(--text); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.rows a:hover { text-decoration-color: currentColor; }
.lock-card .banner { margin-bottom: 16px; }
h1[tabindex="-1"]:focus, main:focus { outline: none; }
@media (max-width: 480px) {
  .stat-row { gap: 8px; }
  .stat { padding: 12px 10px; }
  .stat .k { font-size: var(--fs-xs); }
  .stat .v { font-size: var(--fs-lg); }
}
@media print {
  .rpt > p { margin: 0 0 6pt; }
  .rpt > p:has(.blank) { margin: 0 0 14pt; }
}

/* ---------- Passkeys & recovery ---------- */
.stack-s { display: flex; flex-direction: column; gap: 14px; }
.btn-lg { min-height: 52px; font-size: var(--fs-md); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: var(--fs-xs); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.linklike.center { align-self: center; color: var(--accent); text-decoration: none; min-height: 44px; padding: 0 8px; }
.linklike.center:hover { text-decoration: underline; }
.slots { list-style: none; margin: 10px 0 0; padding: 0; }
.slots li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.slots li p { margin: 0; }
@media print { dialog { display: none !important; } }

/* Sign-in screens */
.center-text { text-align: center; }
.lock-card .features { border-top: 1px solid var(--line); padding-top: 20px; }
.lock:has(> .dev-bar) { grid-template-rows: 1fr auto; gap: 16px; }
.dev-bar {
  justify-self: center; align-self: end;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 32px); padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--surface); border: 1px dashed var(--line-strong); box-shadow: var(--shadow-2); font-size: var(--fs-sm);
}
.inbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.inbox li { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; justify-items: start; }
.inbox li p { margin: 0; }
@media print { .dev-bar { display: none !important; } }

/* Masked amounts (click to reveal) */
.secret { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 4px; margin: 0 -4px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.secret:hover { background: var(--surface-2); }
.secret:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.secret .icon { color: var(--text-2); flex: none; }
.secret-dots { letter-spacing: 0.12em; color: var(--text-2); }
.secret-stack { display: grid; gap: 2px; }


/* ---------- List page toolbar (Instruments, Pedals, Amps): count, then filter, sort and layout ---------- */
.row-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result-count { margin: 0; color: var(--text-2); font-size: var(--fs-md); }
.toolbar-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.tool-btn { position: relative; border: 1px solid var(--line-strong); background: var(--surface); }
.tool-btn[aria-expanded="true"] { background: var(--surface-2); }
.dot-count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 700; line-height: 20px; text-align: center; }
.active-filters { margin-bottom: 16px; align-items: center; }
.chip-active { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); }
.chip-active .icon { width: 16px; height: 16px; }
.filter-body { display: grid; gap: 20px; }
.filter-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.filter-group legend { padding: 0; margin-bottom: 10px; font-weight: 600; }
.filter-group .chips { margin: 0; }
.filter-group .chip { display: inline-flex; align-items: center; gap: 8px; }
.filter-group .chip .n { font-size: var(--fs-xs); opacity: .75; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  /* Phones: count and layout toggle on top; filter and a full-width sort below. */
  .toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px 8px; }
  .toolbar-end { display: contents; }
  .toolbar .result-count { grid-row: 1; grid-column: 1 / 3; }
  .toolbar .seg { grid-row: 1; grid-column: 3; }
  #filter-toggle { grid-row: 2; grid-column: 1; }
  .toolbar-end .field { grid-row: 2; grid-column: 2 / 4; min-width: 0; }
  .toolbar-end .select { width: 100%; }
}
@media (forced-colors: active) { .dot-count { border: 1px solid CanvasText; } }

/* List page sections: one per instrument type, effect type or amp format */
.type-section + .type-section { margin-top: 36px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; }
.section-title .n { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
/* Gain or loss: one line under the revealed amount paid */
.gain-line { display: block; margin-top: 2px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0; white-space: nowrap; }

/* ---------- Small-screen navigation ---------- */
/* Native apps: bottom tab bar. Website: menu button that opens a side panel. */
@media (max-width: 899px) {
  [data-platform="native"] .tabbar { display: grid; }
}
.menu-btn { margin-right: -8px; }
dialog.nav-drawer {
  margin: 0 0 0 auto; width: min(320px, 86vw); height: 100dvh; max-height: none;
  border-radius: 20px 0 0 20px; padding: calc(12px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  gap: 12px;
}
dialog.nav-drawer[open] { animation: drawer-in .26s var(--ease); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px 6px; border-bottom: 1px solid var(--line); }
.drawer-head .brand { padding: 0; font-size: var(--fs-lg); }
.nav-drawer .nav { margin-top: 4px; }
.nav-drawer .nav-link { min-height: 48px; }
.nav-drawer .sidebar-foot { margin-top: auto; }
@media (prefers-reduced-motion: reduce) { dialog.nav-drawer[open] { animation: none; } }

/* "Choose all that apply" groups (e.g. Log care → What was done) */
fieldset.checks-field { border: 0; margin: 0; padding: 0; }
fieldset.checks-field legend { padding: 0; margin-bottom: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.check-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.check-pill:hover { background: var(--surface-2); }
.check-pill input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.check-pill:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 600; }
.check-pill:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (forced-colors: active) { .check-pill:has(input:checked) { outline: 2px solid Highlight; } }

/* Care by instrument: details take the full width on narrow screens, with the
   reminder badge and Log care button on their own line underneath. */
.care-rows li { flex-wrap: wrap; align-items: center; }
.care-rows .grow { flex: 1 1 260px; min-width: 0; }
.care-rows .meta { overflow-wrap: anywhere; }
.care-actions { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; }
.care-actions .badge { white-space: nowrap; }
@media (max-width: 640px) {
  .care-rows .grow { flex-basis: 100%; }
  .care-actions { flex: 1 1 100%; justify-content: space-between; }
}
.dlg-foot .dlg-delete { margin-right: auto; }
/* Phones: Cancel and Save stay together; Delete gets its own line underneath. */
@media (max-width: 560px) {
  .dlg-foot .dlg-delete { order: 3; flex: 1 1 100%; margin-right: 0; justify-content: center; }
}

/* Identification: serial number beside its estimate; wraps to stacked when narrow. */
.serial-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.serial-cell { flex: 0 0 auto; display: grid; gap: 6px; }

/* ---------- Dropdowns (drawn by the app, not the browser) ---------- */
.dd { position: relative; min-width: 0; }
.dd-btn { display: flex; align-items: center; text-align: left; font: inherit; cursor: pointer; }
.dd-btn .dd-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn[aria-expanded="true"] { border-color: var(--focus); }
.dd-btn:disabled { opacity: .6; cursor: not-allowed; }
.dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 100%; width: max-content; max-width: min(320px, calc(100vw - 32px));
  margin: 0; padding: 6px; list-style: none; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  box-shadow: var(--shadow-2);
}
.dd.up .dd-menu { top: auto; bottom: calc(100% + 6px); }
/* Top layer (above dialogs): placed by the script under or over its button. */
.dd-menu[popover] { position: fixed; inset: auto; min-width: 0; }
.dd-group + .dd-group, .dd-opt + .dd-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.dd-group > ul { list-style: none; margin: 0; padding: 0; }
.dd-group-label { padding: 6px 12px 4px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.dd-menu[hidden] { display: none; }
.dd-opt { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 10px 12px; border-radius: 8px; cursor: pointer; line-height: 1.3; }
.dd-opt:hover { background: var(--surface-2); }
.dd-opt:focus-visible, .dd-opt:focus { outline: none; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--focus); }
.dd-opt .icon { width: 18px; height: 18px; color: var(--accent); visibility: hidden; }
.dd-opt[aria-selected="true"] { font-weight: 600; }
.dd-opt[aria-selected="true"] .icon { visibility: visible; }
@media (forced-colors: active) { .dd-menu { border: 1px solid CanvasText; } .dd-opt:focus { outline: 2px solid Highlight; } }

/* ---------- Item page top row: back link and tags, then icon buttons on the right ---------- */
.detail-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.detail-bar .back { margin: 0 0 0 -8px; padding-inline: 8px; }
.detail-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Photo labels (cards and item pages): status top-left, insured shield top-right (hover shows "Insured"). */
.hero-media { position: relative; }
:is(.media, .hero-media) > .badge { pointer-events: none; } /* taps go through to the card or photo */
:is(.media, .hero-media) > .insured-mark { left: auto; right: 12px; pointer-events: auto; }
.hero-media > .insured-mark { cursor: help; }
.media > .insured-mark { cursor: pointer; }
/* The shield matches the status tag: same green style and height everywhere. */
.badge.insured-mark { padding-block: 0; padding-inline: 7px; height: 26px; box-sizing: border-box; display: inline-flex; align-items: center; }
.insured-mark .icon { color: currentColor; }
/* List view: the photo is too small to hold labels, so they sit beside it. */
.row-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.row-badges .badge { position: relative; z-index: 2; pointer-events: none; }
.row-badges .insured-mark { pointer-events: auto; cursor: pointer; }

/* ⓘ button with a popup of extra detail (e.g. the serial number estimate). */
.serial-line { display: flex; align-items: center; gap: 4px; }
.info-wrap { position: relative; display: inline-flex; }
.info-btn { color: var(--info); }
.info-btn[aria-expanded="true"] { background: var(--info-soft); }
.info-pop {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 20;
  width: max-content; max-width: min(300px, calc(100vw - 48px));
  padding: 12px 14px; border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2);
  font-size: var(--fs-sm); line-height: 1.45;
}
.info-pop[hidden] { display: none; }
.info-pop p { margin: 0; }
.info-pop p + p { margin-top: 6px; }
@media (forced-colors: active) { .info-pop { border: 1px solid CanvasText; } }

/* ==========================================================================
   Nocturne components: the shapes and treatments of the design system.
   Colors come from the tokens at the top, so light and dark share these rules.
   ========================================================================== */

/* Side panel (desktop) and the phone menu panel: navy glass in light mode,
   dark glass with a blue highlight in dark mode. Text here is always light. */
.sidebar, dialog.nav-drawer {
  background: var(--side-bg); background-color: var(--side-color); color: #f1f6fb; border-right: 1px solid rgb(241 246 251 / .08);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
dialog.nav-drawer { background-color: var(--brand-2); }
.sidebar { padding: 24px 16px 20px; gap: 6px; }
.sidebar .brand, .nav-drawer .brand { color: #f1f6fb; }
.sidebar .global-search .input, .nav-drawer .input {
  background: rgb(241 246 251 / .06); border-color: rgb(241 246 251 / .14); color: #f1f6fb;
}
.sidebar .global-search .input::placeholder { color: rgb(241 246 251 / .62); }
.sidebar .global-search .icon, .sidebar .global-search .search-clear .icon { color: rgb(241 246 251 / .8); }
.sidebar .nav-link, .nav-drawer .nav-link { min-height: 46px; border-radius: 15px; color: rgb(241 246 251 / .78); font-weight: 500; }
.sidebar .nav-link .icon, .nav-drawer .nav-link .icon { color: rgb(241 246 251 / .62); }
.sidebar .nav-link:hover, .nav-drawer .nav-link:hover { background: rgb(241 246 251 / .06); }
.sidebar .nav-link[aria-current="page"], .nav-drawer .nav-link[aria-current="page"] {
  background: var(--side-active-bg); color: var(--side-active-ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgb(124 180 255 / .22), 0 12px 26px -16px rgb(124 180 255 / .6);
}
.sidebar .nav-link[aria-current="page"] .icon, .nav-drawer .nav-link[aria-current="page"] .icon { color: var(--side-active-icon); }
.sidebar .nav-link .count, .nav-drawer .nav-link .count { background: transparent; color: rgb(241 246 251 / .62); font-weight: 500; }
.sidebar .nav-link[aria-current="page"] .count, .nav-drawer .nav-link[aria-current="page"] .count { color: var(--side-active-icon); font-weight: 600; }
.sidebar .nav-link .count.alert, .nav-drawer .nav-link .count.alert { background: var(--brand-acc); color: var(--brand-acc-ink); font-weight: 700; }
.sidebar .privacy-pill, .nav-drawer .privacy-pill { background: rgb(241 246 251 / .05); border-color: rgb(241 246 251 / .1); color: rgb(241 246 251 / .7); border-radius: 18px; padding: 14px; }
.sidebar .privacy-pill strong, .nav-drawer .privacy-pill strong { color: #f1f6fb; font-weight: 600; }
.sidebar .privacy-pill .icon, .nav-drawer .privacy-pill .icon { color: var(--brand-acc); }
.sidebar .btn-secondary, .nav-drawer .btn-secondary { background: transparent; color: rgb(241 246 251 / .9); border-color: rgb(241 246 251 / .18); }
.sidebar .btn-secondary:hover, .nav-drawer .btn-secondary:hover { background: rgb(241 246 251 / .06); }
.sidebar :focus-visible, .nav-drawer :focus-visible { outline-color: var(--brand-acc); }
.nav-drawer .drawer-head { border-bottom-color: rgb(241 246 251 / .1); }
.nav-drawer .drawer-head .icon-btn { color: #f1f6fb; }
.nav-drawer .drawer-head .icon-btn:hover { background: rgb(241 246 251 / .08); }

/* Phone top bar: the navy bar with rounded lower corners. */
@media (max-width: 899px) {
  .topbar {
    background: linear-gradient(180deg, var(--brand-1), #0a1a34); background-color: var(--brand-1); color: #f1f6fb;
    border-bottom: 0; border-radius: 0 0 24px 24px; box-shadow: 0 10px 30px -20px rgb(5 14 31 / .8);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .topbar .brand { color: #f1f6fb; }
  .topbar .icon-btn { color: #f1f6fb; background: rgb(241 246 251 / .07); box-shadow: inset 0 0 0 1px rgb(241 246 251 / .12); width: 44px; height: 44px; }
  .topbar .icon-btn:hover, .topbar.searching .search-toggle { background: rgb(241 246 251 / .14); }
  .topbar .global-search .input { background: rgb(241 246 251 / .08); border-color: rgb(241 246 251 / .16); color: #f1f6fb; }
  .topbar .global-search .input::placeholder { color: rgb(241 246 251 / .62); }
  .topbar .global-search .icon { color: rgb(241 246 251 / .8); }
  .topbar :focus-visible { outline-color: var(--brand-acc); }
  .main { padding-top: 18px; }
}

/* Page header: ultra-light display title; in dark mode a faint watermark word sits behind it. */
.page-head { position: relative; align-items: center; margin: 4px 0 26px; min-height: 64px; }
.page-head[data-wm]::before {
  content: attr(data-wm); position: absolute; left: -6px; top: 50%; transform: translateY(-52%);
  font: 800 clamp(64px, 11vw, 132px)/1 var(--font-display); letter-spacing: -0.05em; text-transform: uppercase;
  color: var(--wm); white-space: nowrap; pointer-events: none; z-index: 0; max-width: 100%; overflow: hidden;
}
.page-head > * { position: relative; z-index: 1; }
.h1 { font-family: var(--font-display); font-size: clamp(36px, 5vw, 62px); font-weight: 200; letter-spacing: -0.05em; line-height: 1; }
.page-head .btn-primary { padding: 0 18px 0 7px; gap: 8px; box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--accent) 55%, transparent); }
.page-head .btn-primary .icon { width: 30px; height: 30px; padding: 7px; border-radius: 50%; background: var(--add-disc); color: var(--add-plus); stroke-width: 2.4; }

/* Buttons and controls: pills everywhere. */
.btn-secondary { border-color: var(--line); background: var(--surface); }
.tool-btn, .icon-btn.tool-btn { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1); }
.toolbar .dd-btn.select { border-radius: 999px; border-color: var(--line); box-shadow: var(--shadow-1); min-height: 44px; } /* form dropdowns keep the field style */
.seg { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); padding: 4px; }
.seg .icon-btn { width: 40px; height: 36px; color: var(--text-3); }
.seg .icon-btn[aria-pressed="true"] { background: var(--seg-on-bg); color: var(--seg-on-ink); box-shadow: none; }
.input, .select, .textarea { border-radius: var(--radius-s); }
.chip { border-color: var(--line); }

/* Count: a large ultra-light numeral, e.g. "13 instruments". */
.result-count .display-num { font: 200 44px/1 var(--font-display); letter-spacing: -0.04em; color: var(--text); margin-right: 8px; vertical-align: -6px; }
@media (max-width: 560px) { .result-count .display-num { font-size: 36px; } }

/* Section titles: small spaced capitals. */
.section-title { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-2); }
.section-title .n { font-size: var(--fs-xs); color: var(--text); }

/* Cards: glass panel with the photo inset. */
.card { padding: 8px; border-radius: var(--radius-l); border-color: var(--line); box-shadow: var(--shadow-2); }
.card:hover { transform: translateY(-3px); }
.card .media { border-radius: 21px; }
.card-body { padding: 12px 8px 8px; }
.card-title { font-weight: 600; }
.card-meta { color: var(--text-3); }

/* Labels on photos: the owned/insured label is the blue brand pill; others stay neutral. */
:is(.media, .hero-media) > .badge.ok { background: var(--brand-label); color: #ffffff; border-color: rgb(255 255 255 / .2); }
:is(.media, .hero-media) > .badge.ok .dot { background: var(--brand-acc); box-shadow: 0 0 8px var(--brand-acc); }
:is(.media, .hero-media) > .badge.ok.insured-mark .icon { color: #ffffff; }
.row-badges .badge.ok { background: var(--accent-soft); color: var(--accent-soft-ink); }

/* Backup reminder: a card with an icon chip, and an ink pill for the main action. */
.banner.warn { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 14px 16px 14px 14px; box-shadow: var(--shadow-2); }
.banner.warn > .icon { width: 22px; height: 22px; padding: 11px; box-sizing: content-box; border-radius: 50%; background: var(--warn-soft); }
.banner .btn-secondary { background: var(--text); color: var(--surface); border-color: transparent; }
.banner .btn-secondary:hover { background: var(--text-2); }
.banner .btn-ghost { color: var(--text); }

/* Panels, lists, empty states, item pages and windows share the softer radius and glass. */
.panel, .kpi, .list, .stat { border-color: var(--line); box-shadow: var(--shadow-2); }
.empty { border-style: solid; border-color: var(--line); box-shadow: var(--shadow-2); }
.hero-title { font-family: var(--font-display); font-weight: 300; letter-spacing: -0.04em; }
.gallery-main { border-radius: var(--radius-l); }
dialog { border-radius: 28px; border: 1px solid var(--line); }
.dlg-head h2 { font-family: var(--font-display); font-weight: 600; }
.dd-menu { border-radius: 18px; border-color: var(--line); }

/* Sign-in: navy-tinted backdrop, glass card. */
.lock { background: radial-gradient(1100px 600px at 10% -10%, rgb(28 63 120 / .28), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgb(124 180 255 / .16), transparent 60%), var(--bg); }
.lock-card { border-radius: 32px; }
.lock-card h1 { font-family: var(--font-display); font-weight: 300; font-size: var(--fs-2xl); letter-spacing: -0.03em; }

@media (forced-colors: active) {
  .sidebar, .topbar, dialog.nav-drawer { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
  .page-head[data-wm]::before { display: none; }
}

/* One button height: every button, dropdown, chip and control is 44px tall (also the
   minimum touch target). The grid/list switch is one 44px control. Not included: the
   inline "show" toggle in a line of text, the controls on photo tiles and in the
   full-screen photo viewer, and photo thumbnails. */
.btn, .btn-sm, .chip, .icon-btn, .tool-btn { min-height: 44px; }
.btn-sm { padding: 0 16px; }
.icon-btn { height: 44px; }
.input, .select { min-height: 44px; padding-top: 9px; padding-bottom: 9px; }
.dd-btn.select { height: 44px; }
.seg { padding: 4px; }
.seg .icon-btn { height: 36px; min-height: 36px; }

/* Suggestion menu on a text field (e.g. Make): the dropdown menu's look, no checkmark. */
.sg { position: relative; min-width: 0; }
.sg-menu .dd-opt { font-weight: 500; }
.sg-menu .dd-opt[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--focus); font-weight: 600; }
