/* ============================================================
   Larder — shared shopping lists
   Design tokens: chalkboard kitchen, amber stamp ink, sage bought
   ============================================================ */

:root{
  --bg: #1a1d1a;
  --bg-elevated: #1f231e;
  --surface: #262b24;
  --surface-bought: #1e211c;
  --border: #343a30;
  --border-soft: #2b3027;

  --text: #eee9df;
  --text-muted: #a3a596;
  --text-faint: #6f7266;

  --accent: #d9a34a;
  --accent-strong: #e6b968;
  --accent-bg: rgba(217,163,74,0.12);

  --success: #7a9c74;
  --success-bg: rgba(122,156,116,0.14);

  --danger: #c0705f;
  --danger-bg: rgba(192,112,95,0.12);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-tile: 0 4px 14px rgba(0,0,0,0.28);
  --shadow-float: 0 8px 24px rgba(0,0,0,0.4);

  --font-display: 'Kalam', cursive;
  --font-body: 'Space Grotesk', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

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

html, body{
  margin:0; padding:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body{
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

a{ color: inherit; text-decoration: none; }
button{ font-family: inherit; }

/* subtle chalkboard texture */
body::before{
  content:"";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.025), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(255,255,255,0.02), transparent 45%);
  z-index: 0;
}

.app{
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  z-index: 1;
}

/* ---------- Top bar ---------- */
.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 8px;
}

.brand{
  display:flex;
  align-items:baseline;
  gap: 10px;
}

.brand-mark{
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.brand-tag{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: lowercase;
  letter-spacing: 0.03em;
}

.icon-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  width: 40px; height: 40px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:active{ background: var(--bg-elevated); }
.icon-btn svg{ width: 18px; height: 18px; }

.back-row{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 16px 18px 4px;
}

.whoami{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.whoami .dot{
  width: 20px; height:20px;
  border-radius:999px;
  background: var(--accent);
  color: #201804;
  font-weight: 700;
  font-size: 11px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink: 0;
}

/* ---------- Lists overview page ---------- */
.list-grid{
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 16px 120px;
}

.section-label{
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 4px 2px;
}

.list-card{
  position: relative;
  display:block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-tile);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.list-card:active{ transform: scale(0.985); }

.list-card.is-complete{
  border-color: rgba(122,156,116,0.35);
}

.list-card-top{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 10px;
}

.list-card-title{
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  padding-right: 6px;
  word-break: break-word;
}

.list-card-meta{
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.complete-chip{
  display:flex;
  align-items:center;
  gap:5px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex-shrink: 0;
  white-space: nowrap;
}
.complete-chip svg{ width: 11px; height: 11px; }

.progress-row{
  display:flex;
  align-items:center;
  gap: 10px;
  margin-top: 12px;
}

.progress-track{
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

.progress-fill{
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width .4s ease;
}

.list-card.is-complete .progress-fill{
  background: linear-gradient(90deg, var(--success), #93b48d);
}

.progress-pct{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  min-width: 34px;
  text-align: right;
}

.delete-list-btn{
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: 999px;
  background: var(--danger-bg);
  border: 1px solid rgba(192,112,95,0.3);
  color: var(--danger);
  display:flex; align-items:center; justify-content:center;
  cursor: pointer;
}
.delete-list-btn svg{ width: 14px; height: 14px; }

.list-card.is-complete .list-card-top{ padding-right: 34px; }

.empty-state{
  text-align:center;
  padding: 60px 24px;
  color: var(--text-faint);
}
.empty-state .empty-mark{
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.empty-state p{ font-size: 13px; line-height: 1.5; margin: 0; }

/* ---------- FAB ---------- */
.fab{
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: max(24px, calc((100vw - 560px)/2 + 24px));
  width: 58px; height: 58px;
  border-radius: 999px;
  background: var(--accent);
  color: #201804;
  border: none;
  display:flex; align-items:center; justify-content:center;
  box-shadow: var(--shadow-float);
  cursor: pointer;
  z-index: 20;
}
.fab svg{ width: 26px; height: 26px; }
.fab:active{ background: var(--accent-strong); }

/* ---------- Sheet / modal ---------- */
.sheet-backdrop{
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 30;
  display:flex;
  align-items:flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.sheet-backdrop.open{ opacity: 1; pointer-events: auto; }

.sheet{
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-elevated);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--border);
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(20px);
  transition: transform .2s ease;
}
.sheet-backdrop.open .sheet{ transform: translateY(0); }

.sheet h3{
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 14px;
}

.field{
  display:flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label{
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.field input{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
  outline: none;
}
.field input:focus{ border-color: var(--accent); }

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

.btn{
  flex:1;
  padding: 13px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}
.btn.primary{
  background: var(--accent);
  border-color: var(--accent);
  color: #201804;
}
.btn:active{ opacity: 0.85; }

.name-pills{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}
.name-pill{
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.name-pill.active{
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}

/* ---------- List detail page ---------- */
.list-title-wrap{
  flex: 1;
}
.list-title{
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1.5px dashed transparent;
  width: 100%;
  padding: 2px 0;
  outline: none;
}
.list-title:focus, .list-title.editing{
  border-bottom-color: var(--accent);
}
.list-subtitle{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

.completed-banner{
  margin: 4px 18px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid rgba(122,156,116,0.3);
  color: var(--success);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.completed-banner svg{ width: 16px; height: 16px; flex-shrink: 0; }

.item-list{
  display:flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 160px;
}

.item-tile{
  position: relative;
  display:flex;
  align-items:center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 14px 14px 12px;
  cursor: pointer;
  transition: opacity .25s ease, transform .25s ease, background .25s ease;
}
.item-tile:active{ transform: scale(0.985); }

.item-tile.bought{
  background: var(--surface-bought);
  border-color: var(--border-soft);
}

.item-tile.toggling{
  opacity: 0.35;
  transform: scale(0.97);
}

.check-circle{
  width: 26px; height: 26px;
  border-radius: 999px;
  border: 1.5px solid var(--text-faint);
  flex-shrink: 0;
  display:flex; align-items:center; justify-content:center;
  transition: background .2s ease, border-color .2s ease;
}
.item-tile.bought .check-circle{
  background: var(--success);
  border-color: var(--success);
}
.check-circle svg{
  width: 14px; height: 14px;
  color: #16211a;
  opacity: 0;
  transition: opacity .15s ease;
}
.item-tile.bought .check-circle svg{ opacity: 1; }

.item-body{
  flex: 1;
  min-width: 0;
}

.item-name{
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.item-tile.bought .item-name{
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
  text-decoration-thickness: 1.5px;
}

.audit-stamp{
  display:inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1.5px solid var(--accent);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: rotate(-2.5deg);
  transform-origin: left center;
  opacity: 0.9;
}

.qty-pill{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 5px 11px;
  flex-shrink: 0;
  white-space: nowrap;
}
.item-tile.bought .qty-pill{
  color: var(--text-faint);
  border-color: var(--border-soft);
}

/* ---------- Sticky add-item bar ---------- */
.add-bar{
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
}
.add-bar-inner{
  max-width: 560px;
  margin: 0 auto;
  display:flex;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 7px 7px 16px;
  box-shadow: var(--shadow-float);
}
.add-bar input{
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
}
.add-bar .name-input{ flex: 1.6; min-width: 0; }
.add-bar .qty-input{ flex: 1; min-width: 0; border-left: 1px solid var(--border); padding-left: 10px; color: var(--text-muted); }
.add-bar .name-input::placeholder, .add-bar .qty-input::placeholder{ color: var(--text-faint); }

.add-submit{
  width: 42px; height: 42px;
  border-radius: 999px;
  background: var(--accent);
  border: none;
  color: #201804;
  display:flex; align-items:center; justify-content:center;
  flex-shrink: 0;
  cursor: pointer;
}
.add-submit svg{ width: 18px; height: 18px; }
.add-submit:active{ background: var(--accent-strong); }

@media (max-width: 380px){
  .brand-mark{ font-size: 26px; }
  .list-title{ font-size: 22px; }
}
