:root {
  --blue: #8E54C8;
  --blue-dark: #6B3A9E;
  --sun: #FFB648;
  --green: #2FA972;
  --green-bg: #E6F7EE;
  --amber: #E2900A;
  --amber-bg: #FDEEDA;
  --bg: #FFF6EF;
  --card: #ffffff;
  --text: #3A2A22;
  --muted: #9C8579;
  --wood-a: #E7A968;
  --wood-b: #DC9A56;
  --topbar-bg: #241733;
  --purple-text: #D6BBF7;
  --purple-text-dim: #B99AD9;
  --purple-card-text: #4A2E7A;
  --purple-border: #C9A6F0;
  --gold: #F0C24B;
  --lilac-bg-a: #F1E4FB;
  --lilac-bg-b: #E6D2F7;
  --fab-a: #FF6F91;
  --fab-b: #9B4FD1;
  --fab-active: #B23E82;
  --radius: 16px;
  --font-title: "Impact", "Anton", "Arial Narrow Bold", sans-serif;
  --font-count: "Trebuchet MS", "Segoe UI", sans-serif;
  --font-display: "Baloo 2", "Segoe UI", sans-serif;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: repeating-linear-gradient(
    100deg,
    var(--lilac-bg-a) 0px,
    var(--lilac-bg-a) 26px,
    var(--lilac-bg-b) 26px,
    var(--lilac-bg-b) 52px
  );
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 110px;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--topbar-bg);
  padding: calc(18px + env(safe-area-inset-top)) 16px 16px;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.brand-title {
  font-family: "Montserrat", var(--font-display);
  font-weight: 800;
  font-size: clamp(1.3rem, 8vw, 4.2rem);
  line-height: 1;
  color: var(--purple-text);
  margin: 0;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.brand-subtitle {
  font-family: "Dancing Script", cursive;
  font-weight: 700;
  font-size: clamp(1.4rem, 6vw, 2.6rem);
  line-height: 1.2;
  color: var(--gold);
  margin: 0;
}

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

.view-toggle {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.view-btn {
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
  opacity: 0.55;
  transform: scale(0.92);
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.view-btn-grid {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.view-btn-list {
  background: linear-gradient(135deg, var(--gold), #C98A2E);
}

.view-btn.active {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.55), 0 4px 12px rgba(0,0,0,0.4);
}

.total-count {
  font-family: var(--font-count);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--purple-text);
  line-height: 1.1;
}

.stats {
  font-size: 0.85rem;
  color: var(--purple-text-dim);
  margin-top: 2px;
}

.progress-track {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.15);
  margin-top: 10px;
}

.progress-fill-schoon {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-text-dim), var(--blue));
  transition: width 0.3s ease;
}

.progress-fill-was {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  transition: width 0.3s ease;
}

.location-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.location-label {
  font-size: 0.78rem;
  color: var(--purple-text-dim);
  font-weight: 600;
}

.location-toggle {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 3px;
}

.location-btn {
  border: none;
  background: transparent;
  color: var(--purple-text-dim);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.location-btn.active {
  background: var(--purple-text);
  color: var(--purple-card-text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.location-btn.drop-target {
  background: var(--blue);
  color: white;
  transform: scale(1.2);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.6), 0 4px 12px rgba(0,0,0,0.4);
}

.card.dragging,
.thumb.dragging {
  box-shadow: 0 16px 30px rgba(0,0,0,0.4) !important;
  transform: scale(1.06) !important;
  opacity: 0.95;
}

.location-filters {
  padding-top: 0;
}

.filters + .location-filters {
  padding-top: 0;
}

.filters {
  display: flex;
  gap: 8px;
  padding: 14px 16px 10px;
  overflow-x: auto;
}

.filter-btn {
  border: none;
  background: var(--topbar-bg);
  color: var(--purple-text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(58,42,34,0.12);
}

.filter-btn.active {
  background: var(--purple-text);
  color: var(--purple-card-text);
  box-shadow: 0 3px 8px rgba(58,42,34,0.25);
  transform: translateY(-1px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 8px 16px 20px;
}

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--purple-card-text);
  opacity: 0.7;
  padding: 40px 16px;
  font-size: 0.95rem;
  font-weight: 600;
}

.card {
  background: var(--card);
  border: 1.5px solid var(--purple-border);
  border-radius: 14px;
  overflow: visible;
  box-shadow: 0 6px 14px rgba(58,42,34,0.18);
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 8px 8px 10px;
}

.grid .card:nth-child(4n+1) { transform: rotate(-1.5deg); }
.grid .card:nth-child(4n+2) { transform: rotate(1deg); }
.grid .card:nth-child(4n+3) { transform: rotate(-0.75deg); }
.grid .card:nth-child(4n+4) { transform: rotate(1.5deg); }
.grid .card:hover,
.grid .card:active { transform: rotate(0deg) scale(1.02); }

.card .photo-wrap {
  aspect-ratio: 1 / 1;
  background: #F3E4D8;
  overflow: hidden;
  border-radius: 10px;
  position: relative;
  margin-bottom: 6px;
}

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

.card .info {
  padding: 0 2px;
  cursor: pointer;
}

.card .type {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--purple-card-text);
  margin: 0;
}

.card .type.pending {
  font-weight: 600;
  font-style: italic;
  color: var(--muted);
  font-family: var(--font-body);
}

.card .color {
  font-size: 0.75rem;
  color: var(--purple-card-text);
  opacity: 0.75;
  margin: 1px 0 0;
  text-transform: capitalize;
}

.item-location-current {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #6B4FA0;
  background: #F0E7FB;
  border-radius: 999px;
  padding: 3px 9px;
  margin: 6px 0 0;
}

.item-location-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  background: #F0E7FB;
  border-radius: 12px;
  padding: 3px;
  margin: 6px 0 0;
}

.item-location-btn {
  flex: 1 1 auto;
  min-width: 44%;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  color: #8A6FB5;
  background: transparent;
  border: none;
  padding: 5px 4px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.item-location-btn.active {
  background: #ffffff;
  color: #6B4FA0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.status-dot {
  position: absolute;
  bottom: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--card);
  background: var(--card);
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(58,42,34,0.25);
}

.status-dot.schoon { background: var(--green-bg); }
.status-dot.was { background: var(--amber-bg); }

.delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--card);
  background: #fff;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(58,42,34,0.2);
}

/* ---- Grouped list view: per-type dropdowns with mini thumbnails ---- */

.grouped-list {
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.type-group {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(58,42,34,0.14);
  overflow: hidden;
}

.type-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
}

.type-group.expanded .type-group-header {
  border-bottom: 1px solid #f5e4d8;
}

.stat-icon {
  font-size: 1.2rem;
}

.stat-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
}

.stat-total {
  font-weight: 800;
  color: var(--blue);
  font-size: 0.95rem;
}

.group-breakdown {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.chevron {
  font-size: 0.7rem;
  color: var(--muted);
}

.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px;
}

.thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: visible;
  cursor: pointer;
  flex-shrink: 0;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  box-shadow: 0 2px 6px rgba(58,42,34,0.2);
}

.thumb-dot {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--card);
  font-size: 0.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(58,42,34,0.25);
}

.thumb-dot.schoon { background: var(--green-bg); }
.thumb-dot.was { background: var(--amber-bg); }

.thumb-location {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--card);
  background: #F0E7FB;
  font-size: 0.6rem;
  font-family: inherit;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(58,42,34,0.25);
  cursor: pointer;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--fab-a), var(--fab-b));
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 20px;
  box-shadow: 0 6px 18px rgba(155,79,209,0.5);
  z-index: 20;
}

.fab-icon { font-size: 1.2rem; line-height: 0; }

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

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  max-height: 92vh;
  overflow-y: auto;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 999px;
  margin: 8px auto 12px;
}

.sheet h2 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  font-size: 1.4rem;
}

.capture-label { display: block; cursor: pointer; }

.preview-box {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #FBEEE4;
  border: 2px dashed #EFCDB4;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.95rem;
  overflow: hidden;
  margin-bottom: 12px;
}

.preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.analyze-status {
  font-size: 0.85rem;
  color: var(--blue);
  margin: -6px 0 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.field select,
.field input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #EEDCCB;
  color: var(--text);
  background: white;
}

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

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:disabled {
  background: #F5C4B4;
}

.btn-secondary {
  background: #FBEEE4;
  color: var(--text);
}

.btn-recognize {
  display: block;
  width: 100%;
  border: 1px dashed #EFCDB4;
  background: #FBEEE4;
  color: var(--blue-dark);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 11px;
  border-radius: 10px;
  margin: -4px 0 14px;
}

.btn-recognize:disabled {
  color: var(--muted);
}

.edit-preview {
  cursor: default;
  aspect-ratio: 1 / 1;
  max-height: 220px;
}

.delete-link {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: #d94f4f;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 12px 0 4px;
  text-align: center;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.login-box .brand-title {
  color: var(--blue);
  white-space: normal;
  overflow: visible;
}

.login-box .brand-subtitle {
  color: var(--blue-dark);
  margin: 2px 0 12px;
}

.login-box p {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.login-box input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #EEDCCB;
  margin-bottom: 12px;
}

.login-error {
  color: #d94f4f;
  font-size: 0.85rem;
  margin: -6px 0 12px !important;
}

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ob-card {
  width: 100%;
  max-width: 340px;
}

.ob-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.ob-icon {
  font-size: 3rem;
  line-height: 1;
}

.ob-step h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
  margin: 0;
}

.ob-step p {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.4;
}

.ob-sub {
  margin-bottom: 2px !important;
}

.ob-dots {
  display: flex;
  gap: 6px;
  margin: 2px 0;
}

.ob-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #E3D3F7;
}

.ob-dots .dot.active {
  background: var(--blue);
}

.ob-step .btn-primary,
.ob-step .btn-secondary {
  width: 100%;
  flex: none;
}

.ob-step input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #EEDCCB;
  text-align: center;
}

.ob-switch {
  font-size: 0.85rem !important;
  color: var(--muted);
  margin-top: 4px !important;
}

.ob-switch a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.ob-location-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ob-location-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ob-location-input {
  flex: 1;
}

.ob-location-remove {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #EEDCCB;
  background: #FBEEE4;
  color: var(--muted);
  font-size: 0.9rem;
}

.ob-add-location {
  border: 1px dashed #EFCDB4 !important;
}

.ob-code-box {
  font-family: var(--font-count);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--blue);
  background: #F0E7FB;
  border-radius: 14px;
  padding: 16px;
  width: 100%;
}

.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 40;
}
