/* ===== 跨页面过渡动画 (View Transitions API) ===== */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: vt-fade-out 0.35s ease-out both;
  pointer-events: none;
}

::view-transition-new(root) {
  animation: vt-fade-in 0.35s ease-in both;
  pointer-events: none;
}

@keyframes vt-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes vt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

* { box-sizing: border-box; }

:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --card: rgba(255, 255, 255, .78);
    --text: #172033;
    --sub: #687289;
    --line: rgba(23, 32, 51, .09);
    --blue: #1769e0;
    --blue-soft: #e8f1ff;
    --green: #16875b;
    --amber: #c47a08;
    --red: #d64545;
    --shadow: 0 24px 70px rgba(41, 57, 90, .12);
}

body.dark {
    color-scheme: dark;
    --bg: #090b11;
    --card: rgba(25, 29, 39, .78);
    --text: #f3f6fc;
    --sub: #9da7ba;
    --line: rgba(255, 255, 255, .09);
    --blue: #6aa9ff;
    --blue-soft: rgba(59, 130, 246, .15);
    --green: #53d39e;
    --amber: #ffba52;
    --red: #ff7777;
    --shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

body {
    margin: 0;
    min-height: 100vh;
    padding-bottom: 125px;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    transition: color .3s, background .3s;
}

body::before, body::after {
    content: "";
    position: fixed;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    filter: blur(110px);
    opacity: .38;
    z-index: -1;
    animation: float 18s infinite alternate ease-in-out;
}

body::before { top: -240px; left: -160px; background: #3988ff; }
body::after { right: -220px; bottom: -260px; background: #9e68e7; animation-delay: -8s; }
@keyframes float { to { transform: translate(70px, 60px) scale(1.12); } }

.theme-toggle {
    position: fixed;
    top: 28px;
    right: 30px;
    z-index: 10;
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--card);
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.theme-toggle svg { width: 21px; }
.hero { max-width: 720px; margin: auto; padding: 92px 24px 42px; text-align: center; }
.eyebrow { color: var(--blue); font-size: 13px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.hero h1 { margin: 12px 0 14px; font-size: clamp(42px, 7vw, 64px); letter-spacing: -.06em; line-height: 1.08; }
.hero p { max-width: 600px; margin: auto; color: var(--sub); font-size: 17px; line-height: 1.8; }
.container { width: min(820px, calc(100% - 36px)); margin: auto; }

/* ----- IP 地址卡片 ----- */
.ip-card {
    margin-bottom: 22px;
    padding: 20px clamp(20px, 5vw, 32px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--card);
    backdrop-filter: blur(30px);
    box-shadow: var(--shadow);
}

.ip-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.ip-header svg {
    width: 20px;
    height: 20px;
    color: var(--blue);
}

.ip-refresh {
    margin-left: auto;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: transparent;
    color: var(--sub);
    cursor: pointer;
    transition: color .2s, border-color .2s;
}

.ip-refresh svg {
    width: 16px;
    height: 16px;
    color: inherit;
}

.ip-refresh:hover {
    color: var(--blue);
    border-color: var(--blue);
}

.ip-refresh.loading svg {
    animation: spin 1s linear infinite;
}

.ip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ip-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(127, 127, 127, .035);
    min-width: 0;
}

.ip-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--sub);
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
}

.ip-label svg {
    width: 16px;
    height: 16px;
}

.ip-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.ip-badge {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
}

.ip-ok { color: var(--green); }
.ip-err { color: var(--red); }
.ip-na { color: var(--sub); }

@media (max-width: 640px) {
    .ip-grid { grid-template-columns: 1fr; }
    .ip-item { flex-wrap: wrap; }
    .ip-value { width: 100%; order: 1; }
}

/* ----- 双栏结果展示 ----- */
.result-dual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 6px 0 4px;
}

.result-sub {
    padding: 16px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(127, 127, 127, .035);
    text-align: left;
}

.result-sub-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ipv4-badge { color: #fff; background: #1769e0; }
.ipv6-badge { color: #fff; background: #16a34a; }

.result-sub-name {
    display: block;
    margin: 8px 0 3px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.result-sub-code {
    display: block;
    color: var(--sub);
    font-size: 12px;
    font-weight: 650;
}

/* ----- 结构化描述 ----- */
.desc-block {
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(127, 127, 127, .025);
    text-align: left;
}

.desc-block-title {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 750;
    color: var(--text);
}

.desc-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.desc-label {
    flex-shrink: 0;
    color: var(--sub);
    font-weight: 650;
    min-width: 56px;
}

.desc-value {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    padding: 1px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(127, 127, 127, .06);
    white-space: nowrap;
}

.desc-mapping {
    color: var(--blue);
    font-weight: 700;
    font-size: 13px;
}

.desc-text {
    margin: 8px 0 0;
    color: var(--sub);
    font-size: 13px;
    line-height: 1.65;
}

.desc-summary {
    margin: 6px 0 0;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--blue-soft);
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    text-align: left;
}

@media (max-width: 900px) {
    .guide-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .result-dual { grid-template-columns: 1fr; }
}

.detector-card, .type-guide, .details {
    border: 1px solid var(--line);
    background: var(--card);
    backdrop-filter: blur(30px);
    box-shadow: var(--shadow);
}

.detector-card { padding: 46px clamp(24px, 7vw, 70px); border-radius: 34px; text-align: center; }
.result-icon { display: grid; width: 76px; height: 76px; margin: auto; place-items: center; color: var(--blue); border-radius: 24px; background: var(--blue-soft); transition: .3s; }
.result-icon svg { width: 38px; height: 38px; }
.result-icon[data-state="loading"] { animation: pulse 1.5s ease-in-out infinite; }
.result-icon[data-state="good"] { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.result-icon[data-state="limited"] { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.result-icon[data-state="poor"], .result-icon[data-state="error"] { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
@keyframes pulse { 50% { transform: scale(.92); opacity: .65; } }
.status { display: inline-flex; align-items: center; gap: 7px; margin-top: 24px; color: var(--sub); font-size: 14px; font-weight: 650; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status[data-state="loading"] { color: var(--blue); }
.status[data-state="good"] { color: var(--green); }
.status[data-state="limited"] { color: var(--amber); }
.status[data-state="poor"], .status[data-state="error"] { color: var(--red); }
.detector-card h2 { margin: 10px 0 6px; font-size: clamp(29px, 5vw, 39px); letter-spacing: -.04em; }
.type-code { margin: 0; color: var(--blue); font-size: 16px; font-weight: 750; }
.description { max-width: 590px; min-height: 52px; margin: 18px auto 0; color: var(--sub); line-height: 1.75; }
.confidence { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; max-width: 480px; margin: 25px auto 0; color: var(--sub); font-size: 13px; }
.confidence-track { height: 7px; overflow: hidden; border-radius: 9px; background: var(--line); }
.confidence-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width .7s ease; }
.confidence strong { color: var(--text); font-variant-numeric: tabular-nums; }
.start { display: inline-flex; align-items: center; gap: 9px; margin-top: 30px; padding: 14px 26px; color: #fff; border: 0; border-radius: 14px; background: #1769e0; box-shadow: 0 10px 24px rgba(23, 105, 224, .25); font-size: 16px; font-weight: 700; cursor: pointer; transition: transform .2s, opacity .2s; }
.start:hover:not(:disabled) { transform: translateY(-2px); }
.start:disabled { cursor: wait; opacity: .72; }
.start svg { width: 19px; }
.start.loading svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.type-guide { margin-top: 22px; padding: 26px 28px; border-radius: 24px; }
.type-guide h3 { margin: 0 0 17px; font-size: 17px; }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.guide-grid article { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(127, 127, 127, .035); }
.guide-grid b { display: block; margin-bottom: 7px; color: var(--blue); font-size: 15px; }
.guide-grid span { color: var(--sub); font-size: 13px; line-height: 1.6; }

.details { margin-top: 22px; padding: 0 26px; border-radius: 22px; }
.details summary { display: flex; align-items: center; justify-content: space-between; padding: 21px 0; font-weight: 700; cursor: pointer; list-style: none; }
.details summary::-webkit-details-marker { display: none; }
.details summary span { display: flex; align-items: center; gap: 10px; }
.details summary svg { width: 19px; }
.details .chevron { transition: transform .2s; }
.details[open] .chevron { transform: rotate(180deg); }
.details pre { margin: 0; padding: 0 0 23px; overflow-x: auto; color: var(--sub); border-top: 1px solid var(--line); padding-top: 20px; font: 12px/1.8 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.notice { margin: 18px auto 0; padding: 0 12px; color: var(--sub); font-size: 12px; line-height: 1.7; text-align: center; }

/* ----- Dock ----- */
.dock {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line, rgba(128, 128, 128, 0.12));
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  z-index: 999;
  transition: background 0.3s, border-color 0.3s;
}

body.dark .dock {
  border-color: rgba(255, 255, 255, 0.06);
}

.dock-item {
  position: relative;
  color: var(--sub);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dock-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  transition: transform 0.25s;
}

.github-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.dock-item span {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}

.dock-item:hover {
  color: var(--text);
  background: rgba(128, 128, 128, 0.08);
}

.dock-item:hover svg {
  transform: translateY(-6px) scale(1.1);
}

.dock-item:hover span {
  opacity: 1;
}

.dock-item.active {
  color: var(--blue);
}

.dock-item.active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--blue);
}

.dock-item.active:hover::after {
  display: none;
}

@media (max-width: 640px) {
    body::before, body::after {
        width: 320px;
        height: 320px;
        filter: blur(60px);
    }
    body::before { top: -120px; left: -100px; }
    body::after { right: -100px; bottom: -140px; }

    .hero { padding: 72px 20px 30px; }
    .hero h1 { font-size: 36px; }
    .hero p { font-size: 15px; }

    .theme-toggle { top: 20px; right: 20px; width: 43px; height: 43px; }
    .theme-toggle svg { width: 18px; }

    .container { width: calc(100% - 24px); }

    .ip-card { padding: 16px; border-radius: 18px; }
    .ip-grid { gap: 8px; }
    .ip-item { padding: 10px 12px; border-radius: 12px; }
    .ip-label { font-size: 12px; }
    .ip-label svg { width: 14px; height: 14px; }
    .ip-value { font-size: 12px; }

    .detector-card { padding: 32px 20px; border-radius: 24px; }
    .detector-card h2 { font-size: 28px; }
    .description { font-size: 14px; min-height: auto; }
    .result-icon { width: 60px; height: 60px; border-radius: 18px; }
    .result-icon svg { width: 30px; height: 30px; }

    .confidence { font-size: 12px; }

    .start { padding: 12px 22px; font-size: 14px; }

    .result-dual { gap: 8px; }
    .result-sub { padding: 12px; }
    .result-sub-name { font-size: 14px; }
    .desc-block { padding: 12px; }
    .desc-row { font-size: 12px; }
    .desc-value { font-size: 12px; white-space: normal; word-break: break-all; }
    .desc-summary { font-size: 12px; padding: 8px 12px; }

    .guide-grid { grid-template-columns: 1fr; gap: 10px; }
    .type-guide { padding: 20px; border-radius: 18px; }
    .type-guide h3 { font-size: 15px; }
    .guide-grid article { padding: 12px; }
    .guide-grid b { font-size: 14px; }
    .guide-grid span { font-size: 12px; }

    .details { padding: 0 18px; border-radius: 18px; }
    .details summary { padding: 16px 0; font-size: 13px; }
    .details pre { font-size: 11px; }

    .notice { font-size: 11px; padding: 0 8px; }

  .dock { gap: 1px; padding: 4px; bottom: 20px; }
  .dock-item { width: 40px; height: 40px; }
  .dock-item svg { width: 18px; height: 18px; }
  .dock-item span { display: none; }
}

@media (max-width: 400px) {
    .hero { padding: 56px 14px 20px; }
    .hero h1 { font-size: 28px; }
    .detector-card { padding: 24px 14px; border-radius: 20px; }
    .detector-card h2 { font-size: 22px; }
    .ip-card { padding: 12px; }
    .result-icon { width: 48px; height: 48px; border-radius: 14px; }
    .result-icon svg { width: 24px; height: 24px; }
    .start { width: 100%; justify-content: center; }
    .container { width: calc(100% - 12px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
