:root {
  --bg-1: #f3f6fb;
  --bg-2: #dbe8ff;
  --card: rgba(255, 255, 255, 0.92);
  --line: #b8c7e0;
  --text: #172236;
  --muted: #53627a;
  --accent: #2952cc;
  --accent-soft: #dde7ff;
  --visible-bg: #ffffff;
  --space-bg: #fff2c6;
  --space-text: #8a4a09;
  --control-bg: #d8e7ff;
  --control-text: #1849a9;
  --invisible-bg: #ebe4ff;
  --invisible-text: #5633b8;
  --empty-bg: #f9fbff;
  --shadow: 0 18px 50px rgba(19, 39, 84, 0.14);
  --font-ui: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at top left, rgba(41, 82, 204, 0.18), transparent 28rem),
    radial-gradient(circle at top right, rgba(10, 140, 118, 0.13), transparent 24rem),
    linear-gradient(180deg, var(--bg-2), var(--bg-1) 34rem);
}

.page-shell {
  min-height: 100vh;
  padding: 2rem 1rem 3rem;
}

.page-card {
  max-width: 1080px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid rgba(184, 199, 224, 0.8);
  border-radius: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.hero {
  padding: 2.4rem 2.2rem 1.2rem;
  border-bottom: 1px solid rgba(184, 199, 224, 0.7);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(221, 231, 255, 0.78)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4));
}

.eyebrow {
  margin: 0 0 0.7rem;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  max-width: 16ch;
  font-size: clamp(2rem, 4vw, 3.25rem);
}

h2 {
  font-size: 1.2rem;
}

.lede,
.section-copy,
.hint,
.legend,
.resource-list,
p,
li {
  line-height: 1.6;
}

.lede {
  max-width: 68ch;
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 1.04rem;
}

.panel {
  padding: 1.5rem 2.2rem 2rem;
}

.panel + .panel {
  border-top: 1px solid rgba(184, 199, 224, 0.65);
}

.field-label {
  display: inline-block;
  margin-bottom: 0.65rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 12rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  resize: vertical;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font: 500 1rem/1.55 var(--font-mono);
  box-shadow: inset 0 1px 2px rgba(23, 34, 54, 0.05);
}

textarea:focus {
  outline: 3px solid rgba(41, 82, 204, 0.18);
  border-color: var(--accent);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.72rem 1.15rem;
  font: 700 0.96rem/1 var(--font-ui);
  color: #fff;
  background: linear-gradient(135deg, #2457d6, #1a7f89);
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(36, 87, 214, 0.18);
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid rgba(41, 82, 204, 0.18);
}

.button-secondary {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: none;
}

.button-ghost {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(184, 199, 224, 0.85);
  box-shadow: none;
}

.hint,
.section-copy,
.legend,
.summary {
  color: var(--muted);
}

.hint {
  margin: 0.85rem 0 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-copy {
  margin: 0.35rem 0 0;
}

.summary {
  margin: 0;
  white-space: nowrap;
  font-weight: 700;
}

.output {
  min-height: 11rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 248, 255, 0.96)),
    linear-gradient(90deg, rgba(41, 82, 204, 0.02), rgba(86, 51, 184, 0.02));
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: default;
}

.output-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 9rem;
  border-radius: 0.8rem;
  background: var(--empty-bg);
  color: var(--muted);
  text-align: center;
  font-family: var(--font-ui);
}

.marker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.55rem;
  margin: 0 0.1rem;
  padding: 0.02rem 0.35rem;
  border-radius: 0.55rem;
  border: 1px solid transparent;
  font: 700 0.82rem/1.25 var(--font-mono);
  vertical-align: middle;
}

.marker.control {
  background: var(--control-bg);
  color: var(--control-text);
}

.marker.confusable {
  background: #ffe3cf;
  color: #8b3d0a;
}

.marker.invisible,
.marker.hex {
  background: var(--invisible-bg);
  color: var(--invisible-text);
}

.marker:hover,
.marker:focus-visible {
  z-index: 5;
  outline: none;
  border-color: rgba(23, 34, 54, 0.18);
  box-shadow: 0 10px 30px rgba(23, 34, 54, 0.14);
}

.tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.7rem);
  transform: translate(-50%, 0.25rem);
  width: max-content;
  min-width: 14rem;
  max-width: min(22rem, 70vw);
  padding: 0.75rem 0.85rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(31, 57, 125, 0.16);
  background: rgba(18, 26, 45, 0.97);
  color: #edf3ff;
  box-shadow: 0 18px 35px rgba(7, 11, 24, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.marker:hover .tooltip,
.marker:focus-visible .tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border-width: 0.5rem 0.5rem 0;
  border-style: solid;
  border-color: rgba(18, 26, 45, 0.97) transparent transparent;
}

.tooltip-row + .tooltip-row {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(237, 243, 255, 0.12);
}

.tooltip-key {
  display: block;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8fb0ff;
}

.tooltip-value {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.88rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.legend {
  margin: 1rem 0 0;
}

.legend-pill {
  display: inline-block;
  min-width: 2.2rem;
  margin: 0 0.1rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--invisible-bg);
  color: var(--invisible-text);
  font: 700 0.82rem/1.4 var(--font-mono);
  text-align: center;
}

@media (max-width: 760px) {
  .page-shell {
    padding: 1rem 0.6rem 2rem;
  }

  .hero,
  .panel {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }

  .section-heading {
    grid-template-columns: 1fr;
    display: grid;
  }

  .summary {
    white-space: normal;
  }

  .tooltip {
    left: 0;
    bottom: calc(100% + 0.55rem);
    transform: translate(0, 0.25rem);
    max-width: min(18rem, 85vw);
  }

  .marker:hover .tooltip,
  .marker:focus-visible .tooltip {
    transform: translate(0, 0);
  }

  .tooltip::after {
    left: 1.25rem;
    transform: none;
  }
}
