/* vbox — flat editorial UI · borders only · no shadows */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600&display=swap');

:root {
  --font: 'Instrument Sans', system-ui, sans-serif;
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #666666;
  --faint: #999999;
  --line: #e0e0e0;
  --line-strong: #111111;
  --accent: #111111;
  --ok: #111111;
  --warn: #666666;
  --err: #111111;
  --radius: 0;
  --nav-h: 56px;
  --maxw: 400px;
  --stroke: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}

.page-settings .app-shell { padding-bottom: 8px; }

body.page-shop .app-shell {
  max-width: 520px;
}

/* —— Header —— */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.top-main { flex: 1; min-width: 0; }

.top-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.top-sub {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.back {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 8px;
}
.back:hover { color: var(--ink); }

.qr-download {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.qr-download:hover { color: var(--ink); border-color: var(--line-strong); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}
.brand svg { width: 28px; height: 28px; flex: none; }
.brand .word {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.wallet {
  text-align: right;
  flex: none;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  font: inherit;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
.wallet:hover { background: var(--bg); }
.wallet-tap:active { background: #f0f0f0; }
.wallet .label {
  display: block;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.wallet .amount {
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.wallet .unit {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 2px;
}

/* —— Status —— */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 8px;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: transparent;
}
.badge.on { color: var(--ink); border-color: var(--line-strong); }
.badge.on .dot { background: var(--ink); border-color: var(--ink); }

/* —— Lists & panels —— */

.panel {
  border: 1px solid var(--line);
  background: var(--surface);
}

.list { display: flex; flex-direction: column; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); }
.list-item:active { background: #f0f0f0; }

.list-item .body { flex: 1; min-width: 0; }
.list-item .title {
  font-weight: 500;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
}
.list-item .meta {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 1px;
}

.icon-box {
  width: 40px;
  height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
}
.icon-box img { width: 32px; height: 32px; display: block; }

.icon-arrow {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--faint);
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 8px;
}

/* —— QR scanner —— */

.scanner-card {
  margin-bottom: 20px;
  overflow: hidden;
}

.scanner-video-wrap {
  position: relative;
  aspect-ratio: 1;
  background: #111111;
  border-bottom: 1px solid var(--line);
}

.scanner-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.scanner-frame {
  position: absolute;
  inset: 16%;
  border: 1.5px solid #ffffff;
  pointer-events: none;
}

.scanner-frame::before,
.scanner-frame::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  height: 1px;
  background: rgba(255, 255, 255, 0.75);
}

.scanner-frame::before { top: 50%; }
.scanner-frame::after { display: none; }

.scanner-copy {
  padding: 14px 16px 16px;
}

.scanner-copy h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.scanner-copy p {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* —— Shop lanes (2-col cards) —— */

.lanes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lane-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}

.lane-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 8px 6px;
}

.lane-card-top .icon-btn {
  width: 28px;
  height: 28px;
  text-decoration: none;
}

.lane-photo {
  aspect-ratio: 1;
  margin: 0 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
}

.lane-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lane-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 10px 8px 8px;
  min-width: 0;
}

.lane-id {
  font-size: 0.5625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.lane-name {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lane-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.lane-price {
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.lane-price small {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 2px;
}

.lane-stock {
  font-size: 0.6875rem;
  color: var(--muted);
}

.lane-card .btn {
  padding: 9px 8px;
  font-size: 0.6875rem;
}

.lane-card .btn .spinner {
  width: 12px;
  height: 12px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn svg { width: 16px; height: 16px; }

/* —— Buttons —— */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  transition: background 0.1s, color 0.1s;
}
.btn:hover:not(:disabled) { background: var(--ink); color: var(--surface); }
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--line);
  color: var(--faint);
}
.btn-fill {
  background: var(--ink);
  color: var(--surface);
}
.btn-fill:hover:not(:disabled) { background: var(--surface); color: var(--ink); }
.btn-fill:disabled { background: var(--bg); }

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
}

.btn-sm {
  width: auto;
  padding: 6px 12px;
  font-size: 0.6875rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.btn-row .btn { width: auto; flex: 1; min-width: fit-content; }

.spinner {
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* —— Forms —— */

.form-block {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
  margin-bottom: 12px;
}
.form-block h3 {
  margin: 0 0 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--line-strong);
}
.field-hint {
  font-size: 0.75rem;
  color: var(--faint);
  margin-top: 4px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.save-area {
  padding: 16px 0 calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
}

/* —— Settings lines —— */

.settings-lines {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

.settings-line {
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: -1px;
}

.settings-line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.settings-summary {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.settings-edit {
  padding: 0 16px 16px;
  border-top: 1px solid var(--line);
}

.settings-edit .field-row {
  margin-top: 12px;
}

.settings-edit .btn {
  margin-top: 12px;
}

/* —— Banner & note —— */

.note {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.note code {
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  color: var(--ink);
}

.banner {
  display: none;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  font-size: 0.8125rem;
  margin-bottom: 16px;
}
.banner.show { display: block; }

.loading {
  padding: 24px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--faint);
}

/* —— Deposit sheet —— */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: none;
  align-items: flex-end;
  z-index: 60;
}

.sheet.open { display: flex; }

.sheet-panel {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
  padding-bottom: 16px;
}

.sheet-panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.sheet-hint {
  margin: 4px 0 14px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.sheet-actions .btn {
  flex: 1;
  margin: 0;
}

.sheet .field {
  margin: 0;
}

.sheet .field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.sheet .field input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  background: var(--surface);
}

.sheet .field input:focus {
  outline: none;
  border-color: var(--ink);
}

.footer-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
}
.footer-link a {
  color: var(--muted);
  text-decoration: none;
}
.footer-link a:hover { color: var(--ink); }

/* —— Bottom nav —— */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
  display: flex;
}
.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  text-decoration: none;
  color: var(--faint);
  font-size: 0.5625rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-right: 1px solid var(--line);
}
.nav a:last-child { border-right: none; }
.nav a svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: var(--stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav a.active {
  color: var(--ink);
  background: var(--bg);
}

/* —— Log —— */

.log {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
  min-height: 160px;
  max-height: 240px;
  overflow-y: auto;
  font-family: ui-monospace, monospace;
  font-size: 0.6875rem;
  line-height: 1.6;
}
.log-line { color: var(--muted); padding: 2px 0; }
.log-line.info { color: var(--ink); }
.log-line.ok { color: var(--ink); }
.log-line.err { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* —— Toasts —— */

.toasts {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  max-width: var(--maxw);
  margin: 0 auto;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toast {
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 0.8125rem;
}

/* —— Map —— */

.map-wrap {
  border: 1px solid var(--line);
  background: var(--surface);
}
.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.map-head h2 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
#map-mount .map-canvas,
.map-wrap > .map-canvas,
.map-wrap #map-mount .map-canvas {
  width: 100%;
  height: 200px;
}
.map-wrap.full #map-mount,
.map-wrap.full > div:first-child:not(.map-foot) {
  min-height: min(55vh, 440px);
}
.map-wrap.full .map-canvas {
  height: min(55vh, 440px);
}
.map-foot {
  padding: 8px 16px;
  font-size: 0.6875rem;
  color: var(--faint);
  border-top: 1px solid var(--line);
}
.map-foot a { color: var(--muted); }

/* Full-screen map page */
body.page-map {
  overflow: hidden;
  background: #f5f5f5;
}

body.page-map .map-page,
body.page-map #map-mount {
  position: fixed;
  inset: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  z-index: 1;
}

body.page-map .map-page .map-canvas,
body.page-map #map-mount .map-canvas {
  width: 100%;
  height: 100%;
}

body.page-map .toasts {
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
}

body.page-map .leaflet-top.leaflet-left {
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
}
body.page-map .leaflet-top.leaflet-right {
  top: auto;
  bottom: 12px;
  right: 12px;
}
body.page-map .leaflet-bottom.leaflet-right {
  bottom: 8px;
  right: 8px;
}

.leaflet-container { font-family: var(--font); background: #f5f5f5; }
.leaflet-control-attribution {
  font-size: 0.5625rem !important;
  background: var(--surface) !important;
  color: var(--faint) !important;
  border: 1px solid var(--line) !important;
  border-radius: 0 !important;
}
.leaflet-bar {
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}
.leaflet-bar a {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.leaflet-popup-content-wrapper {
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  background: var(--surface);
}
.leaflet-popup-tip { display: none; }
.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 0.8125rem;
}

@media (min-width: 480px) {
  .lanes { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
