/* =====================================================================
   포트 체커 — 다크 테마 스타일 (단일 포트 · TCP+UDP)
   외부 리소스 없이 시스템 폰트만 사용한다 (CSP: style-src 'self')
   ===================================================================== */

:root {
  --bg: #07080e;
  --bg-soft: #0b0d14;
  --panel: #0f1119;
  --panel-2: #12151f;
  --card: #12151f;
  --line: rgba(148, 163, 196, 0.14);
  --line-strong: rgba(148, 163, 196, 0.24);
  --text: #eef1f9;
  --text-dim: #b7c0d4;
  --muted: #8792a8;
  --accent: #6d6cf7;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(109, 108, 247, 0.14);
  --open: #34d399;
  --closed: #f87171;
  --filtered: #fbbf24;
  --error: #94a3b8;
  --radius: 20px;
  --radius-sm: 12px;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", "D2Coding", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", system-ui, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 18px 48px;
  background-color: var(--bg);
  background-image:
    radial-gradient(820px 420px at 50% -10%, rgba(109, 108, 247, 0.18), transparent 68%),
    radial-gradient(620px 340px at 96% 6%, rgba(139, 92, 246, 0.12), transparent 66%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0 0 auto;
  height: 300px;
  pointer-events: none;
  background-image: linear-gradient(180deg, rgba(109, 108, 247, 0.05), transparent 72%);
  z-index: 0;
}

h1,
p {
  margin: 0;
}

/* ------------------------------------------------------------- 머리말 */
.site-head {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-badge {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background-image: linear-gradient(140deg, #7c7cf9, #6a5bf0);
  box-shadow: 0 10px 24px -10px rgba(109, 108, 247, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.25;
}

.brand-text p {
  margin-top: 2px;
  font-size: 12.8px;
  color: var(--muted);
  word-break: keep-all;
}

.live-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 21, 31, 0.8);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--open);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* --------------------------------------------------------------- 본문 */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0) 38%);
  box-shadow: 0 26px 60px -38px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 24px;
}

.intro {
  font-size: 14.5px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 22px;
}

/* -------------------------------------------------------------- 폼 */
.form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
}

label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.link-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 2px;
  margin: -2px -2px;
  border: 0;
  background: transparent;
  color: #8d8cfb;
  font-family: inherit;
  font-size: 12.8px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.16s ease;
}

.link-btn svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.link-btn:hover {
  color: #b0afff;
}

.link-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 12px;
}

.input {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  letter-spacing: -0.005em;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.input::placeholder {
  color: #5b6579;
}

.input:hover {
  border-color: rgba(148, 163, 196, 0.36);
}

.input:focus {
  outline: none;
  border-color: rgba(109, 108, 247, 0.8);
  background-color: #0d0f17;
  box-shadow: 0 0 0 3.5px rgba(109, 108, 247, 0.16);
}

.input-port {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  font-size: 15.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 8l4.5 4.5L14.5 8' fill='none' stroke='%238792a8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 17px;
}

.select option {
  background: #12151f;
  color: var(--text);
}

.hint {
  font-size: 12.8px;
  color: var(--muted);
  line-height: 1.55;
}

/* ------------------------------------------------------------ 버튼 */
.btn-primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 54px;
  padding: 0 24px;
  border: 0;
  border-radius: 13px;
  background-image: linear-gradient(135deg, #6f6ef8, #8b5cf6);
  color: #ffffff;
  font-family: inherit;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 16px 32px -18px rgba(109, 108, 247, 1), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.16s ease, box-shadow 0.2s ease, opacity 0.16s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 20px 38px -18px rgba(124, 108, 250, 1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  cursor: progress;
  opacity: 0.8;
}

.btn-icon {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}

.btn-primary.is-busy .btn-icon {
  display: none;
}

.btn-primary.is-busy::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-primary:focus-visible,
.link-btn:focus-visible,
.input:focus-visible,
.guide summary:focus-visible {
  outline: 2px solid rgba(141, 140, 251, 0.9);
  outline-offset: 2px;
}

.notice {
  font-size: 12.9px;
  color: #79849b;
  line-height: 1.65;
  letter-spacing: -0.005em;
  margin-top: -2px;
}

/* ------------------------------------------------------------ 알림 */
.alert {
  padding: 13px 15px;
  border: 1px solid rgba(248, 113, 113, 0.32);
  border-left: 3px solid var(--closed);
  border-radius: 10px;
  background: rgba(70, 22, 28, 0.4);
  color: #ffd7d7;
  font-size: 13.8px;
  line-height: 1.6;
}

/* ------------------------------------------------------------ 결과 */
.result-stack {
  display: grid;
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--card);
  padding: 19px 21px 20px;
  animation: rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card-summary {
  background-image: linear-gradient(180deg, #151827, #10121b);
  border-color: rgba(148, 163, 196, 0.18);
  padding-top: 21px;
  padding-bottom: 22px;
}

.card-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #79849b;
  margin-bottom: 8px;
}

.card-status {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.35;
  color: var(--text);
}

.card-summary .card-status {
  font-size: 23px;
}

.card-text {
  margin-top: 9px;
  font-size: 14.4px;
  line-height: 1.7;
  color: #a9b3c7;
  word-break: keep-all;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.card-proto {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #79849b;
}

.ms-badge {
  flex: none;
  padding: 4px 10px;
  border: 1px solid rgba(109, 108, 247, 0.3);
  border-radius: 999px;
  background: var(--accent-soft);
  color: #bab9ff;
  font-family: var(--mono);
  font-size: 11.8px;
  letter-spacing: 0;
  white-space: nowrap;
}

.tone-open {
  color: var(--open);
}

.tone-closed {
  color: var(--closed);
}

.tone-filtered {
  color: var(--filtered);
}

.tone-error {
  color: var(--error);
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 2px 4px 0;
  font-family: var(--mono);
  font-size: 11.9px;
  letter-spacing: 0;
  color: #6d7789;
}

/* ---------------------------------------------------------- 안내 */
.guide {
  margin: 2px 2px 0;
  padding: 2px 4px;
}

.guide summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
}

.guide summary::-webkit-details-marker {
  display: none;
}

.guide summary::before {
  content: "+";
  font-family: var(--mono);
  font-size: 13px;
  color: #5f6a80;
}

.guide[open] summary::before {
  content: "−";
}

.guide-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.guide-list li {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  font-size: 13.2px;
  color: var(--muted);
  line-height: 1.65;
}

.guide-list strong {
  font-weight: 700;
  font-size: 13px;
}

.guide-foot {
  margin-top: 14px;
  font-size: 12.6px;
  color: #6d7789;
  line-height: 1.7;
}

/* ------------------------------------------------------------ 바닥 */
.site-foot {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 24px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #5b6579;
}

.foot-sep {
  opacity: 0.6;
}

/* -------------------------------------------------------- 반응형 */
@media (max-width: 560px) {
  body {
    padding: 0 13px 40px;
  }

  .site-head {
    padding: 28px 0 18px;
    gap: 10px;
  }

  .brand-badge {
    width: 41px;
    height: 41px;
    font-size: 15.5px;
    border-radius: 12px;
  }

  .brand-text h1 {
    font-size: 20.5px;
  }

  .brand-text p {
    font-size: 12px;
  }

  .live-badge {
    display: none;
  }

  .panel {
    padding: 19px 17px 20px;
    border-radius: 18px;
  }

  .intro {
    font-size: 14px;
    margin-bottom: 19px;
  }

  .field-grid {
    gap: 10px;
  }

  .input {
    height: 50px;
    font-size: 15.5px;
  }

  .input-port {
    font-size: 16.5px;
  }

  .select {
    font-size: 14.8px;
    padding-right: 32px;
    background-position: right 10px center;
  }

  .card {
    padding: 17px 17px 18px;
    border-radius: 16px;
  }

  .card-status,
  .card-summary .card-status {
    font-size: 20px;
  }

  .card-text {
    font-size: 14px;
  }

  .guide-list li {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
