:root {
  --red: #c0392b;
  --red-dark: #8e2f22;
  --green: #1e8449;
  --bg: #f5f1e8;
  --card: #ffffff;
  --ink: #2c2c2c;
  --muted: #757575;
  --border: #e5ddd0;
  --nav-bg: #ffffff;
  --green: #1e8449;
  --blue: #2c6fbb;
}

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

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 74px; /* space for bottom nav */
  min-height: 100vh;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(120deg, var(--red), var(--red-dark));
  color: #fff;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar-inner { display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 18px; font-weight: 800; }
.unread-badge {
  background: #fff; color: var(--red);
  border-radius: 20px; padding: 2px 10px; font-size: 13px; font-weight: 800;
}

/* ---------- main ---------- */
.app { padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 6px; font-size: 20px; }
.card h3 { margin: 12px 0 8px; font-size: 16px; }

/* ---------- forms ---------- */
label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-top: 10px; }
input, textarea, select {
  width: 100%;
  padding: 14px 14px;
  margin: 6px 0 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

button {
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 15px 20px;      /* >= 44px touch target */
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin: 6px 6px 6px 0;
  min-height: 48px;
  width: 100%;
}
button.secondary { background: #5b6b8c; }
button.danger { background: var(--red); }
button.ghost { background: #eee; color: var(--ink); }
button.small { padding: 10px 14px; font-size: 14px; min-height: 44px; width: auto; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.block { display: block; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }

/* ---------- badges / status ---------- */
.badge {
  display: inline-block; padding: 3px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  background: #e8e3d8;
}
.badge.draft { background: #ece3c8; color: #7a6a1f; }
.badge.open { background: #d6e8ff; color: #1a4f9b; }
.badge.drawn { background: #d4f0dd; color: #1e8449; }
.badge.closed { background: #e3e3e3; color: #555; }

.status { font-size: 14px; color: var(--muted); margin: 6px 0; }
.error { color: var(--red); font-size: 14px; margin: 8px 0; }
.success { color: var(--green); font-size: 14px; margin: 8px 0; }
.muted { color: var(--muted); font-size: 13px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- lists ---------- */
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
ul.plain li:last-child { border-bottom: 0; }

.draw-row { cursor: pointer; }
.draw-title { font-weight: 700; font-size: 16px; }
.draw-sub { font-size: 12px; color: var(--muted); }

.tag { display: inline-block; background: #f0ece2; border-radius: 16px; padding: 4px 12px; margin: 4px 4px 0 0; font-size: 14px; }

/* ---------- result ---------- */
.result-hero { text-align: center; padding: 28px 16px; }
.result-hero .big { font-size: 34px; font-weight: 800; color: var(--red); margin: 8px 0; }

/* ---------- catalog ---------- */
.catalog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cat-item {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column;
}
.cat-img { background: #f0ece2; height: 100px; display:flex; align-items:center; justify-content:center; font-size: 40px; }
.cat-body { padding: 10px; }
.cat-title { font-size: 14px; font-weight: 600; }
.cat-price { color: var(--green); font-weight: 800; margin: 4px 0; }
.chip-cat { font-size: 11px; color: var(--muted); }

/* ---------- chat ---------- */
.chat-window { display: flex; flex-direction: column; min-height: 50vh; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 4px 0; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; margin: 6px 0; font-size: 15px; }
.bubble.mine { background: var(--green); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.theirs { background: #eee; border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row input { margin: 0; }
.chat-input-row button { width: auto; flex: 0 0 auto; margin: 0; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; background: none; color: var(--muted); border: 0;
  width: auto; margin: 0; padding: 12px 4px; min-height: 56px;
  font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 0;
}
.nav-item.active { color: var(--red); }
.nav-ico { font-size: 20px; line-height: 1; }

/* ---------- join code ---------- */
.join-code-box {
  background: #f3efe7; border: 1px dashed var(--border); border-radius: 10px;
  padding: 12px; font-family: monospace; font-size: 22px; letter-spacing: 4px;
  text-align: center; margin: 10px 0;
}

/* ---------- misc ---------- */
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: 14px; z-index: 50; opacity: 0; transition: opacity .2s;
  pointer-events: none; max-width: 90%;
}
.toast.show { opacity: 1; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--red);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; flex: 0 0 44px;
}

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .bigico { font-size: 48px; }

.spinner { text-align: center; color: var(--muted); padding: 40px; }
