/* Flipped design system. Colours come from the group's mood board:
   Dusty Olive, Khaki Beige, Old Rose and Blackberry Cream on a warm cream base. */

@font-face { font-family: 'EB Garamond'; src: url('/fonts/eb-garamond.woff2') format('woff2'); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'EB Garamond'; src: url('/fonts/eb-garamond-italic.woff2') format('woff2'); font-weight: 400 600; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter.woff2') format('woff2'); font-weight: 400 600; font-style: normal; font-display: swap; }

:root {
  /* Base */
  --bg: #F6F0E6;            /* page */
  --surface: #FCF9F4;       /* raised cards */
  --surface-2: #EEE7DB;     /* sunken panels, photo tiles */
  --surface-3: #E6DDCE;
  --line: rgba(74, 34, 64, 0.10);
  --line-strong: rgba(74, 34, 64, 0.18);

  /* Brand */
  --olive: #7B8A63;         /* Dusty Olive: primary actions */
  --olive-600: #687752;
  --olive-700: #56633F;
  --olive-50: #E4E9DA;      /* light sage panels */
  --olive-100: #D6DEC7;
  --khaki: #C9BBA0;         /* Khaki Beige */
  --khaki-50: #EFE8DA;
  --rose: #D69FAA;          /* Old Rose */
  --rose-50: #F4E2E4;       /* tip banners */
  --rose-100: #EBCDD2;
  --rose-ink: #B06A93;      /* logo wordmark */
  --plum: #4A2240;          /* Blackberry Cream: headings */
  --plum-700: #3A1A33;

  /* Text */
  --ink: #2F2A2C;
  --ink-2: #5E5658;
  --muted: #6F6667;         /* 4.5:1+ on bg, surface-2, sage and rose panels */
  --on-olive: #FFFFFF;

  /* Feedback */
  --danger: #A8464B;
  --success: var(--olive-600);

  /* Type */
  --font-serif: 'EB Garamond', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Shape and depth */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 30px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(58, 26, 51, 0.06), 0 2px 8px rgba(58, 26, 51, 0.05);
  --shadow-2: 0 4px 14px rgba(58, 26, 51, 0.10), 0 1px 3px rgba(58, 26, 51, 0.06);
  --shadow-3: 0 18px 40px rgba(58, 26, 51, 0.18);

  /* Layout */
  --gutter: 20px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--olive-700); }
/* iPhone: no double-tap zoom on quick repeated taps, and no link-preview / Save Image menu on long-press. */
button, a, label, summary, [role='button'], [role='tab'], [role='radio'], .chip, .tile { touch-action: manipulation; }
a, img { -webkit-touch-callout: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; }

/* ---------- App frame ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.view {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}
.app.has-tabs .view { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); }

.screen {
  padding: calc(var(--safe-top) + 20px) var(--gutter) 28px;
  animation: screen-in 0.32s var(--ease) both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 20px;
}
.screen-header .back { margin: 4px 4px 0 -8px; }
.screen-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--plum);
  margin: 0;
}
.screen-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 14.5px; }

.serif { font-family: var(--font-serif); }
.italic { font-style: italic; }
.plum { color: var(--plum); }
.rose-ink { color: var(--rose-ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.h2 { font-family: var(--font-serif); font-weight: 500; font-size: 24px; line-height: 1.15; color: var(--plum); margin: 0; }
.h3 { font-family: var(--font-serif); font-weight: 500; font-size: 20px; line-height: 1.2; color: var(--plum); margin: 0; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--olive-600); /* white on --olive is only 3.7:1; olive-600 is 4.8:1 */
  color: var(--on-olive);
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: 0.005em;
  box-shadow: var(--shadow-1);
  transition: transform 0.15s var(--ease), background 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); background: var(--olive-700); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: var(--surface); color: var(--plum); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.secondary:active { background: var(--surface-2); }
.btn.rose { background: var(--rose-ink); }
.btn.ghost { background: transparent; color: var(--olive-700); box-shadow: none; padding: 0 12px; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px rgba(168, 70, 75, 0.35); }
.btn.sm { min-height: 38px; padding: 0 16px; font-size: 14px; }
.btn svg { width: 19px; height: 19px; flex: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--olive-50);
  color: var(--olive-700);
  transition: transform 0.15s var(--ease), background 0.15s;
}
.icon-btn:active { transform: scale(0.94); background: var(--olive-100); }
.icon-btn.plain { background: transparent; }
.icon-btn.rose { background: var(--rose-50); color: var(--rose-ink); }
.icon-btn svg { width: 21px; height: 21px; }

.link-btn { border: 0; background: none; padding: 4px 0; color: var(--olive-700); font-weight: 600; font-size: 14px; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter);
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter);
}
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background 0.15s, color 0.15s, transform 0.15s var(--ease);
  user-select: none;
  -webkit-user-select: none;
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed='true'], .chip.active { background: var(--olive-600); color: var(--on-olive); }
.chip .count { font-size: 12px; opacity: 0.7; }
.chip svg { width: 16px; height: 16px; }

/* Segmented control */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}
.segmented button[aria-selected='true'] { background: var(--surface); color: var(--plum); box-shadow: var(--shadow-1); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-1);
}
.card.flat { box-shadow: none; background: var(--surface-2); }
.card.sage { box-shadow: none; background: var(--olive-50); }
.card.rose { box-shadow: none; background: var(--rose-50); }
.card.outline { box-shadow: inset 0 0 0 1px var(--line); background: transparent; }
.card-title { font-family: var(--font-serif); font-size: 21px; font-weight: 500; color: var(--plum); margin: 0; line-height: 1.2; }

.tip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--rose-50);
  color: var(--ink);
  font-size: 14px;
}
.tip svg { width: 18px; height: 18px; color: var(--rose-ink); flex: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-1);
}
.pill svg { width: 14px; height: 14px; }
.pill.sage { background: var(--olive-50); color: var(--olive-700); box-shadow: none; }

.check-line { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.check-line svg { width: 14px; height: 14px; color: var(--olive); }

/* ---------- Item tiles ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
  text-align: left;
  aspect-ratio: 1 / 1.08;
  transition: transform 0.15s var(--ease);
}
.tile:active { transform: scale(0.98); }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .tile-label {
  position: absolute;
  left: 8px; right: 8px; bottom: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(252, 249, 244, 0.92);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.thumb {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-2);
}
.thumb.sm { width: 44px; height: 44px; border-radius: 10px; }
.thumb.lg { width: 76px; height: 76px; }

.swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  flex: none;
}
.swatch.lg { width: 34px; height: 34px; }

/* ---------- Forms ---------- */
.field { display: block; }
.field + .field { margin-top: 16px; }
.label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--ink);
}
.input:focus, .select:focus, .textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--olive); }
.range { width: 100%; accent-color: var(--olive); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: rgba(252, 249, 244, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 50px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.15s;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a[aria-current='page'] { color: var(--plum); font-weight: 600; }
.tabbar a[aria-current='page'] svg { color: var(--olive-700); }

/* ---------- Empty states ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 32px 20px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.empty .empty-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--olive-700);
}
.empty .empty-icon svg { width: 28px; height: 28px; }
.empty h3 { margin: 4px 0 0; font-family: var(--font-serif); font-weight: 500; font-size: 22px; color: var(--plum); }
.empty p { margin: 0; color: var(--ink-2); font-size: 14px; max-width: 300px; }

/* ---------- Overlays: sheet, dialog, toast ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(46, 26, 40, 0.38);
  animation: fade-in 0.2s ease both;
  touch-action: none; /* dragging on the dimmed page must not scroll it */
}
/* While a sheet is open the page behind stays put (set by ui.js). */
html.sheet-open { overflow: hidden; }
.backdrop.closing { animation: fade-out 0.2s ease both; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 41;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px var(--gutter) calc(24px + var(--safe-bottom));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--bg);
  box-shadow: var(--shadow-3);
  animation: sheet-up 0.34s var(--ease) both;
}
.sheet.closing { animation: sheet-down 0.24s ease both; }
.sheet-grip { width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: var(--line-strong); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-title { font-family: var(--font-serif); font-weight: 500; font-size: 26px; color: var(--plum); margin: 0; line-height: 1.1; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.toast-wrap {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  z-index: 60;
  display: flex;
  justify-content: center;
  padding: 0 var(--gutter);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 420px;
  padding: 12px 16px 12px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: toast-in 0.4s var(--ease) both;
  pointer-events: none; /* never swallow taps on the button underneath */
}
/* With a sheet open its main button sits where the toast would be, so show the toast up top. */
html.sheet-open .toast-wrap { top: calc(var(--safe-top) + 12px); bottom: auto; }
.toast.closing { animation: fade-out 0.25s ease both; }
.toast .toast-icon {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  background: var(--olive-50);
  color: var(--olive-700);
}
.toast .toast-icon svg { width: 18px; height: 18px; }
.toast strong { display: block; font-size: 14px; color: var(--plum); }
.toast span { display: block; font-size: 12.5px; color: var(--ink-2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Spinner and scan line */
.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--olive-100);
  border-top-color: var(--olive);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scanline {
  position: absolute;
  left: 6%; right: 6%;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--olive) 20%, var(--olive) 80%, transparent);
  box-shadow: 0 0 18px 6px rgba(123, 138, 99, 0.35);
  animation: scan 1.8s ease-in-out infinite alternate;
}
@keyframes scan { from { top: 10%; } to { top: 88%; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
