:root {
  --blue: #009de0; --blue-dark: #007bb0; --green: #1a9f5b; --red: #d33;
  --bg: #f5f7f9; --card: #fff; --text: #1b2733; --muted: #6b7a88; --line: #e2e8ee;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; }
a { color: var(--blue-dark); text-decoration: none; }
h1 { font-size: 1.7rem; margin: 0 0 .3rem; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 .8rem; }
button { font: inherit; cursor: pointer; }

/* top bar */
#topbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
#topbar[hidden] { display: none; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
#search { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; font: inherit; background: var(--bg); }
.listbtn { background: var(--blue); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.listbtn span { background: #fff; color: var(--blue-dark); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }

main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 80px; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.muted { color: var(--muted); }

/* buttons */
.btn { display: inline-block; background: var(--blue); color: #fff; border: 0; border-radius: 12px; padding: 12px 22px; font-weight: 600; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { background: #b8c4cf; cursor: not-allowed; }
.btn.green { background: var(--green); }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--line); }

/* welcome */
.welcome { max-width: 760px; margin: 20px auto; background: var(--card); border-radius: var(--radius); padding: 28px; box-shadow: 0 2px 12px rgba(0,0,0,.05); }
.welcome label { display: block; font-weight: 600; margin: 22px 0 8px; }
.welcome input[type=text] { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font: inherit; }
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.type { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 14px 10px; text-align: center; font-weight: 600; }
.type .e { display: block; font-size: 1.8rem; margin-bottom: 4px; }
.type.on { border-color: var(--blue); background: #e8f6fd; }

/* category tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.tile { background: var(--card); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: 0 1px 6px rgba(0,0,0,.05); transition: transform .1s; }
.tile:hover { transform: translateY(-2px); }
.tile .pic { aspect-ratio: 1; background: #fff center/contain no-repeat; border-bottom: 1px solid var(--line); }
.tile .t { padding: 10px 12px; }
.tile b { display: block; font-size: .95rem; line-height: 1.25; }
.tile small { color: var(--muted); }
.reco { background: #e8f6fd; border-radius: var(--radius); padding: 4px 18px 18px; }
.reco h2 { margin-top: 14px; }

/* product grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; }
.card { position: relative; background: var(--card); border: 2px solid transparent; border-radius: var(--radius); overflow: hidden; padding: 0; text-align: left; box-shadow: 0 1px 6px rgba(0,0,0,.05); }
.card:hover { border-color: var(--blue); }
.card .pic { aspect-ratio: 1; background: #fff center/contain no-repeat; }
.card .t { padding: 8px 10px 10px; }
.card .n { font-size: .85rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.1em; }
.card .m { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.card.added { border-color: var(--green); }
.badge { position: absolute; top: 8px; right: 8px; background: var(--green); color: #fff; font-weight: 700; font-size: .8rem; padding: 3px 9px; border-radius: 999px; }
.more { text-align: center; margin: 24px 0; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15,25,35,.55); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 50; }
.modal[hidden] { display: none; }
.sheet { background: #fff; border-radius: 18px; width: 100%; max-width: 760px; max-height: 94vh; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; }
.sheet .left { padding: 16px; background: #fff; }
.sheet .big { aspect-ratio: 1; background: #fff center/contain no-repeat; border: 1px solid var(--line); border-radius: 12px; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs button { width: 52px; height: 52px; border: 2px solid var(--line); border-radius: 8px; background: #fff center/contain no-repeat; padding: 0; }
.thumbs button.on { border-color: var(--blue); }
.sheet .right { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.sheet h3 { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.sheet .close { align-self: flex-end; border: 0; background: var(--bg); width: 36px; height: 36px; border-radius: 50%; font-size: 1.1rem; }
.priceRow { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.priceRow span { font-size: 1.4rem; font-weight: 700; }
.priceRow input { width: 100%; font: inherit; font-size: 1.4rem; padding: 10px 12px; border: 2px solid var(--blue); border-radius: 12px; }
.err { color: var(--red); font-size: .9rem; min-height: 1.2em; }
@media (max-width: 640px) { .sheet { grid-template-columns: 1fr; } }

/* my list */
.row { display: grid; grid-template-columns: 64px 1fr 130px 44px; gap: 12px; align-items: center; background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.row .pic { width: 64px; height: 64px; background: #fff center/contain no-repeat; border: 1px solid var(--line); border-radius: 8px; }
.row .n { font-size: .92rem; line-height: 1.25; }
.row .pr { display: flex; align-items: center; gap: 4px; }
.row .pr input { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.row .x { border: 0; background: var(--bg); width: 36px; height: 36px; border-radius: 50%; color: var(--red); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.steps { background: #fff; border-radius: var(--radius); padding: 14px 20px; margin: 16px 0; }
.empty { text-align: center; padding: 50px 10px; color: var(--muted); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1b2733; color: #fff; padding: 12px 20px; border-radius: 999px; z-index: 60; }
.toast[hidden] { display: none; }
