/* Beaned Up — app.css
 * Palette: espresso brown #3b2314, warm cream #faf3e7, caramel #b07d4f,
 * coffee-bean black #17100b, muted green accent #6b8f5e.
 * Dark mode via [data-theme="dark"] on <html>. Safe-area insets honored.
 */

:root {
  --bg: #faf3e7;
  --surface: #fffdf8;
  --surface-2: #f3e7d3;
  --text: #2a1a10;
  --text-dim: #7a6552;
  --espresso: #3b2314;
  --caramel: #b07d4f;
  --caramel-dark: #96683d;
  --black: #17100b;
  --green: #6b8f5e;
  --border: #e3d2b8;
  --danger: #b3261e;
  --shadow: 0 2px 10px rgba(59, 35, 20, 0.10);
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #17100b;
  --surface: #241811;
  --surface-2: #2e2013;
  --text: #f3e7d3;
  --text-dim: #b39a7d;
  --espresso: #d9b48c;
  --border: #453322;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

body.no-scroll { overflow: hidden; }

h2 { font-size: 1.35rem; margin: 0 0 4px; }
h3 { font-size: 1.05rem; }
a { color: var(--caramel-dark); }
[data-theme="dark"] a { color: var(--caramel); }

button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 1px;
}

/* ---------------- header / tabs ---------------- */

.app-header {
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  background: var(--espresso);
  color: #faf3e7;
}
[data-theme="dark"] .app-header { background: #241811; color: var(--text); }
.app-title { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.2px; }
.app-tagline { font-size: 0.85rem; opacity: 0.85; }

#screen-root {
  padding: 14px 14px 10px;
  max-width: 640px;
  margin: 0 auto;
}

.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tab-btn {
  flex: 1;
  min-height: 58px;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
  font-size: 0.72rem;
}
.tab-btn.tab-on { color: var(--espresso); font-weight: 700; }
[data-theme="dark"] .tab-btn.tab-on { color: var(--caramel); }
.tab-icon { font-size: 1.25rem; }
.tab-center { color: var(--text-dim); }
.tab-icon-big {
  font-size: 1.7rem;
  background: var(--caramel);
  color: #fff;
  width: 54px; height: 54px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-top: -22px;
  border: 3px solid var(--bg);
  box-shadow: var(--shadow);
}
.tab-badge {
  position: absolute;
  top: 6px; right: calc(50% - 22px);
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 19px; height: 19px;
  border-radius: 10px;
  padding: 1px 5px;
  text-align: center;
}

/* ---------------- generic ---------------- */

.screen-head { margin-bottom: 10px; }
.section-h { margin: 20px 0 8px; }
.dim { color: var(--text-dim); font-size: 0.9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.empty-card {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.warn-card {
  background: #fdf0e0;
  border: 1px solid var(--caramel);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}
[data-theme="dark"] .warn-card { background: #3a2a12; }

.btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.btn-primary { background: var(--caramel); border-color: var(--caramel); color: #fff; }
.btn-primary:disabled { opacity: 0.45; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; margin-top: 10px; }
.btn-small { min-height: 38px; padding: 5px 12px; font-size: 0.88rem; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-big { min-height: 54px; font-size: 1.05rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btn-row .btn { flex: 1; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.chip {
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.chip-on { background: var(--espresso); color: #faf3e7; border-color: var(--espresso); }
[data-theme="dark"] .chip-on { background: var(--caramel); color: #17100b; border-color: var(--caramel); }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  vertical-align: middle;
}
.badge-sample { background: #e8dcc4; color: #6d5320; }
[data-theme="dark"] .badge-sample { background: #4a3a16; color: #e8cf8f; }
.badge-green { background: var(--green); color: #fff; }
.badge-row { margin: 0 0 6px; }

.avatar {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--caramel);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

.mini-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.mini-row > span, .mini-row > div { min-width: 0; }
.row-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- fields / forms ---------------- */

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.field input[type="text"], .field input[type="search"], .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field input[type="range"] { width: 100%; min-height: 44px; }
.field input[type="file"] { min-height: 44px; padding-top: 10px; }

.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.seg button.seg-on { background: var(--espresso); color: #faf3e7; border-color: var(--espresso); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  font-weight: 600;
}
.switch-row input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--caramel); }

.picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shop-pick-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.shop-pick-row #l-shop-name { flex: 1; font-weight: 700; }
.shop-pick-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.shop-pick-box .dim { display: block; margin-top: 6px; }

.optional-details {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 2px 12px 4px;
  margin-bottom: 12px;
}
.optional-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  cursor: pointer;
}
.optional-details[open] summary { margin-bottom: 8px; }
.optional-details .field:last-child { margin-bottom: 6px; }

/* ---------------- home feed ---------------- */

.stat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.88rem;
}
.chip-alert { border-color: var(--green); background: var(--surface-2); }

.feed-head { display: flex; gap: 10px; align-items: center; }
.feed-who { flex: 1; min-width: 0; }
.feed-rating { font-weight: 800; color: var(--caramel-dark); }
[data-theme="dark"] .feed-rating { color: var(--caramel); }
.feed-drink { font-size: 1.08rem; font-weight: 700; margin-top: 8px; }
.feed-shop { margin-top: 2px; }
.feed-notes { margin: 6px 0 0; }
.log-photo { max-width: 100%; border-radius: 12px; margin-top: 8px; }

/* ---------------- shops ---------------- */

.shop-card { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.shop-card-main { flex: 1; min-width: 0; }
.shop-name { font-weight: 800; }
.shop-meta, .shop-counts { color: var(--text-dim); font-size: 0.88rem; }
.fav-btn {
  background: none; border: none;
  font-size: 1.4rem; min-width: 44px; min-height: 44px;
  color: var(--caramel);
}
.detail-loc { font-weight: 700; margin: 2px 0 6px; }
.detail-line { margin: 4px 0; }
.copy-note { color: var(--green); font-weight: 700; }

/* ---------------- bean up ---------------- */

.compose-h { margin: 16px 0 8px; }
.friend-pick { display: flex; flex-direction: column; gap: 8px; }
.friend-chip {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px;
  padding: 6px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-align: left;
}
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset-card {
  min-height: 64px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  padding: 10px;
}
.preset-card.chip-on { border-color: var(--caramel); background: var(--surface-2); color: var(--text); }
.preset-custom { grid-column: 1 / -1; border-style: dashed; }
.char-count { text-align: right; margin: 2px 0 0; font-weight: 700; color: var(--text-dim); }
.char-count .over { color: var(--danger); }
.preview-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  min-height: 56px;
}
.preview-msg { font-size: 1.15rem; font-weight: 800; margin-top: 6px; }
.reply-note {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

/* ---------------- activity ---------------- */

.act-row { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.act-unread { border-color: var(--green); }
.act-main { flex: 1; min-width: 0; }
.act-top { display: flex; justify-content: space-between; gap: 8px; }
.act-msg { margin-top: 2px; }
.thread { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 16px;
  background: var(--surface-2);
  align-self: flex-start;
}
.bubble-me { background: var(--caramel); color: #fff; align-self: flex-end; }
.bubble-time { font-size: 0.72rem; opacity: 0.75; margin-top: 2px; }
.thread-reply-mark { text-align: center; color: var(--text-dim); font-size: 0.75rem; }

/* ---------------- profile ---------------- */

.profile-head { display: flex; gap: 12px; align-items: flex-start; }
.profile-head h2 { margin-top: 2px; }
.profile-head .btn { margin-left: auto; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-box strong { display: block; font-size: 1.5rem; }
.stat-box span { color: var(--text-dim); font-size: 0.85rem; }
.settings-card .field:last-of-type { margin-bottom: 4px; }

/* ---------------- sheets / toast / celebrate ---------------- */

#sheet-root { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(23, 16, 11, 0.5); }
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: calc(6px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}
@media (min-width: 640px) {
  .sheet { border-radius: 22px; bottom: 3vh; }
}
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 0 4px; }
.sheet-head h2 { flex: 1; font-size: 1.15rem; }
.sheet-close {
  order: 2;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
.sheet-body { padding-bottom: 6px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--black);
  color: #faf3e7;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 80;
  max-width: 90vw;
  text-align: center;
}
#toast.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

#celebrate { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.celebrate-p {
  position: absolute;
  bottom: 90px;
  font-size: 1.7rem;
  animation: float-up 1.5s ease-out forwards;
}
@keyframes float-up {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-46vh); opacity: 0; }
}

.onboard { text-align: center; padding-top: 18px; }
.onboard-icon { font-size: 3rem; }
.onboard-dots { margin: 12px 0; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--border);
  margin: 0 3px;
}
.dot-on { background: var(--caramel); }

@media (prefers-reduced-motion: reduce) {
  .celebrate-p { animation: none; display: none; }
  #toast { transition: none; }
}
