:root {
  color-scheme: light;
  --paper: #f4f0e7;
  --white: #fff;
  --ink: #252a27;
  --muted: #58625b;
  --wine: #823448;
  --wine-dark: #6b283a;
  --forest: #21332e;
  --line: #e3d9d1;
  --field: #877970;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  font: 16px/1.5 var(--sans);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 58% 0, #faf7f0, transparent 76%), var(--paper);
  color: var(--ink);
}
img { max-width: 100%; display: block; }
button, select, input { font: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button:not(:disabled), select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .68; }
:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
p, h1, h2, h3 { margin: 0; overflow-wrap: anywhere; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.19; }
h1 { font-size: clamp(1.75rem, 1.25rem + 1.35vw, 2.25rem); }
h2 { font-size: clamp(1.35rem, 1.15rem + .65vw, 1.68rem); }
h3 { font-size: 1.19rem; }
input, select, fieldset { min-width: 0; }
.shell { width: min(100%, 1184px); margin-inline: auto; padding-inline: clamp(16px, 3.4vw, 32px); }
.shell.narrow { width: min(100%, 1024px); }
main.shell { padding-block: 28px 48px; }
.site-header { border-bottom: 1px solid var(--line); }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wordmark {
  color: var(--wine); font: bold 1.75rem/1.15 var(--serif);
  letter-spacing: -.035em; text-decoration: none;
}
.profile-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.profile { padding: 0; border: 0; border-radius: 50%; background: transparent; width: 44px; height: 44px; }
.avatar {
  position: relative; display: grid; place-items: center; width: 60px; height: 60px; flex: none;
  overflow: hidden; border-radius: 50%; background: #e9d9d5; color: var(--wine);
  border: 2px solid #fff; font: bold 1.35rem/1 var(--serif);
}
.avatar img { position: absolute; width: 100%; height: 100%; inset: 0; object-fit: cover; }
.profile .avatar { width: 44px; height: 44px; font-size: 1rem; }
.quiet, .outline, .primary {
  display: inline-flex; justify-content: center; align-items: center; text-align: center;
  padding: 8px 12px; min-height: 44px; border-radius: 12px; border: 1px solid transparent;
  text-decoration: none; font-weight: 600; line-height: 1.3; font-size: .9rem;
}
.quiet { background: transparent; color: var(--forest); }
.quiet:hover { background: #eee7dd; }
.outline { background: transparent; color: var(--forest); border-color: #b7a79b; }
.outline:hover { background: #f6efe8; }
.outline.wine { color: var(--wine); border-color: var(--wine); }
.outline.wine:hover { background: #f8ebee; }
.primary { color: white; background: var(--wine); border-color: var(--wine); padding-inline: 19px; }
.primary:hover { background: var(--wine-dark); }
.fill { width: 100%; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 20px; }
.empty { padding: 24px; color: var(--muted); }
.empty h1 + p { margin-top: 12px; }
.empty .outline { margin-top: 16px; }
.muted, .domain { color: var(--muted); font-size: .875rem; }
.domain { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin: 10px 0 26px; }
.title-line h1 { font-size: clamp(1.85rem, 1.35rem + 1.6vw, 2.6rem); }
.back { margin: -6px 0 8px -10px; }
.standalone-title { margin-bottom: 20px; }

.theme-new-year { --theme: #eaf3f8; }
.theme-birthday { --theme: #fff0ed; }
.theme-wedding { --theme: #faf4ee; }
.theme-housewarming { --theme: #eaf1e8; }
.theme-baby { --theme: #fff2e7; }
.theme-anniversary { --theme: #f6e8ea; }
.theme-graduation { --theme: #e9eef7; }
.theme-custom { --theme: #f4f0e7; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.cards:has(.list-card:only-child) { grid-template-columns: minmax(0, 510px); }
.cards:has(.list-card:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 950px; }
.cards .list-card:only-child .card-title { min-height: 178px; }
.list-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.card-title {
  isolation: isolate; position: relative; display: flex; align-items: center;
  min-height: 154px; height: calc(100% - 60px); padding: 24px 32% 24px 24px;
  color: var(--ink); text-decoration: none; background: var(--theme); overflow: hidden;
}
.card-title:focus-visible { outline-offset: -4px; }
.card-title h2 { z-index: 1; font-size: clamp(1.45rem, 1.05rem + .85vw, 1.9rem); }
.card-title:hover h2 { color: var(--wine); }
.motif { position: absolute; pointer-events: none; display: grid; place-items: center; right: 12px; top: 8px; bottom: 8px; width: 25%; min-height: 0; }
.motif img { width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center; }
.card-actions { border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 2px; min-height: 60px; padding: 5px 9px; }
.card-actions .quiet + .quiet { color: var(--wine); }
.themed-banner {
  position: relative; isolation: isolate; display: flex; flex-wrap: nowrap; align-items: center;
  min-height: 148px; gap: 20px; padding: 22px 25% 22px 24px;
  border-radius: 20px; border: 1px solid #00000010; background: var(--theme); overflow: hidden;
}
.themed-banner h1, .themed-banner h2 { z-index: 1; }
.themed-banner .motif { width: 21%; right: 14px; }
.themed-banner .avatar { width: 88px; height: 88px; }
.snow { position: absolute; pointer-events: none; right: 6px; top: 0; bottom: 0; width: 22%; overflow: hidden; }
.snow i {
  position: absolute; top: 10%; left: 70%; font: normal 11px/1 var(--sans); color: #fff;
  text-shadow: 0 0 1px #527484; opacity: 0; animation: drift 2.6s both ease-in-out;
}
.snow i:nth-child(2) { left: 38%; top: 0; font-size: 8px; color: #b7c8d4; animation-delay: .2s; }
.snow i:nth-child(3) { left: 18%; top: 19%; font-size: 9px; animation-delay: .45s; }
.snow i:nth-child(4) { left: 88%; top: 0; font-size: 7px; color: #b7c8d4; animation-delay: .55s; }
.snow i:nth-child(5) { left: 54%; top: 2%; font-size: 6px; animation-delay: .35s; }
@keyframes drift {
  0% { opacity: 0; transform: translate(0, 0); }
  26% { opacity: .95; }
  100% { opacity: 0; transform: translate(8px, 64px); }
}
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

form label:not(.radio, .select-gift) { display: block; font-weight: 600; }
input:not([type=checkbox], [type=radio]), select {
  width: 100%; min-height: 44px; border: 1px solid var(--field); border-radius: 12px;
  padding: 9px 12px; background: white; color: var(--ink); font-weight: 400;
}
label > input:not([type=checkbox], [type=radio]), label > select { display: block; margin-top: 6px; }
input[type=file] { min-height: 48px; }
input::placeholder { color: var(--muted); opacity: 1; }
input[type=checkbox], input[type=radio] { accent-color: var(--wine); width: 17px; height: 17px; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; padding: 0; }
.radio, .select-gift { display: flex; align-items: center; gap: 9px; min-height: 44px; cursor: pointer; }
.error { color: var(--wine-dark); font-size: .9rem; }
.error:empty { display: none; }
.stack { display: grid; gap: 16px; }
.form-panel { padding: clamp(16px, 3.1vw, 24px); }
.login-panel { width: min(100%, 410px); padding: 28px; margin: clamp(24px, 9vh, 86px) auto 36px; }
.login-panel h1 { font-size: 1.85rem; margin: 0 0 20px; }
.login-panel form { display: grid; gap: 12px; }
.password-field { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px; }
.editor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-block: 16px; }
.add-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin-block: 14px; }
#add-gift .error { margin-top: 10px; }
#editor-gifts { margin-top: 18px; }
.bulk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-block: 16px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #f6ebe7; color: var(--wine-dark);
}
.gift-list { display: grid; gap: 10px; }
.gift-row {
  border: 1px solid var(--line); border-radius: 14px; background: var(--white);
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
}
.gift-content { flex: 1 1 12rem; min-width: 0; }
.gift-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.select-gift { width: 36px; justify-content: center; flex: none; }
.gift-actions .quiet { padding-inline: 9px; }
.guest-hint { color: var(--muted); margin: 12px 0 22px; }
.guest-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.guest-section h2 { margin-bottom: 12px; }
.guest-main { padding-bottom: 32px; }
main > .themed-banner {
  --avatar-size: clamp(132px, 22vw, 184px);
  min-height: calc(var(--avatar-size) + 8px);
  gap: clamp(14px, 2.4vw, 24px);
  padding: 3px 24% 3px 4px;
}
main > .themed-banner .avatar { width: var(--avatar-size); height: var(--avatar-size); border-width: 3px; }
main > .themed-banner h1 { font-size: clamp(2rem, 1.5rem + 1.7vw, 3rem); padding-block: 9px; }
.guest-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px 20px; padding: 18px 22px; }
.guest-row:has(.product-photo:not([hidden])) { grid-template-columns: minmax(0, 1fr) clamp(92px, 15vw, 152px); }
.guest-row .product-photo {
  grid-column: 2; grid-row: 1 / 3; width: 100%; align-self: center;
  padding: clamp(6px, 1.2vw, 12px);
  border: 1px solid #e9e0d7;
  background: #f6f1ea;
}
.guest-row .gift-content, .guest-row .gift-actions { grid-column: 1; }
.guest-row .gift-content { grid-row: 1; }
.guest-row .gift-actions { gap: 6px 9px; }
.guest-row h3 { font-size: clamp(1.25rem, 1.06rem + .63vw, 1.65rem); }
.guest-row .go-link { margin-left: -9px; }
.guest-row .wine { padding-inline: 16px; }
.product-photo { width: 76px; aspect-ratio: 1; object-fit: contain; border-radius: 12px; }
.product-input { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.product-input .product-photo { width: 64px; }
.product-input .photo-picker { position: relative; display: inline-flex; cursor: pointer; }
.product-input .photo-picker:focus-within { outline: 2px solid var(--forest); outline-offset: 2px; }
.product-input .photo-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.photo-status:not(:empty) { margin: 2px 0 0 12px; }
.crop-tools { display: grid; grid-template-columns: minmax(122px, 176px) minmax(0, 1fr); align-items: center; gap: 18px; }
.crop-canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--paper); touch-action: none; cursor: grab; }
.crop-canvas:active { cursor: grabbing; }
dialog:has(.crop-tools) { width: min(620px, calc(100% - 32px)); }
.crop-settings { display: grid; gap: 8px; }
.crop-settings p { color: var(--muted); font-size: .875rem; }
.crop-settings input[type="range"] { display: block; margin: 0; padding: 0; min-height: 24px; border: 0; accent-color: var(--wine); }
.foot { display: flex; justify-content: center; padding-bottom: 20px; }
.foot a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border-radius: 8px; color: var(--wine); font: bold .875rem/1.15 var(--serif); text-underline-offset: 2px;
}
.toast {
  position: fixed; z-index: 5; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 12px;
  color: white; background: var(--forest); font-size: .9rem; pointer-events: none;
}
dialog {
  width: min(480px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 20px;
  color: var(--ink); padding: 24px; background: white; max-height: calc(100% - 40px);
}
dialog::backdrop { background: #31282360; }
dialog form { display: grid; gap: 14px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
@media(max-width: 1023px) { .cards { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media(max-width: 639px) {
  .cards, .cards:has(.list-card:nth-child(2):last-child) { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .cards .list-card:only-child .card-title { min-height: 137px; }
  main > .themed-banner { --avatar-size: clamp(88px, 27vw, 140px); gap: 11px; padding-right: 22%; }
  main > .themed-banner h1 { font-size: clamp(1.2rem, .8rem + 2.55vw, 1.85rem); }
  .guest-row { padding: 13px 14px; gap: 5px 8px; }
  .guest-row:has(.product-photo:not([hidden])) { grid-template-columns: minmax(0, 1fr) clamp(64px, 22vw, 90px); }
  .guest-row .product-photo { grid-row: 1; align-self: start; }
  .guest-row .gift-actions { grid-column: 1 / -1; gap: 3px 5px; }
  main.shell { padding-block: 20px 36px; }
  .title-line { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
  .topbar { min-height: 66px; }
  .topbar:not(.narrow) .wordmark { font-size: clamp(1.15rem, 5.4vw, 1.62rem); }
  .profile-actions { gap: 0; }
  .signout { padding-inline: 6px; font-size: .8rem; }
  .card-title { min-height: 116px; padding: 16px 26% 16px 16px; }
  .card-title .motif { width: 22%; }
  .themed-banner { min-height: 124px; gap: 10px; padding: 16px 23% 16px 12px; }
  .themed-banner .motif { width: 21%; right: 7px; }
  .themed-banner .avatar { width: 54px; height: 54px; }
  .themed-banner h1 { font-size: clamp(1.35rem, .72rem + 2.9vw, 1.82rem); }
  .owner-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 5px 6px; padding: 10px; }
  .owner-row:has(.product-photo:not([hidden])) { grid-template-columns: 34px 54px minmax(0, 1fr); }
  .owner-row .product-photo { width: 54px; }
  .owner-row .gift-actions { grid-column: 1 / -1; padding-left: 7px; }
  .add-line { grid-template-columns: minmax(0,1fr); gap: 7px; }
  .add-line .primary { justify-self: start; }
}

@media(max-width: 440px) {
  .crop-tools { grid-template-columns: minmax(0, 1fr); }
  .crop-canvas { width: min(100%, 160px); margin-inline: auto; }
}
