:root {
  --bg: #f4f4f2;
  --card: #ffffff;
  --text: #16161a;
  --muted: #8a8a92;
  --border: #ececea;
  --accent-yellow: #ffe14d;
  --accent-green: #35d692;
  --accent-red: #ff8f8f;
  --radius: 16px;
}

* { box-sizing: border-box; }

/* Safety net: an <svg> with no width/height attribute defaults to the
   browser's intrinsic 300x150 box, which silently wrecked the delete
   button on item cards (its icon had no explicit size anywhere). Every
   inline icon in this app is meant to sit inline with its surrounding
   text, so 1em is the right universal default; buttons that need a
   specific pixel size (tabbar, icon-btn) already override this below. */
svg { width: 1em; height: 1em; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Nunito", "Segoe UI", Roboto, Arial, sans-serif;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 78px;
}

.screen { padding: 20px 20px 8px; flex: 1; }

h1.title {
  font-size: 30px;
  font-weight: 800;
  margin: 4px 0 18px;
  letter-spacing: -0.5px;
}

.row { display: flex; align-items: center; justify-content: space-between; }
.row-gap { gap: 10px; }

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
}
.icon-btn.active { background: var(--text); color: #fff; border-color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Sign-in ---------- */
.auth-tabs {
  display: flex;
  background: var(--border);
  border-radius: 999px;
  padding: 4px;
  margin: 30px 0 24px;
}
.auth-tabs div {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
}
.auth-tabs div.active { background: #fff; color: var(--text); }

.social-btn {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: var(--text);
  opacity: 1;
}
.social-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.social-btn .badge-circle { width: 28px; height: 28px; border-radius: 50%; display:flex; align-items:center; justify-content:center; font-size:14px; background:#f0f0f0; flex-shrink:0; }
.social-btn .chev { margin-left: auto; color: var(--muted); }
.social-btn.primary { background: var(--text); color: #fff; border-color: var(--text); justify-content: center; }

.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 24px; line-height: 1.5; }

/* ---------- Items ---------- */
.toolbar { display: flex; gap: 8px; }

.add-item-box {
  display: flex; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin: 16px 0;
}
.add-item-box input {
  flex: 1; border: none; outline: none; font-size: 14px; padding: 8px 10px; background: transparent; color: var(--text);
}
.add-item-box button {
  background: var(--text); color: #fff; border: none; border-radius: 12px; padding: 0 18px; font-weight: 700; cursor: pointer;
}

.items-list { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.items-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }

.item-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.items-list .item-card { display: flex; }
.items-list .item-thumb { width: 130px; flex-shrink: 0; }
.items-grid .item-thumb { width: 100%; aspect-ratio: 1; }

.item-thumb { position: relative; background: #eee; }
.item-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-badge {
  position: absolute; left: 8px; bottom: 8px;
  width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.item-badge.price_drop { background: var(--accent-yellow); }
.item-badge.back_in_stock { background: var(--accent-green); }
.item-badge.out_of_stock { background: var(--accent-red); }

.item-body { padding: 12px 14px; flex: 1; min-width: 0; }
.item-shop { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: 0.3px; }
.item-title { font-weight: 700; font-size: 14px; margin: 4px 0 8px; line-height: 1.3; }
.item-price { font-weight: 800; font-size: 16px; }
.item-price .old { color: var(--muted); text-decoration: line-through; font-weight: 500; font-size: 13px; margin-left: 6px; }
.item-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.item-actions a.buy {
  background: transparent; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; font-weight: 700; font-size: 13px; color: var(--text); text-decoration: none;
}
.item-actions .menu-btn { margin-left: auto; border: none; background: transparent; cursor: pointer; font-size: 18px; color: var(--muted); }
.item-actions .menu-btn svg { width: 20px; height: 20px; display: block; }
.item-status { font-size: 12px; color: var(--muted); font-style: italic; }

.empty-state { text-align: center; margin-top: 60px; color: var(--muted); }
.empty-state h2 { color: var(--text); font-size: 20px; margin-bottom: 8px; }

/* ---------- Notifications ---------- */
.notif-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; gap: 12px; margin-bottom: 12px; }
.notif-thumb { width: 56px; height: 56px; border-radius: 12px; background: #eee; object-fit: cover; flex-shrink: 0; }
.notif-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.notif-title { font-weight: 700; font-size: 14px; margin: 4px 0; }
.notif-message { font-size: 13px; color: var(--text); }

/* ---------- Shops ---------- */
.section-title { font-weight: 800; font-size: 18px; margin: 22px 0 12px; }
.shop-row { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--border); padding: 14px 16px; }
.shop-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.shop-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.shop-row + .shop-row { border-top: none; }
.shop-logo { width: 34px; height: 34px; border-radius: 50%; background: #f0f0f0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.shop-name { font-weight: 700; flex: 1; }
.star-btn { border: none; background: transparent; font-size: 18px; cursor: pointer; color: #ddd; }
.star-btn.on { color: #111; }

/* ---------- Profile ---------- */
.avatar { width: 96px; height: 96px; border-radius: 50%; background: #eee; margin: 20px auto; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 800; color: var(--muted); }
.profile-name { text-align: center; font-weight: 800; font-size: 20px; }
.profile-email { text-align: center; color: var(--muted); margin-bottom: 20px; }
.settings-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 16px; }
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.switch { position: relative; width: 46px; height: 27px; border-radius: 999px; background: #e2e2e2; cursor: pointer; transition: background .15s; flex-shrink:0; }
.switch.on { background: var(--text); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on::after { left: 22px; }
.logout-btn { width: 100%; background: var(--text); color: #fff; border: none; border-radius: var(--radius); padding: 16px; font-weight: 700; font-size: 15px; margin-top: 20px; cursor: pointer; }

/* ---------- Bottom nav ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 10px 0 20px;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer;
}
.tab.active { color: var(--text); }
.tab svg { width: 22px; height: 22px; }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 90%; text-align: center; z-index: 50;
}
.toast.show { opacity: 1; }

a { color: inherit; }
