:root {
  --bg: #0b0d11;
  --bg-raise: #12151b;
  --bg-panel: #151920;
  --bg-input: #0e1116;
  --border: #232a34;
  --border-soft: #1b2129;
  --text: #e8ecf1;
  --text-dim: #9aa5b1;
  --text-faint: #6b7683;
  --accent: #3ecf8e;
  --accent-dim: rgba(62, 207, 142, 0.12);
  --accent-text: #0b0d11;
  --danger: #e2604f;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

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

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  background: rgba(11, 13, 17, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.site-header .wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.brand .tld { color: var(--accent); }
.site-nav { display: flex; gap: 22px; font-size: 14.5px; }
.site-nav a { color: var(--text-dim); }
.site-nav a:hover { color: var(--text); text-decoration: none; }
@media (max-width: 720px) { .site-nav { display: none; } }

/* ---------- hero / tool ---------- */
.hero { padding: 40px 0 8px; }
.hero h1 {
  font-size: clamp(26px, 4.2vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.hero .sub {
  color: var(--text-dim);
  max-width: 640px;
  margin: 0 0 28px;
  font-size: 17px;
}

.tool {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.controls {
  display: grid;
  grid-template-columns: 1.3fr 1.1fr 0.9fr 0.8fr 0.7fr;
  gap: 14px;
}
@media (max-width: 900px) { .controls { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .controls { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field select,
.field input[type="number"],
.field input[type="text"] {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.field select:focus,
.field input:focus { border-color: var(--accent); }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa5b1' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.ns-row { display: none; grid-template-columns: 1fr 2fr; gap: 14px; margin-top: 14px; }
.ns-row.show { display: grid; }
@media (max-width: 520px) { .ns-row { grid-template-columns: 1fr; } }
.hint { font-size: 13px; color: var(--text-faint); margin-top: 8px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.btn {
  height: 42px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-raise);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { border-color: #303945; background: #191e26; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.btn-primary:hover { background: #35bd80; border-color: #35bd80; }
.btn.ok { border-color: var(--accent); color: var(--accent); }
.auto-copy {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.auto-copy input { accent-color: var(--accent); width: 16px; height: 16px; }
@media (max-width: 720px) { .auto-copy { margin-left: 0; } }

/* ---------- output ---------- */
.output { margin-bottom: 14px; }
.single-out {
  display: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  text-align: center;
}
.single-out.show { display: block; }
.single-out code {
  display: block;
  font-family: var(--mono);
  font-size: clamp(15px, 2.6vw, 26px);
  letter-spacing: 0.02em;
  color: var(--accent);
  word-break: break-all;
  cursor: pointer;
}
.single-out .tip { font-size: 13px; color: var(--text-faint); margin-top: 10px; }

.list-out {
  display: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list-out.show { display: block; }
.list-out .list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-dim);
}
.list-out pre {
  margin: 0;
  padding: 14px 16px;
  max-height: 420px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.8;
  color: #cfe7db;
}
.list-out ol {
  margin: 0;
  padding: 8px 0;
  max-height: 420px;
  overflow: auto;
  list-style: none;
}
.list-out ol li {
  padding: 4px 16px;
  font-family: var(--mono);
  font-size: 14px;
  color: #cfe7db;
  cursor: pointer;
  white-space: nowrap;
  overflow-x: auto;
}
.list-out ol li:hover { background: var(--accent-dim); }
.list-out ol li.copied { color: var(--accent); }

/* ---------- sections ---------- */
section { padding: 44px 0 8px; }
section h2 {
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.015em;
  margin: 0 0 14px;
}
section .lead { color: var(--text-dim); max-width: 720px; margin: 0 0 24px; }
section p { color: var(--text-dim); max-width: 760px; }
section p strong, section li strong { color: var(--text); }
section ul { color: var(--text-dim); }

/* decoder */
.decoder-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.decoder-box .dec-row { display: flex; gap: 10px; }
.decoder-box input[type="text"] {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  outline: none;
  min-width: 0;
}
.decoder-box input:focus { border-color: var(--accent); }
@media (max-width: 520px) { .decoder-box .dec-row { flex-direction: column; } }

.dec-result { margin-top: 18px; display: none; }
.dec-result.show { display: block; }
.dec-status { font-size: 15px; margin-bottom: 12px; }
.dec-status.valid { color: var(--accent); }
.dec-status.invalid { color: var(--danger); }
.dec-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  border-top: 1px solid var(--border-soft);
}
.dec-grid > div {
  padding: 9px 4px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14.5px;
  overflow-wrap: anywhere;
}
.dec-grid > div:nth-child(odd) { color: var(--text-faint); }
.dec-grid > div:nth-child(even) { font-family: var(--mono); color: var(--text); cursor: pointer; }
.dec-grid > div:nth-child(even):hover { color: var(--accent); }
@media (max-width: 520px) {
  .dec-grid { grid-template-columns: 1fr; }
  .dec-grid > div:nth-child(odd) { border-bottom: 0; padding-bottom: 0; }
}

/* structure diagram */
.structure {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  overflow-x: auto;
}
.structure .uuid-vis {
  font-family: var(--mono);
  font-size: clamp(14px, 2.4vw, 22px);
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.seg-a { color: #5eb1ef; }
.seg-b { color: #d5a458; }
.seg-c { color: var(--accent); }
.seg-d { color: #c58ce0; }
.seg-e { color: #8a95a3; }
.structure .legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 22px;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-dim);
}
.structure .legend b { font-family: var(--mono); font-weight: 600; }

/* versions grid */
.vgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 860px) { .vgrid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .vgrid { grid-template-columns: 1fr; } }
.vcard {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.vcard.wide { grid-column: span 2; }
@media (max-width: 540px) { .vcard.wide { grid-column: span 1; } }
.vcard h3 { margin: 0 0 8px; font-size: 17px; }
.vcard h3 span { color: var(--accent); font-family: var(--mono); margin-right: 6px; }
.vcard p { margin: 0; font-size: 14.5px; color: var(--text-dim); }

/* code tabs */
.code-tabs { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tab-bar { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border-soft); }
.tab-bar button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 12px 18px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.tab-bar button:hover { color: var(--text); }
.tab-bar button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; margin: 0; padding: 18px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.7; color: #c9d4de; }
.tab-pane.active { display: block; }

/* faq */
.faq details {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.faq summary {
  cursor: pointer;
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 600;
  list-style: none;
  position: relative;
  padding-right: 42px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 20px;
}
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin: 0; padding: 0 18px 16px; font-size: 15px; }

/* history */
.history-box { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); }
.history-box .h-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  font-size: 14px;
  color: var(--text-dim);
}
.history-box .h-head button { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 13px; font-family: inherit; }
.history-box .h-head button:hover { color: var(--danger); }
.history-box ul { list-style: none; margin: 0; padding: 0 0 8px; max-height: 260px; overflow: auto; }
.history-box li {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 5px 18px;
  font-family: var(--mono);
  font-size: 13.5px;
  color: #cfe7db;
  cursor: pointer;
  overflow-x: auto;
  white-space: nowrap;
}
.history-box li:hover { background: var(--accent-dim); }
.history-box li .h-meta { color: var(--text-faint); font-size: 12px; margin-left: auto; }
.history-empty { padding: 6px 18px 16px; color: var(--text-faint); font-size: 14px; }

/* footer */
.site-footer {
  margin-top: 56px;
  border-top: 1px solid var(--border-soft);
  padding: 26px 0 34px;
  font-size: 14px;
  color: var(--text-faint);
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--text-dim); }
