/* TokenTool — 铭牌 + 规格架 design tokens */
:root {
  --chalk: #fbfbfc;
  --panel: #ffffff;
  --rule: #e0e2e7;
  --ink: #14161a;
  --ink-2: #5b6370;
  --mute: #8e96a3;
  --danger: #b42318;
  --fill: #f4f5f7;
  --fill-2: #ebedf0;
  --shadow: 0 1px 2px rgba(20, 22, 26, 0.04);
  --font: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", "Noto Sans Mono", monospace;
  --head-h: 56px;
  --content: 1080px;
  --tool-content: 1120px;
  --tool-head: 52px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--chalk);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* —— 顶栏 —— */
.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--head-h);
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}

.site-head__inner {
  max-width: var(--tool-content);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand:hover {
  opacity: 0.72;
}

.crumbs {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  color: var(--ink-2);
  font-size: 13px;
}

.crumbs__sep {
  color: var(--mute);
}

.crumbs__current {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head-spacer {
  flex: 1;
}

.head-link {
  font-size: 13px;
  color: var(--ink-2);
  flex-shrink: 0;
}

.head-link:hover {
  color: var(--ink);
}

/* 搜索 */
.search {
  position: relative;
  width: min(236px, 42vw);
  flex-shrink: 0;
}

.search input {
  width: 100%;
  height: 32px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--chalk);
  font-size: 13px;
  outline: none;
}

.search input::placeholder {
  color: var(--mute);
}

.search input:focus {
  border-color: var(--ink);
  background: var(--panel);
}

.search__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--mute);
  pointer-events: none;
}

/* —— 首页布局 —— */
.home {
  max-width: var(--content);
  margin: 0 auto;
  padding: 40px 24px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

/* 顶栏 slogan + 本地计算备注 */
.head-slogan {
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mute);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.rack__label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mute);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.rack {
  list-style: none;
  border-top: 1px solid var(--rule);
}

.rack__row {
  border-bottom: 1px solid var(--rule);
}

.rack__link {
  display: grid;
  grid-template-columns: minmax(72px, 88px) minmax(100px, 1fr) minmax(0, 1.4fr);
  gap: 12px 16px;
  align-items: baseline;
  padding: 16px 4px;
  transition: background 0.15s ease;
}

.rack__link:hover {
  background: var(--panel);
}

.rack__link:focus-visible {
  outline-offset: -2px;
}

.rack__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.rack__desc {
  font-size: 13px;
  color: var(--ink-2);
}

.rack__sample {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rack__empty {
  padding: 28px 4px;
  color: var(--ink-2);
  font-size: 14px;
  border-bottom: 1px solid var(--rule);
}

.rack__empty code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}

/* 上电动效：仅一次 */
@media (prefers-reduced-motion: no-preference) {
  .rack__row.is-booting {
    opacity: 0;
  }

  .rack__row.is-booted {
    animation: rack-in 0.45s ease forwards;
  }

  @keyframes rack-in {
    from {
      opacity: 0;
      transform: translateY(4px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .rack__label.is-booting {
    opacity: 0;
  }

  .rack__label.is-booted {
    animation: rack-in 0.4s ease forwards;
  }
}

.site-foot {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 24px 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 12px;
  color: var(--mute);
}

.site-foot a:hover {
  color: var(--ink);
}

/* —— 工具页 —— */
.tool {
  max-width: var(--tool-content);
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.tool__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 13px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--panel);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--fill-2);
  border-color: var(--rule);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--panel);
}

.btn--primary:hover:not(:disabled) {
  background: #2a2f36;
  border-color: #2a2f36;
}

.channels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.channels--fit {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  max-width: var(--tool-content);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card__label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mute);
  letter-spacing: 0.06em;
}

.card .field-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.card > div:not(.tool__actions) input,
.card .field-row input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--fill);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  outline: none;
}

.card > div:not(.tool__actions) input:focus,
.card .field-row input:focus {
  border-color: var(--ink);
  background: var(--panel);
}

.card .field-row .btn {
  height: 36px;
  padding: 0 12px;
  flex-shrink: 0;
}

.card > div:not(.tool__actions) input::placeholder,
.card .field-row input::placeholder {
  color: var(--mute);
}

.card .out {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--fill);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-all;
  overflow: auto;
}

.card .out.num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  word-break: normal;
  text-align: center;
}

.card .out.is-error {
  color: var(--danger);
  border-left: 2px solid var(--danger);
  font-family: var(--font);
}

.card .out.is-empty {
  color: var(--mute);
}

.channel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.channel__tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mute);
  letter-spacing: 0.08em;
  padding: 8px 12px 0;
}

.channel__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 10px 10px;
  min-height: 0;
}

.channel textarea,
.channel input,
.channel .out {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--fill);
  padding: 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}

.channel textarea {
  flex: 1;
  min-height: 92px;
  max-height: 300px;
  resize: vertical;
  outline: none;
}

.channel textarea:focus,
.channel input:focus {
  border-color: var(--ink);
  background: var(--panel);
}

.channel textarea::placeholder,
.channel input::placeholder {
  color: var(--mute);
}

.channel input {
  height: 36px;
}

.channel .out {
  flex: 1;
  min-height: 92px;
  max-height: 300px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow: auto;
}

.channel .out.is-empty {
  color: var(--mute);
}

.channel .out.num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.04em;
  word-break: normal;
}

.channel .out.is-error {
  color: var(--danger);
  border-left: 2px solid var(--danger);
  white-space: pre-wrap;
  font-family: var(--font);
  font-size: 13px;
}

.channel .qr-box {
  flex: 1;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fill);
  border-radius: 6px;
  padding: 10px;
}

.channel .qr-box img,
.channel .qr-box canvas {
  max-width: 100%;
  height: auto;
  background: var(--panel);
  padding: 8px;
}

.channel .qr-box .placeholder {
  color: var(--mute);
  font-size: 13px;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-row input {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.range-row input.range-count {
  flex: 0 0 64px;
}

.range-row .range-sep {
  flex-shrink: 0;
  color: var(--mute);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1;
}

.tool__hint {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.65;
  max-width: 70ch;
}

.tool__hint code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}

.tool__error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 13px;
  min-height: 1.5em;
}

/* —— MD5 页：输入/输出占满屏高（保持现有宽度）、内部滚动 —— */
body[data-tool="md5"] {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body[data-tool="md5"] .site-head {
  position: static;
  flex-shrink: 0;
}

body[data-tool="md5"] .tool,
body[data-tool="json"] .tool {
  flex: 1;
  min-height: 0;
  align-self: center;
  width: 100%;
  max-width: var(--tool-content);
  display: flex;
  flex-direction: column;
  padding: 16px 24px 0;
}

body[data-tool="md5"] .tool__actions {
  flex-shrink: 0;
  margin-bottom: 10px;
}

body[data-tool="md5"] .channels {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}

body[data-tool="md5"] .channel {
  min-height: 0;
  max-height: none;
}

body[data-tool="md5"] .channel textarea,
body[data-tool="md5"] .channel .out {
  min-height: 0;
  max-height: none;
}

body[data-tool="md5"] .channel textarea {
  resize: none;
}

body[data-tool="md5"] .tool__hint {
  flex-shrink: 0;
  padding: 10px 0 16px;
}

/* —— JSON 页：输入/输出占满整屏、内部滚动 —— */
body[data-tool="json"] {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body[data-tool="json"] .site-head {
  position: static;
  flex-shrink: 0;
}



body[data-tool="json"] .tool__actions {
  flex-shrink: 0;
  margin-bottom: 10px;
}

body[data-tool="json"] .channels {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}

body[data-tool="json"] .channel {
  min-height: 0;
  max-height: none;
}

body[data-tool="json"] .channel textarea,
body[data-tool="json"] .channel .out {
  min-height: 0;
  max-height: none;
}

body[data-tool="json"] .channel textarea {
  resize: none;
}

body[data-tool="json"] .tool__hint {
  flex-shrink: 0;
  padding: 10px 0 16px;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--panel);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 响应式 */
@media (max-width: 900px) {
  .channels {
    grid-template-columns: 1fr;
  }

  .channel .out,
  .channel textarea {
    min-height: 84px;
  }

  .rack__link {
    grid-template-columns: 80px 1fr;
    grid-template-rows: auto auto;
  }

  .rack__sample {
    grid-column: 1 / -1;
    white-space: normal;
  }
}

@media (max-width: 760px) {
  .home {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 28px 16px 40px;
  }

  .head-slogan,
  .head-note {
    display: none;
  }

  .site-head__inner {
    padding: 0 16px;
    gap: 12px;
  }

  .tool {
    padding: 20px 16px 40px;
  }

  .site-foot {
    padding: 0 16px 32px;
  }

  .search {
    width: min(160px, 36vw);
  }
}
