@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations'), url('/fonts/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f1f1f4;
  --surface-3: #e7e7ec;
  --text: #0c0c10;
  --text-2: #3f3f46;
  --muted: #6b6b76;
  --faint: #a1a1aa;
  --border: rgba(12, 12, 24, 0.08);
  --border-strong: rgba(12, 12, 24, 0.15);
  --accent: #6d5dfc;
  --accent-2: #d946ef;
  --accent-ink: #5b4bf0;
  --accent-soft: rgba(109, 93, 252, 0.11);
  --on-accent: #ffffff;
  --success: #15803d;
  --success-bright: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.13);
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --img-bg: #ffffff;
  --header-bg: rgba(246, 246, 248, 0.75);
  --overlay: rgba(10, 10, 16, 0.45);
  --shadow-sm: 0 1px 2px rgba(16, 16, 32, 0.06);
  --shadow: 0 1px 2px rgba(16, 16, 32, 0.04), 0 10px 30px -12px rgba(16, 16, 32, 0.14);
  --shadow-hover: 0 2px 4px rgba(16, 16, 32, 0.05), 0 22px 44px -18px rgba(16, 16, 32, 0.28);
  --shadow-lg: 0 30px 80px -20px rgba(10, 10, 30, 0.38);
  --radius: 20px;
  --radius-sm: 13px;
  --radius-xs: 9px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --max: 1200px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #09090b;
    --surface: #131317;
    --surface-2: #1b1b21;
    --surface-3: #25252d;
    --text: #fafafa;
    --text-2: #d4d4d8;
    --muted: #a1a1aa;
    --faint: #71717a;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --accent: #8b7dff;
    --accent-ink: #a99fff;
    --accent-soft: rgba(139, 125, 255, 0.16);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.13);
    --danger: #fb7185;
    --danger-soft: rgba(251, 113, 133, 0.13);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --img-bg: #f4f4f5;
    --header-bg: rgba(9, 9, 11, 0.72);
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 22px 44px -18px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #09090b;
  --surface: #131317;
  --surface-2: #1b1b21;
  --surface-3: #25252d;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #71717a;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #8b7dff;
  --accent-ink: #a99fff;
  --accent-soft: rgba(139, 125, 255, 0.16);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.13);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --img-bg: #f4f4f5;
  --header-bg: rgba(9, 9, 11, 0.72);
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 22px 44px -18px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

/* person colours */
[data-color='violet'] { --g1: #8b5cf6; --g2: #6366f1; }
[data-color='rose'] { --g1: #fb7185; --g2: #e11d48; }
[data-color='amber'] { --g1: #fbbf24; --g2: #f97316; }
[data-color='emerald'] { --g1: #34d399; --g2: #059669; }
[data-color='sky'] { --g1: #38bdf8; --g2: #2563eb; }
[data-color='indigo'] { --g1: #818cf8; --g2: #4338ca; }
[data-color='fuchsia'] { --g1: #e879f9; --g2: #a21caf; }
[data-color='teal'] { --g1: #2dd4bf; --g2: #0f766e; }
[data-color='orange'] { --g1: #fb923c; --g2: #dc2626; }
[data-color='slate'] { --g1: #94a3b8; --g2: #334155; }

/* occasion colours */
[data-occasion] { --o1: #6366f1; --o2: #06b6d4; }
[data-occasion='christmas'] { --o1: #ef4444; --o2: #166534; }
[data-occasion='birthday'] { --o1: #f472b6; --o2: #8b5cf6; }
[data-occasion='hanukkah'] { --o1: #60a5fa; --o2: #1e3a8a; }
[data-occasion='wedding'] { --o1: #fbbf24; --o2: #e11d48; }
[data-occasion='baby'] { --o1: #7dd3fc; --o2: #f9a8d4; }
[data-occasion='graduation'] { --o1: #facc15; --o2: #1f2937; }
[data-occasion='anniversary'] { --o1: #fb7185; --o2: #9f1239; }
[data-occasion='housewarming'] { --o1: #fdba74; --o2: #0f766e; }
[data-occasion='other'] { --o1: #2dd4bf; --o2: #6366f1; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.icon.fill { fill: currentColor; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  height: 62px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: url('/icon.svg') center/cover;
  box-shadow: 0 4px 14px -4px rgba(109, 93, 252, 0.6);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- layout ---------- */
.app { max-width: var(--max); margin: 0 auto; padding: 28px 20px 96px; min-height: calc(100dvh - 62px); }
.page-enter { animation: pageIn 0.35s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 560;
  font-size: 14px;
  white-space: nowrap;
  transition: transform 0.15s var(--ease), background 0.15s, border-color 0.15s, box-shadow 0.2s, opacity 0.15s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn.primary {
  --btn-bg: var(--text);
  --btn-fg: var(--bg);
  --btn-border: transparent;
}
.btn.primary:hover { background: var(--text); opacity: 0.88; }
.btn.accent {
  --btn-fg: #fff;
  --btn-border: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px -10px rgba(109, 93, 252, 0.8);
}
.btn.accent:hover { filter: brightness(1.06); }
.btn.ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { --btn-fg: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: transparent; }
.btn.success { --btn-bg: var(--success-soft); --btn-fg: var(--success); --btn-border: transparent; }
.btn.success:hover { background: var(--btn-bg); filter: brightness(0.96); }
.btn.danger.solid:hover { background: var(--danger); filter: brightness(1.08); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 40px; padding: 0; }
.btn.sm.icon-only { width: 32px; }
.btn .spinner { width: 16px; height: 16px; }

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  opacity: 0.8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 560; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  font-size: 15px;
}
.textarea { height: auto; min-height: 84px; padding: 11px 14px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 14px; color: var(--faint); pointer-events: none; }
.input-group > .input { padding-left: 40px; }
.input-group > .addon { position: absolute; right: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-error { color: var(--danger); font-size: 13px; font-weight: 500; min-height: 0; }
.form-error:empty { display: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background 0.2s; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; }
.segmented button { border: 0; background: transparent; height: 32px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 560; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--g1), var(--g2)); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25); transition: transform 0.15s; }
.swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--g2); transform: scale(1.05); }

.priority-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.priority-picker button { border: 1px solid var(--border-strong); background: var(--surface); height: 36px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 560; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.priority-picker button.active { border-color: transparent; background: var(--text); color: var(--bg); }

.occasion-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.occasion-picker button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 10px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 560; text-align: left; transition: all 0.15s; }
.occasion-picker button .emoji { font-size: 18px; }
.occasion-picker button.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }

/* ---------- avatars ---------- */
.avatar {
  --size: 44px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g1, #8b5cf6), var(--g2, #6366f1));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: calc(var(--size) * 0.38);
  letter-spacing: -0.01em;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 6px 18px -8px var(--g2, #6366f1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.avatar.emoji { font-size: calc(var(--size) * 0.5); text-shadow: none; }
.avatar.xl { --size: 84px; }
.avatar.lg { --size: 60px; }
.avatar.sm { --size: 28px; }

/* ---------- cards & chips ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip.success { background: var(--success-soft); color: var(--success); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.glass { background: rgba(255, 255, 255, 0.88); color: #18181b; backdrop-filter: blur(8px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.chip.dark { background: rgba(12, 12, 16, 0.78); color: #fff; backdrop-filter: blur(8px); }

/* ---------- home ---------- */
.hero { position: relative; padding: 36px 0 30px; text-align: center; }
.hero::before {
  content: '';
  position: absolute;
  inset: -40px -20vw auto;
  height: 360px;
  background:
    radial-gradient(40% 60% at 30% 40%, rgba(139, 92, 246, 0.18), transparent 70%),
    radial-gradient(35% 55% at 70% 30%, rgba(236, 72, 153, 0.14), transparent 70%),
    radial-gradient(30% 50% at 50% 70%, rgba(56, 189, 248, 0.12), transparent 70%);
  filter: blur(10px);
  z-index: -1;
  pointer-events: none;
}
.hero h1 { font-size: clamp(34px, 6vw, 60px); font-weight: 760; letter-spacing: -0.045em; line-height: 1.02; }
.hero h1 .grad { background: linear-gradient(120deg, var(--accent), var(--accent-2) 60%, #f59e0b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 16px auto 0; max-width: 560px; color: var(--muted); font-size: 17px; }
.hero .row { justify-content: center; margin-top: 26px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 18px; }
.toolbar .input-group { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .input { height: 40px; border-radius: 999px; background: var(--surface); }
.toolbar .select { height: 40px; border-radius: 999px; width: auto; font-size: 14px; }

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.person-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s;
}
.person-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 80px;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  opacity: 0.14;
  mask-image: linear-gradient(to bottom, #000, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent);
}
.person-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.person-card .top { display: flex; align-items: center; gap: 14px; position: relative; }
.person-card h3 { font-size: 18px; font-weight: 680; }
.person-card .bio { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.person-card .foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.person-card .lock { position: absolute; top: 16px; right: 16px; color: var(--success); }
.new-person-card {
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  box-shadow: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  min-height: 160px;
  cursor: pointer;
}
.new-person-card:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.new-person-card .plus { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); }

/* ---------- person page ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 500; margin-bottom: 18px; }
.back-link:hover { color: var(--text); }
.profile { display: flex; align-items: center; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.profile .info { flex: 1; min-width: 220px; }
.profile h1 { font-size: clamp(28px, 4.5vw, 40px); font-weight: 750; letter-spacing: -0.035em; }
.profile .bio { color: var(--muted); margin-top: 6px; max-width: 640px; }
.profile .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.profile .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.owner-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  color: var(--success);
  font-size: 14px;
  font-weight: 560;
  flex-wrap: wrap;
}
.owner-bar .btn { --btn-bg: var(--surface); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  font-weight: 560;
  color: var(--text-2);
  white-space: nowrap;
  transition: all 0.15s;
}
.tab:hover { border-color: var(--faint); }
.tab.active { background: var(--text); color: var(--bg); border-color: transparent; }
.tab .count { font-size: 12px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.tab.add { border-style: dashed; color: var(--muted); }

.list-hero {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  padding: 28px;
  margin-bottom: 20px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(125deg, var(--o1), var(--o2));
  box-shadow: 0 24px 60px -30px var(--o2);
  isolation: isolate;
}
.list-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 90% at 100% 0%, rgba(255, 255, 255, 0.28), transparent 60%),
    radial-gradient(50% 80% at 0% 100%, rgba(0, 0, 0, 0.18), transparent 60%);
  z-index: -1;
}
.list-hero .deco { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); font-size: 92px; opacity: 0.22; filter: saturate(0.6); pointer-events: none; z-index: -1; }
.list-hero .eyebrow { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.85; }
.list-hero h2 { font-size: clamp(24px, 3.6vw, 34px); font-weight: 750; margin-top: 6px; letter-spacing: -0.03em; }
.list-hero .desc { margin-top: 8px; opacity: 0.9; max-width: 620px; white-space: pre-line; }
.list-hero .stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.list-hero .stat { background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.22); backdrop-filter: blur(6px); border-radius: 14px; padding: 8px 14px; min-width: 92px; }
.list-hero .stat b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.list-hero .stat span { font-size: 12px; opacity: 0.85; }
.list-hero .hero-actions { position: absolute; top: 18px; right: 18px; display: flex; gap: 6px; }
.list-hero .hero-actions .btn { --btn-bg: rgba(255, 255, 255, 0.18); --btn-fg: #fff; --btn-border: rgba(255, 255, 255, 0.25); backdrop-filter: blur(6px); }
.list-hero .hero-actions .btn:hover { background: rgba(255, 255, 255, 0.3); }

.spoiler-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.spoiler-banner .ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.spoiler-banner .txt { flex: 1; min-width: 220px; font-size: 14px; }
.spoiler-banner .txt b { display: block; font-weight: 620; }
.spoiler-banner .txt span { color: var(--muted); }

/* ---------- item grid ---------- */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 18px; }
.item-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s;
}
.item-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.item-card .thumb { position: relative; aspect-ratio: 1 / 0.86; background: var(--img-bg); border-bottom: 1px solid var(--border); overflow: hidden; }
.item-card .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 18px; transition: transform 0.5s var(--ease); mix-blend-mode: multiply; }
.item-card:hover .thumb img { transform: scale(1.04); }
.thumb .placeholder, .detail-image .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--o1, #8b5cf6), var(--o2, #6366f1));
  color: rgba(255, 255, 255, 0.92);
}
.thumb .placeholder .icon { width: 42px; height: 42px; stroke-width: 1.5; }
.item-card .badges-tl { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.item-card .badges-tr { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.item-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item-card .store { font-size: 12px; color: var(--muted); font-weight: 560; display: flex; align-items: center; gap: 6px; }
.item-card h3 { font-size: 15px; font-weight: 620; line-height: 1.35; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-card .note { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; min-height: 40px; }
.price { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.price .was { font-weight: 500; font-size: 13px; color: var(--faint); text-decoration: line-through; margin-left: 6px; }
.price.none { font-weight: 500; font-size: 13px; color: var(--faint); }
.item-card.claimed .thumb img, .item-card.claimed .thumb .placeholder { opacity: 0.4; filter: grayscale(0.7); }
.item-card.claimed h3 { color: var(--muted); }
.claim-ribbon {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(12, 12, 16, 0.8);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}
.claim-ribbon.mine { background: linear-gradient(135deg, #16a34a, #15803d); }
.owner-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; opacity: 0; transform: translateY(-4px); transition: all 0.2s var(--ease); }
.item-card:hover .owner-tools, .item-card:focus-within .owner-tools { opacity: 1; transform: none; }
.owner-tools .btn { --btn-bg: rgba(255, 255, 255, 0.92); --btn-fg: #18181b; --btn-border: rgba(0, 0, 0, 0.06); backdrop-filter: blur(8px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
.owner-tools .btn:hover { background: #fff; }
.owner-tools .btn.danger { --btn-fg: #e11d48; }
@media (hover: none) { .owner-tools { opacity: 1; transform: none; } }

.empty {
  text-align: center;
  padding: 56px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty .big { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }

.received-section { margin-top: 40px; }
.received-section summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); padding: 8px 0; }
.received-section summary::-webkit-details-marker { display: none; }
.received-section[open] summary .chev { transform: rotate(90deg); }
.received-section summary .chev { transition: transform 0.2s; }
.received-section .items-grid { margin-top: 12px; }
.received-section .item-card { opacity: 0.72; }

/* ---------- skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s var(--ease);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.28s var(--ease);
  overscroll-behavior: contain;
}
.modal:focus { outline: none; }
.modal.wide { max-width: 880px; }
.modal.medium { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 22px 24px 6px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h2 { font-size: 20px; font-weight: 700; flex: 1; }
.modal-body { padding: 14px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 22px; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
.modal-foot .left { margin-right: auto; }
.modal-close { position: absolute; top: 16px; right: 16px; z-index: 3; }
.closing .modal-backdrop, .modal-backdrop.closing { animation: fadeOut 0.18s forwards; }
.modal-backdrop.closing .modal { animation: popOut 0.18s forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes popOut { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* item detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.detail-image { position: relative; background: var(--img-bg); min-height: 360px; border-radius: 26px 0 0 26px; overflow: hidden; }
.detail-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 32px; mix-blend-mode: multiply; }
.detail-image .placeholder .icon { width: 64px; height: 64px; stroke-width: 1.3; }
.detail-info { padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detail-info h2 { font-size: 22px; font-weight: 700; line-height: 1.25; padding-right: 36px; }
.detail-info .price { font-size: 28px; }
.detail-info .desc { color: var(--text-2); font-size: 14px; white-space: pre-line; }
.detail-info .notes-box { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; white-space: pre-line; }
.detail-info .notes-box b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--warn); margin-bottom: 4px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.claims-list { display: flex; flex-direction: column; gap: 8px; }
.claim-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.claim-row .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sparkline { width: 100%; height: 72px; display: block; }
.sparkline .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.sparkline .area { fill: url(#spark-grad); }
.sparkline .dot { fill: var(--accent); }
.history-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.history-box .row { font-size: 12.5px; color: var(--muted); }

/* add item */
.link-box {
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--border);
}
.link-box .input-group .input { height: 50px; padding-left: 18px; padding-right: 116px; border-radius: 999px; }
.link-box label { display: inline-flex; align-items: center; gap: 6px; }
.link-box .input-group .addon .btn { height: 38px; }
.preview-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.8;
  border-radius: var(--radius-sm);
  background: var(--img-bg);
  border: 1px solid var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--faint);
}
.preview-img img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.preview-img .img-actions { position: absolute; bottom: 8px; left: 8px; right: 8px; display: flex; gap: 6px; justify-content: center; }
.preview-img .img-actions .btn { --btn-bg: rgba(255, 255, 255, 0.94); --btn-fg: #18181b; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.edit-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-strong); }
.fetch-status { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 10px; color: var(--muted); }
.fetch-status.ok { color: var(--success); }
.fetch-status.warn { color: var(--warn); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 540;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--ease);
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success .icon { color: var(--success-bright); }
.toast.out { animation: toastOut 0.25s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------- admin ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { padding: 16px 18px; }
.stat-card b { display: block; font-size: 26px; font-weight: 720; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-card span { font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.panel { padding: 22px; margin-bottom: 18px; }
.panel h3 { font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.login-card { max-width: 400px; margin: 40px auto; padding: 30px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.center-msg { text-align: center; padding: 80px 20px; }
.center-msg h1 { font-size: 26px; margin-bottom: 8px; }

/* ---------- menu ---------- */
.menu { position: fixed; z-index: 150; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); animation: popIn 0.16s var(--ease); }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; background: transparent; border-radius: 9px; font-size: 14px; text-align: left; color: var(--text); }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; height: 1px; background: var(--border); margin: 4px 0; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .app { padding: 18px 16px 90px; }
  .topbar-inner { padding: 0 16px; height: 56px; }
  .brand-name { font-size: 16px; }
  .hide-mobile { display: none !important; }
  .detail { grid-template-columns: 1fr; }
  .detail-image { min-height: 260px; border-radius: 26px 26px 0 0; }
  .edit-layout { grid-template-columns: 1fr; }
  .edit-layout .preview-img { max-width: 240px; margin: 0 auto; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .items-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .item-card .body { padding: 12px; }
  .item-card h3 { font-size: 14px; }
  .item-card .foot { flex-direction: column; align-items: stretch; }
  .item-card .foot .btn { width: 100%; }
  .item-card .foot .btn.icon-only { width: 32px; align-self: flex-end; margin-top: -30px; }
  .owner-tools { top: auto; bottom: 8px; right: 8px; }
  .item-card .badges-tl .chip { height: 22px; font-size: 11px; padding: 0 7px; }
  .price { font-size: 16px; }
  .list-hero { padding: 22px 20px; }
  .list-hero .deco { font-size: 64px; right: 10px; top: auto; bottom: -6px; transform: none; }
  .list-hero .hero-actions { position: static; margin-bottom: 12px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal.wide, .modal.medium { max-width: none; border-radius: 24px 24px 0 0; max-height: 94dvh; animation: sheetIn 0.32s var(--ease); }
  .modal-backdrop.closing .modal { animation: sheetOut 0.2s forwards; }
  .modal-foot { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .people-grid { grid-template-columns: 1fr; }
  .profile { gap: 14px; }
  .profile .avatar.xl { --size: 64px; }
}
@media (max-width: 420px) {
  .grid-2 { grid-template-columns: 1fr; }
  .items-grid { gap: 10px; }
}
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
