:root {
  --bg: #f6f6f8; --card: #fff; --text: #1c1c1e; --muted: #6e6e73; --line: #e5e5ea;
  --brand: #e8457c; --brand-soft: #fde7ef; --green: #1f9d55; --green-soft: #e3f6ea; --danger: #d62839;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --muted: #98989f; --line: #2c2c2e;
          --brand-soft: #3a1b26; --green-soft: #163322; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body, button, a, .header, .item { touch-action: manipulation; }
.header, .btn, .item, .sheet h3, h1, h2, h3 { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); overscroll-behavior-y: none; }
button, input, textarea { font: inherit; color: inherit; }
img { display: block; }
.loading { text-align: center; padding: 40px; color: var(--muted); }

/* Header */
.header { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 12px 16px 10px; }
.header .row { display: flex; align-items: center; gap: 10px; }
.header h1 { font-size: 24px; margin: 0; flex: 1; letter-spacing: -.3px; white-space: nowrap; }
.btn { white-space: nowrap; }
.logo { width: 40px; height: 40px; border-radius: 11px; flex: none; margin-right: auto; }
.search-wrap { position: relative; margin-top: 12px; }
.search-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .6; }
.search { width: 100%; padding: 12px 14px 12px 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-size: 16px; -webkit-appearance: none; }
.search:focus { border-color: var(--brand); }

.btn { border: 0; border-radius: 12px; padding: 11px 16px; background: var(--brand); color: #fff;
  font-weight: 600; cursor: pointer; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }

/* List */
.list { padding: 0 16px 40px; display: flex; flex-direction: column; gap: 10px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 8px; }
.count { font-size: 13px; color: var(--muted); }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 16px;
  padding: 12px; text-decoration: none; color: inherit; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.item:active { transform: scale(.985); opacity: .85; }
.thumb { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; background: var(--bg); flex: none; }
.thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 28px; }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 600; font-size: 16px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.item .prices { display: flex; gap: 18px; margin-top: 8px; }
.pr { display: flex; flex-direction: column; }
.pr .pl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.pr .pv { font-size: 15px; font-weight: 700; }
.pr.sell .pv { color: var(--green); }
.pr.buy .pv { color: var(--brand); }
.del-btn { flex: none; background: none; border: 0; font-size: 20px; padding: 10px 6px; opacity: .55; cursor: pointer; }
.del-btn:active { opacity: 1; }
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; line-height: 1.6; }

/* Detail */
.detail { padding: 0 16px 40px; }
.hero { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 16px; background: var(--card); }
.hero.empty { height: 200px; display: grid; place-items: center; color: var(--muted); font-size: 48px; }
.detail h2 { font-size: 24px; margin: 14px 0 6px; }
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.price-box { background: var(--card); border-radius: 14px; padding: 12px 14px; }
.price-box .label { font-size: 13px; color: var(--muted); }
.price-box .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.price-box.buy .value { color: var(--brand); }
.price-box.sell .value { color: var(--green); }
.price-box .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.note { background: var(--card); border-radius: 14px; padding: 12px 14px; white-space: pre-wrap; color: var(--muted); }
/* Forms */
.form { padding: 0 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-size: 16px; }
.field input:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.img-pick { display: flex; gap: 12px; align-items: center; }
.img-pick .preview { width: 110px; height: 110px; border-radius: 12px; object-fit: cover; background: var(--card);
  border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); }
.img-pick .choices { display: flex; flex-direction: column; gap: 8px; }
.hint { font-size: 12px; color: var(--muted); }

/* Login */
.login { min-height: 80vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 340px; background: var(--card); border-radius: 18px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 4px; text-align: center; }
.logo-full { width: 160px; height: 160px; border-radius: 28px; margin: 0 auto 4px; }
.login .box input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 18px; text-align: center; outline: none; }
.err { color: var(--danger); font-size: 14px; text-align: center; }

/* Sheet (modal) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; }
.sheet { background: var(--bg); width: 100%; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 12px; }
.sheet h3 { margin: 0; }
.sheet .btn { text-align: center; text-decoration: none; display: block; }
.imp-ok { background: var(--green-soft); color: var(--green); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.imp-err { background: var(--brand-soft); color: var(--danger); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-top: 8px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-bottom));
  background: #333; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 30; }
