:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-strong: #f0f6f2;
  --text: #20201d;
  --muted: #686b63;
  --line: #ddd8cd;
  --primary: #176b5b;
  --primary-dark: #0f4e43;
  --danger: #b33a3a;
  --success: #2f7d45;
  --shadow: 0 12px 36px rgba(32, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 5vw, 48px);
  background: rgba(247, 245, 239, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.hero,
.split-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

h1,
h2 {
  margin: 0 0 10px;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 6vw, 54px);
}

h2 {
  font-size: 22px;
}

.muted {
  color: var(--muted);
}

.note {
  display: inline-block;
  margin: 10px 0 0;
  padding: 8px 10px;
  background: var(--surface-strong);
  border: 1px solid #cdded2;
  border-radius: 8px;
  color: #345648;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  margin-bottom: 18px;
}

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

.narrow {
  width: min(440px, 100%);
  margin: 8vh auto 0;
}

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

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

textarea {
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.secondary,
.button.secondary {
  background: #fff;
  color: var(--primary);
}

.primary-soft,
.button.primary-soft {
  background: var(--surface-strong);
  color: var(--primary-dark);
  border-color: #bdd5c7;
}

.secondary:hover,
.button.secondary:hover,
.primary-soft:hover,
.button.primary-soft:hover {
  background: var(--surface-strong);
}

.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
}

.ghost:hover {
  background: var(--surface-strong);
}

.danger,
.danger-light {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.danger-light {
  background: #fff;
  color: var(--danger);
}

.success {
  border-color: var(--success);
  background: var(--success);
}

.status-button {
  color: var(--text);
  border-color: var(--line);
}

.status-button-thinking {
  background: #edf0ee;
  border-color: #d5dbd7;
  color: #4f5751;
}

.status-button-thinking:hover {
  background: #dde3df;
}

.status-button-will-buy {
  background: #ffe7a3;
  border-color: #ecc65b;
  color: #5f4700;
}

.status-button-will-buy:hover {
  background: #f7d777;
}

.status-button-bought {
  background: #cdebd3;
  border-color: #86c896;
  color: #245b34;
}

.status-button-bought:hover {
  background: #b9e2c2;
}

.status-button-chip-in {
  background: #ffd7d7;
  border-color: #e69a9a;
  color: #7c2727;
}

.status-button-chip-in:hover {
  background: #ffc2c2;
}

.status-text {
  font-weight: 800;
}

.status-thinking {
  color: #66706a;
}

.status-will_buy {
  color: #9a6f00;
}

.status-bought {
  color: var(--success);
}

.status-chip_in {
  color: #b33a3a;
}

.status-pill.status-will_buy {
  background: #fff0bf;
  color: #7b5900;
}

.status-pill.status-bought {
  background: #dff2e3;
  color: #27633a;
}

.status-pill.status-thinking {
  background: #edf0ee;
  color: #566059;
}

.status-pill.status-chip_in {
  background: #ffe0e0;
  color: #842b2b;
}

.row,
.actions,
.gift-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.parse-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.parse-status[data-state="loading"]::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 2px solid #bdd5c7;
  border-top-color: var(--primary);
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

.parse-status[data-state="ok"] {
  color: var(--success);
}

.parse-status[data-state="error"] {
  color: var(--danger);
}

.is-loading {
  background: #faf9f5;
}

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

.wrap {
  flex-wrap: wrap;
}

.flash {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #cdded2;
  background: var(--surface-strong);
  color: #234639;
}

.flash.error {
  border-color: #ecc6c6;
  background: #fff1f1;
  color: #842b2b;
}

.list-card,
.invite-row,
.item-row,
.gift-card,
.admin-gift-view {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8efe9;
  color: #2e5f46;
  font-weight: 700;
  white-space: nowrap;
}

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

.admin-gift-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-gift-view {
  align-items: flex-start;
}

.admin-gift-card.is-dragging {
  opacity: 0.58;
  border-color: var(--primary);
}

.drag-handle {
  flex: 0 0 auto;
  width: 34px;
  min-height: 42px;
  padding: 0;
  border-color: var(--line);
  background: #faf9f5;
  color: var(--muted);
  cursor: grab;
  letter-spacing: 1px;
}

.drag-handle:active {
  cursor: grabbing;
}

.icon-button {
  width: 40px;
  padding-inline: 0;
}

.item-edit {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) minmax(160px, 1.5fr) minmax(100px, 0.7fr);
  gap: 10px;
  flex: 1;
}

.item-edit textarea,
.item-edit .row {
  grid-column: 1 / -1;
}

.status-box {
  min-width: 150px;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: #faf9f5;
}

.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.move-item-control,
.move-item-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.move-item-form select {
  min-height: 40px;
  max-width: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.invite-row {
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.invite-row:first-child {
  border-top: 0;
}

.guest-items {
  display: grid;
  gap: 14px;
}

.gift-card {
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.gift-card.disabled {
  background: #faf9f5;
}

.gift-main {
  min-width: 0;
}

.gift-main h3 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
}

.status-line {
  margin: 12px 0 0;
  color: var(--primary-dark);
}

.participant-line {
  margin: 8px 0 0;
  color: #842b2b;
  font-weight: 650;
}

.gift-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.back {
  display: inline-block;
  margin-bottom: 10px;
}

.delete-list {
  margin-top: 22px;
}

.guest-name {
  color: var(--muted);
  font-weight: 700;
}

.empty {
  color: var(--muted);
}

@media (max-width: 820px) {
  .grid.two,
  .item-edit {
    grid-template-columns: 1fr;
  }

  .hero,
  .split-header,
  .list-card,
  .invite-row,
  .item-row,
  .gift-card,
  .admin-gift-view {
    flex-direction: column;
  }

  .actions,
  .gift-actions,
  .admin-card-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .actions .button,
  .gift-actions form,
  .gift-actions button,
  .admin-card-actions button,
  .move-item-form,
  .move-item-form select {
    width: 100%;
    max-width: none;
  }

  .status-box {
    width: 100%;
  }

  .page {
    width: min(100% - 24px, 1120px);
    padding-top: 20px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .panel,
  .gift-card,
  .admin-gift-card {
    padding: 14px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 20px;
  }
}
