:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --field: #f7faff;
  --text: #0f172a;
  --muted: #52647d;
  --muted-2: #8a9ab0;
  --line: #dbe4ef;
  --line-strong: #c7d4e4;
  --primary: #2563eb;
  --primary-soft: #e8f0ff;
  --accent: #83c9d8;
  --ok: #14845d;
  --warn: #a16207;
  --error: #b42318;
  --code-bg: #f8fbff;
  --code-text: #172033;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --focus: rgba(37, 99, 235, 0.18);
}

:root.dark {
  color-scheme: dark;
  --bg: #0f1723;
  --surface: #151e2b;
  --surface-soft: #111a26;
  --field: #101925;
  --text: #e8eef8;
  --muted: #a8b5c8;
  --muted-2: #75859b;
  --line: #263448;
  --line-strong: #34465d;
  --primary: #80a7ff;
  --primary-soft: #1c2a46;
  --accent: #79c7d6;
  --ok: #74d3a8;
  --warn: #e4c56d;
  --error: #ff8a80;
  --code-bg: #0d1420;
  --code-text: #e8eef8;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  --focus: rgba(128, 167, 255, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
}

.site-bar {
  width: min(1360px, calc(100% - 48px));
  min-height: 66px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 26px;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  font-weight: 780;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 850;
}

.tool-tabs {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.nav-button,
.icon-button,
.secondary-button,
.primary-button,
.mode-button,
.example-row button,
.action-row button,
.action-row a {
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.nav-button {
  min-height: 42px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 1rem;
}

.icon-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.page-shell {
  width: min(1040px, calc(100% - 48px));
  min-width: 0;
  margin: 0 auto;
  padding: 34px 0 72px;
}

.masthead {
  min-width: 0;
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--line);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-bottom: 22px;
  color: var(--muted-2);
  font-size: 0.92rem;
  font-weight: 650;
}

.breadcrumb span::after {
  content: "/";
  margin-left: 9px;
  color: var(--line-strong);
}

.breadcrumb strong {
  color: var(--text);
  font-weight: 760;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  line-height: 1.12;
  font-weight: 820;
}

h2 {
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 780;
}

.masthead-lead {
  max-width: 760px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.92fr);
  gap: 20px;
  align-items: stretch;
  margin-top: 22px;
  min-width: 0;
}

.tool-panel,
.result-section,
.guide-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-panel,
.result-section {
  padding: 18px;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading.compact {
  margin-bottom: 0;
}

.panel-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.panel-badge {
  color: var(--muted-2);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.tool-form {
  display: grid;
  gap: 14px;
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.34fr);
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 760;
}

input {
  min-width: 0;
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  padding: 0 13px;
  outline: none;
}

input::placeholder {
  color: var(--muted-2);
}

input:focus {
  border-color: color-mix(in srgb, var(--primary) 62%, var(--line));
  box-shadow: 0 0 0 3px var(--focus);
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mode-button {
  min-height: 40px;
  border-color: var(--line);
  background: var(--field);
  color: var(--muted);
  font-weight: 720;
}

.mode-button:hover,
.mode-button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.primary-button {
  min-height: 48px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  font-weight: 780;
}

.primary-button:hover {
  border-color: color-mix(in srgb, var(--accent) 80%, var(--primary));
  background: color-mix(in srgb, var(--accent) 86%, var(--primary));
}

.secondary-button {
  min-height: 36px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  font-size: 0.86rem;
  font-weight: 720;
}

.secondary-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-row button {
  min-height: 32px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 680;
}

.example-row button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.message {
  min-height: 1.35em;
  margin-top: 10px;
  color: var(--error);
  font-size: 0.9rem;
  font-weight: 680;
}

.message.is-ok {
  color: var(--ok);
}

.result-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 390px;
}

.result-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted-2);
  text-align: center;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted-2);
  font-size: 1.05rem;
}

.result-empty p {
  color: var(--muted);
  font-weight: 760;
}

.result-empty span {
  max-width: 260px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.result-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.result-item {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.result-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  min-width: 0;
}

.result-node strong {
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 780;
}

.result-node span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 660;
}

.result-host {
  grid-column: 1 / -1;
  color: var(--primary);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.result-output {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.result-meta {
  color: var(--muted-2);
  font-size: 0.78rem;
  font-weight: 720;
}

.output-code {
  display: block;
  min-width: 0;
  max-width: 100%;
  max-height: 98px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 10px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre;
  word-break: normal;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.action-row button,
.action-row a {
  min-height: 32px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 720;
}

.action-row button:hover,
.action-row a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.guide-section {
  margin-top: 26px;
  padding: 0;
  overflow: hidden;
}

.guide-section .section-heading {
  padding: 18px 18px 0;
}

.guide-list {
  display: grid;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.guide-detail {
  border-bottom: 1px solid var(--line);
}

.guide-detail:last-child {
  border-bottom: 0;
}

.guide-detail summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 0 18px;
  color: var(--text);
  cursor: pointer;
  font-weight: 760;
  list-style: none;
}

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

.guide-detail summary::after {
  content: "⌄";
  color: var(--muted);
  font-size: 1rem;
}

.guide-detail[open] summary::after {
  transform: rotate(180deg);
}

.guide-body {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.guide-body ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.1rem;
}

.guide-body li {
  color: var(--muted);
  line-height: 1.65;
}

.guide-code {
  min-width: 0;
}

.guide-code pre {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}

.guide-content {
  display: none;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: min(340px, calc(100vw - 36px));
}

.toast {
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 13px;
  box-shadow: var(--shadow);
  font-weight: 720;
}

.toast.is-error {
  border-left-color: var(--error);
}

.qr-dialog {
  width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 18px;
  box-shadow: var(--shadow);
}

.qr-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

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

.qr-dialog img {
  display: block;
  width: 230px;
  height: 230px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.qr-dialog p {
  margin: 14px 0 0;
  max-height: 100px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-all;
}

.site-bar,
.page-shell,
.masthead,
.workspace,
.tool-panel,
.result-section,
.guide-section,
.result-list,
.result-item,
.result-output,
.guide-code {
  min-width: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 960px) {
  .site-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 9px 0;
  }

  .tool-tabs {
    grid-column: 1 / -1;
    order: 3;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .result-section {
    min-height: 0;
  }
}

@media (max-width: 620px) {
  .site-bar,
  .page-shell {
    width: min(100% - 22px, 560px);
  }

  .page-shell {
    padding: 24px 0 46px;
  }

  .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .tool-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
  }

  .nav-button {
    min-height: 38px;
    padding: 0 9px;
    background: var(--surface);
    border-color: var(--line);
  }

  .masthead {
    padding-bottom: 22px;
  }

  .breadcrumb {
    margin-bottom: 16px;
    font-size: 0.86rem;
  }

  h1 {
    font-size: clamp(1.65rem, 9vw, 2.25rem);
  }

  .tool-panel,
  .result-section {
    padding: 15px;
  }

  .panel-heading,
  .section-heading {
    display: grid;
    gap: 8px;
  }

  .panel-badge {
    white-space: normal;
  }

  .field-grid.two,
  .mode-row {
    grid-template-columns: 1fr;
  }

  .action-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
