:root {
  color-scheme: light;
  --navy: #13233f;
  --blue: #246bfe;
  --blue-dark: #174bb8;
  --blue-soft: #edf4ff;
  --mint: #0aa47f;
  --red: #d83c4d;
  --amber: #a65d00;
  --ink: #182235;
  --muted: #667085;
  --line: #dce3ec;
  --surface: #ffffff;
  --background: #f4f7fb;
  --shadow: 0 14px 40px rgba(19, 35, 63, 0.09);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--background); }

body {
  margin: 0;
  min-width: 280px;
  color: var(--ink);
  background: var(--background);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

button, input, select { font: inherit; }

button { touch-action: manipulation; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  background: #f8faff;
  border-inline: 1px solid rgba(19, 35, 63, 0.06);
}

.app-shell.admin-shell { width: min(100%, 1480px); }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px 20px;
  color: white;
  background: var(--navy);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark, .icon-slot {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  color: var(--navy);
  background: white;
  font-weight: 900;
}

.brand-copy { min-width: 0; }
.brand-copy strong, .brand-copy span { display: block; }
.brand-copy strong { font-size: 15px; }
.brand-copy span { margin-top: 2px; color: #c9d6eb; font-size: 12px; }

.page { padding: 22px 18px 40px; }
.admin-shell .page { padding-inline: clamp(18px, 3vw, 40px); }

.hero { margin-bottom: 20px; }
.hero h1 { margin: 0; font-size: clamp(24px, 6vw, 32px); line-height: 1.25; letter-spacing: -0.035em; }
.hero p { margin: 10px 0 0; color: var(--muted); line-height: 1.65; }

.notice {
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid #bad1ff;
  border-radius: 14px;
  color: #194a9a;
  background: var(--blue-soft);
  font-size: 13px;
  line-height: 1.55;
}

.notice.warning { border-color: #f0cc8a; color: #744200; background: #fff7e7; }
.notice.danger { border-color: #ffc2c8; color: #982332; background: #fff0f2; }
.notice p { margin: 0; }
.notice p + p { margin-top: 8px; }

.card {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-title { min-width: 0; }
.card-title h2, .card-title h3 { margin: 0; line-height: 1.35; letter-spacing: -0.025em; }
.card-title h2 { font-size: 19px; }
.card-title h3 { font-size: 16px; }
.card-title p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.icon-slot {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: var(--blue);
  background: var(--blue-soft);
}

.icon-slot svg { display: block; width: 22px; height: 22px; }

.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: #344054; font-size: 13px; font-weight: 750; }

.field input, .field select, .server-field input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

.field input:focus, .field select:focus, .server-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 254, 0.14);
}

.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.button:hover { background: var(--blue-dark); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.secondary { border: 1px solid #cbd5e1; color: var(--ink); background: white; }
.button.secondary:hover { background: #f4f6f9; }
.button.danger { background: var(--red); }
.button.full { width: 100%; }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #344054;
  background: #eef1f5;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.chip.success { color: #06705a; background: #e6f8f3; }
.chip.waiting { color: #805000; background: #fff2d4; }
.chip.failed { color: #a12536; background: #ffe8eb; }

.status-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #98a2b3; }
.status-dot.online { background: var(--mint); box-shadow: 0 0 0 4px rgba(10, 164, 127, 0.12); }

.qr-wrap { display: grid; justify-items: center; gap: 16px; }
.qr-frame { width: min(100%, 280px); aspect-ratio: 1; padding: 12px; border: 1px solid var(--line); border-radius: 22px; background: white; }
.qr-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }

.pair-code {
  color: var(--navy);
  font-size: clamp(27px, 9vw, 38px);
  font-weight: 900;
  letter-spacing: 0.09em;
  text-align: center;
  white-space: nowrap;
}

.countdown { color: var(--muted); font-size: 14px; text-align: center; }
.countdown strong { color: var(--red); }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: #98a2b3; font-size: 12px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.list { display: grid; gap: 10px; }
.list-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}

button.list-item { width: 100%; color: inherit; text-align: left; cursor: pointer; }
button.list-item:hover { border-color: #9abaff; background: #f7faff; }

.list-copy { min-width: 0; }
.list-copy strong, .list-copy span { display: block; }
.list-copy strong { line-height: 1.35; }
.list-copy span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  flex: 0 0 auto;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: #cbd5e1; transition: 0.2s; cursor: pointer; }
.toggle span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 2px 7px rgba(0, 0, 0, 0.2); transition: 0.2s; }
.toggle input:checked + span { background: var(--blue); }
.toggle input:checked + span::after { transform: translateX(22px); }
.toggle input:disabled + span { opacity: 0.55; cursor: wait; }
.toggle input:focus-visible + span { outline: 3px solid rgba(36, 107, 254, 0.35); outline-offset: 3px; }

.empty { padding: 28px 16px; color: var(--muted); text-align: center; line-height: 1.6; }
.hidden { display: none !important; }
.full-width { width: 100%; }
.text-left { text-align: left; }
.error-text { color: var(--red); font-size: 13px; line-height: 1.5; }
.success-text { color: #087c63; font-size: 13px; line-height: 1.5; }

.server-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 13px; }
.server-field .button { min-height: 48px; }

.admin-nav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.admin-nav button { flex: 0 0 auto; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric { min-height: 112px; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.metric span, .metric strong { display: block; }
.metric span { min-height: 36px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.metric strong { margin-top: 8px; color: var(--navy); font-size: 28px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: white; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; line-height: 1.45; }
th { position: sticky; top: 0; color: #475467; background: #f8fafc; white-space: nowrap; }
td code { font-size: 11px; }

.toast {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  width: min(calc(100% - 36px), 380px);
  padding: 14px 16px;
  border-radius: 14px;
  color: white;
  background: var(--navy);
  box-shadow: 0 18px 50px rgba(19, 35, 63, 0.24);
  line-height: 1.5;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.feature-preview {
  display: grid;
  grid-template-rows: 44px minmax(92px, auto) minmax(38px, auto) 46px;
  align-content: start;
  gap: 11px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfe;
}

.feature-preview .icon-slot { align-self: start; }
.feature-preview h3 { margin: 0; font-size: 15px; line-height: 1.4; }
.feature-preview p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.feature-preview .button { align-self: end; }

.prototype-label {
  display: inline-flex;
  align-items: center;
  align-self: start;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #785200;
  background: #fff1bf;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

@media (max-width: 680px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-shell .page { padding-inline: 14px; }
}

@media (max-width: 430px) {
  .feature-grid { grid-template-columns: 1fr; }
  .feature-preview { grid-template-rows: 44px auto auto 46px; }
}

@media (max-width: 380px) {
  .page { padding-inline: 13px; }
  .card { padding: 15px; border-radius: 17px; }
  .server-field { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .pair-code { letter-spacing: 0.04em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
