/* =====================================================================
   Plum HQ — styles
   ===================================================================== */
:root {
  --orange:   #e8743b;
  --orange-d: #cf5f2a;
  --teal:     #2c8c7d;
  --bg:       #faf6f1;
  --surface:  #ffffff;
  --surface-2:#f2ece3;
  --text:     #2a2320;
  --text-dim: #7d7268;
  --border:   #e7ddd0;
  --danger:   #c4453d;
  --shadow:   0 6px 22px rgba(60, 40, 20, 0.10);
  --radius:   18px;
  --tabbar-h: 64px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --orange:   #f08a52;
    --orange-d: #e8743b;
    --teal:     #46a895;
    --bg:       #16130f;
    --surface:  #221d18;
    --surface-2:#2c261f;
    --text:     #f1e9df;
    --text-dim: #a99c8d;
    --border:   #3a322a;
    --danger:   #e8736b;
    --shadow:   0 6px 22px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { overscroll-behavior-y: none; }

button, input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  color: inherit;
}
button { cursor: pointer; border: none; background: none; }
a { color: var(--orange); }

/* ---- Splash --------------------------------------------------------- */
.splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
}
.splash-mark { font-size: 64px; }
.splash-name { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.spinner {
  width: 26px; height: 26px; margin-top: 6px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- App frame ------------------------------------------------------ */
#app { min-height: 100%; display: flex; flex-direction: column; }

.view {
  flex: 1;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 40;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: var(--text-dim);
  font-size: 11px; font-weight: 600;
}
.tab-icon { font-size: 22px; filter: grayscale(0.5); opacity: 0.7; transition: 0.15s; }
.tab.active { color: var(--orange); }
.tab.active .tab-icon { filter: none; opacity: 1; transform: translateY(-1px); }

/* ---- Headings & text ------------------------------------------------ */
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.page-sub   { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
.section-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--text-dim);
  margin: 22px 4px 8px;
}
.muted { color: var(--text-dim); }
.center { text-align: center; }

/* ---- Cards ---------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }

/* ---- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px; font-weight: 700;
  transition: transform 0.08s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-teal    { background: var(--teal);   color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); }
.btn-danger  { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-lg { padding: 16px 20px; font-size: 17px; border-radius: 16px; }

/* ---- Forms ---------------------------------------------------------- */
.field { display: block; margin-top: 14px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; display: block; }
.input, .textarea, select.input {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}
.input:focus, .textarea:focus, select.input:focus {
  outline: none; border-color: var(--orange);
}
.textarea { min-height: 76px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.checkrow { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.checkrow input { width: 20px; height: 20px; accent-color: var(--orange); }

/* ---- Pickers (emoji / colour) -------------------------------------- */
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.swatch-emoji {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--surface-2); border: 2px solid transparent;
  font-size: 24px; display: flex; align-items: center; justify-content: center;
}
.swatch-emoji.sel { border-color: var(--orange); background: var(--surface); }
.swatch-color {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid transparent;
}
.swatch-color.sel { border-color: var(--text); }

/* ---- Avatars -------------------------------------------------------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
  width: 40px; height: 40px; font-size: 20px;
  color: #fff;
}
.avatar.sm { width: 28px; height: 28px; font-size: 14px; }
.avatar.lg { width: 64px; height: 64px; font-size: 32px; }

/* ---- Home: ping buttons -------------------------------------------- */
.dinner-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 100%;
  padding: 26px 18px;
  border-radius: 24px;
  background: linear-gradient(160deg, #f6a04a, var(--orange));
  color: #fff;
  box-shadow: 0 10px 26px rgba(232, 116, 59, 0.4);
  transition: transform 0.09s ease;
}
.dinner-btn:active { transform: scale(0.97); }
.dinner-btn:disabled { opacity: 0.7; }
.dinner-emoji { font-size: 46px; }
.dinner-text  { font-size: 21px; font-weight: 800; }
.dinner-hint  { font-size: 13px; opacity: 0.9; }

.ping-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ping-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow);
}
.ping-chip:active { transform: scale(0.97); }
.ping-chip .e { font-size: 22px; }

/* ---- List rows ------------------------------------------------------ */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-title { font-weight: 600; }
.list-sub { font-size: 13px; color: var(--text-dim); margin-top: 1px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* shopping checkbox */
.tick {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; flex-shrink: 0;
}
.tick.on { background: var(--teal); border-color: var(--teal); }
.done .list-title { text-decoration: line-through; color: var(--text-dim); }

/* ---- Calendar ------------------------------------------------------- */
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cal-nav {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface-2); font-size: 18px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.cal-month { font-size: 17px; font-weight: 800; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow {
  text-align: center; font-size: 11px; font-weight: 700;
  color: var(--text-dim); padding-bottom: 4px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 11px; font-size: 14px; font-weight: 600;
  background: var(--surface);
  border: 1px solid transparent;
}
.cal-cell.dim { color: var(--text-dim); opacity: 0.4; }
.cal-cell.today { border-color: var(--orange); color: var(--orange); }
.cal-cell.sel { background: var(--orange); color: #fff; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); margin-top: 3px; }
.cal-cell.sel .cal-dot { background: #fff; }

.event-row { border-left: 4px solid var(--teal); padding-left: 12px; }

/* ---- Banners -------------------------------------------------------- */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px;
  border-radius: 14px;
  background: #fff4e9;
  border: 1px solid #f3d3b4;
  color: #8a4a16;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  .banner { background: #3a2a18; border-color: #5a4022; color: #f0c79a; }
}
.banner .b-emoji { font-size: 20px; }
.banner .b-body { flex: 1; }
.banner .b-title { font-weight: 800; margin-bottom: 2px; }

/* ---- Empty states --------------------------------------------------- */
.empty { text-align: center; padding: 36px 16px; color: var(--text-dim); }
.empty .e-emoji { font-size: 40px; }
.empty .e-text { margin-top: 8px; font-size: 14px; }

/* ---- Floating add button ------------------------------------------- */
.fab {
  position: fixed; right: 18px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--orange); color: #fff;
  font-size: 30px; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(232, 116, 59, 0.45);
  z-index: 30;
}
.fab:active { transform: scale(0.93); }

/* ---- Bottom sheet --------------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 12, 6, 0.45);
  display: flex; align-items: flex-end;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%;
  max-height: 90vh;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(var(--safe-bottom) + 22px);
  overflow-y: auto;
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { transform: translateY(100%); } }
.sheet-grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 8px auto 6px;
}
.sheet-title { font-size: 19px; font-weight: 800; margin: 4px 0 6px; }

/* ---- Toast ---------------------------------------------------------- */
#toast-host {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 80; pointer-events: none;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 22px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
  max-width: 88%;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---- Onboarding ----------------------------------------------------- */
.onb {
  min-height: 100%;
  padding: calc(var(--safe-top) + 30px) 22px calc(var(--safe-bottom) + 30px);
  display: flex; flex-direction: column;
}
.onb-hero { text-align: center; margin-bottom: 8px; }
.onb-hero .mark { font-size: 60px; }
.onb-hero h1 { font-size: 30px; font-weight: 900; margin-top: 6px; }
.onb-hero p { color: var(--text-dim); margin-top: 6px; }

.code-display {
  font-size: 34px; font-weight: 900; letter-spacing: 6px;
  text-align: center; color: var(--orange);
  padding: 16px; background: var(--surface-2); border-radius: 14px;
  margin: 10px 0;
}

/* ---- Misc ----------------------------------------------------------- */
.error-box {
  margin: 30px 16px; padding: 16px;
  background: var(--surface); border: 1px solid var(--danger);
  border-radius: 14px; color: var(--text);
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: var(--surface-2); color: var(--text-dim);
}
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--text-dim);
}
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
