:root {
  --ink: #07141a;
  --muted: #3d5a66;
  --paper: #f7fbfc;
  --card: #ffffff;
  --line: #c9dde4;
  --teal: #0e7490;
  --teal-deep: #0a4f63;
  --teal-bright: #14b8a6;
  --sky: #5ec8e8;
  --warn-bg: #fff8e8;
  --warn-line: #f0d9a0;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok: #067a5a;
  --ok-bg: #eefaf5;
  --cf: #f48120;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 24px 60px rgba(7, 40, 52, 0.18);
  --font: "DM Sans", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: #082029;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(94, 200, 232, 0.45), transparent 60%),
    radial-gradient(700px 480px at 90% 10%, rgba(20, 184, 166, 0.35), transparent 55%),
    linear-gradient(160deg, #0a3a4a 0%, #0e7490 42%, #0b5f6e 72%, #082029 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from { filter: hue-rotate(0deg) saturate(1); transform: scale(1); }
  to { filter: hue-rotate(12deg) saturate(1.08); transform: scale(1.03); }
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.site-header {
  text-align: center;
  padding: 2.5rem 1rem 1.25rem;
  animation: rise 0.7s ease both;
}

.logo-box {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 1rem;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-icon { opacity: 0.95; }

.header-note {
  margin: 0.75rem 0 0;
  color: rgba(232, 244, 248, 0.85);
  font-size: 0.88rem;
}

.header-note a { color: var(--sky); }

/* ── Main ── */
.main {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  flex: 1;
}

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

/* ── Search panel ── */
.search-panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.4rem 1.15rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.8s 0.05s ease both;
}

.search-row {
  display: flex;
  gap: 0;
}

.search-row input {
  flex: 1;
  min-width: 0;
  padding: 0.8rem 0.95rem;
  border: 1.5px solid var(--line);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.98rem;
}

.search-row input::placeholder { color: #8aa3ad; }

.search-row input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
  z-index: 1;
  position: relative;
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.15s, background 0.15s;
}

.btn-primary {
  border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(180deg, #1290b0, var(--teal-deep));
  color: #fff;
  border-color: var(--teal-deep);
  padding-left: 1.3rem;
  padding-right: 1.3rem;
  box-shadow: 0 6px 18px rgba(10, 79, 99, 0.25);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.65; cursor: wait; transform: none; }

.btn-blue {
  background: linear-gradient(180deg, #1290b0, var(--teal-deep));
  color: #fff;
  border-color: var(--teal-deep);
  text-decoration: none;
  font-weight: 600;
}

.btn-blue:hover { filter: brightness(1.06); text-decoration: none; color: #fff; }

.btn-ghost {
  background: var(--paper);
  color: var(--muted);
  border-color: var(--line);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.45rem 0.7rem;
}

.btn-ghost:hover { color: var(--teal-deep); border-color: var(--teal); background: #fff; }
.btn-ghost.copied { color: var(--ok); border-color: #9ad4c2; background: var(--ok-bg); }

.private-opt {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
}

.private-opt input { accent-color: var(--teal); margin: 0; }
.private-opt em { color: #6b8a96; font-style: italic; font-size: 0.82rem; }

.status-bar {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.88rem;
}

.status-bar strong { color: var(--ink); font-weight: 600; }

.status-bar.scanning #status-text::after {
  animation: dots 1.2s steps(4, end) infinite;
  content: "";
}

@keyframes dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

.alert-error {
  margin-top: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--danger-bg);
  border: 1px solid #f5c4c0;
  color: var(--danger);
}

/* ── Results panel ── */
.result-panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.4rem 1.4rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.8s 0.1s ease both;
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.result-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.result-title span { color: var(--teal); }

.globe-icon { font-size: 1.1rem; opacity: 0.65; }

.permalink {
  width: 100%;
  padding: 0.55rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-family: var(--mono);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.stat:nth-child(2n) { border-right: 0; }
.stat:nth-last-child(-n+2) { border-bottom: 0; }

.stat-label {
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: capitalize;
}

.stat-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.compare-select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 140px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 480px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  text-align: left;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid #e8f1f4;
  vertical-align: middle;
}

.data-table tbody tr:nth-child(even) { background: #f8fcfd; }
.data-table tbody tr:hover { background: #eef7fa; }
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr.row-no-ip td { color: var(--muted); }
.data-table tbody tr.row-no-ip .ip-cell { font-style: italic; color: #8aa3ad; }

.host-link {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}

.host-link:hover { text-decoration: underline; color: var(--teal-deep); }

.ip-cell {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--ink);
}

.cf-cell { text-align: center; width: 90px; }

.cf-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #c5d5dc;
}

.cf-icon.active { color: var(--cf); }

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem !important;
}

.show-no-ip-btn {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--teal-deep);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.show-no-ip-btn:hover {
  background: #fff;
  border-color: var(--teal);
  color: var(--teal);
}

.ip-summary {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table-compact tbody td { padding: 0.4rem 0.85rem; }

/* ── Info panel ── */
.info-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  margin-bottom: 2rem;
  color: rgba(232, 244, 248, 0.9);
  font-size: 0.9rem;
  animation: rise 0.9s 0.15s ease both;
}

.info-panel h3 {
  margin: 0 0 0.6rem;
  font-family: var(--display);
  color: #fff;
  font-size: 1.05rem;
}

.info-panel p { margin: 0 0 0.6rem; }
.info-panel p:last-child { margin-bottom: 0; }

.info-panel code {
  background: rgba(255, 255, 255, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
}

.info-note {
  font-size: 0.85rem;
  color: rgba(232, 244, 248, 0.7);
  font-style: italic;
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 1rem 1rem 2rem;
  color: rgba(232, 244, 248, 0.65);
  font-size: 0.85rem;
}

.site-footer a { color: var(--sky); }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; }
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 20, 26, 0.55);
}

.modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 80vh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1rem;
}

.modal-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.modal-close:hover { color: var(--ink); }

.modal-body {
  padding: 0.75rem 1rem 1rem;
  overflow-y: auto;
  font-size: 0.88rem;
}

.modal-body .status-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}

.modal-body .status-line:last-child { border-bottom: 0; }

.status-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--mono);
}

.status-pill.ok { background: var(--ok-bg); color: var(--ok); }
.status-pill.bad { background: var(--danger-bg); color: var(--danger); }
.status-pill.warn { background: var(--warn-bg); color: #8a6918; }

@media (max-width: 640px) {
  .search-row { flex-direction: column; }
  .search-row input { border-right: 1.5px solid var(--line); border-radius: var(--radius); }
  .btn-primary { border-radius: var(--radius); width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat { border-right: 0 !important; }
  .stat:not(:last-child) { border-bottom: 1px solid var(--line); }
}
