:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --ink: #202124;
  --muted: #626773;
  --line: rgba(32, 33, 36, 0.13);
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --panel-soft: #eef3ef;
  --field: rgba(251, 252, 250, 0.94);
  --green: #237a57;
  --blue: #246bdb;
  --coral: #c45b42;
  --gold: #ad7b18;
  --violet: #7259c9;
  --ink-soft: #30343a;
  --warn: #9b4d18;
  --shadow: 0 24px 60px rgba(39, 45, 48, 0.13);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418;
  --ink: #f4f7f5;
  --muted: #a9b1bd;
  --line: rgba(244, 247, 245, 0.14);
  --panel: rgba(24, 28, 34, 0.88);
  --panel-solid: #181c22;
  --panel-soft: #20262d;
  --field: rgba(15, 18, 22, 0.86);
  --green: #58d59b;
  --blue: #83aefe;
  --coral: #ff9b82;
  --gold: #f3bd62;
  --violet: #b8a5ff;
  --ink-soft: #e9edf1;
  --warn: #ffba73;
  --shadow: 0 28px 74px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 86px;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, color-mix(in srgb, var(--ink) 4%, transparent) 1px, transparent 1px),
    linear-gradient(135deg, color-mix(in srgb, var(--bg) 85%, #fff) 0%, var(--bg) 50%, color-mix(in srgb, var(--bg) 78%, var(--blue)) 100%);
  background-size: 44px 44px, 44px 44px, auto;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  transition: background 220ms ease, color 220ms ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    repeating-linear-gradient(115deg, transparent 0 54px, color-mix(in srgb, var(--blue) 9%, transparent) 54px 55px),
    repeating-linear-gradient(25deg, transparent 0 72px, color-mix(in srgb, var(--coral) 8%, transparent) 72px 73px);
  animation: backgroundSlide 24s linear infinite;
}

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

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

button {
  -webkit-tap-highlight-color: transparent;
}

textarea,
.output-input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  padding: 13px 14px;
}

textarea {
  resize: vertical;
}

textarea:focus,
.output-input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent);
}

.topbar,
main,
.footer {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.brand img {
  display: block;
  filter: drop-shadow(0 8px 18px rgba(32, 33, 36, 0.16));
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.nav a {
  border-radius: 8px;
  padding: 8px 10px;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav a:hover,
.nav a:focus-visible {
  background: color-mix(in srgb, var(--blue) 15%, transparent);
  color: var(--blue);
  transform: translateY(-1px);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.theme-toggle-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: currentColor;
}

:root[data-theme="light"] .theme-toggle-icon::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--panel-solid);
}

:root[data-theme="dark"] .theme-toggle-icon {
  box-shadow:
    0 -9px 0 -7px currentColor,
    0 9px 0 -7px currentColor,
    -9px 0 0 -7px currentColor,
    9px 0 0 -7px currentColor,
    7px 7px 0 -7px currentColor,
    -7px -7px 0 -7px currentColor,
    7px -7px 0 -7px currentColor,
    -7px 7px 0 -7px currentColor;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.98fr) minmax(360px, 0.82fr);
  gap: 34px;
  align-items: center;
  min-height: calc(100vh - 66px);
  padding: 52px 0 42px;
}

.hero-copy {
  animation: riseIn 720ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 18px;
  font-size: clamp(44px, 7vw, 92px);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(30px, 4.4vw, 54px);
  line-height: 1.02;
}

h3 {
  margin-bottom: 0;
  font-size: clamp(22px, 2.2vw, 30px);
  line-height: 1.08;
}

.hero-lede {
  max-width: 710px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(19px, 2vw, 25px);
  font-weight: 670;
  line-height: 1.22;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero-visual {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111418;
  box-shadow: var(--shadow);
  animation: visualIn 820ms cubic-bezier(0.2, 0.8, 0.2, 1) 80ms both;
}

.hero-visual canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
}

.visual-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: end;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(17, 20, 24, 0.76);
  color: #f7faf5;
  padding: 16px;
  backdrop-filter: blur(14px);
}

.visual-panel span,
.visual-panel small {
  color: rgba(247, 250, 245, 0.68);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.visual-panel strong {
  grid-row: span 2;
  color: #9be3bf;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 22px;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0 0 28px;
}

.quick-stats article,
.tool-command {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(42, 48, 43, 0.07);
}

.quick-stats article {
  min-height: 112px;
  padding: 18px;
}

.quick-stats strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 30px;
  line-height: 1;
}

.quick-stats span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.tool-command {
  display: grid;
  grid-template-columns: minmax(220px, 0.28fr) minmax(280px, 1fr);
  gap: 24px;
  align-items: start;
  padding: 24px;
  margin-bottom: 34px;
}

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

.tool-map a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
  font-size: 14px;
  font-weight: 780;
  padding: 8px;
  text-align: center;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.tool-map a:hover,
.tool-map a:focus-visible {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 14%, transparent);
  color: var(--blue);
  transform: translateY(-1px);
}

.tool-section {
  border-top: 1px solid var(--line);
  padding: 64px 0 10px;
}

.section-heading {
  margin-bottom: 20px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 10px 0 40px;
}

.tool-panel {
  position: relative;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.tool-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-top: 5px solid var(--panel-accent, var(--green));
  background:
    linear-gradient(125deg, color-mix(in srgb, #fff 32%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--panel-accent, var(--green)) 8%, transparent), transparent 44%);
  pointer-events: none;
}

.tool-panel > * {
  position: relative;
  z-index: 1;
}

.tool-panel:hover,
.tool-panel:focus-within {
  border-color: color-mix(in srgb, var(--panel-accent, var(--green)) 65%, var(--line));
  box-shadow: 0 30px 74px rgba(39, 45, 48, 0.16);
  transform: translateY(-4px);
}

.tool-panel.wide {
  grid-column: 1 / -1;
}

.accent-a { --panel-accent: var(--green); }
.accent-b { --panel-accent: var(--blue); }
.accent-c { --panel-accent: var(--coral); }
.accent-d { --panel-accent: var(--gold); }
.accent-e { --panel-accent: var(--violet); }

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.button-row,
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.small-button,
.icon-button,
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 820;
  padding: 8px 12px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.small-button:hover,
.small-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible,
.secondary-action:hover,
.secondary-action:focus-visible {
  border-color: var(--panel-accent, var(--blue));
  background: color-mix(in srgb, var(--panel-accent, var(--blue)) 13%, var(--panel-solid));
  color: color-mix(in srgb, var(--panel-accent, var(--blue)) 80%, var(--ink));
  transform: translateY(-1px);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.primary-action {
  width: 100%;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.primary-action:hover,
.primary-action:focus-visible {
  background: color-mix(in srgb, var(--green) 82%, #000);
  transform: translateY(-1px);
}

.secondary-action {
  background: var(--panel);
}

.link-action {
  width: auto;
  min-width: 128px;
}

.primary-action.compact {
  width: fit-content;
}

.two-col,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

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

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

.result-strip span,
.result-box,
.markdown-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.result-strip strong {
  display: block;
  color: color-mix(in srgb, var(--panel-accent, var(--green)) 78%, var(--ink));
  font-size: 25px;
  line-height: 1.1;
}

.status {
  min-height: 21px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.status.is-error {
  color: var(--warn);
  font-weight: 800;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 800;
}

input[type="range"],
.check-grid input {
  accent-color: var(--green);
}

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

.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 10px;
  color: var(--muted);
  font-weight: 750;
}

.color-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
}

input[type="color"] {
  width: 74px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  cursor: pointer;
  padding: 4px;
}

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

.swatch-grid button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.markdown-preview {
  min-height: 240px;
  overflow: auto;
  color: var(--ink);
  font-weight: 500;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 14px 0 8px;
  font-size: 24px;
}

.markdown-preview p,
.markdown-preview li {
  color: var(--muted);
}

.markdown-preview code {
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  padding: 2px 5px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 28px 0 38px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 740;
}

.footer a {
  color: var(--blue);
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 640ms ease, transform 640ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes backgroundSlide {
  from { background-position: 0 0, 0 0; }
  to { background-position: 240px 120px, -180px 220px; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes visualIn {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr auto;
    align-items: start;
    padding: 14px 0;
  }

  .nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .hero,
  .tool-command,
  .tool-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-visual,
  .hero-visual canvas {
    min-height: 420px;
  }

  .quick-stats,
  .result-strip,
  .tool-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar,
  main,
  .footer {
    width: min(100% - 24px, 1240px);
  }

  .hero {
    padding-top: 34px;
  }

  h1 {
    font-size: 42px;
  }

  .hero-lede {
    font-size: 18px;
  }

  .quick-stats,
  .result-strip,
  .check-grid,
  .swatch-grid,
  .tool-map,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .tool-command,
  .tool-panel {
    padding: 16px;
  }

  .panel-heading,
  .footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .color-row {
    grid-template-columns: 1fr;
  }

  input[type="color"] {
    width: 100%;
  }
}
