:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #66706a;
  --line: #d9ded8;
  --accent: #176b5d;
  --accent-strong: #0d4f44;
  --accent-soft: #dfeee9;
  --danger: #b42318;
  --danger-strong: #8d1f16;
  --hero-a: #dfeee9;
  --hero-b: #f5f6f2;
}

body[data-theme="birthday"] {
  --bg: #fbf7fb;
  --accent: #b83280;
  --accent-strong: #8f2866;
  --accent-soft: #f7deed;
  --hero-a: #ffd6e8;
  --hero-b: #ffe9b8;
}

body[data-theme="christmas"] {
  --bg: #f4f7f3;
  --accent: #166534;
  --accent-strong: #104b27;
  --accent-soft: #dbeee0;
  --hero-a: #d7f0dd;
  --hero-b: #f7d4d0;
}

body[data-theme="neutral"] {
  --bg: #f5f6f2;
  --accent: #176b5d;
  --accent-strong: #0d4f44;
  --accent-soft: #dfeee9;
  --hero-a: #dfeee9;
  --hero-b: #f3ead8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a.icon-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
  text-decoration: none;
}

button:hover,
button:focus-visible,
a.icon-button:hover,
a.icon-button:focus-visible {
  background: var(--accent-strong);
}

button.secondary,
a.icon-button.secondary {
  border: 1px solid color-mix(in srgb, var(--accent) 55%, #000);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover,
button.secondary:focus-visible,
a.icon-button.secondary:hover,
a.icon-button.secondary:focus-visible {
  background: var(--accent-soft);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.loading {
  position: relative;
  color: transparent;
}

button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

button.secondary.loading::after {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: var(--accent);
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

button.danger {
  background: var(--danger);
}

button.danger:hover,
button.danger:focus-visible {
  background: var(--danger-strong);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:disabled {
  background: #f7f8f5;
  color: var(--muted);
  cursor: default;
  opacity: 1;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  gap: 6px;
}

a {
  color: var(--accent-strong);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1rem;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.panel-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.session-name {
  color: var(--muted);
  font-weight: 700;
  padding: 0 2px 4px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.login-panel,
.main-stack,
.wishlist-panel,
.account-panel,
.public-panel {
  display: grid;
  gap: 18px;
}

.app-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: 280px minmax(0, 1fr);
}

.side-nav {
  display: grid;
  gap: 10px;
  position: sticky;
  top: 18px;
}

.nav-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  justify-content: start;
  text-align: left;
}

.nav-button.active,
.nav-button:hover,
.nav-button:focus-visible {
  background: var(--accent-soft);
}

.menu-block {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 14px;
}

.theme-hero {
  min-height: 132px;
  overflow: hidden;
  position: relative;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
}

.theme-hero::before,
.theme-hero::after {
  content: "";
  position: absolute;
  inset: auto;
}

.theme-hero[data-theme="birthday"]::before {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 12% 28%, #fff 0 5px, transparent 6px),
    radial-gradient(circle at 28% 62%, #b83280 0 6px, transparent 7px),
    radial-gradient(circle at 48% 30%, #f59e0b 0 5px, transparent 6px),
    radial-gradient(circle at 70% 64%, #2563eb 0 6px, transparent 7px),
    radial-gradient(circle at 86% 26%, #16a34a 0 5px, transparent 6px);
}

.theme-hero[data-theme="birthday"]::after {
  right: 56px;
  bottom: 20px;
  width: 86px;
  height: 74px;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 26px 0 #f472b6, -52px 18px 0 #fde68a;
}

.theme-hero[data-theme="christmas"]::before {
  left: 44px;
  bottom: 18px;
  width: 0;
  height: 0;
  border-left: 58px solid transparent;
  border-right: 58px solid transparent;
  border-bottom: 118px solid #166534;
}

.theme-hero[data-theme="christmas"]::after {
  left: 80px;
  bottom: 12px;
  width: 32px;
  height: 18px;
  background: #7c2d12;
  box-shadow: 260px -42px 0 18px #fff, 306px -22px 0 14px #fff;
}

.theme-hero[data-theme="neutral"]::before {
  left: 42px;
  top: 32px;
  width: 96px;
  height: 68px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 138px 10px 0 #eef2ff, 276px -8px 0 #fef3c7;
}

.theme-hero[data-theme="neutral"]::after {
  right: 44px;
  bottom: 30px;
  width: 130px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
}

.form-grid {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide {
  grid-column: span 2;
}

.full {
  grid-column: 1 / -1;
}

.input-with-action {
  position: relative;
}

.input-with-action input {
  padding-right: 44px;
}

.detect-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 400;
  min-height: 32px;
  padding: 0;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
}

.detect-btn:hover,
.detect-btn:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.detect-btn.loading {
  color: transparent;
  position: absolute;
}

.detect-btn.loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  top: 50%;
  left: 50%;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

.compact-label {
  min-width: 190px;
}

.share-box {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
}

.share-field {
  width: 100%;
}

.share-control {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 40px 40px;
  margin-top: 8px;
}

.share-url,
.item-url {
  overflow-wrap: anywhere;
}

.share-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 1.15rem;
  justify-content: center;
  min-height: 40px;
  padding: 0;
  width: 40px;
}

.icon-button svg {
  height: 20px;
  width: 20px;
}

.items {
  display: grid;
  gap: 12px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.wish-edit {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button-row {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-row.end {
  justify-content: flex-end;
}

.icon-row {
  justify-content: flex-end;
}

.public-open .item {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: 0 8px 22px rgb(32 33 36 / 7%);
}

.public-reserved {
  margin-top: 8px;
}

.public-reserved .item {
  opacity: 0.72;
}

.public-item {
  align-items: start;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 14px;
}

.wish-row {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: 88px minmax(0, 1fr) auto;
}

.wish-row > .item-content,
.wish-row > .wish-edit {
  min-width: 0;
}

.item-content {
  display: grid;
  gap: 6px;
}

.wish-preview {
  width: 88px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #f7f8f5;
  flex: none;
  align-self: start;
  position: relative;
}

.wish-preview-refresh {
  background: rgb(0 0 0 / 48%);
  border-radius: 4px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 400;
  height: 22px;
  line-height: 1;
  min-height: unset;
  opacity: 0;
  padding: 0;
  position: absolute;
  right: 4px;
  top: 4px;
  transition: opacity 140ms ease;
  width: 22px;
}

.wish-preview:hover .wish-preview-refresh,
.wish-preview-refresh:focus-visible {
  opacity: 1;
}

.wish-preview-refresh:hover,
.wish-preview-refresh:focus-visible {
  background: rgb(0 0 0 / 68%);
}

.wish-preview-refresh:disabled {
  cursor: wait;
  opacity: 0.5;
}

.wish-preview--placeholder {
  background: #f1f2ef;
}

.wish-preview-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wish-preview-placeholder {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.75rem;
  font-weight: 700;
  height: 100%;
  justify-content: center;
  letter-spacing: 0;
  text-transform: uppercase;
  width: 100%;
}

.item-title {
  font-weight: 800;
}

.item-title-hidden {
  color: var(--muted);
}

.item-price {
  color: var(--accent-strong);
  font-weight: 800;
}

.item-description,
.empty-state,
.message {
  color: var(--muted);
}

.label-with-info {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.info-dot {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  height: 18px;
  justify-content: center;
  line-height: 1;
  width: 18px;
}

.section-title {
  margin-top: 8px;
}

.account-form {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.message {
  margin: 0;
  min-height: 22px;
}

.toast {
  background: #202124;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgb(0 0 0 / 22%);
  color: #fff;
  left: 50%;
  max-width: min(560px, calc(100vw - 32px));
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  top: 18px;
  transform: translate(-50%, -8px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

.toast:not(:empty) {
  opacity: 1;
  transform: translate(-50%, 0);
}

.image-picker-dialog {
  width: min(520px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
}

.image-picker-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.image-picker-inner {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.image-picker-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.image-picker-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.image-picker-status {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0;
  min-height: 1.2em;
}

.image-picker-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  min-height: 120px;
}

.image-picker-thumb {
  aspect-ratio: 1;
  background: #f1f2ef;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 120ms ease;
}

.image-picker-thumb:hover,
.image-picker-thumb:focus-visible {
  border-color: var(--accent, #4a7c59);
  outline: none;
}

.image-picker-thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.confirm-dialog {
  width: min(460px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
}

.confirm-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.confirm-dialog form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.copy-buffer {
  position: fixed;
  left: -1000px;
  top: -1000px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .panel-header,
  .share-box {
    align-items: stretch;
    flex-direction: column;
  }

  .app-layout,
  .form-grid,
  .wish-edit,
  .own-wish-controls,
  .public-item {
    grid-template-columns: 1fr;
  }

  .wish-row {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .wish-row > .button-row {
    grid-column: span 2;
    justify-content: flex-end;
  }

  .side-nav {
    position: static;
  }

  .wide {
    grid-column: auto;
  }
}
