:root {
  color-scheme: light;
  --blue: #175cd3;
  --blue-dark: #1247a6;
  --blue-soft: #eaf2ff;
  --ink: #17253d;
  --muted: #64748b;
  --line: #dce4ef;
  --surface: #fff;
  --background: #f7f9fc;
  --danger: #bb3545;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--background); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #91b8f8; outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; }
h1 { font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1.1; margin-bottom: 1rem; font-weight: 750; }
h2 { font-size: clamp(1.4rem, 2.5vw, 1.8rem); line-height: 1.2; margin-bottom: .4rem; font-weight: 700; }
h3 { font-size: 1.05rem; line-height: 1.35; margin-bottom: .25rem; font-weight: 650; }
.app-shell { min-height: 100vh; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 4vw, 3.5rem); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { border: 0; background: transparent; display: inline-flex; align-items: center; gap: .65rem; padding: 0; color: var(--ink); font-size: 1.2rem; font-weight: 750; letter-spacing: -.035em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: var(--blue); }
.brand-mark svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.topbar-actions { display: flex; align-items: center; gap: 1.25rem; }
.user-email { color: var(--muted); font-size: .875rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { width: min(1080px, calc(100% - 2.5rem)); margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) 0 6rem; }
main:focus { outline: none; }
.eyebrow { color: var(--blue); font-size: .78rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 .8rem; }
.lede { max-width: 570px; color: var(--muted); font-size: 1.08rem; line-height: 1.65; margin-bottom: 0; }
.section-description { color: var(--muted); margin: .25rem 0 0; line-height: 1.5; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: 6px; padding: .65rem .95rem; font-weight: 650; text-decoration: none; transition: background .15s, border-color .15s; }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { color: #fff; background: var(--ink); }
.button-ghost { color: var(--ink); background: var(--surface); border-color: var(--line); }
.button-ghost:hover { background: #f1f5fb; border-color: #b7c6da; }
.button-danger { color: var(--danger); background: #fff3f4; }
.button-small { min-height: 36px; padding: .45rem .75rem; font-size: .875rem; }
.button:disabled, .rank-controls button:disabled { opacity: .4; cursor: not-allowed; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 1.2rem; }
.icon-button:hover { color: var(--ink); background: #f1f5fb; }
.dashboard-hero { display: flex; align-items: end; justify-content: space-between; gap: 3rem; padding-bottom: clamp(3rem, 6vw, 5rem); }
.dashboard-hero h1 { max-width: 640px; }
.hero-stat { display: flex; flex-direction: column; align-items: flex-start; min-width: 170px; padding: 0 0 .4rem 1.3rem; border-left: 2px solid #b8d2fa; }
.hero-stat strong { color: var(--blue); font-size: 2.4rem; line-height: 1; letter-spacing: -.05em; }
.hero-stat span { color: var(--muted); font-size: .875rem; margin-top: .55rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; }
.wishlist-grid { display: block; border-top: 1px solid var(--line); }
.wishlist-card { display: flex; align-items: center; gap: 1.1rem; min-height: 100px; padding: 1rem .25rem; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; transition: background .15s; }
.wishlist-card:hover { background: var(--blue-soft); }
.card-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--blue-soft); color: var(--blue); font-size: 1.2rem; }
.wishlist-card-main { flex: 1; min-width: 0; }
.wishlist-card-main h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wishlist-card-main > span { color: var(--muted); font-size: .85rem; }
.role-chip { display: inline-flex; align-items: center; border-radius: 4px; padding: .3rem .5rem; background: var(--blue-soft); color: var(--blue-dark); font-size: .75rem; font-weight: 650; text-transform: capitalize; white-space: nowrap; }
.role-chip.gifter { background: #eef2f7; color: #52647d; }
.row-chevron { color: #8a9bb0; font-size: 1.5rem; line-height: 1; }
.empty-state { padding: 3rem 1rem; border-top: 1px solid var(--line); text-align: center; }
.empty-state h2 { margin-bottom: .5rem; }
.empty-state p { color: var(--muted); line-height: 1.55; margin-bottom: 1.5rem; }
.loading-state { min-height: 50vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin .8s linear infinite; margin-bottom: 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.back-button { border: 0; background: transparent; color: var(--blue); padding: 0; margin-bottom: 1.8rem; font-weight: 650; }
.back-button:hover { text-decoration: underline; }
.list-header { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.list-header h1 { margin-bottom: .5rem; overflow-wrap: anywhere; }
.header-actions { display: flex; gap: .7rem; flex-wrap: wrap; }
.list-tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1.8rem; }
.list-tab { display: inline-block; padding: .75rem 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 650; text-decoration: none; }
.list-tab:hover { color: var(--blue); }
.list-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.privacy-banner { display: flex; align-items: center; gap: .65rem; padding: .85rem 1rem; margin-bottom: 1.5rem; border-left: 3px solid var(--blue); background: var(--blue-soft); color: #244a81; font-size: .9rem; line-height: 1.45; }
.privacy-icon { color: var(--blue); }
.items-list { border-top: 1px solid var(--line); }
.item-card { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 1.2rem; padding: 1.2rem .25rem; border-bottom: 1px solid var(--line); }
.item-image { width: 84px; height: 84px; object-fit: cover; border-radius: 5px; background: #e9eff7; }
.item-placeholder { display: grid; place-items: center; color: #7c9dd0; font-size: 1.6rem; }
.item-copy { min-width: 0; }
.item-copy h3 { margin-bottom: .35rem; overflow-wrap: anywhere; }
.item-copy p { color: var(--muted); margin: 0; line-height: 1.5; font-size: .9rem; overflow-wrap: anywhere; }
.item-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .55rem; }
.product-link { color: var(--blue); font-size: .875rem; font-weight: 650; text-decoration: none; }
.product-link:hover { text-decoration: underline; }
.preview-description { color: var(--muted); font-size: .82rem; line-height: 1.4; }
.item-actions { display: flex; align-items: center; gap: .5rem; }
.rank-controls { display: flex; flex-direction: column; gap: .25rem; margin-right: .35rem; }
.rank-controls button { width: 30px; height: 28px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--blue); }
.rank-controls button:not(:disabled):hover { background: var(--blue-soft); }
.claimed-badge { color: #19744a; font-size: .83rem; font-weight: 650; white-space: nowrap; }
.claimed-badge.other { color: var(--muted); }
.members-panel { padding: 0; }
.members-panel .section-heading { margin-bottom: 1.5rem; }
.member-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem .25rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.member-row:last-child { border-bottom: 1px solid var(--line); }
.member-row > span:last-child { display: flex; align-items: center; gap: .5rem; flex: none; }
.member-row small { color: var(--muted); }
dialog { width: min(520px, calc(100% - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 24px 70px rgba(24, 43, 70, .22); }
dialog::backdrop { background: rgba(16, 31, 54, .5); backdrop-filter: blur(2px); }
.dialog-card { padding: 1.75rem; }
.dialog-wide { width: 100%; }
.dialog-heading { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.dialog-heading h2 { margin: 0; }
label, legend { color: var(--ink); font-size: .9rem; font-weight: 650; }
input, textarea, select { width: 100%; margin-top: .45rem; padding: .7rem .8rem; border: 1px solid #bac8d9; border-radius: 5px; background: var(--surface); color: var(--ink); }
input::placeholder, textarea::placeholder { color: #91a0b3; }
textarea { resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%); background-position: calc(100% - 17px) 52%,calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.span-2 { grid-column: 1 / -1; }
.hint { float: right; color: var(--muted); font-size: .8rem; font-weight: 400; }
.file-label input { padding: .55rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.5rem; }
.privacy-note { margin-top: 1rem; padding: .7rem .8rem; border-left: 2px solid var(--blue); background: var(--blue-soft); color: #244a81; font-size: .85rem; }
.privacy-note p { margin: 0; }
.link-preview { margin-top: .2rem; padding: .8rem; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); }
.link-preview[hidden] { display: none; }
.link-preview p { margin: .4rem 0 0; font-size: .85rem; }
.preview-heading { display: flex; align-items: center; gap: .75rem; }
.preview-heading img { width: 52px; height: 52px; border-radius: 4px; object-fit: cover; }
.preview-heading div { display: grid; gap: .2rem; }
.preview-heading strong { color: var(--ink); }
.preview-heading small { color: var(--muted); }
.toast-region { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: grid; gap: .6rem; }
.toast { max-width: 330px; padding: .85rem 1rem; border-radius: 6px; background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(24,43,70,.18); animation: toast-in .2s ease; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
@media (max-width: 800px) {
  .dashboard-hero { align-items: flex-start; flex-direction: column; gap: 2rem; }
  .list-header { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .item-card { grid-template-columns: 72px minmax(0, 1fr); align-items: start; }
  .item-image { width: 72px; height: 72px; }
  .item-actions { grid-column: 2; flex-wrap: wrap; }
  .rank-controls { flex-direction: row; }
}
@media (max-width: 560px) {
  .topbar { height: 64px; padding: 0 .9rem; }
  .user-email { display: none; }
  main { width: calc(100% - 2rem); padding-top: 2.5rem; }
  .dashboard-hero { padding-bottom: 3rem; }
  .hero-stat { padding-left: 1rem; }
  .wishlist-card { gap: .75rem; }
  .card-icon { width: 38px; height: 38px; }
  .list-tabs { gap: 1.2rem; }
  .item-card { grid-template-columns: 60px minmax(0, 1fr); gap: .85rem; }
  .item-image { width: 60px; height: 60px; }
  .member-row { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .dialog-card { padding: 1.25rem; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}
