:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --text: #101110;
  --muted: #686d66;
  --border: #dfe2dc;
  --black: #090909;
  --accent: #c7ff3c;
  --accent-strong: #84c900;
  --ok: #146b3a;
  --ok-bg: #e8f5ec;
  --warn: #8b4f00;
  --warn-bg: #fff2d4;
  --bad: #a6261d;
  --bad-bg: #fdeceb;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 max(32px, env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; letter-spacing: 0; }

.app-header {
  min-height: 106px;
  padding: calc(18px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 22px max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--black);
  color: #fff;
  border-bottom: 4px solid var(--accent);
}

.brand-logo {
  width: 58px;
  height: 58px;
  flex: none;
  display: block;
  object-fit: cover;
  object-position: center 28%;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 6px;
}

.app-header h1 { margin: 0; font-size: 22px; line-height: 1.1; }
.app-header p { margin: 4px 0 0; color: #c9ccc7; font-size: 13px; }
.brand-copy { min-width: 0; }
.language-switch {
  margin-left: auto;
  flex: none;
  display: grid;
  grid-template-columns: repeat(2, 40px);
  overflow: hidden;
  border: 1px solid #525552;
  border-radius: 6px;
}
.language-switch button {
  width: 40px;
  height: 34px;
  padding: 0;
  border: 0;
  border-right: 1px solid #525552;
  background: transparent;
  color: #c9ccc7;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.language-switch button:last-child { border-right: 0; }
.language-switch button[aria-pressed="true"] { background: var(--accent); color: var(--black); }
.language-switch button:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

main { width: min(760px, 100%); margin: 0 auto; padding: 18px 16px; }

.search-panel, .store-card, .map-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search-panel { padding: 16px; }

.field-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.message-box { position: relative; }

textarea, input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbf9;
  color: var(--text);
  font-size: 16px;
}

textarea { min-height: 104px; resize: vertical; padding: 12px 92px 12px 12px; }
input { height: 44px; padding: 0 11px; }
textarea:focus, input:focus { outline: 3px solid rgba(199, 255, 60, .65); border-color: #87945f; }

.message-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.icon-button svg { width: 19px; height: 19px; }
.icon-button:hover, .icon-button.active { background: var(--accent); border-color: var(--accent-strong); }
.icon-button.recording { background: var(--bad); color: #fff; border-color: var(--bad); }

.candidate-box {
  margin-top: 10px;
  padding: 11px;
  border: 1px solid #e4c66f;
  border-radius: 6px;
  background: var(--warn-bg);
  font-size: 13px;
}
.photo-review { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; align-items: start; }
.photo-preview { width: 116px; aspect-ratio: 1; object-fit: cover; border: 1px solid #d0a84c; border-radius: 6px; background: #fff; }
.candidate-question { margin: 0; line-height: 1.5; }
.candidate-list { margin-top: 8px; display: grid; gap: 7px; }
.candidate-button {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #bf8d36;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  display: grid;
  gap: 2px;
  text-align: left;
  cursor: pointer;
}
.candidate-button:hover { border-color: var(--black); }
.candidate-label { font-weight: 800; }
.candidate-normalized, .candidate-details { color: var(--muted); font-size: 12px; }
.candidate-confidence { margin-top: 3px; color: #355c00; font-size: 11px; font-weight: 800; text-transform: uppercase; }

.location-grid { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 12px; margin-top: 16px; }
.location-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 7px; }
.location-button { width: 44px; height: 44px; }
.radius-row { display: grid; grid-template-columns: minmax(0, 1fr) 24px; align-items: center; gap: 5px; }
.radius-row span { color: var(--muted); font-size: 13px; }

.btn-primary {
  width: 100%;
  height: 46px;
  margin-top: 14px;
  border: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--black);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}
.btn-primary svg { width: 18px; height: 18px; }
.btn-primary:hover { background: #242424; }
.btn-primary:disabled { opacity: .55; cursor: wait; }

#status { min-height: 22px; margin: 10px 2px; color: var(--muted); font-size: 13px; }
#status.status-error { color: var(--bad); }
#status.status-ok { color: var(--ok); }

.map-panel { width: 100%; height: 300px; margin-bottom: 12px; overflow: hidden; }
.simulation-banner, .configuration-banner, .source-banner, .notice { margin-bottom: 10px; padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.simulation-banner { border: 1px solid #e2ba5d; background: var(--warn-bg); color: var(--warn); font-weight: 750; }
.configuration-banner { border: 1px solid #e2ba5d; background: var(--warn-bg); color: var(--warn); font-weight: 750; }
.source-banner { border: 1px solid #9fcf55; background: #f4fae9; color: #31520a; font-weight: 700; }
.notice-warn { border: 1px solid #ebc2bd; background: var(--bad-bg); color: var(--bad); }
.notice-neutral { border: 1px solid var(--line); background: #f6f7f8; color: var(--muted); }
.radar-summary { margin: 10px 2px 14px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.results-section-head { margin: 18px 2px 9px; }
.results-section-head h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.results-section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.nearby-stores { border-top: 1px solid var(--border); }
.nearby-store-row {
  min-height: 88px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 14px;
  align-items: start;
}
.nearby-store-main { min-width: 0; }
.nearby-store-main p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.nearby-store-meta { display: grid; justify-items: end; gap: 5px; }
.nearby-store-meta strong { color: var(--muted); font-size: 12px; }
.inventory-status { padding: 3px 6px; border-radius: 4px; font-size: 10px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.inventory-status.status-ready { background: var(--ok-bg); color: var(--ok); }
.inventory-status.status-pending { background: #f0f1f2; color: #5c6269; }
.nearby-store-row > .route-link { grid-column: 1 / -1; margin-top: 0; justify-self: start; }
.show-more-stores {
  width: 100%;
  min-height: 42px;
  margin: 10px 0 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}
.show-more-stores:hover { border-color: var(--black); }

.store-card { margin-bottom: 12px; padding: 15px; }
.store-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.store-head h2, .store-card h2 { margin: 0; font-size: 17px; line-height: 1.25; }
.store-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.store-head > span { flex: none; color: var(--muted); font-size: 13px; font-weight: 700; }
.store-map-trigger {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}
.store-map-trigger svg { width: 16px; height: 16px; flex: none; color: #568400; }
.store-map-trigger:hover span, .store-map-trigger:focus-visible span { text-decoration: underline; }
.store-map-trigger:focus-visible { outline: 3px solid rgba(132, 201, 0, .35); outline-offset: 3px; border-radius: 3px; }

.item-row { margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--border); }
.item-row-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item-name { min-width: 0; font-weight: 800; }
.confidence { flex: none; padding: 3px 7px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.badge-high { background: var(--ok-bg); color: var(--ok); }
.badge-medium { background: var(--warn-bg); color: var(--warn); }
.badge-low, .badge-unknown { background: var(--bad-bg); color: var(--bad); }
.item-facts { display: flex; flex-wrap: wrap; gap: 5px 9px; margin-top: 7px; color: var(--muted); font-size: 13px; }
.item-facts b { color: var(--text); }
.item-sentence { margin: 8px 0 0; font-size: 13px; line-height: 1.55; }
.item-actions { display: flex; gap: 15px; margin-top: 9px; }
.item-actions a, .route-link { color: #355c00; font-size: 13px; font-weight: 750; text-decoration: none; }
.item-actions a:hover, .route-link:hover { text-decoration: underline; }
.route-link { margin-top: 13px; display: inline-flex; align-items: center; gap: 6px; }
.route-link svg { width: 16px; height: 16px; }

.maps-dialog {
  width: min(430px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .28);
}
.maps-dialog::backdrop { background: rgba(0, 0, 0, .58); }
.maps-dialog-content { padding: 16px; }
.maps-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.maps-dialog-head > div { min-width: 0; }
.maps-dialog-head h2 { margin: 0 0 12px; font-size: 17px; line-height: 1.3; }
.maps-dialog-head strong { display: block; font-size: 15px; }
.maps-dialog-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.maps-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.maps-dialog-actions a {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.maps-dialog-actions a:first-child { background: var(--black); color: #fff; border-color: var(--black); }
.maps-dialog-actions a:last-child { background: var(--accent); border-color: var(--accent-strong); }
.maps-dialog-actions svg { width: 18px; height: 18px; flex: none; }

@media (max-width: 430px) {
  main { padding: 14px 10px; }
  .app-header { min-height: 96px; padding-bottom: 18px; }
  .brand-logo { width: 52px; height: 52px; }
  .language-switch { grid-template-columns: repeat(2, 36px); }
  .language-switch button { width: 36px; }
  .search-panel, .store-card { padding: 13px; }
  .location-grid { grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; }
  .item-row-head { display: block; }
  .confidence { display: inline-block; margin-top: 6px; }
  .map-panel { height: 250px; }
  .photo-review { grid-template-columns: 88px minmax(0, 1fr); gap: 9px; }
  .photo-preview { width: 88px; }
  .maps-dialog-actions { grid-template-columns: 1fr; }
  .nearby-store-row { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .nearby-store-meta { grid-row: 2; display: flex; justify-content: space-between; align-items: center; }
  .nearby-store-row > .route-link { grid-row: 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
