:root {
  --bg: #f4efe6;
  --bg-2: #fdfaf4;
  --ink: #152235;
  --muted: #5f6d82;
  --line: rgba(21, 34, 53, 0.12);
  --line-strong: rgba(21, 34, 53, 0.2);
  --card: rgba(255, 252, 246, 0.84);
  --card-strong: #ffffff;
  --accent: #0f766e;
  --accent-2: #dc5f3c;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --shadow: 0 24px 64px rgba(17, 32, 59, 0.12);
  --radius: 24px;
  --radius-sm: 16px;
  --content-width: 1240px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at top left, rgba(220, 95, 60, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 30%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

.site-shell {
  min-height: 100vh;
}

.site-header,
.site-footer,
.page {
  padding-inline: 20px;
}

.site-header__inner,
.site-footer__inner,
.hero,
.catalog,
.tool-hero,
.tool-layout,
.page--narrow {
  width: min(100%, var(--content-width));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(253, 250, 244, 0.78);
  border-bottom: 1px solid rgba(21, 34, 53, 0.08);
}

.site-header__inner {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding-block: 10px;
}

.brand {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

.brand__mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: white;
  font-size: 1.35rem;
  font-weight: 800;
  text-transform: lowercase;
  background: linear-gradient(135deg, var(--accent), #194f7f);
  box-shadow: var(--shadow);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.site-nav--compact {
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
}

.site-nav__link,
.chip,
.chip--static {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  color: var(--ink);
  transition: 160ms ease;
}

.site-nav__compact-link,
.site-nav__current,
.site-nav__menu summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}

.site-nav__current {
  color: var(--muted);
}

.site-nav__menu {
  position: relative;
}

.site-nav__menu summary {
  cursor: pointer;
  list-style: none;
}

.site-nav__menu summary::-webkit-details-marker {
  display: none;
}

.site-nav__popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  gap: 8px;
  width: min(480px, calc(100vw - 32px));
  max-height: 60vh;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 252, 246, 0.98);
  box-shadow: var(--shadow);
}

.site-nav__popover .site-nav__link {
  justify-content: flex-start;
}

.site-nav__link:hover,
.chip:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.site-nav__link[aria-current="page"],
.chip.is-active {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #194f7f);
}

.page {
  padding-block: 22px 48px;
}

.hero,
.tool-hero {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  align-items: stretch;
}

.hero__copy,
.hero__panel,
.tool-hero__copy,
.tool-hero__aside,
.tool-panel,
.side-card,
.tool-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.hero__copy,
.tool-hero__copy {
  position: relative;
  overflow: hidden;
  padding: 32px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(255, 252, 246, 0.82)),
    var(--card);
}

.hero__copy::after,
.tool-hero__copy::after {
  content: "";
  position: absolute;
  inset: auto -40px -70px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.18), transparent 70%);
}

.hero__panel,
.tool-hero__aside {
  padding: 26px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

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

h1 {
  font-size: clamp(2.3rem, 5vw, 4.4rem);
}

h2 {
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.hero__copy p,
.tool-hero__copy p {
  max-width: 60ch;
  margin-top: 16px;
  font-size: 1.05rem;
}

.hero__hint {
  margin-top: 14px;
  font-size: 0.92rem;
}

.catalog {
  margin-top: 28px;
}

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

.tool-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.tool-card {
  overflow: hidden;
}

.tool-card__link {
  display: block;
  height: 100%;
  padding: 24px;
  text-decoration: none;
}

.tool-card__eyebrow {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.tool-card h2 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

.tool-card__features,
.bullet-list {
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--ink);
}

.tool-card__features li,
.bullet-list li {
  margin-top: 8px;
}

.tool-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.74fr);
  margin-top: 24px;
}

.tool-panel,
.side-card {
  padding: 24px;
}

.tool-root {
  display: grid;
  gap: 18px;
}

.stack {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-strong);
}

.panel h2,
.panel h3 {
  margin-bottom: 10px;
}

.panel p + p {
  margin-top: 10px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.field {
  display: grid;
  gap: 8px;
  align-content: start;
}

.field > span,
.fieldset__title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 160px;
  resize: vertical;
}

#qr-text {
  min-height: 96px;
}

.qr-builder {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr);
  align-items: start;
}

.calc-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.9fr);
  align-items: start;
}

.calc-panel {
  gap: 14px;
}

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

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

.calc-keypad button,
.calc-memory button,
.calc-quick-actions button {
  min-height: 44px;
}

.calc-keypad__operator {
  border-color: rgba(15, 118, 110, 0.18);
  background: rgba(15, 118, 110, 0.08);
}

.calc-keypad__equals {
  background: linear-gradient(135deg, var(--accent-2), #b94a2b);
  color: white;
  border-color: transparent;
}

.qr-builder__settings {
  align-content: start;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  border-radius: 6px;
  vertical-align: middle;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.button-row,
.chip-row,
.hero-metadata,
.inline-list,
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.button,
button {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #194f7f);
  color: white;
}

.button--secondary,
button.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: white;
}

.button--ghost,
button.ghost {
  color: var(--muted);
  border-color: var(--line);
  background: transparent;
}

.result,
.code-block,
.stats,
.list-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(244, 247, 250, 0.75);
}

.result strong,
.stats strong {
  display: block;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--ink);
}

.stats strong {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.result pre,
.code-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.92rem;
}

.stats-grid,
.output-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.stat {
  padding: 14px;
  border-radius: 16px;
  background: white;
  border: 1px solid var(--line);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat strong {
  margin-top: 6px;
  font-size: 1.2rem;
}

.helper {
  color: var(--muted);
  font-size: 0.9rem;
}

.notice {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(220, 95, 60, 0.18);
  background: rgba(220, 95, 60, 0.08);
  color: #8a3f2a;
}

.success {
  border-color: rgba(15, 118, 110, 0.18);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-builder__wrap {
  overflow-x: auto;
}

.table-builder__table {
  min-width: 720px;
}

.table-builder__table th,
.table-builder__table td {
  min-width: 180px;
}

.table-builder__table .field {
  min-width: 160px;
}

.table-builder__cell,
.table-builder__table select {
  min-height: 42px;
  padding: 10px 12px;
}

.table th,
.table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

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

.mini-list {
  display: grid;
  gap: 10px;
}

.mini-list a {
  text-decoration: none;
  color: var(--ink);
}

.tool-sidebar {
  display: grid;
  gap: 18px;
  align-content: start;
}

.side-card h2 {
  margin-bottom: 12px;
}

.site-footer {
  padding-bottom: 32px;
}

.site-footer__inner {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.hero-metadata {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-state {
  max-width: 620px;
  margin: 80px auto 0;
  padding: 32px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.preview {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 220px;
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.7);
}

.sql-preview {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
}

.sql-token--keyword {
  color: var(--accent);
  font-weight: 700;
}

.sql-token--string,
.sql-token--placeholder {
  color: var(--accent-2);
}

.sql-token--comment {
  color: var(--muted);
  font-style: italic;
}

.sql-token--number {
  color: #194f7f;
}

.sql-insight-list {
  display: grid;
  gap: 12px;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 32, 59, 0.22);
  backdrop-filter: blur(4px);
}

.busy-overlay__card {
  display: grid;
  justify-items: center;
  gap: 14px;
  min-width: min(92vw, 320px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 252, 246, 0.98);
  box-shadow: var(--shadow);
  text-align: center;
}

.busy-overlay__spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(21, 34, 53, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.site-nav__popover--compact {
  width: 180px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.bmi-visual {
  display: grid;
  gap: 18px;
}

.bmi-input-grid {
  grid-template-columns: minmax(220px, 1.2fr) minmax(140px, 0.7fr) minmax(140px, 0.7fr);
  align-items: start;
}

.bmi-input-grid input,
.bmi-input-grid select {
  min-height: 42px;
  padding: 10px 12px;
}

.bmi-scale {
  position: relative;
  padding-top: 42px;
}

.bmi-scale__segments {
  display: grid;
  grid-template-columns: 28fr 22fr 17fr 33fr;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.bmi-scale__segment {
  display: grid;
  min-height: 48px;
  place-items: center;
  font-size: 0.86rem;
  font-weight: 700;
  color: #102033;
}

.bmi-scale__segment--under {
  background: #cfe8ff;
}

.bmi-scale__segment--healthy {
  background: #cfeecf;
}

.bmi-scale__segment--over {
  background: #ffe3b3;
}

.bmi-scale__segment--obese {
  background: #ffc9bf;
}

.bmi-scale__marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 6px;
}

.bmi-scale__marker strong {
  padding: 4px 10px;
  border-radius: 999px;
  background: #102033;
  color: white;
  font-size: 0.85rem;
  line-height: 1;
}

.bmi-scale__pin {
  width: 2px;
  height: 34px;
  background: #102033;
}

.preview canvas,
.preview img,
.preview svg {
  max-width: 100%;
  max-height: 420px;
}

.screen-test {
  display: grid;
  gap: 16px;
}

.screen-test__controls {
  align-items: end;
}

.inline-check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  color: var(--ink);
  font-size: 0.92rem;
}

.screen-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: clamp(320px, 58vh, 720px);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #000;
  cursor: pointer;
  outline: none;
  user-select: none;
}

.screen-stage:focus {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.screen-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.screen-stage--hide-cursor {
  cursor: none;
}

.screen-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.screen-stage__hud {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: min(520px, calc(100% - 28px));
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.68);
  color: white;
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-flasher {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.32);
  cursor: grab;
  transform: translate(-50%, -50%);
  animation: screen-flasher 480ms steps(1, end) infinite;
  touch-action: none;
}

.screen-flasher:active {
  cursor: grabbing;
}

.screen-test__stats .stat strong {
  font-size: 1rem;
  line-height: 1.25;
}

@keyframes screen-flasher {
  0% { background: #ffffff; }
  16% { background: #ff0000; }
  32% { background: #00ff00; }
  48% { background: #0000ff; }
  64% { background: #000000; }
  80% { background: #ffff00; }
  100% { background: #ffffff; }
}

.response-test {
  display: grid;
  gap: 16px;
}

.response-test__controls {
  align-items: end;
}

.response-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: clamp(240px, 42vh, 520px);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #777d84;
}

.response-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.response-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.response-stage__overlay {
  position: absolute;
  right: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(11, 15, 20, 0.72);
  color: white;
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.response-test__stats .stat strong {
  font-size: 1.05rem;
  line-height: 1.25;
}

.response-guide .result {
  display: grid;
  gap: 8px;
}

.response-guide .result strong {
  font-size: 1.05rem;
}

.response-guide .helper {
  margin: 0;
}

.list-reset {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-reset li + li {
  margin-top: 10px;
}

.reorder-list {
  display: grid;
  gap: 10px;
}

.reorder-item {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(21, 34, 53, 0.08);
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 1024px) {
  .hero,
  .tool-hero,
  .tool-layout {
    grid-template-columns: 1fr;
  }

  .site-header__inner,
  .section-heading,
  .site-footer__inner {
    flex-direction: column;
    align-items: stretch;
  }

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

  .site-nav--compact {
    justify-content: space-between;
  }
}

@media (max-width: 720px) {
  .site-header__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .page,
  .site-header,
  .site-footer {
    padding-inline: 14px;
  }

  .hero__copy,
  .hero__panel,
  .tool-hero__copy,
  .tool-hero__aside,
  .tool-panel,
  .side-card,
  .empty-state {
    padding: 20px;
  }

  .grid.two,
  .grid.three,
  .grid.five {
    grid-template-columns: 1fr;
  }

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

  .bmi-input-grid {
    grid-template-columns: 1fr;
  }

  .calc-layout {
    grid-template-columns: 1fr;
  }

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

  .calc-memory,
  .calc-quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-nav--compact {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
  }

  .site-nav__compact-link,
  .site-nav__menu summary {
    min-height: 32px;
    padding: 0 9px;
    font-size: 0.82rem;
  }

  .site-nav__menu {
    position: static;
  }

  .site-nav__popover {
    position: fixed;
    top: 66px;
    left: 14px;
    right: 14px;
    width: auto;
    max-width: none;
    max-height: min(70vh, calc(100vh - 90px));
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3.1rem);
  }

  .brand {
    min-width: 0;
    gap: 10px;
  }

  .brand strong {
    font-size: 0.92rem;
    line-height: 1.1;
  }

  .brand span:last-child {
    display: none;
  }

  .site-nav__current {
    display: none;
  }

  .table-builder__table {
    min-width: 560px;
  }
}
