/* Clean, modern UI: a dark navy base with the logo's red / yellow / blue as
   accents. Flat surfaces with hairline borders, no drop shadows. */
:root {
  --red: #f0383a;
  --red-hover: #ff5254;
  --yellow: #ffd60a;
  --blue: #4d82f0;
  --ink: #f1f4fb;
  --ink-2: #cdd5e8;
  --muted: #94a2c4;
  --line: #243156;
  --line-strong: #34447a;
  --bg: #0f1730;
  --card: #16203f;
  --subtle: #1e2a50;
  --radius: 14px;
  --radius-sm: 10px;
  --red-soft: color-mix(in srgb, var(--red) 14%, transparent);
  --blue-soft: color-mix(in srgb, var(--blue) 16%, transparent);
  --yellow-soft: color-mix(in srgb, var(--yellow) 18%, transparent);
  --ring: 0 0 0 3px color-mix(in srgb, var(--blue) 35%, transparent);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; padding-bottom: 4rem; }
a { color: var(--blue); text-underline-offset: 2px; }
h1, h2, h3 { color: var(--ink); letter-spacing: -.02em; }
h1 { font-size: 2rem; line-height: 1.15; font-weight: 800; margin: 0 0 .35rem; }
h2 { font-size: 1.2rem; line-height: 1.3; font-weight: 700; margin: 2.25rem 0 .9rem; }
h3 { font-size: 1rem; font-weight: 650; margin: 0 0 .25rem; letter-spacing: -.01em; }
img { max-width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mt { margin-top: 1rem; }
.mt0 { margin-top: 0; }
.center { text-align: center; }
.narrow { max-width: 460px; margin: 3rem auto; }

/* Header: frosted white bar with a thin red / yellow / blue accent on top. */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar::before {
  content: ""; display: block; height: 3px;
  background: linear-gradient(90deg, var(--red) 0 33.3%, var(--yellow) 33.3% 66.6%, var(--blue) 66.6%);
}
.topbar-inner { display: flex; align-items: center; gap: 2rem; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; }
.brand img { height: 44px; width: auto; display: block; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--ink-2); text-decoration: none; padding: .4rem .75rem; border-radius: 8px; font-weight: 550; font-size: .95rem; }
.nav a:hover { background: var(--subtle); color: var(--ink); }
.nav a.active { color: var(--ink); background: var(--subtle); }
.nav a.btn { margin-left: auto; color: #fff; background: var(--red); }
.account { display: flex; align-items: center; gap: 1rem; font-size: .925rem; }
.account-link { display: flex; align-items: center; gap: .45rem; color: var(--ink-2); text-decoration: none; font-weight: 550; }
.account-link:hover { color: var(--ink); }
.account .link { color: var(--muted); text-decoration: none; }
.account .link:hover { color: var(--ink); }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.avatar.big { width: 64px; height: 64px; }
@media (max-width: 900px) {
  .topbar-inner { gap: .75rem; padding-top: .4rem; padding-bottom: .4rem; }
  .nav a { padding: .35rem .5rem; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; justify-content: center;
  background: var(--red); color: #fff; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .55rem 1rem; font: inherit; font-size: .925rem; font-weight: 600; text-decoration: none;
  cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--red-hover); }
.btn:focus-visible, .link:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--red); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--subtle); }
.btn-danger { background: var(--card); color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.btn-danger:hover { background: var(--red-soft); }
.btn-small { padding: .35rem .75rem; font-size: .85rem; border-radius: 8px; }
.btn-big { padding: .8rem 1.6rem; font-size: 1.05rem; border-radius: 12px; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; margin-top: 1rem; }
.btn-google:hover { background: #f8f9fa; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 2.25rem 0 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions, .form-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.form-actions { margin-top: 1.5rem; }
.back { display: inline-block; margin-top: 1.25rem; text-decoration: none; font-size: .925rem; }

.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin: 1rem 0; font-size: .95rem; border: 1px solid; }
.flash-success { background: color-mix(in srgb, #16a34a 9%, var(--card)); color: color-mix(in srgb, #15803d 80%, var(--ink)); border-color: color-mix(in srgb, #16a34a 30%, transparent); }
.flash-error { background: var(--red-soft); color: color-mix(in srgb, var(--red) 75%, var(--ink)); border-color: color-mix(in srgb, var(--red) 30%, transparent); }

/* Landing */
.hero { text-align: center; padding: 3rem 0 3.5rem; }
.hero-logo { width: min(440px, 85%); height: auto; display: block; margin: 0 auto 2rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -.035em; line-height: 1.08; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 620px; margin: 1.25rem auto 2rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.feature { position: relative; overflow: hidden; }
.feature::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--red); }
.feature:nth-child(2)::before { background: var(--yellow); }
.feature:nth-child(3)::before { background: var(--blue); }
.feature h2 { margin-top: 0; font-size: 1.05rem; }
.feature p { color: var(--muted); margin-bottom: 0; }

/* Dashboard stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.stat { text-decoration: none; color: inherit; display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: .2rem; padding: 1.1rem 1.25rem; }
.stat strong { font-size: 2rem; line-height: 1.1; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; font-weight: 500; display: block; }
.stat span::first-letter { text-transform: uppercase; }
.stat, .collection-card, .item-card { transition: border-color .15s, transform .15s; }
.stat:hover, .collection-card:hover, .item-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }

/* Item and collection cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.item-card, .collection-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.collection-card { text-decoration: none; color: inherit; }
.thumb { aspect-ratio: 4 / 3; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: .5rem; background: #fff; }
.placeholder { font-size: 2.5rem; opacity: .7; }
.placeholder.big { font-size: 5rem; }
.card-body { padding: .9rem 1rem 1rem; }
.card-body h3 { font-size: .95rem; }
.card-body h3 a { color: inherit; text-decoration: none; }
.card-body p { margin: .25rem 0 0; }
.meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--muted); margin: 0 0 .5rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--subtle); color: var(--ink-2); vertical-align: middle; }
.tag-lego { background: var(--red-soft); color: color-mix(in srgb, var(--red) 85%, var(--ink)); }
.tag-action_figure { background: var(--blue-soft); color: color-mix(in srgb, var(--blue) 85%, var(--ink)); }
.tag-owned { background: color-mix(in srgb, #16a34a 12%, transparent); color: color-mix(in srgb, #16a34a 80%, var(--ink)); }
.tag-wishlist, .tag-public { background: var(--yellow-soft); color: color-mix(in srgb, #a16207 85%, var(--ink)); }
.priority { font-weight: 600; }
.priority.p1 { color: var(--red); }
.priority.p2 { color: #d97706; }
.priority.p3 { color: var(--muted); }

/* Tabs and filters */
.tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tabs a { padding: .55rem 0; text-decoration: none; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-color: var(--red); }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filters input[type=search] { flex: 1; min-width: 200px; }

/* Forms */
input, select, textarea {
  font: inherit; font-size: .95rem; color: inherit; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: .55rem .75rem; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.filters select, .inline select { width: auto; }
input[type=radio], input[type=checkbox] { width: auto; accent-color: var(--red); }
textarea { resize: vertical; }
.form { max-width: 760px; }
.field { display: flex; flex-direction: column; gap: .35rem; font-weight: 550; font-size: .875rem; color: var(--ink-2); margin-top: 1.1rem; flex: 1; border: 0; padding: 0; }
.field legend { font-weight: 550; margin-bottom: .35rem; padding: 0; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row .field { min-width: 160px; }
.req { color: var(--red); }
.segmented { border: 0; padding: 0; margin: 0 0 1rem; display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.segmented legend { font-weight: 550; font-size: .875rem; color: var(--ink-2); margin-bottom: .4rem; padding: 0; }
.segmented label { border: 1px solid var(--line-strong); border-radius: 999px; padding: .35rem .9rem; cursor: pointer; font-size: .9rem; font-weight: 500; transition: background-color .15s, border-color .15s; }
.segmented label:hover { background: var(--subtle); }
.segmented label:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--card); }
.segmented label:has(input:focus-visible) { box-shadow: var(--ring); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-weight: 400; }
.check { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }

/* Item detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.5rem; margin-top: .75rem; }
@media (max-width: 720px) { .detail { grid-template-columns: 1fr; } }
.detail-media { display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); min-height: 260px; overflow: hidden; padding: 1rem; }
.detail-media img { max-height: 480px; object-fit: contain; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 1rem 0; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.notes { white-space: pre-wrap; background: var(--subtle); border-radius: var(--radius-sm); padding: .75rem 1rem; }

.share, .add-bar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; padding: .85rem 1.1rem; margin-bottom: 1rem; font-size: .925rem; }
.share a { word-break: break-all; }
.inline { display: flex; gap: .5rem; }

.removable .link { color: var(--muted); }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 2rem 1.5rem; text-align: center; }

.footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1.5rem; padding-bottom: 2rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.footer > span:first-child { font-weight: 600; color: var(--ink-2); }

/* Shelves */
.shelf { margin-top: 2.25rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.shelf-head h2 { margin: .75rem 0; display: flex; align-items: center; gap: .6rem; }
.shelf-head h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--red); flex: none; }
.shelf:nth-of-type(3n+2) .shelf-head h2::before { background: var(--blue); }
.shelf:nth-of-type(3n) .shelf-head h2::before { background: var(--yellow); }
.shelf-tools { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.shelf-tools details[open] { flex-basis: 100%; order: 10; }
.shelf-tools details form { margin-top: .4rem; }
.shelf-tools summary { list-style: none; }
.shelf-tools summary::-webkit-details-marker { display: none; }
.link.danger { color: var(--red); }
.item-tools { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .5rem; font-size: .85rem; }
.item-tools select { font-size: .8rem; padding: .25rem .4rem; max-width: 140px; }
.js .js-hide { display: none; }

/* Display name / profile */
.prefixed { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--card); }
.prefixed .prefix { display: flex; align-items: center; padding: 0 .1rem 0 .75rem; color: var(--muted); font-weight: 400; white-space: nowrap; }
.prefixed input { border: 0; border-radius: 0; padding-left: .1rem; box-shadow: none; }
.prefixed:focus-within { border-color: var(--blue); box-shadow: var(--ring); }
.hint { font-weight: 400; color: var(--muted); }
.profile-id { display: flex; align-items: center; gap: 1rem; }

/* Catalog search-and-autofill */
.lookup { display: none; position: relative; background: var(--subtle); border: 1px solid var(--line); border-radius: var(--radius); padding: .25rem 1rem .85rem; margin: .5rem 0 .25rem; }
.js form:has(input[name=kind][value=lego]:checked) .lookup { display: block; }
.lookup .field { margin-top: .75rem; }
.lookup-status:empty { display: none; }
.lookup-status, .attribution { margin: .5rem 0 0; }
.lookup-results { list-style: none; margin: .5rem 0 0; padding: .25rem; max-height: 360px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.lookup-option { display: flex; gap: .75rem; align-items: center; width: 100%; padding: .5rem .6rem; background: none; border: 0; border-radius: 8px; color: inherit; font: inherit; font-size: .925rem; text-align: left; cursor: pointer; }
.lookup-option:hover, .lookup-option:focus { background: var(--subtle); outline: none; }
.lookup-option img, .lookup-thumb { width: 56px; height: 42px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; flex: none; display: flex; align-items: center; justify-content: center; }
.lookup-option > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.lookup-option strong { font-weight: 600; }
