:root {
  color-scheme: light;
  --background: #f4f5f3;
  --surface: #ffffff;
  --surface-muted: #f8f9f7;
  --text: #17211b;
  --text-muted: #68716b;
  --border: #dce1dd;
  --border-strong: #c4ccc6;
  --accent: #196b46;
  --accent-hover: #115538;
  --accent-soft: #e9f5ee;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warning: #9a6700;
  --warning-soft: #fff8e6;
  --code-background: #151b18;
  --code-text: #e7eee9;
  --syntax-annotation: #ffb86c;
  --syntax-class: #ffd580;
  --syntax-comment: #819086;
  --syntax-keyword: #ff7ab2;
  --syntax-number: #c5a3ff;
  --syntax-property: #78dce8;
  --syntax-string: #a9dc76;
  --syntax-variable: #f3f4f4;
  --focus: #26875b;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #0e1311;
  --surface: #151b18;
  --surface-muted: #1a211d;
  --text: #edf3ef;
  --text-muted: #9ba8a0;
  --border: #2c3630;
  --border-strong: #414d46;
  --accent: #65c993;
  --accent-hover: #82d8a9;
  --accent-soft: #163324;
  --danger: #ff8a80;
  --danger-soft: #351d1b;
  --warning: #f5c451;
  --warning-soft: #302714;
  --code-background: #090d0b;
  --code-text: #e4ede7;
  --focus: #65c993;
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--background);
}

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

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.5rem;
  background: var(--text);
  color: var(--surface);
  transform: translateY(-160%);
}

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

.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.header-content,
main,
footer {
  width: min(1440px, calc(100% - 3rem));
  margin-inline: auto;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--text);
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

main {
  padding-block: 2rem;
}

.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

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

h1 {
  max-width: 1100px;
  margin-inline: auto;
  margin-bottom: 0.8rem;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.03;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  letter-spacing: -0.025em;
}

.hero-copy {
  max-width: 680px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.privacy-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.83rem;
  font-weight: 600;
}

.privacy-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
}

.configuration {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--surface);
}

.editor-header,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.configuration-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(190px, 1fr) minmax(200px, 1fr) minmax(280px, 1.35fr);
  gap: 0.9rem;
}

.field {
  display: grid;
  gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input[type="text"],
select {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.55rem;
  outline: none;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 68px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--surface-muted);
  cursor: pointer;
}

.check-field input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
}

.check-field span {
  display: grid;
  gap: 0.2rem;
}

.check-field strong {
  font-size: 0.8rem;
  line-height: 1.3;
}

.check-field small {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px minmax(0, 1fr);
  align-items: stretch;
  gap: 0.75rem;
}

.editor-card {
  display: flex;
  min-width: 0;
  min-height: 520px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--surface);
}

.editor-header {
  min-height: 78px;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.editor-header label {
  font-size: 0.98rem;
  font-weight: 760;
}

.counter {
  color: var(--text-muted);
  font-size: 0.73rem;
  white-space: nowrap;
}

.counter.warning {
  color: var(--warning);
  font-weight: 700;
}

.code-editor-wrap {
  position: relative;
  height: 380px;
  min-height: 380px;
  flex: 1;
  overflow: hidden;
  background: var(--code-background);
  resize: vertical;
}

.code-editor,
.code-highlight {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 1.15rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
}

.code-highlight {
  z-index: 0;
  margin: 0;
  overflow: hidden;
  color: var(--code-text);
  pointer-events: none;
}

.code-editor {
  z-index: 1;
  resize: none;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  caret-color: var(--code-text);
  color: transparent;
  overflow: auto;
  -webkit-text-fill-color: transparent;
}

.code-editor::placeholder {
  color: color-mix(in srgb, var(--code-text) 42%, transparent);
  -webkit-text-fill-color: color-mix(in srgb, var(--code-text) 42%, transparent);
}

.code-editor::selection {
  background: color-mix(in srgb, var(--focus) 55%, transparent);
}

.token-annotation {
  color: var(--syntax-annotation);
}

.token-class {
  color: var(--syntax-class);
  font-weight: 700;
}

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

.token-keyword {
  color: var(--syntax-keyword);
  font-weight: 650;
}

.token-number {
  color: var(--syntax-number);
}

.token-property {
  color: var(--syntax-property);
}

.token-string {
  color: var(--syntax-string);
}

.token-variable {
  color: var(--syntax-variable);
  font-weight: 650;
}

.editor-actions {
  min-height: 62px;
  justify-content: flex-start;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.editor-actions-end {
  justify-content: flex-end;
}

.generate-column {
  display: grid;
  place-items: center;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.58rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 0.52rem;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 720;
}

.button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.button-primary {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--accent);
  color: var(--surface);
}

[data-theme="dark"] .button-primary {
  color: #07120c;
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--text);
  color: var(--surface);
}

.theme-toggle {
  border-color: var(--border);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.status {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--surface);
  font-size: 0.85rem;
}

.status[data-kind="error"] {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.status[data-kind="warning"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.status[data-kind="success"] {
  background: var(--accent-soft);
  color: var(--accent);
}

footer {
  padding-block: 1.5rem 2.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}

footer p {
  margin: 0;
}

footer a {
  color: var(--accent);
  font-weight: 700;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 38%, transparent);
  outline-offset: 2px;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 14%, transparent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .configuration-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .generate-column {
    min-height: 52px;
  }

  .button-primary {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .header-content,
  main,
  footer {
    width: min(100% - 1.25rem, 1440px);
  }

  main {
    padding-top: 2.25rem;
  }

  .hero {
    text-align: left;
  }

  .privacy-badge {
    justify-content: flex-start;
  }

  .configuration-grid {
    grid-template-columns: 1fr;
  }

  .editor-card {
    min-height: 520px;
  }

  .code-editor-wrap,
  .code-editor,
  .code-highlight {
    min-height: 380px;
  }

  .editor-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .editor-actions {
    flex-wrap: wrap;
  }

  .editor-actions .button {
    flex: 1 1 auto;
  }
}

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