:root {
  color-scheme: light;
  --bg: #f7fbfa;
  --surface: #ffffff;
  --surface-soft: #edf6f3;
  --ink: #10201c;
  --muted: #61716c;
  --line: #d9e6e1;
  --teal: #057c70;
  --teal-dark: #075b54;
  --amber: #d9941e;
  --red: #b64a42;
  --shadow: 0 22px 62px rgba(28, 50, 44, 0.12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1715;
  --surface: #16221f;
  --surface-soft: #20312d;
  --ink: #edf7f4;
  --muted: #a5b7b1;
  --line: #31433e;
  --teal: #19a896;
  --teal-dark: #7de0d2;
  --amber: #f1b84b;
  --red: #ff8d82;
  --shadow: 0 22px 62px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 72%, transparent), transparent 380px),
    radial-gradient(circle at 84% 10%, color-mix(in srgb, var(--teal) 17%, transparent), transparent 340px),
    radial-gradient(circle at 68px 80px, color-mix(in srgb, var(--amber) 13%, transparent), transparent 190px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.app-shell { min-height: 100vh; padding: 16px; }
.topbar, .workspace, .tool-actions { max-width: 1440px; margin: 0 auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 0 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 12px rgba(32, 53, 47, 0.16));
}

.brand strong, .brand span { display: block; }
.brand strong { font-size: 28px; line-height: 1.05; }
.brand span span { margin-top: 5px; color: var(--muted); font-size: 14px; font-weight: 680; }

.site-nav, .tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.tool-actions { margin: -4px auto 12px; }

.site-nav > a, .tools-menu summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
  cursor: pointer;
}

.site-nav > a:hover, .tools-menu[open] summary, .tools-menu summary:hover { background: var(--surface-soft); }
.tools-menu { position: relative; }
.tools-menu summary { list-style: none; gap: 6px; }
.tools-menu summary::-webkit-details-marker { display: none; }
.tools-menu summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.tools-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 6px;
  width: min(340px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 8px;
}

.tools-panel a {
  display: grid;
  gap: 3px;
  border-radius: var(--radius);
  color: inherit;
  padding: 10px;
  text-decoration: none;
}

.tools-panel a:hover, .tools-panel a[aria-current="page"] { background: var(--surface-soft); }
.tools-panel strong, .tools-panel span { display: block; }
.tools-panel strong { font-size: 13px; }
.tools-panel span { color: var(--muted); font-size: 12px; line-height: 1.35; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.mode-panel, .tool-card, .panel {
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mode-panel {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 36px);
  overflow: hidden;
  padding: 12px;
}

.mode-panel::after {
  content: "";
  display: block;
  flex: 0 0 18px;
  margin: 0 -18px -18px;
  background: linear-gradient(180deg, transparent, var(--surface));
  pointer-events: none;
}

.panel-heading { display: grid; gap: 8px; margin-bottom: 16px; }
.panel-heading.inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1, h2, p { margin: 0; }
h1 { max-width: 320px; font-size: clamp(26px, 3vw, 36px); line-height: 1.05; }
h2 { font-size: 16px; }

.panel-heading p, .panel-heading span, .tool-heading p, .result-strip span, .input-field span, .field-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mode-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.mode-button {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 7px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.mode-button .mode-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--teal);
}

.mode-button svg { width: 20px; height: 20px; }
.mode-button strong, .mode-button span { display: block; }
.mode-button strong { font-size: 14px; }
.mode-button span:not(.mode-icon) { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.mode-button.is-active { border-color: color-mix(in srgb, var(--teal) 55%, var(--line)); background: color-mix(in srgb, var(--teal) 9%, var(--surface)); }
.mode-button.is-active .mode-icon { background: var(--teal); color: #fff; }

.tool-area { min-width: 0; }
.tool-card { padding: 16px; }
.tool-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.tool-heading h2 { font-size: clamp(20px, 2.4vw, 26px); line-height: 1.1; }

.question-preview {
  border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--amber) 11%, var(--surface));
  padding: 10px 12px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 780;
}

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

.input-field { display: grid; gap: 5px; }
.input-field.full { grid-column: 1 / -1; }
.input-field label { color: var(--muted); font-size: 12px; font-weight: 800; }

.input-field input, .input-field select, .input-field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-size: 16px;
  font-weight: 680;
}

.input-field textarea {
  min-height: 68px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

.number-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
}

.number-input-wrap input {
  border-radius: var(--radius) 0 0 var(--radius);
}

.stepper {
  display: grid;
  grid-template-rows: 1fr 1fr;
  min-width: 46px;
}

.stepper-button {
  display: grid;
  place-items: center;
  min-width: 46px;
  min-height: 21px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0;
  background: color-mix(in srgb, var(--surface-soft) 60%, var(--surface));
  color: var(--teal-dark);
  padding: 0;
}

.stepper-button:first-child {
  border-bottom: 0;
  border-radius: 0 var(--radius) 0 0;
}

.stepper-button:last-child {
  border-radius: 0 0 var(--radius) 0;
}

.stepper-button:hover {
  background: color-mix(in srgb, var(--teal) 12%, transparent);
}

.stepper-button svg {
  width: 22px;
  height: 22px;
  stroke-width: 3;
}

.result-strip {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  padding: 12px;
}

.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-strip span, .result-strip p { color: color-mix(in srgb, #fff 82%, var(--teal)); }
.result-strip strong { overflow-wrap: anywhere; font-size: clamp(28px, 4vw, 42px); line-height: 1; }
.result-strip p { max-width: 760px; line-height: 1.42; }
.copy-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.result-button {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 820;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.panel { padding: 12px; }
.steps-list { display: grid; gap: 8px; margin: 0; padding-left: 20px; }
.steps-list li { color: var(--muted); line-height: 1.45; }
.quick-grid, .recent-list { display: grid; gap: 7px; }

.quick-button, .recent-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.quick-button strong, .quick-button span, .recent-item strong, .recent-item span { display: block; }
.quick-button strong, .recent-item strong { font-size: 13px; }
.quick-button span, .recent-item span { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.about-panel p, .seo-panel p { color: var(--muted); line-height: 1.58; }

.about-note {
  margin-top: 10px;
  border-left: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  padding: 0;
  font-size: 12px;
  font-weight: 820;
}

.seo-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding: 18px 2px 8px;
}

.seo-panel h2 { margin-bottom: 10px; font-size: 20px; }
.seo-panel h3 { margin: 18px 0 6px; font-size: 16px; }
.seo-panel p + p { margin-top: 10px; }
.source-note { font-size: 13px; }
.is-empty { color: var(--muted); font-size: 13px; line-height: 1.45; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  max-width: 1440px;
  margin: 18px auto 0;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

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

.site-footer a {
  color: var(--teal-dark);
  font-weight: 760;
  text-decoration: none;
}

.ad-slot[hidden] {
  display: none;
}

.ad-slot.is-active {
  display: grid;
  place-items: center;
  min-height: 90px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, var(--surface-soft));
  color: var(--muted);
}

.ad-slot-leaderboard {
  max-width: 970px;
  margin: 0 auto 14px;
}

.ad-slot-result.is-active {
  min-height: 120px;
}

.related-tools {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

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

.related-tool-grid a {
  display: grid;
  gap: 5px;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: inherit;
  padding: 12px;
  text-decoration: none;
}

.related-tool-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 980px) {
  .topbar, .workspace { max-width: 760px; display: grid; }
  .workspace { grid-template-columns: 1fr; }
  .mode-panel { position: static; max-height: none; overflow: visible; }
  .mode-panel::after { display: none; }
  .mode-list { overflow: visible; padding-right: 0; }
  .support-grid, .input-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { padding: 12px; }
  .brand strong { font-size: 20px; }
  .brand span span { font-size: 12px; }
  .site-nav, .tool-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; }
  .icon-button { width: 100%; }
  .tool-card, .panel, .mode-panel { padding: 12px; }
  .question-preview { font-size: 16px; }
  .result-head { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .panel-heading { margin-bottom: 10px; }
  h1 { font-size: 26px; }
  .mode-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-button {
    grid-template-columns: 28px 1fr;
    min-height: 48px;
    padding: 8px;
  }
  .mode-button .mode-icon {
    width: 28px;
    height: 28px;
  }
  .mode-button span:not(.mode-icon) span {
    display: none;
  }
}

/* Layout rethink: task first, answer and steps in a right rail. */
.workspace {
  display: block;
}

.tool-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 370px);
  gap: 14px;
  align-items: start;
}

.tool-card {
  grid-column: 1;
  grid-row: 1;
}

.results-column {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.results-column .result-strip {
  position: static;
  margin-top: 0;
}

.results-column .panel {
  padding: 14px;
}

.tool-heading h1 {
  max-width: 600px;
  font-size: clamp(28px, 3.1vw, 42px);
  line-height: 1.03;
}

.tool-heading h2 {
  margin-top: 12px;
  color: var(--teal-dark);
  font-size: clamp(22px, 2.1vw, 30px);
}

.mode-panel {
  position: static;
  grid-column: 1;
  grid-row: 2;
  max-height: none;
  overflow: visible;
}

.mode-panel::after {
  display: none;
}

.mode-panel .panel-heading {
  grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
  align-items: end;
  gap: 12px;
}

.mode-panel .panel-heading h2 {
  font-size: 18px;
}

.mode-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-height: none;
  overflow: visible;
}

.support-grid,
.seo-panel {
  grid-column: 1 / -1;
}

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

@media (max-width: 1080px) {
  .tool-area {
    grid-template-columns: 1fr;
  }

  .tool-card,
  .results-column,
  .mode-panel,
  .support-grid,
  .seo-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .results-column {
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  }

  .results-column .result-strip {
    grid-row: 1 / span 2;
  }

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

@media (max-width: 760px) {
  .tool-area,
  .results-column,
  .support-grid,
  .mode-panel .panel-heading {
    grid-template-columns: 1fr;
  }

  .results-column .result-strip {
    grid-row: auto;
  }

  .tool-heading h1 {
    font-size: 28px;
  }

  .mode-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 300px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 3px;
  }

  .question-preview {
    padding: 10px;
    font-size: 15px;
  }

  .site-footer {
    flex-direction: column;
  }

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

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

  .input-grid {
    gap: 10px;
  }

  .input-field {
    gap: 5px;
    padding: 8px;
  }

  input,
  select {
    min-height: 42px;
  }
}
