/* SPDX-License-Identifier: Apache-2.0
   Copyright 2026 CLSOFTLAB (씨엘소프트랩), Dr. Lee Il-guk (이일국)
   style.css — calm, dignified, accessible, offline-first UI.
   Large targets (>=56px), high contrast, light/dark, 360px, reduced-motion. */

:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #16241f;
  --ink-soft: #47605a;
  --brand: #1f6f5c;
  --brand-ink: #ffffff;
  --brand-soft: #d7ece5;
  --accent: #b4531f; /* warm, for call/urgent — not alarming red */
  --danger: #9a2f2f;
  --line: #d6e0dc;
  --ok: #1f6f5c;
  --wait: #8a6d1f;
  --focus: #0b6bcb;
  --radius: 16px;
  --tap: 56px;
  --maxw: 640px;
  font-size: 17px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1614;
    --surface: #172420;
    --surface-2: #1e2f2a;
    --ink: #eaf2ef;
    --ink-soft: #a9c1ba;
    --brand: #4fbfa0;
    --brand-ink: #06231b;
    --brand-soft: #1c3a33;
    --accent: #e0895a;
    --danger: #e08a8a;
    --line: #2a3d37;
    --focus: #7db4f0;
  }
}

body.large-text {
  font-size: 21px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

#root {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip:focus {
  left: 0;
}

/* --- top bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 1rem calc(0.4rem + env(safe-area-inset-top));
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.brand {
  font-size: 1.25rem;
  color: var(--brand);
  letter-spacing: -0.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chip {
  min-height: 40px;
  min-width: 44px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.badge {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge-on {
  background: var(--brand-soft);
  color: var(--brand);
}
.badge-off {
  background: #f3e2cf;
  color: var(--accent);
}
.queuebadge {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--wait);
  background: var(--surface-2);
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
}
.notice {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
}

/* --- main / screens --- */
main {
  flex: 1;
  padding: 1rem 1rem 6rem;
}
.screen {
  animation: fade 0.2s ease;
}
.center {
  text-align: center;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
  }
}
.hero {
  font-size: 2.6rem;
  color: var(--brand);
  margin: 1.5rem 0 0.25rem;
}
.h1 {
  font-size: 1.6rem;
  margin: 0.25rem 0 0.5rem;
}
.h2 {
  font-size: 1.15rem;
  margin: 1.25rem 0 0.5rem;
}
.lead {
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0.25rem 0 1rem;
}
.muted {
  color: var(--ink-soft);
}
.small {
  font-size: 0.88rem;
}
.warn {
  background: #f3e2cf;
  color: var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 12px;
}

/* --- mode picker --- */
.modegrid {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}
.modecard {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  min-height: var(--tap);
  cursor: pointer;
  color: var(--ink);
}
.modecard:hover {
  border-color: var(--brand);
}
.modecard-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brand);
}
.modecard-desc {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* --- cards / buttons --- */
.bigcard,
.tagcard,
.resultcard,
.registerbox,
.helpsec {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 0.75rem 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0 1.1rem;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface-2);
}
.btn.big {
  min-height: 72px;
  font-size: 1.3rem;
  width: 100%;
}
.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-call {
  background: var(--accent);
  color: #fff;
}
.btn.small {
  min-height: 44px;
  font-size: 0.9rem;
}
.btn:focus-visible,
a:focus-visible,
input:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.demorow {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}
.demorow .btn {
  flex: 1;
  min-width: 140px;
}
.simlog {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.simlog li {
  padding: 0.25rem 0;
  border-bottom: 1px dashed var(--line);
}
.storefwd {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

/* --- switch --- */
.switchrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--tap);
}
.switchlabel {
  font-size: 1.2rem;
  font-weight: 600;
}
.switch {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 38px;
  flex: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.slider {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.2s;
}
.slider::before {
  content: "";
  position: absolute;
  height: 30px;
  width: 30px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.switch input:checked + .slider {
  background: var(--brand);
}
.switch input:checked + .slider::before {
  transform: translateX(26px);
}
.scanstate {
  font-size: 1.05rem;
  margin: 0.5rem 0 0.25rem;
}
.note {
  color: var(--ink-soft);
}

/* --- help card (citizen) --- */
.helpcard {
  background: var(--brand-soft);
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin: 1rem 0;
}
.helpcard-title {
  color: var(--brand);
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
}
.helpcard-body {
  font-size: 1.1rem;
  margin: 0 0 0.9rem;
}
.helpcard-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.helpcard .how {
  margin-top: 0.9rem;
}
.helpcard .how ol {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}
.helpcard .how li {
  margin: 0.3rem 0;
}

/* --- sightings --- */
.sightings {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}
.sighting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.5rem;
}
.pill {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-ok {
  background: var(--brand-soft);
  color: var(--brand);
}
.pill-wait {
  background: #f4ecd2;
  color: var(--wait);
}
.pill-find {
  background: #f3d9c9;
  color: var(--accent);
}

/* --- guardian --- */
.tagcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.tagcard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.tagcard-actions .btn {
  flex: 1;
  min-width: 120px;
}
.form label {
  display: block;
  margin: 0.75rem 0;
  font-weight: 600;
}
.form input[type="text"],
.form input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  min-height: var(--tap);
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 400;
}
.form input[type="file"] {
  padding: 0.75rem;
}
.checkrow {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 400;
}
.checkrow input {
  width: 28px;
  height: 28px;
  margin-top: 2px;
  flex: none;
}
.privacy {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  color: var(--ink-soft);
  font-weight: 400;
}
.registerbox summary {
  cursor: pointer;
  list-style: none;
}
.alerts ul {
  padding-left: 1.1rem;
}

/* --- homing (직접 찾기) --- */
.arrowhost {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0 0.5rem;
}
.arrow {
  font-size: 8rem;
  line-height: 1;
  color: var(--brand);
  transition: transform 0.6s ease;
  will-change: transform;
}
.distance {
  font-size: 2rem;
  font-weight: 800;
  margin: 0.5rem 0 0.25rem;
}
.direction {
  font-size: 1.2rem;
  color: var(--ink-soft);
}
.homing-controls {
  display: flex;
  gap: 0.6rem;
  margin: 1rem 0;
}
.homing-controls .btn-primary {
  flex: 2;
}
.homing-controls .btn-ghost {
  flex: 1;
}
.transcript {
  list-style: none;
  padding: 0;
  text-align: left;
  max-height: 40vh;
  overflow-y: auto;
}
.transcript li {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
.back {
  align-self: flex-start;
  margin-bottom: 0.5rem;
}

/* --- police --- */
.audit {
  color: var(--ink-soft);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  margin-top: 0.75rem;
}

/* --- settings --- */
.settingrow,
.settingcol {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.settingcol {
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.seg {
  min-height: 48px;
  padding: 0 1rem;
  border: none;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}
.seg.on {
  background: var(--brand);
  color: var(--brand-ink);
}
.exportout {
  background: var(--surface-2);
  padding: 0.75rem;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.8rem;
  max-height: 40vh;
}

/* --- bottom nav --- */
.bottomnav {
  position: sticky;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  min-height: var(--tap);
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.4rem 0.15rem;
}
.tab.active {
  color: var(--brand);
  box-shadow: inset 0 3px 0 var(--brand);
}

/* --- responsive: 360px --- */
@media (max-width: 380px) {
  :root {
    font-size: 16px;
  }
  .hero {
    font-size: 2.1rem;
  }
  .helpcard-actions {
    grid-template-columns: 1fr;
  }
  .tab {
    font-size: 0.72rem;
  }
}

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