*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@font-face {
  font-family: aliBaBa;
  src:
    url('https://oss.eventnet.cn/H5/zz/public/fonts/AlibabaPuHuiTi-3-55-Regular-s/AlibabaPuHuiTi-3-55-Regular-s.woff2')
      format('woff2'),
    url('https://oss.eventnet.cn/H5/zz/public/fonts/AlibabaPuHuiTi-3-55-Regular-s/AlibabaPuHuiTi-3-55-Regular-s.ttf')
      format('truetype');
  font-display: swap;
}

*,
input,
textarea {
  font-family:
    aliBaBa,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    'Open Sans',
    'Helvetica Neue',
    sans-serif;
}

textarea {
  resize: none;
}

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --accent: #4f46e5;
  --accent2: #7c3aed;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --success: #10b981;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(148, 163, 184, 0.2);
  --glow: 0 0 40px rgba(79, 70, 229, 0.15);
  --badge-bg: rgba(79, 70, 229, 0.1);
  --badge-border: rgba(79, 70, 229, 0.2);
  --badge-text: var(--accent);
  --h1-gradient: linear-gradient(135deg, #1e293b 0%, #4f46e5 50%, #7c3aed 100%);
  --tooltip-bg: rgba(255, 255, 255, 0.98);
  --tooltip-border: rgba(148, 163, 184, 0.28);
  --tooltip-text: #0f172a;
  --tooltip-shadow: 0 18px 40px rgba(148, 163, 184, 0.22), 0 4px 12px rgba(148, 163, 184, 0.12);
}

html.dark {
  --bg: #0d0f18;
  --surface: #141722;
  --surface2: #1c2032;
  --border: #2a2f47;
  --border-hover: #3d4566;
  --accent: #6c63ff;
  --accent2: #a259ff;
  --text: #e8eaf6;
  --text-muted: #7b82a8;
  --text-dim: #4a5080;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --badge-bg: rgba(108, 99, 255, 0.15);
  --badge-border: rgba(108, 99, 255, 0.35);
  --badge-text: #a09dff;
  --h1-gradient: linear-gradient(135deg, #e8eaf6 0%, #a09dff 50%, #c084fc 100%);
  --tooltip-bg: rgba(15, 23, 42, 0.98);
  --tooltip-border: rgba(148, 163, 184, 0.22);
  --tooltip-text: #f8fafc;
  --tooltip-shadow: 0 18px 40px rgba(0, 0, 0, 0.36), 0 4px 12px rgba(0, 0, 0, 0.16);
}

html {
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Background decoration ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(108, 99, 255, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 110%, rgba(162, 89, 255, 0.1) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.wrapper {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Header ── */
header {
  text-align: center;
  margin-bottom: 40px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  border-radius: 100px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--badge-text);
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}

h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  background: var(--h1-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
  max-width: 760px;
  margin: 0 auto;
  white-space: nowrap;
}

.subtitle code {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  color: var(--badge-text);
  font-family: 'Menlo', 'Consolas', monospace;
}

.range-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.range-panel .section-title {
  margin-bottom: 12px;
}

.range-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.range-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    background-color 0.2s ease;
}

.range-option:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.range-option input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.range-option-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.range-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.range-code {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Menlo', 'Consolas', monospace;
}

.range-option input:checked ~ .range-option-content .range-name {
  color: var(--accent);
}

.range-option input:checked ~ .range-option-content .range-code {
  color: var(--badge-text);
}

.range-note {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 12px;
}

.range-tooltip {
  position: fixed;
  z-index: 30;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--tooltip-border);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 12px;
  line-height: 1.6;
  box-shadow: var(--tooltip-shadow);
  backdrop-filter: blur(12px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.range-tooltip::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  transform: translateX(-50%) rotate(45deg);
  background: inherit;
  border-right: inherit;
  border-bottom: inherit;
  border-bottom-right-radius: 2px;
}

.range-tooltip.place-below::before {
  top: -6px;
  bottom: auto;
  border-right: none;
  border-bottom: none;
  border-left: inherit;
  border-top: inherit;
  border-bottom-right-radius: 0;
  border-top-left-radius: 2px;
}

.range-tooltip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.theme-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.3s;
  box-shadow: var(--shadow);
  z-index: 10;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color 0.3s;
}

.card:focus-within {
  border-color: var(--border-hover);
  box-shadow: var(--shadow), var(--glow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.char-count {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── Textarea ── */
textarea {
  width: 100%;
  min-height: 220px;
  padding: 20px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.8;
  resize: vertical;
  caret-color: var(--accent);
}

textarea::placeholder {
  color: var(--text-dim);
}

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

.stat-dot.green {
  background: var(--success);
}

.stat-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ── Action buttons ── */
.actions {
  display: flex;
  gap: 12px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  outline: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(108, 99, 255, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 16px;
}

/* ── Output area ── */
#output-section {
  display: none;
}
#output-section.visible {
  display: block;
}

.output-content {
  padding: 20px;
  font-size: 15px;
  line-height: 1.8;
  word-break: break-all;
  white-space: pre-wrap;
  min-height: 120px;
}

.highlight-bad {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 3px;
  padding: 0 2px;
  border-bottom: 2px solid var(--danger);
  cursor: help;
  position: relative;
  font-weight: 700;
  display: inline-block;
  animation: pulse-bad 1.5s ease-in-out infinite;
}

@keyframes pulse-bad {
  0%,
  100% {
    background: var(--danger-bg);
  }
  50% {
    background: rgba(255, 77, 109, 0.25);
  }
}

.highlight-fixed {
  color: var(--success);
  background: rgba(34, 211, 165, 0.12);
  border-radius: 3px;
  padding: 0 2px;
  border-bottom: 2px solid var(--success);
  cursor: help;
  font-weight: 700;
  display: inline-block;
}

/* ── Toast ── */
#toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--success);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  z-index: 999;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Character table ── */
.map-section {
  margin-top: 48px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.map-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s;
}

.map-item:hover {
  border-color: var(--border-hover);
}

.map-chars {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  flex-shrink: 0;
}

.map-arrow {
  font-size: 12px;
  color: var(--text-dim);
}

.map-bad {
  color: var(--danger);
}
.map-good {
  color: var(--success);
}

.map-meta {
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'Menlo', 'Consolas', monospace;
  line-height: 1.4;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 32px 0;
}

/* Responsive */
@media (max-width: 600px) {
  .subtitle {
    max-width: 100%;
    white-space: normal;
  }

  .actions {
    flex-direction: column;
  }
  .btn {
    width: 100%;
    justify-content: center;
  }
  .map-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .range-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) and (min-width: 601px) {
  .range-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Orange grid theme shared with the tools collection ── */
:root,
html.dark {
  color-scheme: light;
  --bg: #f6f5ef;
  --surface: rgba(255, 255, 255, 0.76);
  --surface2: rgba(246, 245, 239, 0.88);
  --border: #d9d7cc;
  --border-hover: #ff8d72;
  --accent: #ff5a36;
  --accent2: #ff784f;
  --danger: #e34f38;
  --danger-bg: rgba(227, 79, 56, 0.1);
  --success: #178354;
  --text: #202018;
  --text-muted: #77766d;
  --text-dim: #aaa89e;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 24px 70px rgba(53, 49, 35, 0.12);
  --glow: 0 0 0 4px #ffe4d9;
  --badge-bg: #ffe4d9;
  --badge-border: rgba(255, 90, 54, 0.2);
  --badge-text: #ff5a36;
  --h1-gradient: none;
  --tooltip-bg: rgba(255, 255, 255, 0.98);
  --tooltip-border: rgba(32, 32, 24, 0.14);
  --tooltip-text: #202018;
  --tooltip-shadow: 0 18px 40px rgba(53, 49, 35, 0.14);
}

body {
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 200, 91, 0.3), transparent 27rem),
    radial-gradient(circle at 88% 90%, rgba(255, 90, 54, 0.16), transparent 24rem),
    var(--bg);
  color: var(--text);
}

body::before {
  z-index: 0;
  background-image: linear-gradient(rgba(32, 32, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 32, 24, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.wrapper {
  max-width: 940px;
  padding-top: 54px;
}

header {
  margin-bottom: 32px;
  text-align: left;
}

.badge {
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1 {
  margin-bottom: 16px;
  color: var(--text);
  background: none;
  font-family: Georgia, 'Songti SC', serif;
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 500;
  letter-spacing: -0.05em;
  -webkit-text-fill-color: currentColor;
}

.subtitle {
  max-width: 760px;
  margin: 0;
  line-height: 1.8;
  white-space: normal;
}

.range-panel,
.card {
  border-color: rgba(32, 32, 24, 0.12);
  background: var(--surface);
  backdrop-filter: blur(16px);
}

.range-option {
  background: rgba(255, 255, 255, 0.54);
}

.range-option:has(input:checked) {
  border-color: rgba(255, 90, 54, 0.32);
  background: var(--badge-bg);
}

.btn-primary {
  background: var(--accent);
  box-shadow: 0 7px 20px rgba(255, 90, 54, 0.25);
}

.btn-primary:hover {
  background: #e94827;
  box-shadow: 0 10px 26px rgba(255, 90, 54, 0.32);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.7);
}

#toast {
  color: var(--success);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

@media (max-width: 600px) {
  .wrapper {
    padding: 30px 10px 44px;
  }

}
