/* =====================================================
   Wifi Snap · clean minimal · coral accent · v0.12
   ===================================================== */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --fg: #1a1a1a;
  --fg-soft: #3a3a3a;
  --muted: #777370;
  --line: #e7e4dd;
  --line-strong: #d1cdc4;
  --accent: #cc785c;
  --accent-dark: #a85d44;
  --accent-soft: #f5e6e0;
  --error: #b3361e;
  --ok: #2d7a3e;
  --warn: #b8860b;
  --radius: 6px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 🔴 중요: [hidden] HTML 속성이 display:flex 등 클래스 스타일에 밀리지 않도록 강제.
   이게 없으면 .modal[hidden], .shared-banner[hidden] 등이 페이지 로드 시 보임. */
[hidden] {
  display: none !important;
}

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.93em;
  letter-spacing: -0.01em;
}

/* ===== Layout ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.5rem;
  padding-top: max(1.1rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}
main {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  flex: 1;
}
footer {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  text-align: center;
  border-top: 1px solid var(--line);
}

/* ===== Brand (new identity) ===== */
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: 'Pretendard', sans-serif;
  letter-spacing: -0.025em;
}
.brand-logo {
  color: var(--accent);
  flex-shrink: 0;
}
.brand-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.03em;
}
.brand-accent {
  color: var(--accent);
  font-weight: 700;
}

/* ===== Nav ===== */
.nav { display: flex; gap: 0.15rem; }
.nav button {
  background: none; border: none;
  font: inherit; font-size: 0.88rem;
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s;
}
.nav button:hover { color: var(--fg); background: var(--line); }

/* ===== Hero ===== */
.hero {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin-bottom: 0.75rem;
}
.hero .accent { color: var(--accent); }
.lead { font-size: 1rem; max-width: 30rem; margin-bottom: 2rem; }

/* ===== Utility ===== */
.muted { color: var(--muted); }
.small { font-size: 0.82rem; line-height: 1.5; }

/* ===== Buttons ===== */
button, .secondary {
  font: inherit;
  font-weight: 500;
  padding: 0.7rem 1.25rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-block;
  text-align: center;
}
button:hover, .secondary:hover {
  background: var(--bg);
  border-color: var(--fg-soft);
}
button.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
button.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
button.ghost {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.5rem 0;
  margin-top: 1.25rem;
  font-weight: 400;
}
button.ghost:hover { color: var(--fg); background: none; }
button.ghost.danger:hover { color: var(--error); }
button.ghost-mini {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  line-height: 1;
}
button.ghost-mini:hover { color: var(--accent); background: none; }
button.ghost-mini.regen {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  margin-left: auto;
}
button.ghost-mini.regen:hover { background: var(--accent-soft); }

.secondary { display: inline-block; }
.actions {
  display: flex; gap: 0.6rem; flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.row {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-top: 0.75rem;
}

/* ===== Banners (home onboarding) ===== */
.banner {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  border: 1px solid;
}
.banner-warn {
  background: #fdf6e3;
  border-color: #ead9a8;
  color: #5e4a16;
}
.banner-info {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #5a2f1f;
}
.banner-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.banner-icon { font-size: 1.1rem; }
.banner-head strong { font-weight: 700; font-size: 0.95rem; }
.banner p {
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0.3rem 0;
}
.banner p em { font-style: italic; font-weight: 600; }
.banner-actions {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  margin-top: 0.7rem;
}
.banner-actions button {
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
}
.inapp-howto {
  margin-top: 0.7rem !important;
  padding: 0.6rem 0.85rem;
  background: rgba(255,255,255,0.5);
  border-radius: var(--radius);
  line-height: 1.7 !important;
}
.inapp-howto kbd {
  display: inline-block;
  padding: 0.05em 0.4em;
  background: white;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  margin: 0 0.1em;
  color: var(--fg);
}

/* ===== Shared banner ===== */
.shared-banner {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-weight: 500;
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
}

/* ===== Nearby ===== */
.nearby {
  margin-bottom: 2rem;
  padding: 1rem 1.1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
}
.nearby-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.6rem;
}
.nearby-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.nearby-item {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: all 0.12s;
}
.nearby-item:last-child { margin-bottom: 0; }
.nearby-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}
.nearby-name { font-weight: 600; margin-bottom: 0.15rem; }
.nearby-sub { font-size: 0.82rem; color: var(--muted); }
.nearby-arrow { color: var(--accent); font-size: 1.2rem; margin-left: 0.75rem; }

/* ===== Hints ===== */
.hints {
  display: flex; flex-direction: column;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.hint { display: flex; gap: 1rem; align-items: flex-start; }
.hint-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
  padding-top: 0.15rem;
  letter-spacing: 0.05em;
}
.hint strong { display: block; font-weight: 600; margin-bottom: 0.2rem; }

/* ===== Camera ===== */
.camera {
  margin-bottom: 2rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
}
#video {
  width: 100%; display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.cam-actions {
  display: flex; gap: 0.5rem; padding: 0.85rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.cam-actions .primary { flex: 1; }

/* ===== Fields ===== */
.field { margin: 1.25rem 0; }
.field label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.45rem;
  font-weight: 600;
}
.field .value {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.12s;
}
.field .value:hover { border-color: var(--line-strong); }
.field .value > span {
  flex: 1;
  word-break: break-all;
  font-size: 1.05rem;
}
.field .value button {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

/* inline edit */
.field.editable .value { padding: 0.5rem 0.5rem 0.5rem 1rem; }
.inline-edit {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  color: var(--fg);
  padding: 0.4rem 0;
  min-width: 0;
  width: 100%;
}
.inline-edit:focus { outline: none; }
.field.editable .value:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* settings inputs */
.field input[type=password],
.field input[type=text],
.field select {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  color: var(--fg);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===== Meta row ===== */
.meta {
  display: flex; gap: 0.5rem 1rem; flex-wrap: wrap;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin: -0.5rem 0 1.25rem;
  padding: 0.25rem 0;
}
.meta strong { color: var(--fg); font-weight: 500; }

/* engine indicator */
#out-engine.engine-ocr {
  color: var(--warn);
  font-weight: 500;
}

/* ocr preload group */
#ocr-preload-group {
  margin-top: 0.75rem;
}
#ocr-preload-group .row {
  margin-top: 0;
}
#ocr-status {
  margin-top: 0.6rem;
}

/* ===== Label input ===== */
.label-block {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.label-block input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  color: var(--fg);
}
.label-block input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--accent);
  background: var(--surface);
}
.label-block input::placeholder { color: var(--muted); }
.label-block input:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== Toggle ===== */
.toggle {
  display: flex; align-items: center; gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 0;
}
.toggle input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== QR ===== */
.qr-block {
  display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}
#qr-canvas {
  padding: 0.75rem;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}
#qr-canvas img, #qr-canvas canvas { display: block; }
.qr-block p { text-align: center; }

.qr-actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 1rem;
  justify-content: center;
}
.qr-actions button {
  font-size: 0.88rem;
  padding: 0.55rem 1rem;
}

/* 카톡 버튼 */
#btn-share-kakao {
  background: #fee500;
  border-color: #fee500;
  color: #3a1d1d;
  font-weight: 600;
}
#btn-share-kakao:hover {
  background: #fdd800;
  border-color: #fdd800;
  color: #3a1d1d;
}

/* 캡티브 포털 보조 */
.captive-helper {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--line);
  text-align: center;
  width: 100%;
}
.captive-helper a {
  color: var(--accent);
  font-weight: 500;
}

/* ===== Commands ===== */
.cmd-block {
  margin: 0.5rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.cmd-block summary {
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  display: flex; align-items: center; gap: 0.5rem;
  list-style: none;
}
.cmd-block summary::-webkit-details-marker { display: none; }
.cmd-block summary::after {
  content: '+';
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.cmd-block[open] summary::after { content: '−'; }
.cmd-block summary:hover { background: var(--bg); }
.os-icon {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  font-weight: 700;
  width: 18px;
  display: inline-block;
}
.cmd-block pre {
  padding: 1rem;
  background: var(--bg);
  border-top: 1px solid var(--line);
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}
.cmd-foot {
  padding: 0.75rem 1rem 1rem;
  background: var(--bg);
}
.cmd-foot button {
  font-size: 0.82rem;
  padding: 0.4rem 0.8rem;
  margin-bottom: 0.6rem;
}
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  background: var(--line);
  border-radius: 3px;
}

/* CLI block - taller, multiple steps */
.cli-block .cmd-foot p {
  margin-bottom: 0.4rem;
}
.cli-step {
  margin-top: 1rem !important;
  font-size: 0.9rem;
}
.cli-step:first-of-type {
  margin-top: 0.5rem !important;
}
.cli-block pre {
  margin-bottom: 0.3rem;
}
.cli-note {
  margin-top: 1rem !important;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
  line-height: 1.6 !important;
}

/* wifi-snap:// 클릭 링크 (v0.11) */
.ws-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.2rem;
  background: var(--fg);
  color: var(--bg) !important;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.93rem;
  text-decoration: none;
  margin: 0.6rem 0 0.5rem;
  transition: all 0.12s ease;
  border-bottom-color: var(--fg) !important;
}
.ws-link:hover {
  background: var(--accent);
  border-color: var(--accent) !important;
  color: white !important;
}
.ws-link-icon {
  font-size: 0.7rem;
  line-height: 1;
  color: var(--accent);
}
.ws-link:hover .ws-link-icon {
  color: white;
}

.cli-bootstrap-note {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  background: #fdf6e3;
  border-left: 3px solid #b8860b;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #4a3a16;
}
.cli-bootstrap-note strong {
  color: #5c4a16;
}
.alt-methods {
  margin-top: 0.6rem;
  font-size: 0.88rem;
}
.alt-methods summary {
  cursor: pointer;
  font-weight: 500;
  padding: 0.3rem 0;
  list-style: none;
  display: flex;
  align-items: center;
}
.alt-methods summary::-webkit-details-marker { display: none; }
.alt-methods summary::before {
  content: '▸';
  margin-right: 0.4rem;
  transition: transform 0.15s;
  color: var(--accent);
}
.alt-methods[open] summary::before {
  transform: rotate(90deg);
}
.alt-methods ol {
  margin-top: 0.5rem;
  padding-left: 1.4rem;
  color: #5c4a16;
}
.alt-methods li {
  margin-bottom: 0.4rem;
}
.alt-methods code {
  background: rgba(255,255,255,0.5);
}

/* ===== Headings ===== */
h2 {
  font-size: 1.5rem;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
  font-weight: 700;
}
h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}

/* ===== Settings ===== */
.setting-block {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}
.setting-block:last-child { border-bottom: none; }

/* install / camera status badges */
.install-status,
.camera-status {
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.install-status.installed,
.camera-status.granted {
  background: #ecf5ee;
  border-color: #c6e0cd;
  color: var(--ok);
}
.camera-status.denied {
  background: #fce8e3;
  border-color: #f0c7ba;
  color: var(--error);
}
.camera-status.prompt {
  background: #fdf6e3;
  border-color: #ead9a8;
  color: var(--warn);
}
.install-guide {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--muted);
  margin-top: 0.5rem;
}
.install-guide strong { color: var(--fg); font-weight: 600; }
.install-guide ol { padding-left: 1.4rem; margin: 0.5rem 0; }
.install-guide li { margin-bottom: 0.3rem; }
.install-guide kbd {
  display: inline-block;
  padding: 0.1em 0.45em;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
  margin: 0 0.15em;
  color: var(--fg);
}

/* ===== History ===== */
#history-list { margin-top: 1.25rem; }
.history-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  gap: 1rem;
}
.h-info { flex: 1; min-width: 0; }
.history-item .h-label {
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: var(--accent);
}
.history-item .h-ssid {
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.2rem;
  word-break: break-all;
}
.history-item .h-pass {
  color: var(--fg-soft);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  word-break: break-all;
}
.history-item .h-meta {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.4rem;
  letter-spacing: 0.02em;
}
.h-loc-pin { font-size: 0.85rem; }
.h-actions {
  display: flex; flex-direction: column; gap: 0.3rem;
  align-items: stretch;
}
.h-actions button {
  font-size: 0.74rem;
  padding: 0.32rem 0.55rem;
  white-space: nowrap;
}

/* ===== States ===== */
#result-loading {
  padding: 4rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}
.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 0.6rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  padding: 1.5rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--error);
}
.error strong { display: block; margin-bottom: 0.5rem; font-size: 1.05rem; }
.error p { color: var(--fg); margin: 0.4rem 0 1rem; word-break: break-word; }
.error button { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.ok { color: var(--ok); font-size: 0.85rem; font-weight: 500; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.12s;
}
a:hover { border-bottom-color: var(--accent); }

#version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78em;
  color: var(--muted);
}

/* ===== Confirm Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-content h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.modal-content p {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  word-break: break-word;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.modal-actions button {
  padding: 0.6rem 1.1rem;
  font-size: 0.92rem;
}
.danger-btn {
  background: var(--error);
  color: white;
  border-color: var(--error);
}
.danger-btn:hover {
  background: #952f1a;
  border-color: #952f1a;
  color: white;
}

/* ===== Speed test (v0.10) ===== */
.speed-section {
  margin: 0 0 1.75rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.speed-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.speed-head strong { font-size: 0.95rem; }
.speed-head button {
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
}
.speed-hint { margin: 0; }
.speed-progress {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.speed-result { margin-top: 1rem; }
.speed-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.75rem 0;
}
.speed-card {
  text-align: center;
  padding: 0.65rem 0.4rem;
  background: var(--bg);
  border-radius: var(--radius);
}
.speed-card-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.speed-card-unit {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 0.1rem;
}
.speed-card-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.speed-card.tier-excellent .speed-card-val { color: #2d7a3e; }
.speed-card.tier-good      .speed-card-val { color: #3a7a5c; }
.speed-card.tier-ok        .speed-card-val { color: #b8860b; }
.speed-card.tier-slow      .speed-card-val { color: #b3361e; }

.speed-meta {
  text-align: center;
  margin-top: 0.5rem !important;
}
.speed-error {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  background: #fce8e3;
  border: 1px solid #f0c7ba;
  border-radius: var(--radius);
  color: var(--error);
}
.speed-error strong { display: block; margin-bottom: 0.25rem; }
.speed-error p { margin: 0; color: var(--fg); word-break: break-word; }

/* ===== History speed badge ===== */
.h-speed {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1em 0.45em;
  border-radius: 3px;
  margin-left: 0.4rem;
  letter-spacing: -0.02em;
}
.h-speed.tier-excellent { background: #d8edda; color: #1e5a2a; }
.h-speed.tier-good      { background: #dbe9e0; color: #2a5a3e; }
.h-speed.tier-ok        { background: #fdf6e3; color: #856104; }
.h-speed.tier-slow      { background: #fce8e3; color: #8a2616; }

/* ===== Map ===== */
#map-canvas {
  width: 100%;
  height: 520px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  margin-top: 1rem;
  background: var(--surface);
}
.map-footnote {
  text-align: center;
  margin-top: 0.75rem;
}
/* Leaflet overrides */
.leaflet-popup-content-wrapper {
  border-radius: 8px !important;
}
.leaflet-popup-content {
  margin: 0.7rem 0.9rem !important;
}

/* ===== Audio transmit/receive (v0.12) ===== */
.pill {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.1em 0.5em;
  margin-left: 0.35em;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 99px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

#btn-transmit-audio {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
#btn-transmit-audio:hover {
  background: var(--accent);
  color: white;
}

/* 송신 진행 패널 */
.transmit-panel {
  margin-top: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-align: left;
}
.transmit-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.88rem;
  color: #5a2f1f;
  margin-bottom: 0.5rem;
}
.transmit-bar {
  width: 100%;
  height: 6px;
  background: rgba(204, 120, 92, 0.2);
  border-radius: 3px;
  overflow: hidden;
}
#transmit-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s linear;
}
.transmit-tip {
  margin-top: 0.6rem !important;
  color: #6a3a26 !important;
}

/* 수신 패널 */
.receive-panel {
  margin: 0 0 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
}
.receive-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.receive-head strong { font-size: 1rem; }

.receive-state {
  margin-top: 0.85rem;
  text-align: center;
  padding: 0.5rem 0;
}
.receive-state.error-state {
  background: #fce8e3;
  border: 1px solid #f0c7ba;
  color: var(--error);
  padding: 0.85rem;
  border-radius: var(--radius);
  text-align: left;
}
.receive-state.error-state strong { display: block; margin-bottom: 0.4rem; }
.receive-state.error-state p { color: var(--fg); margin-bottom: 0.6rem; }
.receive-state.ok-state {
  padding: 1.5rem 0;
}

.mic-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin: 1rem 0 0.75rem;
}
.mic-icon {
  font-size: 3rem;
  line-height: 1;
  animation: micPulse 1.4s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.08); opacity: 1; }
}
.mic-level {
  width: 200px;
  max-width: 80%;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}
#mic-level-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  transition: width 0.08s linear;
}
.mic-status { margin: 0.5rem 0 1rem; }
.success-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: var(--ok);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: bold;
}

/* ===== Mobile ===== */
@media (max-width: 520px) {
  .hero { font-size: 2rem; }
  .topbar { padding: 0.9rem 1.1rem; }
  main { padding: 1.75rem 1.1rem 3rem; }
  .nav button { padding: 0.4rem 0.55rem; font-size: 0.85rem; }
  .field .value > span { font-size: 0.95rem; }
  .inline-edit { font-size: 0.95rem; }
  .actions { gap: 0.5rem; }
  .actions button, .actions .secondary { flex: 1; }
  .qr-actions { flex-direction: column; width: 100%; }
  .qr-actions button { width: 100%; }
  .history-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .h-actions {
    flex-direction: row;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .brand-text { font-size: 1rem; }
}

/* ===== Page-load animation ===== */
section[data-view] {
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
