/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;

  --bg: #f7f7f3;
  --bg-soft: #f1f1ec;
  --surface: #ffffff;
  --surface-2: #f7f7f4;
  --field: #fbfbf9;
  --text: #17171c;
  --text-soft: #61626b;
  --text-faint: #8d8e97;
  --border: #e6e5de;
  --border-strong: #d5d4cb;
  --border-soft: rgba(23, 23, 28, 0.07);

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: #4f46e5;
  --accent-soft: #efefff;
  --accent-ring: rgba(79, 70, 229, 0.16);
  --green: #0b8f6c;
  --green-soft: #e6f7f1;
  --red: #d33d43;
  --red-soft: #fdf0f0;
  --amber: #a16207;
  --amber-soft: #fef6e6;

  --shadow-xs: 0 1px 2px rgba(23, 23, 28, 0.04);
  --shadow-sm: 0 1px 2px rgba(23, 23, 28, 0.04), 0 6px 18px rgba(23, 23, 28, 0.04);
  --shadow-md: 0 16px 40px rgba(23, 23, 28, 0.09), 0 2px 8px rgba(23, 23, 28, 0.04);
  --shadow-lg: 0 24px 70px rgba(23, 23, 28, 0.13);

  --glow-a: rgba(99, 102, 241, 0.1);
  --glow-b: rgba(20, 184, 166, 0.07);

  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --container: 1120px;
  --header-h: 64px;

  --font-sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Code", "Roboto Mono", Consolas,
    "Liberation Mono", monospace;

  --swatch-checker: repeating-conic-gradient(#e9e9e4 0% 25%, #ffffff 0% 50%) 50% / 12px 12px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d0e12;
  --bg-soft: #111319;
  --surface: #161821;
  --surface-2: #1c1f29;
  --field: #14161e;
  --text: #f0f1f5;
  --text-soft: #a5a8b4;
  --text-faint: #7b7f8d;
  --border: #252935;
  --border-strong: #343947;
  --border-soft: rgba(255, 255, 255, 0.06);

  --accent: #9299ff;
  --accent-hover: #b3b8ff;
  --accent-text: #aeb3ff;
  --accent-soft: #1d2038;
  --accent-ring: rgba(146, 153, 255, 0.2);
  --green: #4edeae;
  --green-soft: #142a24;
  --red: #ff7378;
  --red-soft: #2d171a;
  --amber: #f0c36b;
  --amber-soft: #2a2213;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 18px 44px rgba(0, 0, 0, 0.42), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.55);

  --glow-a: rgba(99, 102, 241, 0.14);
  --glow-b: rgba(20, 184, 166, 0.08);

  --swatch-checker: repeating-conic-gradient(#2a2e3a 0% 25%, #1a1d25 0% 50%) 50% / 12px 12px;
}

/* Tool accent colors — also inherited by .tool-icon */
[data-tool="timestamp"] {
  --tool-bg: #e9f0ff;
  --tool-fg: #2f6fed;
  --tool-tint: rgba(59, 130, 246, 0.1);
}
[data-tool="json"] {
  --tool-bg: #fff3df;
  --tool-fg: #c2740a;
  --tool-tint: rgba(245, 158, 11, 0.11);
}
[data-tool="unit"] {
  --tool-bg: #e5f7ee;
  --tool-fg: #0d9267;
  --tool-tint: rgba(16, 185, 129, 0.1);
}
[data-tool="qrcode"] {
  --tool-bg: #f2eaff;
  --tool-fg: #7c3aed;
  --tool-tint: rgba(139, 92, 246, 0.11);
}
[data-tool="color"] {
  --tool-bg: #ffe9ee;
  --tool-fg: #db3d68;
  --tool-tint: rgba(244, 63, 94, 0.1);
}
[data-tool="text"] {
  --tool-bg: #e4f5ff;
  --tool-fg: #0b86bf;
  --tool-tint: rgba(14, 165, 233, 0.1);
}
[data-tool="base64"] {
  --tool-bg: #ecebff;
  --tool-fg: #5b52e0;
  --tool-tint: rgba(99, 102, 241, 0.11);
}
[data-tool="url"] {
  --tool-bg: #e2f7f4;
  --tool-fg: #0b8f86;
  --tool-tint: rgba(20, 184, 166, 0.1);
}

[data-theme="dark"] [data-tool="timestamp"] {
  --tool-bg: #182440;
  --tool-fg: #7dabff;
}
[data-theme="dark"] [data-tool="json"] {
  --tool-bg: #312511;
  --tool-fg: #f4b44d;
}
[data-theme="dark"] [data-tool="unit"] {
  --tool-bg: #122c24;
  --tool-fg: #52ddb0;
}
[data-theme="dark"] [data-tool="qrcode"] {
  --tool-bg: #271b3d;
  --tool-fg: #b795ff;
}
[data-theme="dark"] [data-tool="color"] {
  --tool-bg: #341821;
  --tool-fg: #ff8ba8;
}
[data-theme="dark"] [data-tool="text"] {
  --tool-bg: #122b39;
  --tool-fg: #6ccbf3;
}
[data-theme="dark"] [data-tool="base64"] {
  --tool-bg: #211f3c;
  --tool-fg: #a4a7ff;
}
[data-theme="dark"] [data-tool="url"] {
  --tool-bg: #102d2a;
  --tool-fg: #5cd8c9;
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 460px at 12% -8%, var(--glow-a), transparent 62%),
    radial-gradient(760px 420px at 92% 0%, var(--glow-b), transparent 60%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body > main {
  flex: 1;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

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

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

button {
  cursor: pointer;
}

img,
svg {
  display: block;
  max-width: 100%;
}

code,
kbd,
pre {
  font-family: var(--font-mono);
}

::selection {
  color: #fff;
  background: #4f46e5;
}

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

[hidden] {
  display: none !important;
}

/* ---------- Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 28px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 10px 16px;
  color: #fff;
  background: #4f46e5;
  border-radius: 8px;
  transform: translateY(-150%);
  transition: transform 0.18s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--text-soft);
}

.faint {
  color: var(--text-faint);
}

.nowrap {
  white-space: nowrap;
}

.spacer {
  flex: 1 1 auto;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(170%) blur(18px);
  backdrop-filter: saturate(170%) blur(18px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border-radius: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  color: #fff;
  background: linear-gradient(140deg, #5b55eb 10%, #8b5cf6 58%, #d946ef 110%);
  border-radius: 10px;
  box-shadow: 0 5px 14px rgba(79, 70, 229, 0.3);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  font-size: 16.5px;
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.brand-en {
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: 0.17em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  border-radius: 9px;
  transition: color 0.16s ease, background-color 0.16s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link svg {
  width: 15px;
  height: 15px;
}

.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px;
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    transform 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn-primary {
  color: #fff;
  background: #4f46e5;
  border-color: #4f46e5;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}

.btn-primary:hover {
  color: #fff;
  background: #4338ca;
  border-color: #4338ca;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}

.btn-soft {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
}

.btn-ghost {
  color: var(--text-soft);
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: transparent;
}

.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.icon-btn:disabled,
.icon-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn:disabled:hover,
.icon-btn[disabled]:hover {
  color: var(--text-faint);
  background: transparent;
  border-color: transparent;
}

.icon-btn.is-copied {
  color: var(--green);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
}

.label .hint,
.hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
}

.hint.is-over {
  font-weight: 600;
  color: var(--red);
}

.input,
.textarea,
.select {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.input,
.select {
  height: 44px;
  padding: 0 12px;
  font-size: 14px;
}

.select {
  padding-right: 34px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238d8e97' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}

.textarea {
  min-height: 140px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.65;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
  opacity: 0.78;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.input.is-invalid,
.textarea.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(211, 61, 67, 0.12);
}

.input-group {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.input-group .input {
  flex: 1;
}

textarea.code-area {
  min-height: 260px;
  font-family: var(--font-mono);
  font-size: 12.8px;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}

textarea.code-area.is-wrapped {
  white-space: pre-wrap;
  word-break: break-all;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="color"] {
  width: 46px;
  height: 44px;
  flex: none;
  padding: 4px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 6px;
}

input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 6px;
}

/* Custom switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background-color 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch input:disabled + .switch-track {
  opacity: 0.5;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.segmented button {
  height: 32px;
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"],
.segmented button.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.segmented.block {
  display: flex;
}

.segmented.block button {
  flex: 1;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 22px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs [role="tab"] {
  position: relative;
  flex: none;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: none;
  border: 0;
  transition: color 0.16s ease;
}

.tabs [role="tab"]::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform 0.18s ease;
}

.tabs [role="tab"]:hover {
  color: var(--text);
}

.tabs [role="tab"][aria-selected="true"] {
  color: var(--text);
}

.tabs [role="tab"][aria-selected="true"]::after {
  transform: scaleX(1);
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.chip[aria-pressed="true"] {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.chip.small {
  height: 28px;
  padding: 0 10px;
  font-size: 11.5px;
}

/* ---------- Hero ---------- */
.hero {
  padding-top: 78px;
  padding-bottom: 30px;
  text-align: center;
}

.hero-copy {
  max-width: 810px;
  margin-inline: auto;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  margin-bottom: 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
}

.pulse-dot {
  position: relative;
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
}

.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  background: rgba(16, 185, 129, 0.25);
  border-radius: 50%;
  animation: pulse 2.4s ease-out infinite;
}

.hero h1 {
  margin-bottom: 20px;
  font-size: clamp(40px, 6.4vw, 70px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.06;
}

.hero h1 .line {
  display: block;
}

.text-gradient {
  color: #4f46e5;
  background: linear-gradient(108deg, #4f46e5 4%, #7c3aed 42%, #0d9488 96%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .text-gradient {
  background: linear-gradient(108deg, #a5b4fc 4%, #c4b5fd 46%, #5eead4 98%);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-desc {
  max-width: 610px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-soft);
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 590px;
  height: 56px;
  padding: 0 10px 0 18px;
  margin: 32px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-shell:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring), var(--shadow-sm);
}

.search-shell > svg {
  width: 19px;
  height: 19px;
  flex: none;
  color: var(--text-faint);
}

.search-shell input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  font-size: 14.5px;
  background: transparent;
  border: 0;
  outline: none;
}

.search-shell input::-webkit-search-cancel-button {
  display: none;
}

.search-shell kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.hero-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px 18px;
  margin-top: 17px;
  font-size: 12px;
  color: var(--text-faint);
}

.hero-note span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hero-note svg {
  width: 13px;
  height: 13px;
  color: var(--green);
}

.hero-hot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.hero-hot a {
  padding: 3px 9px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.hero-hot a:hover {
  color: var(--accent-text);
  border-color: var(--accent);
}

/* ---------- Tools section ---------- */
.tools-section {
  padding-top: 54px;
  padding-bottom: 24px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.section-head h2 {
  margin-bottom: 5px;
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.section-head p {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.result-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.result-count strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 21px 21px 18px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: var(--shadow-xs);
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.tool-card::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, var(--tool-tint, rgba(99, 102, 241, 0.1)), transparent 68%);
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.tool-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.tool-card:hover::before {
  opacity: 1;
}

.tool-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  color: var(--tool-fg, var(--accent));
  background: var(--tool-bg, var(--accent-soft));
  border-radius: 13px;
}

.tool-icon svg {
  width: 22px;
  height: 22px;
}

.tool-tag {
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.tool-card h3 {
  margin: 17px 0 6px;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tool-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-soft);
}

.tool-card-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 17px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-faint);
  transition: color 0.2s ease, gap 0.2s ease;
}

.tool-card-link svg {
  width: 13px;
  height: 13px;
}

.tool-card:hover .tool-card-link {
  gap: 8px;
  color: var(--accent-text);
}

.empty-state {
  padding: 56px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 18px;
}

.empty-state svg {
  width: 30px;
  height: 30px;
  margin: 0 auto 12px;
  color: var(--text-faint);
}

.empty-state h3 {
  margin-bottom: 5px;
  font-size: 16px;
}

.empty-state p {
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-soft);
}

/* Feature band */
.feature-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 64px 0 72px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.feature {
  display: flex;
  gap: 14px;
  padding: 24px 22px;
  background: var(--surface);
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.feature-icon svg {
  width: 18px;
  height: 18px;
}

.feature h3 {
  margin: 1px 0 3px;
  font-size: 13.5px;
  font-weight: 700;
}

.feature p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-soft);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto;
  padding: 46px 0 26px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}

.footer-main {
  display: grid;
  grid-template-columns: 1.1fr 1.9fr;
  gap: 48px;
  padding-bottom: 34px;
}

.footer-brand .brand {
  margin-bottom: 12px;
}

.footer-brand p {
  max-width: 280px;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-soft);
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 22px;
  align-content: start;
}

.footer-links a {
  font-size: 12.5px;
  color: var(--text-soft);
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: var(--accent-text);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 20px;
  font-size: 11.5px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}

.footer-bottom .dot-sep {
  margin: 0 7px;
  opacity: 0.6;
}

/* ---------- Tool pages ---------- */
.tool-main {
  padding-top: 30px;
  padding-bottom: 80px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 22px;
  overflow: hidden;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

.breadcrumb a {
  color: var(--text-soft);
  transition: color 0.15s ease;
}

.breadcrumb a:hover {
  color: var(--accent-text);
}

.breadcrumb svg {
  width: 12px;
  height: 12px;
  flex: none;
  opacity: 0.65;
}

.breadcrumb span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 17px;
  margin-bottom: 26px;
}

.page-head .tool-icon {
  width: 54px;
  height: 54px;
  border-radius: 15px;
}

.page-head .tool-icon svg {
  width: 25px;
  height: 25px;
}

.page-head h1 {
  margin: 1px 0 6px;
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 780;
  letter-spacing: -0.035em;
}

.page-head p {
  max-width: 720px;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-soft);
}

.panel {
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.panel-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-title h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.panel-title p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

.panel-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.panel-kicker .pulse-dot {
  width: 6px;
  height: 6px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-18 {
  margin-top: 18px;
}

.mt-24 {
  margin-top: 24px;
}

/* Value / result lists */
.value-list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.value-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 47px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.value-row:last-child {
  border-bottom: 0;
}

.value-label {
  width: 74px;
  flex: none;
  font-size: 11.5px;
  color: var(--text-faint);
}

.value-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}

.value-row .icon-btn {
  margin: -5px -4px -5px 0;
}

.result-box {
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.result-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
}

.result-value {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.result-value.sm {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
}

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.alert svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
}

.alert-error {
  color: var(--red);
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 24%, transparent);
}

.alert-warn {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 26%, transparent);
}

.alert-info {
  color: var(--text-soft);
  background: var(--surface-2);
}

.alert-content {
  min-width: 0;
}

.alert-title {
  margin-bottom: 2px;
  font-weight: 700;
}

.alert code,
.alert pre {
  font-family: var(--font-mono);
}

.error-context {
  padding: 9px 11px;
  margin: 9px 0 0;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-soft);
  white-space: pre;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 0;
  font-size: 11.5px;
  color: var(--text-faint);
}

.meta-line strong {
  font-weight: 600;
  color: var(--text-soft);
}

.mini-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.mini-badge.is-ok {
  color: var(--green);
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 25%, transparent);
}

.mini-badge.is-bad {
  color: var(--red);
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 25%, transparent);
}

/* ---------- Timestamp ---------- */
.now-panel {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 24px;
  align-items: center;
  margin-bottom: 18px;
  background:
    linear-gradient(118deg, var(--surface) 42%, var(--accent-soft) 135%);
}

.big-ts {
  margin: 4px 0 8px;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: clamp(31px, 4.4vw, 43px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.now-ms-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.now-ms-row code {
  font-size: 11.5px;
  color: var(--text-soft);
}

.now-side {
  padding-left: 24px;
  border-left: 1px solid var(--border);
}

.live-clock {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.live-date {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.live-zone {
  margin: 9px 0 0;
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------- JSON ---------- */
.json-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.json-toolbar .switch {
  margin-left: 2px;
}

.json-toolbar .spacer {
  min-width: 10px;
}

.json-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.editor-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
  font-size: 12.5px;
  font-weight: 650;
}

.editor-head .btn-row {
  gap: 2px;
}

.editor-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  min-height: 18px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  vertical-align: 1px;
  background: var(--text-faint);
  border-radius: 50%;
}

.status-dot.ok {
  background: var(--green);
}

.status-dot.bad {
  background: var(--red);
}

#json-error {
  margin-top: 16px;
}

#json-error .error-context {
  color: var(--red);
}

/* ---------- Unit converter ---------- */
.unit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 20px;
}

.unit-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.unit-input,
.unit-result {
  display: flex;
  align-items: center;
  height: 58px;
  padding: 0 15px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.unit-input {
  width: 100%;
  outline: none;
}

.unit-input:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.unit-result {
  color: var(--accent-text);
  white-space: nowrap;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 18%, var(--border));
  overflow-x: auto;
  scrollbar-width: none;
}

.unit-result::-webkit-scrollbar {
  display: none;
}

.unit-select {
  height: 42px;
  font-size: 13px;
}

.swap-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin-top: 31px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  transition: color 0.16s ease, border-color 0.16s ease, transform 0.3s ease;
}

.swap-btn:hover {
  color: var(--accent-text);
  border-color: var(--accent);
  transform: rotate(180deg);
}

.swap-btn svg {
  width: 17px;
  height: 17px;
}

.unit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}

.unit-formula {
  font-family: var(--font-mono);
  color: var(--text-soft);
}

.conv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.conv-table th {
  padding: 0 10px 9px;
  font-size: 10.5px;
  font-weight: 650;
  color: var(--text-faint);
  text-align: left;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.conv-table th:last-child,
.conv-table td:last-child {
  text-align: right;
}

.conv-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

.conv-table tr:last-child td {
  border-bottom: 0;
}

.conv-table tbody tr {
  transition: background-color 0.14s ease;
}

.conv-table tbody tr:hover {
  background: var(--surface-2);
}

.conv-table tbody tr.is-target {
  background: var(--accent-soft);
}

.conv-table .unit-sym {
  margin-left: 5px;
  font-size: 11px;
  color: var(--text-faint);
}

.conv-table .conv-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---------- QR code ---------- */
.qr-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 420px);
  gap: 18px;
  align-items: start;
}

.qr-preview-panel {
  position: sticky;
  top: calc(var(--header-h) + 18px);
}

.qr-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 358px;
  padding: 24px;
  overflow: hidden;
  background-color: var(--surface-2);
  background-image: radial-gradient(var(--border-strong) 0.8px, transparent 0.8px);
  background-size: 13px 13px;
  border: 1px dashed var(--border-strong);
  border-radius: 15px;
}

.qr-canvas-box {
  display: none;
  width: 100%;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  line-height: 0;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
}

.qr-canvas-box.is-visible {
  display: block;
}

.qr-canvas-box canvas {
  width: 100%;
  height: auto;
}

.qr-placeholder {
  max-width: 220px;
  text-align: center;
  color: var(--text-faint);
}

.qr-placeholder svg {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  opacity: 0.5;
}

.qr-placeholder p {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
}

.qr-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 13px;
}

.qr-caption .meta-line {
  gap: 4px 10px;
}

.qr-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 13px;
}

.qr-actions .btn {
  width: 100%;
}

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

.qr-controls .field {
  margin-bottom: 0;
}

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

.color-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.color-field input[type="color"] {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--border);
}

.color-field input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  background: transparent;
  border: 0;
  outline: none;
}

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

.range-row input[type="range"] {
  flex: 1;
}

.range-value {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  height: 27px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
}

#qr-error {
  margin-top: 14px;
}

/* ---------- Color ---------- */
.color-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.swatch-hero {
  height: 132px;
  background: var(--swatch-checker);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.swatch-hero-inner {
  width: 100%;
  height: 100%;
  transition: background-color 0.16s ease;
}

.color-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.color-toolbar input[type="color"] {
  width: 46px;
  height: 44px;
}

.hex-input {
  flex: 1;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 16px;
}

@media (min-width: 561px) {
  .format-grid > .format-card:last-child {
    grid-column: span 2;
  }
}

.format-card {
  position: relative;
  min-width: 0;
  padding: 10px 38px 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.format-card .format-label {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.format-card .format-value {
  display: block;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.format-card .icon-btn {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
}

.palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
}

.palette {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
}

.palette button {
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.palette button:hover {
  z-index: 1;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px) scale(1.06);
}

.contrast-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.contrast-row .field {
  margin-bottom: 0;
}

.contrast-swap {
  width: 36px;
  height: 44px;
  padding: 0;
  color: var(--text-soft);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.contrast-swap:hover {
  color: var(--accent-text);
  border-color: var(--accent);
}

.contrast-swap svg {
  width: 16px;
  height: 16px;
  margin: auto;
}

.contrast-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.contrast-number {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.contrast-number strong {
  font-family: var(--font-mono);
  font-size: 43px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}

.contrast-number span {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
}

.grade-pill {
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 650;
  border-radius: 999px;
}

.grade-pill.good {
  color: var(--green);
  background: var(--green-soft);
}

.grade-pill.mid {
  color: var(--amber);
  background: var(--amber-soft);
}

.grade-pill.bad {
  color: var(--red);
  background: var(--red-soft);
}

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

.contrast-preview {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 108px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.contrast-preview .preview-large {
  font-size: 21px;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.contrast-preview .preview-small {
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.5;
  opacity: 0.9;
}

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

.wcag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  font-size: 11px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.wcag-item .verdict {
  font-weight: 700;
  color: var(--text-faint);
}

.wcag-item.pass {
  color: var(--green);
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 20%, transparent);
}

.wcag-item.pass .verdict {
  color: var(--green);
}

.contrast-note {
  margin: 12px 0 0;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--text-faint);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  font-size: 10.5px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.preset-chip:hover {
  border-color: var(--border-strong);
}

.preset-chip i {
  width: 9px;
  height: 9px;
  border: 1px solid var(--border);
  border-radius: 50%;
}

/* ---------- Text stats ---------- */
.text-input-panel textarea {
  min-height: 290px;
}

.text-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.editor-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 14px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}

.editor-footer strong {
  font-weight: 650;
  color: var(--text-soft);
}

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

.stat-card {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat-value {
  display: block;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.stat-label {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.stat-card.accent {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 18%, var(--border));
}

.stat-card.accent .stat-value {
  color: var(--accent-text);
}

.frequency-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.freq-row {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) 45px;
  gap: 9px;
  align-items: center;
  font-size: 11.5px;
}

.freq-char {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.freq-bar {
  height: 6px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 999px;
}

.freq-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.freq-count {
  color: var(--text-faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Base64 ---------- */
.code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.code-grid textarea {
  min-height: 250px;
}

.options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.code-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 19px;
  font-size: 11.5px;
  color: var(--text-faint);
}

#b64-error {
  margin-top: 14px;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 150px;
  padding: 24px;
  text-align: center;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-strong);
  border-radius: 13px;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.dropzone:hover,
.dropzone.is-drag {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.dropzone svg {
  width: 27px;
  height: 27px;
  color: var(--text-faint);
}

.dropzone strong {
  font-size: 13px;
  font-weight: 650;
}

.dropzone span {
  font-size: 11.5px;
  color: var(--text-faint);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.file-info svg {
  width: 16px;
  height: 16px;
  color: var(--text-faint);
}

.file-info .file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info .file-size {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.file-preview {
  max-width: 140px;
  max-height: 100px;
  object-fit: contain;
  border-radius: 6px;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.file-actions .btn:disabled {
  opacity: 0.45;
}

#b64-file-output {
  min-height: 170px;
}

/* ---------- URL ---------- */
.url-parts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.url-part {
  min-width: 0;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.url-part dt {
  margin-bottom: 2px;
  font-size: 9.5px;
  font-weight: 650;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.url-part dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
}

.query-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.query-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.query-table th,
.query-table td {
  padding: 9px 11px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.query-table th {
  font-size: 10px;
  font-weight: 650;
  color: var(--text-faint);
  background: var(--surface-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.query-table tr:last-child td {
  border-bottom: 0;
}

.query-table td {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.query-table td:first-child {
  width: 34%;
  color: var(--accent-text);
}

.query-empty {
  padding: 20px;
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

.url-error {
  margin-top: 14px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  font-size: 12.5px;
  font-weight: 500;
  color: #fff;
  background: #17171c;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  animation: toast-in 0.22s ease both;
}

.toast svg {
  width: 15px;
  height: 15px;
  flex: none;
}

[data-theme="dark"] .toast {
  color: #17171c;
  background: #f0f1f5;
}

.toast.is-error {
  color: #fff;
  background: #c7353b;
}

[data-theme="dark"] .toast.is-error {
  color: #fff;
  background: #c7353b;
}

.toast.is-leaving {
  animation: toast-out 0.18s ease both;
}

/* ---------- 404 ---------- */
.error-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--header-h) - 220px);
  padding-top: 72px;
  padding-bottom: 72px;
  text-align: center;
}

.error-code {
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: clamp(90px, 16vw, 150px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.08em;
  color: var(--text);
  background: linear-gradient(135deg, var(--text) 20%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.error-page h1 {
  margin-bottom: 8px;
  font-size: 24px;
}

.error-page p {
  max-width: 380px;
  margin: 0 auto 24px;
  font-size: 13.5px;
  color: var(--text-soft);
}

/* ---------- Animations ---------- */
@keyframes pulse {
  0% {
    opacity: 0.75;
    transform: scale(0.75);
  }
  70%,
  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

.hero-copy > * {
  animation: fade-up 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.hero-copy > *:nth-child(2) {
  animation-delay: 0.05s;
}

.hero-copy > *:nth-child(3) {
  animation-delay: 0.1s;
}

.hero-copy > *:nth-child(4) {
  animation-delay: 0.15s;
}

.hero-copy > *:nth-child(5) {
  animation-delay: 0.2s;
}

.tool-card {
  animation: fade-up 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.tool-card:nth-child(2) {
  animation-delay: 0.03s;
}

.tool-card:nth-child(3) {
  animation-delay: 0.06s;
}

.tool-card:nth-child(4) {
  animation-delay: 0.09s;
}

.tool-card:nth-child(5) {
  animation-delay: 0.12s;
}

.tool-card:nth-child(6) {
  animation-delay: 0.15s;
}

.tool-card:nth-child(7) {
  animation-delay: 0.18s;
}

.tool-card:nth-child(8) {
  animation-delay: 0.21s;
}

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qr-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}

@media (max-width: 900px) {
  .json-grid,
  .split,
  .color-layout,
  .code-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .qr-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .qr-preview-panel {
    position: static;
  }

  .footer-main {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .feature-band {
    grid-template-columns: 1fr;
    margin: 48px 0 56px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .container {
    padding-inline: 20px;
  }

  .hero {
    padding-top: 52px;
  }

  .hero h1 {
    letter-spacing: -0.04em;
  }

  .hero-desc {
    font-size: 14.5px;
  }

  .now-panel {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .now-side {
    padding: 16px 0 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .unit-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-top: 16px;
  }

  .swap-btn {
    margin: -2px auto;
    transform: rotate(90deg);
  }

  .swap-btn:hover {
    transform: rotate(270deg);
  }

  .unit-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .json-toolbar {
    gap: 10px;
  }

  .json-toolbar .spacer {
    display: none;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .tool-card {
    padding: 19px;
  }

  .footer-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .url-parts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .text-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .text-toolbar .btn-row {
    width: 100%;
  }

  .text-toolbar .btn-row .btn {
    flex: 1;
  }

  .page-head {
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .header-inner {
    gap: 10px;
  }

  .brand-en {
    display: none;
  }

  .brand-text {
    font-size: 15.5px;
  }

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

  .nav-link {
    padding: 0 8px;
  }

  .hero {
    padding: 44px 0 22px;
  }

  .hero h1 {
    font-size: clamp(34px, 10.5vw, 46px);
  }

  .hero-desc {
    padding-inline: 4px;
    font-size: 14px;
  }

  .eyebrow {
    margin-bottom: 19px;
    font-size: 11px;
  }

  .search-shell {
    height: 52px;
    padding-left: 15px;
    margin-top: 26px;
  }

  .search-shell kbd {
    display: none;
  }

  .hero-note {
    gap: 5px 12px;
  }

  .hero-hot {
    margin-top: 20px;
  }

  .tools-section {
    padding-top: 40px;
  }

  .tool-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tool-card p {
    min-height: 0;
  }

  .feature-band {
    margin: 42px 0 50px;
  }

  .panel {
    padding: 18px;
    border-radius: 16px;
  }

  .page-head h1 {
    font-size: 25px;
  }

  .page-head p {
    font-size: 12.5px;
  }

  .page-head .tool-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
  }

  .page-head .tool-icon svg {
    width: 22px;
    height: 22px;
  }

  .json-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
  }

  .json-toolbar > div:first-child {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .json-toolbar .segmented {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .json-toolbar .segmented button {
    flex: 1;
    padding: 0 8px;
    white-space: nowrap;
  }

  .json-toolbar .switch {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  .json-toolbar .spacer {
    display: none;
  }

  .json-toolbar .btn {
    width: auto;
    flex: none;
    grid-row: 2;
    padding: 0 13px;
  }

  .json-toolbar #json-format {
    grid-column: 2;
  }

  .json-toolbar #json-minify {
    grid-column: 3;
  }

  #indent-label {
    flex: none;
  }

  #json-input,
  #json-output {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .code-grid textarea {
    min-height: 180px;
  }

  .qr-controls,
  .color-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .color-toolbar {
    flex-wrap: wrap;
  }

  .color-toolbar .hex-input {
    min-width: 120px;
  }

  .format-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .palette {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .preview-pair,
  .wcag-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .url-parts {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-main {
    gap: 24px;
  }

  .footer-links {
    gap: 9px 16px;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }

  .breadcrumb {
    margin-bottom: 16px;
  }

  .tool-main {
    padding-top: 22px;
    padding-bottom: 56px;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-value {
    font-size: 18px;
  }

  .contrast-number strong {
    font-size: 37px;
  }

  .qr-actions {
    grid-template-columns: 1fr;
  }
}

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
