:root {
  --bg: #f7f7f3;
  --surface: #ffffff;
  --ink: #161716;
  --muted: #686a62;
  --line: #dfded4;
  --soft: #edf3ef;
  --accent: #0f6b5c;
  --accent-dark: #0b4e43;
  --danger: #a83b2d;
  --shadow: 0 22px 50px rgba(25, 27, 22, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, white);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 18px;
  top: 12px;
  z-index: 100;
  transform: translateY(-140%);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 9px 12px;
  text-decoration: none;
  transition: transform 160ms ease;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(18px, 4vw, 50px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 243, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 23px;
  font-style: italic;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
}

.site-nav a {
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 7px;
}

.site-nav a:hover {
  background: var(--soft);
  color: var(--ink);
}

main {
  width: min(1240px, calc(100vw - 34px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.tool-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 780;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 830px;
  margin-bottom: 14px;
  font-size: clamp(38px, 5vw, 70px);
  line-height: 0.94;
  font-weight: 850;
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.quick-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 250px;
}

.quick-stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 11px;
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  align-items: start;
}

.workspace,
.settings {
  min-width: 0;
}

.input-card,
.panel,
.result-card,
.worksheet-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input-card {
  padding: 12px;
  box-shadow: var(--shadow);
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.field-head label {
  margin-bottom: 8px;
}

.field-head span {
  margin-bottom: 8px;
  white-space: nowrap;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.preset-row button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 11px;
  cursor: pointer;
  font-size: 13px;
}

.preset-row button:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--accent);
}

#sourceText {
  width: 100%;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: 0;
  padding: 0 14px;
  background: #fbfbf8;
  color: var(--ink);
  font-size: 22px;
}

#sourceText:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.icon-button,
.mode,
.secondary-button,
.small-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  min-height: 54px;
  color: var(--muted);
}

.modebar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.mode {
  padding: 0 14px;
  color: var(--muted);
}

.mode.active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--soft);
  color: var(--accent);
  font-weight: 760;
}

.mode-note {
  min-height: 20px;
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.result-card {
  min-height: 198px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.result-card.active {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: 0 16px 38px rgba(15, 107, 92, 0.12);
}

.result-card:hover {
  transform: translateY(-1px);
}

.result-head,
.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}

.result-head {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.result-stage {
  position: relative;
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 110px;
  padding: 22px;
  overflow: hidden;
}

.result-text {
  position: relative;
  z-index: 1;
  color: var(--ink);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.result-caption {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.mode-image {
  background-image:
    linear-gradient(45deg, #ecebe4 25%, transparent 25%),
    linear-gradient(-45deg, #ecebe4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ecebe4 75%),
    linear-gradient(-45deg, transparent 75%, #ecebe4 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.mode-signature::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 42px;
  height: 2px;
  background: color-mix(in srgb, var(--ink) 32%, transparent);
}

.mode-signature .result-caption {
  padding-left: 2px;
}

.mode-tattoo {
  background:
    linear-gradient(110deg, rgba(184, 126, 91, 0.2), rgba(239, 204, 176, 0.72)),
    radial-gradient(circle at 24% 18%, rgba(255, 255, 255, 0.48), transparent 28%);
}

.mode-tattoo::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(22, 23, 22, 0.42) 0 1px, transparent 1px 14px);
}

.mode-worksheet {
  background:
    repeating-linear-gradient(#fff 0 36px, #d8d4c9 37px 38px),
    var(--surface);
}

.font-script {
  font-family: "Brush Script MT", "Segoe Script", "Apple Chancery", cursive;
}

.font-formal {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.font-bold {
  font-family: "Lucida Handwriting", "Segoe Script", cursive;
  font-weight: 800;
}

.font-social {
  font-family: "Trebuchet MS", ui-sans-serif, sans-serif;
  font-style: italic;
}

.font-mono-script {
  font-family: "Courier New", monospace;
  font-style: italic;
}

.result-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.panel {
  padding: 16px;
}

.panel h2 {
  margin-bottom: 14px;
  font-size: 16px;
}

.panel select,
.panel input[type="range"] {
  width: 100%;
  margin-bottom: 14px;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

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

.swatch {
  width: 31px;
  height: 31px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.swatch.active {
  box-shadow: 0 0 0 2px var(--accent);
}

.export-actions,
.favorites {
  display: grid;
  gap: 8px;
}

.secondary-button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
  color: var(--muted);
}

.secondary-button:hover,
.small-button:hover,
.icon-button:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--accent);
}

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

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}

.worksheet-preview {
  margin-top: 14px;
  padding: 18px;
}

.worksheet-line {
  min-height: 58px;
  border-bottom: 1px dashed #b8b4a9;
  display: flex;
  align-items: center;
  color: color-mix(in srgb, var(--ink) 62%, transparent);
}

.worksheet-line span {
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 38px;
}

.seo-band {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 28px;
  margin-top: 42px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.seo-band h2 {
  font-size: 28px;
  line-height: 1.05;
  margin-bottom: 12px;
}

.seo-band p {
  color: var(--muted);
  line-height: 1.65;
}

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

.feature {
  display: grid;
  gap: 7px;
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  text-decoration: none;
}

.feature strong {
  font-size: 16px;
}

.feature span {
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.faq-grid {
  display: grid;
  gap: 10px;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px 16px;
}

summary {
  cursor: pointer;
  font-weight: 760;
}

details p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.content-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

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

.content-card p,
.content-card li {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.content-card ul {
  margin: 0;
  padding-left: 18px;
}

.content-page {
  display: grid;
  gap: 24px;
}

.content-section {
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 8px;
}

.letter-tile {
  display: grid;
  place-items: center;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 34px;
}

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

.letter-example {
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: clamp(68px, 12vw, 132px);
  color: var(--accent);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(18px, 4vw, 50px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

@media print {
  .site-header,
  .tool-hero,
  .modebar,
  .result-grid,
  .settings,
  .seo-band,
  .site-footer,
  .input-card {
    display: none !important;
  }

  main {
    width: auto;
    padding: 0;
  }

  .app-shell {
    display: block;
  }

  .worksheet-preview {
    display: block !important;
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (max-width: 980px) {
  .tool-hero,
  .app-shell,
  .seo-band {
    grid-template-columns: 1fr;
  }

  .quick-stats {
    justify-content: flex-start;
  }

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

@media (max-width: 720px) {
  .site-header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 12px;
  }

  .site-nav {
    display: flex;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .site-nav a {
    flex: 0 0 auto;
  }

  main {
    width: min(100vw - 24px, 1240px);
    padding-top: 24px;
  }

  h1 {
    font-size: 42px;
  }

  .result-grid,
  .settings,
  .feature-grid,
  .content-grid,
  .letter-pair {
    grid-template-columns: 1fr;
  }

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

  .icon-button {
    width: 100%;
  }

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