: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;
}

body {
  padding-bottom: 40px;
}

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

.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 {
  flex: 1;
  padding: 13px 4px;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  font-family: inherit;
}

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

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: 22px;
  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 delete bar (appears when at least one item is selected) */
.delete-bar {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: 999px;
  background: #b3301a;
  color: #fdf7ee;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(129, 33, 15, 0.4);
  z-index: 16;
  cursor: pointer;
  white-space: nowrap;
}

.delete-bar:active { background: #8f2513; }

.delete-bar svg {
  width: 18px;
  height: 18px;
}

/* Floating filter/select toolbar */
.float-toolbar {
  position: fixed;
  left: 18px;
  bottom: 22px;
  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;
}

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

/* Buyer chips */
.buyer-chip {
  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; }

/* 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;
}

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

.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-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;
}

.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-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 6px auto 14px;
}

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

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

.sheet input[type="text"],
.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;
}

.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: #fff;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 600;
  font-family: inherit;
}

.quick-option.selected {
  border-color: var(--accent);
  background: #fbede6;
  color: var(--accent-dark);
}

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