:root {
  --bg: #f7f2ea;
  --card: #fffdfa;
  --ink: #2c2016;
  --muted: #7a6c5c;
  --accent: #a8451e;
  --accent-dark: #7e3115;
  --border: #e6dbc9;
  --gray-bg: #e7e2d8;
  --gray-text: #8c8474;
  --radius: 10px;
  --fab-size: 56px;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

body {
  padding-bottom: 40px;
}

/* Hero */
.hero {
  position: relative;
  height: 14vh;
  min-height: 84px;
  max-height: 130px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.event-pill {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 55%;
  padding: 5px 10px;
  border-radius: 999px;
  border: none;
  background: rgba(20, 12, 6, 0.4);
  color: rgba(253, 247, 238, 0.85);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.event-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-pill svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 68%;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 12, 6, 0.05) 0%, rgba(20, 12, 6, 0.55) 75%, rgba(15, 9, 4, 0.82) 100%);
}

.hero-title {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0 16px 10px;
  color: #fdf7ee;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.2px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.tabs {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tab-group {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.tab {
  padding: 13px 2px;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-bell {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.tab-bell svg {
  width: 15px;
  height: 15px;
}

.tab-bell .count-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: #ff3b30;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bg);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 12px 100px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Floating add button (FAB) */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fdf7ee;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(126, 49, 21, 0.35);
  z-index: 15;
  cursor: pointer;
}

.fab:active { background: var(--accent-dark); }

.fab svg {
  width: 26px;
  height: 26px;
}

/* Batch action bar (appears when at least one item is selected) */
.batch-bar {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 8px 20px rgba(44, 32, 22, 0.28);
  z-index: 16;
  overflow: hidden;
  border: 1px solid var(--border);
}

.batch-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border: none;
  border-right: 1px solid var(--border);
  background: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.86rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.batch-btn:last-child { border-right: none; }

.batch-btn svg {
  width: 16px;
  height: 16px;
}

.batch-btn-danger {
  color: #b3301a;
}

.batch-btn:active { background: #f2ece1; }

/* Floating filter/select toolbar */
.float-toolbar {
  position: fixed;
  left: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(44, 32, 22, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 15;
}

.float-toolbar.hidden { display: none; }

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #fdf7ee;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

.icon-btn.active-icon {
  background: rgba(253, 247, 238, 0.22);
}

.icon-btn .dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff3b30;
  border: 1.5px solid rgba(44, 32, 22, 0.62);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin: 10px 8px;
}

.status-divider-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.status-divider-line {
  flex: 1;
  height: 2px;
  background: var(--border);
}

.empty-hint {
  color: var(--muted);
  text-align: center;
  padding: 20px 8px;
  font-size: 0.92rem;
}

/* Buyer chips */
.buyer-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(44, 32, 22, 0.04);
  cursor: pointer;
}

.buyer-chip:active { background: #f5efe4; }

.buyer-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

.buyer-chip .buyer-name { font-weight: 600; flex: 1; }

/* Item rows */
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(44, 32, 22, 0.04);
  cursor: pointer;
}

/* Status color wash, left to right, fading out well before the midpoint */
.status-bg-required { background-image: linear-gradient(to right, rgba(214, 90, 135, 0.24) 0%, rgba(214, 90, 135, 0.05) 42%, rgba(214, 90, 135, 0) 58%); }
.status-bg-desired { background-image: linear-gradient(to right, rgba(210, 160, 35, 0.24) 0%, rgba(210, 160, 35, 0.05) 42%, rgba(210, 160, 35, 0) 58%); }
.status-bg-bought { background-image: linear-gradient(to right, rgba(80, 145, 90, 0.24) 0%, rgba(80, 145, 90, 0.05) 42%, rgba(80, 145, 90, 0) 58%); }
.status-bg-taken { background-image: linear-gradient(to right, rgba(115, 115, 115, 0.24) 0%, rgba(115, 115, 115, 0.05) 42%, rgba(115, 115, 115, 0) 58%); }

.item-row.done {
  opacity: 0.7;
}

.item-row.armed {
  box-shadow: 0 4px 12px rgba(44, 32, 22, 0.18);
}

.drag-handle {
  touch-action: none;
  width: 22px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: grab;
  margin-left: -2px;
}

.drag-handle svg {
  width: 17px;
  height: 17px;
}

.item-row.dragging .drag-handle {
  color: var(--accent);
}

.item-row.dragging {
  position: relative;
  z-index: 30;
  background: #fffef9;
  box-shadow: 0 10px 24px rgba(44, 32, 22, 0.22);
}

.item-row.drag-over-top {
  box-shadow: 0 -3px 0 0 var(--accent);
}

.item-row.drag-over-bottom {
  box-shadow: 0 3px 0 0 var(--accent);
}

.item-name {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  padding: 4px 0;
}

.item-name.required {
  font-weight: 800;
}

.item-name-row {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.item-meta {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.item-row.selectable {
  padding-left: 10px;
}

.select-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  flex-shrink: 0;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.select-checkbox svg {
  width: 13px;
  height: 13px;
  color: #fff;
  visibility: hidden;
}

.item-row.checked {
  border-color: var(--accent);
  background: #fbede6;
}

.item-row.checked .select-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.item-row.checked .select-checkbox svg {
  visibility: visible;
}

.done-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gray-text);
  flex-shrink: 0;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.done-check svg {
  width: 13px;
  height: 13px;
  color: #fff;
}

.item-row.status-taken .done-check {
  background: #6e8aa8;
}

.item-row.status-taken .badge.gray {
  background: #dde6ee !important;
  color: #4a6178 !important;
}

.item-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.badge {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  color: #3a2c1c;
  background: #fff;
  cursor: pointer;
}

.badge.gray {
  background: var(--gray-bg) !important;
  color: var(--gray-text) !important;
}

.badge.required {
  font-weight: 800;
}

/* Sheet (bottom modal) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 8, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}

.sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 10px 18px 24px;
  transform: translateY(110%);
  transition: transform 0.25s ease;
  z-index: 21;
  max-width: 640px;
  margin: 0 auto;
  max-height: 85vh;
  overflow-y: auto;
}

.sheet.show {
  transform: translateY(0);
}

.sheet-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

.sheet-close-btn svg {
  width: 15px;
  height: 15px;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 6px auto 14px;
  touch-action: none;
}

.sheet h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
  font-family: "Playfair Display", Georgia, serif;
  touch-action: none;
}

.sheet label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 0 6px;
  touch-action: none;
}

.sheet input[type="text"],
.sheet input[type="number"],
.sheet input[type="date"],
.sheet select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}

.qty-price-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.qty-price-row .field-group {
  display: flex;
  flex-direction: column;
}

.qty-price-row .field-group label {
  margin: 12px 0 6px;
}

.sheet .qty-price-row input[type="number"] {
  width: 110px;
  text-align: right;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.color-swatch {
  height: 42px;
  border-radius: 8px;
  border: 2px solid transparent;
  position: relative;
}

.color-swatch.selected {
  border-color: var(--ink);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sheet-actions-3 { justify-content: space-between; }

.sheet-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fdf7ee;
}

.btn-secondary {
  background: var(--gray-bg);
  color: var(--ink);
}

.btn-danger {
  background: #f3ded8;
  color: #8a2f14;
  flex: 0 0 auto;
  padding: 12px 14px !important;
}

/* Quick select */
.quick-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.quick-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background-color: #fff;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 600;
  font-family: inherit;
  transition: border-color 0.15s, font-size 0.15s;
}

.quick-option.selected {
  border-color: var(--ink);
  border-width: 2px;
  font-weight: 800;
  font-size: 1.06rem;
}

.quick-option .check {
  color: var(--accent);
  font-weight: 700;
}

/* Quantity stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stepper-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
}

.stepper-btn:active { background: #f2ece1; }

.stepper-value {
  min-width: 32px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Event list (inside event-sheet) */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.event-row.selected {
  border-color: var(--accent);
  background: #fbede6;
}

.event-row.completed {
  opacity: 0.62;
}

.event-row-main {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.event-row-name {
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-row-dates {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
}

.event-status {
  font-weight: 700;
}

.event-status-upcoming { color: #4a72a8; }
.event-status-active { color: var(--accent); }
.event-status-completed { color: var(--gray-text); }

.event-choice-banner {
  background: #fbede6;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.86rem;
  color: var(--accent-dark);
  font-weight: 600;
  margin-bottom: 10px;
}

.event-copy-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.event-copy-btn svg {
  width: 16px;
  height: 16px;
}

.event-rename-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.event-rename-btn svg {
  width: 16px;
  height: 16px;
}

.event-delete-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: #b3301a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.event-delete-btn svg {
  width: 16px;
  height: 16px;
}

/* Activity feed (bell icon) */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 70vh;
  overflow-y: auto;
  margin-bottom: 6px;
}

.activity-feed-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 12px 2px 2px;
}

.activity-feed-date:first-child {
  margin-top: 2px;
}

.activity-feed-item {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--ink);
}

.field-error {
  color: #b3301a;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 10px;
}

.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.delete-warning {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.btn-danger-wide {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  background: #b3301a;
  color: #fdf7ee;
}

.btn-danger-wide:active { background: #8f2513; }

#buyer-mark-seen {
  display: block;
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 4px;
}
