* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #fafbfc;
  --text: #111827; --text-2: #4b5563; --muted: #8b93a1;
  --border: #e5e8ec; --border-2: #d5dae1;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: #eef0fe; --accent-text: #4338ca;
  --ok: #067a4b; --ok-bg: #e3f6ed; --bad: #c2372a; --bad-bg: #fdecea; --warn: #92610a; --warn-bg: #fdf3d8;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 16px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.16);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117; --surface: #171b23; --surface-2: #1c212b;
    --text: #edeef2; --text-2: #b0b6c1; --muted: #7d8494;
    --border: #262c37; --border-2: #343b48;
    --accent: #7b74f2; --accent-hover: #918bf5; --accent-soft: #262a45; --accent-text: #a5a0f8;
    --ok: #4ecb92; --ok-bg: #143528; --bad: #f28b7d; --bad-bg: #3d1f1a; --warn: #e8bb5e; --warn-bg: #3a2e12;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,.45);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
  }
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), #9333ea);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 800;
}
.brand .tagline { font-size: 12.5px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.topbar .spacer { flex: 1; }

/* ---------- 탭 (세그먼트) ---------- */
.tabs-wrap { padding: 20px clamp(16px, 4vw, 40px) 0; }
nav.tabs {
  display: inline-flex; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-sm);
  max-width: 100%; overflow-x: auto;
}
.tab {
  appearance: none; border: none; background: transparent; cursor: pointer;
  padding: 8px 18px; border-radius: 9px; white-space: nowrap;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }

main { padding: 20px clamp(16px, 4vw, 40px) 80px; max-width: 1060px; }
.panel { display: none; }
.panel.active { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 페이지 헤딩 ---------- */
.page-head { margin: 6px 0 18px; }
.page-head h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { color: var(--text-2); font-size: 14px; margin-top: 3px; }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 14px 0 8px; }
.card > h2:first-child { margin-top: 0; }

/* ---------- 필드 ---------- */
.field-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  margin: 18px 0 8px;
}
.field-label:first-child { margin-top: 0; }
.step-num {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
}
input[type=text], input[type=number], textarea, select {
  padding: 11px 14px; border: 1.5px solid var(--border-2); border-radius: var(--r-sm);
  font-size: 15px; font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input[type=text], textarea { width: 100%; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea { resize: vertical; }

/* ---------- 버튼 ---------- */
button {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: 10px 18px; border: 1.5px solid var(--border-2); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600;
  transition: all .15s; box-shadow: var(--shadow-sm);
}
button:hover { border-color: var(--accent); color: var(--accent-text); transform: translateY(-1px); }
button:active { transform: none; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button.small { padding: 6px 13px; font-size: 12.5px; border-radius: 8px; }
button:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------- 선택 칩 ---------- */
.row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.chk {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  border: 1.5px solid var(--border-2); border-radius: 999px;
  padding: 8px 16px; cursor: pointer; user-select: none;
  background: var(--surface); transition: all .15s;
}
.chk:hover { border-color: var(--accent); }
.chk:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent-text); font-weight: 600;
}
.chk input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.chk input[type=radio] { accent-color: var(--accent); }
.muted { color: var(--muted); font-size: 12.5px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ---------- 후보/추천 카드 그리드 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cand {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 14px; box-shadow: var(--shadow-sm); transition: all .15s;
}
.cand:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cand code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 13.5px; font-weight: 600; word-break: break-all; }

/* 전체 TLD 목록 */
.tld-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 6px;
  max-height: 340px; overflow-y: auto; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
}
.tld-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  border: 1.5px solid var(--border-2); border-radius: 8px; padding: 7px 10px;
  background: var(--surface); cursor: pointer; user-select: none; font-size: 13px; transition: all .12s;
}
.tld-chip:hover { border-color: var(--accent); }
.tld-chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.tld-chip .t { font-family: "JetBrains Mono", Consolas, monospace; font-weight: 600; }
.tld-chip .p { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.tld-chip input { accent-color: var(--accent); }

/* 추천 박스 강조 */
#recommend-box { border: 1.5px solid color-mix(in srgb, var(--accent) 45%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 55%, var(--surface)), var(--surface) 90px); }
#recommend-box .cand { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }

/* ---------- 테이블 ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--r-md); overflow: auto; background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
td code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 13px; font-weight: 600; }

/* ---------- 배지 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3.5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.gray { background: var(--border); color: var(--text-2); }
.hidden { display: none !important; }

/* ---------- 내 도메인 ---------- */
.dom-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.dom-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; cursor: pointer; flex-wrap: wrap; transition: background .12s; }
.dom-head:hover { background: var(--surface-2); }
.dom-head .name { font-weight: 700; font-size: 15.5px; font-family: "JetBrains Mono", Consolas, monospace; letter-spacing: -0.01em; }
.dom-head .spacer { flex: 1; }
.dom-body { border-top: 1px solid var(--border); padding: 18px 20px; background: var(--surface-2); }
.dom-body table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.dns-form { display: grid; grid-template-columns: 130px 96px 1fr 84px 70px auto; gap: 8px; align-items: center; margin-top: 10px; }
.dns-form input, .dns-form select { padding: 8px 10px; font-size: 13px; width: 100%; border-width: 1px; }
@media (max-width: 720px) { .dns-form { grid-template-columns: 1fr 1fr; } }

/* ---------- 설정 가이드 ---------- */
.guide { counter-reset: step; list-style: none; }
.guide li {
  position: relative; margin: 0 0 12px 40px; font-size: 14px; line-height: 1.7; color: var(--text-2);
}
.guide li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: -40px; top: 1px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.guide b { color: var(--text); }
.guide code, code.inline {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 6px;
  font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; color: var(--accent-text);
}
a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

/* ---------- 모달 ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(10, 14, 22, .55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 26px 28px;
  width: min(480px, 100%); box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal table { border: none; }
.modal td { padding: 7px 4px; border: none; font-size: 14px; }
.modal td:first-child { color: var(--muted); width: 110px; font-size: 13px; }
.modal .row.right { margin-top: 18px; }

/* ---------- 진행 상태 ---------- */
#queue-status { margin: 12px 2px; font-size: 13px; color: var(--accent-text); font-weight: 500; min-height: 20px; }
#recommend-progress { font-size: 13px; font-weight: 500; }

/* ---------- 토글 스위치 ---------- */
.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: var(--border-2); border-radius: 999px; transition: .18s; }
.switch .sl:before { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .sl { background: var(--ok); }
.switch input:checked + .sl:before { transform: translateX(17px); }

/* ---------- 반응형 ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .card { padding: 16px; border-radius: var(--r-md); }
  .brand .tagline { display: none; }
  th, td { padding: 10px 12px; }
  .page-head h2 { font-size: 18px; }
}
