:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #0f766e;
  --accent: #db2777;
  --warning: #d97706;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #b42318;
  --success: #047857;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 2000;
  transform: translateY(-160%);
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(12px);
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.nav-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 18px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #ef4444 0 25%, #f59e0b 25% 50%, #22c55e 50% 75%, #3b82f6 75% 100%);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.brand-mark i {
  text-shadow: 0 1px 4px rgba(15, 23, 42, 0.4);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.nav-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 8px;
  padding: 0 11px;
  color: #334155;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: #eff6ff;
  color: var(--primary);
}

.mobile-menu-button {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.page-main {
  padding: 32px 0 48px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: 30px;
  line-height: 1.25;
}

.page-description {
  margin: 12px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 15px;
}

.section {
  margin-top: 24px;
}

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

.section-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.section-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.category-bar,
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.category-btn,
.filter-btn {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  background: #e2e8f0;
  color: #334155;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.category-btn:hover,
.filter-btn:hover {
  transform: translateY(-1px);
}

.category-btn.active,
.filter-btn.active {
  background: var(--primary);
  color: #fff;
}

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

.tool-card {
  min-height: 148px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
}

.tool-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  font-size: 18px;
}

.tool-title {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.tool-desc {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.home-tool-grid .tool-card {
  min-height: 72px;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.home-tool-grid .tool-card > div {
  min-width: 0;
}

.search-panel,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.input,
.select {
  height: 40px;
  padding: 0 11px;
}

.textarea {
  min-height: 140px;
  padding: 11px;
  resize: vertical;
  font-family: Menlo, Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
  line-height: 1.6;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  padding: 0 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}

.button:hover {
  border-color: #94a3b8;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.secondary {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.1);
  color: var(--secondary);
}

.button.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.tool-page {
  max-width: 980px;
}

.tool-shell {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.tool-card-head .tool-icon {
  margin: 0;
}

.tool-card-title {
  margin: 0;
  font-size: 21px;
  line-height: 1.3;
}

.tool-root {
  min-height: 360px;
  padding: 18px;
}

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

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

.tool-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.tool-field label {
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-output {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

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

.metric {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

button.metric {
  width: 100%;
  cursor: pointer;
  text-align: left;
  appearance: none;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.color-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 16px 0;
}

.color-category {
  margin-top: 22px;
}

.color-category h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 18px;
}

.category-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.color-card {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  appearance: none;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.04);
}

.color-card:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

.color-swatch {
  height: 76px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.color-info {
  min-height: 86px;
  padding: 10px;
}

.color-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.color-value,
.color-extra {
  margin-top: 3px;
  color: var(--muted);
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
}

.preview-box {
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  color: #fff;
  text-align: center;
  font-weight: 800;
}

.preview-box span {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.35);
}

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

.scheme-swatch,
.palette-swatch {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  border: 0;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 2px 8px rgba(15, 23, 42, 0.08);
}

.scheme-swatch strong,
.palette-swatch strong {
  font-size: 13px;
}

.scheme-swatch span,
.palette-swatch span {
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
}

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

.content-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.content-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.content-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 11px 10px;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  color: #475569;
  background: var(--surface-soft);
  font-weight: 850;
}

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

.inline-swatch {
  width: 30px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 4px;
}

.empty-box,
.tool-loading,
.tool-message {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.tool-message.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 2400;
  max-width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 10px 13px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
  font-size: 13px;
}

.sponsor-image-ad {
  display: block;
  max-width: 720px;
  overflow: hidden;
  margin: 24px auto 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  text-decoration: none;
}

.sponsor-image-ad img {
  display: block;
  width: 100%;
  height: auto;
}

.sponsor-image-ad:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 3px;
}

.site-footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  padding: 28px 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.footer-links a {
  color: #475569;
  font-size: 13px;
  text-decoration: none;
}

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

.copyright {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

[hidden],
.d-none {
  display: none !important;
}

@media (max-width: 1050px) {
  .tool-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .nav-links {
    position: fixed;
    inset: 64px 12px auto 12px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
    box-shadow: var(--shadow);
  }

  .nav-links.active {
    display: flex;
  }

  .nav-link {
    justify-content: flex-start;
  }

  .mobile-menu-button {
    display: inline-flex;
  }

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

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

  .tool-row,
  .search-form,
  .color-toolbar {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .container {
    width: min(100% - 22px, 1120px);
  }

  .page-main {
    padding-top: 22px;
  }

  .page-title {
    font-size: 25px;
  }

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

  .tool-card {
    min-height: 132px;
    padding: 12px;
  }

  .tool-icon {
    width: 38px;
    height: 38px;
  }

  .content-grid,
  .color-grid,
  .metric-grid,
  .swatch-list {
    grid-template-columns: 1fr;
  }

  .color-swatch {
    height: 66px;
  }

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

  .button {
    width: 100%;
  }
}
