:root {
  --night: #160F22;
  --night-2: #211833;
  --night-3: #2E2346;
  --ink: #F3F0FA;
  --ink-soft: #B9AFCF;
  --magenta: #FF00A0;
  --cyan: #00F0FF;
  --violet: #8B5CF6;
  --amber: #F59E0B;
  --mint: #2EF2A0;
  --danger: #FF3B57;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --text: 'Figtree', system-ui, sans-serif;
  --radius-xl: 28px;
  --radius-m: 16px;
  --radius-s: 10px;
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ink);
  font: 16px/1.45 var(--text);
  -webkit-tap-highlight-color: transparent;
}
main {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.05; margin: 0 0 12px; letter-spacing: -0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
p { margin: 0 0 12px; }
a { color: var(--cyan); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

/* Buttons */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: 700 1rem var(--text); color: var(--night);
  background: var(--ink); border-radius: var(--radius-m);
  padding: 14px 18px; min-height: 52px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, filter .12s ease;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.big { width: 100%; font-size: 1.15rem; min-height: 64px; border-radius: var(--radius-xl); }
.btn.hot { background: linear-gradient(120deg, var(--magenta), var(--violet)); color: #fff; }
.btn.cool { background: linear-gradient(120deg, var(--cyan), var(--violet)); color: var(--night); }
.btn.mint { background: var(--mint); }
.btn.ghost { background: var(--night-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* Dashboard: tiles fill the screen above the tab bar */
.dash {
  display: flex; flex-direction: column; gap: 12px;
  min-height: calc(100dvh - var(--tabs-h) - 48px - env(safe-area-inset-bottom));
}
.dash .brand { font-family: var(--display); font-weight: 800; font-size: 1.3rem; margin: 0; }
.tiles { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1.6fr 1fr 1fr; gap: 12px; min-height: 420px; }
.tile {
  container-type: size;
  border-radius: var(--radius-xl); padding: 16px 18px;
  background: var(--night-2);
  display: flex; flex-direction: column; justify-content: space-between;
  text-decoration: none; color: inherit; overflow: hidden; position: relative;
}
.tile .label { font-weight: 600; color: var(--ink-soft); font-size: .95rem; }
.tile .value {
  font-family: var(--display); font-weight: 800; line-height: .9; letter-spacing: -0.03em;
  font-size: clamp(1.8rem, 34cqh, 5rem); font-variant-numeric: tabular-nums;
}
.tile .sub { color: var(--ink-soft); font-size: .9rem; }
.tile.kitty {
  grid-column: 1 / -1;
  background: radial-gradient(120% 140% at 0% 0%, var(--magenta) 0%, var(--violet) 55%, #3B1E8C 100%);
}
.tile.kitty .label, .tile.kitty .sub { color: rgba(255,255,255,.82); }
.tile.kitty .value { font-size: clamp(3rem, 52cqh, 9rem); color: #fff; text-shadow: 0 0 40px rgba(255,0,160,.55); }
.tile.pierre .value { color: var(--cyan); }
.tile.maeve .value { color: var(--magenta); }
.tile.listed .value { color: var(--violet); }
.tile.drafts .value { color: var(--amber); }
.dash .actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }

/* Forms */
label.field { display: block; }
label.field > span { display: block; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; font-size: .95rem; }
input, textarea, select {
  width: 100%; font: 1rem var(--text); color: var(--ink);
  background: var(--night-2); border: 2px solid var(--night-3); border-radius: var(--radius-s);
  padding: 12px 14px; min-height: 48px;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--violet); outline: none; }
.error-text { color: var(--danger); font-size: .9rem; margin-top: 4px; }
.copyable { position: relative; }
.copy {
  position: absolute; right: 6px; top: 30px;
  background: var(--night-3); color: var(--ink); border: 0; border-radius: 8px;
  padding: 6px 10px; font: 600 .85rem var(--text); cursor: pointer;
}

/* Origin picker */
.origins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.origin {
  border: 2px solid var(--night-3); background: var(--night-2); color: var(--ink);
  border-radius: var(--radius-m); padding: 14px 8px; font: 700 1rem var(--text); cursor: pointer; min-height: 72px;
}
.origin small { display: block; font-weight: 400; color: var(--ink-soft); margin-top: 4px; }
.origin[aria-pressed="true"] { border-color: var(--cyan); background: #0d2c38; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: var(--radius-s); overflow: hidden; background: var(--night-2); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .del { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 30px; height: 30px; background: rgba(0,0,0,.6); color: #fff; font-size: 1rem; cursor: pointer; }
.drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 2px dashed var(--violet); border-radius: var(--radius-m); min-height: 120px; padding: 16px;
  color: var(--ink-soft); cursor: pointer;
}
.drop input { display: none; }

/* Item list */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.chip {
  flex: none; border: 2px solid var(--night-3); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font: 600 .95rem var(--text); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--night); border-color: var(--ink); }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { display: block; text-decoration: none; color: inherit; background: var(--night-2); border-radius: var(--radius-m); overflow: hidden; }
.card .pic { aspect-ratio: 1; background: var(--night-3) center/cover no-repeat; position: relative; }
.card .body { padding: 10px 12px 12px; }
.card .title { font-weight: 600; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .price { font-family: var(--display); font-weight: 800; font-size: 1.2rem; margin-top: 4px; }
.status { position: absolute; left: 8px; top: 8px; border-radius: 999px; padding: 3px 10px; font: 700 .8rem var(--text); color: var(--night); }
.status.draft { background: var(--amber); }
.status.listed { background: var(--violet); color: #fff; }
.status.sold { background: var(--mint); }
.tag-third { position: absolute; right: 8px; top: 8px; background: var(--cyan); color: var(--night); border-radius: 999px; padding: 3px 9px; font: 800 .85rem var(--display); }

/* Kitty / movements */
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.share { background: var(--night-2); border-radius: var(--radius-m); padding: 14px; }
.share b { display: block; font-family: var(--display); font-size: 1.7rem; font-weight: 800; }
.share.pierre b { color: var(--cyan); }
.share.tiers b { color: var(--amber); }
.share.maeve b { color: var(--magenta); }
.moves { list-style: none; margin: 0; padding: 0; }
.moves li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--night-3); }
.moves .what { color: var(--ink-soft); font-size: .9rem; }
.pos { color: var(--mint); }
.neg { color: var(--danger); }
.segmented { display: flex; background: var(--night-2); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.segmented button { flex: 1; border: 0; background: transparent; color: var(--ink-soft); font: 700 1rem var(--text); padding: 10px; border-radius: 999px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--night); }

/* Sheet (modal) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 6, 18, .7); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--night-2); width: 100%; max-width: 720px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto; }

/* Tabs */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: rgba(22, 15, 34, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--night-3);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs a { flex: 1; text-align: center; padding: 0; height: var(--tabs-h); line-height: var(--tabs-h); color: var(--ink-soft); text-decoration: none; font-weight: 700; }
#tabs a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 3px 0 var(--magenta); }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; z-index: 30;
  background: var(--ink); color: var(--night); font-weight: 600; border-radius: var(--radius-m); padding: 14px 16px;
}
#toast.bad { background: var(--danger); color: #fff; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; width: 100%; height: 100%; }

.login { min-height: 90dvh; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.login h1 { font-size: clamp(2.6rem, 12vw, 4.5rem); background: linear-gradient(120deg, var(--magenta), var(--violet), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--ink-soft); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.back { color: var(--ink-soft); text-decoration: none; font-weight: 700; }
details summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; padding: 8px 0; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
#tabs[hidden], #toast[hidden] { display: none; }
