:root {
  color-scheme: light dark;
  --canvas: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #eef2ed;
  --field: #fbfcf8;
  --ink: #161817;
  --ink-soft: #343a37;
  --muted: #68726d;
  --muted-strong: #4c5651;
  --line: #d9e1da;
  --line-strong: #b7c3ba;
  --accent: #2d6cdf;
  --accent-strong: #1f55b7;
  --success: #267360;
  --warning: #a86821;
  --danger: #c9493d;
  --focus: #7da6f4;
  --shadow-soft: 0 1px 2px rgba(16, 24, 20, 0.06), 0 16px 40px rgba(16, 24, 20, 0.08);
  --shadow-raised: 0 12px 28px rgba(16, 24, 20, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #101211;
    --surface: #171a18;
    --surface-muted: #202520;
    --field: #121513;
    --ink: #f2f5ef;
    --ink-soft: #dce4dc;
    --muted: #9aa79f;
    --muted-strong: #bdc8c0;
    --line: #303831;
    --line-strong: #465047;
    --accent: #8ab4ff;
    --accent-strong: #a9c8ff;
    --success: #7cc9aa;
    --warning: #e1a95f;
    --danger: #ff8b7f;
    --focus: #9ec0ff;
    --shadow-soft: 0 18px 44px rgba(0, 0, 0, 0.28);
    --shadow-raised: 0 20px 46px rgba(0, 0, 0, 0.34);
  }
}

:root[data-theme="light"] {
  --canvas: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #eef2ed;
  --field: #fbfcf8;
  --ink: #161817;
  --ink-soft: #343a37;
  --muted: #68726d;
  --muted-strong: #4c5651;
  --line: #d9e1da;
  --line-strong: #b7c3ba;
  --accent: #2d6cdf;
  --accent-strong: #1f55b7;
  --success: #267360;
  --warning: #a86821;
  --danger: #c9493d;
  --focus: #7da6f4;
  --shadow-soft: 0 1px 2px rgba(16, 24, 20, 0.06), 0 16px 40px rgba(16, 24, 20, 0.08);
  --shadow-raised: 0 12px 28px rgba(16, 24, 20, 0.12);
}

:root[data-theme="dark"] {
  --canvas: #101211;
  --surface: #171a18;
  --surface-muted: #202520;
  --field: #121513;
  --ink: #f2f5ef;
  --ink-soft: #dce4dc;
  --muted: #9aa79f;
  --muted-strong: #bdc8c0;
  --line: #303831;
  --line-strong: #465047;
  --accent: #8ab4ff;
  --accent-strong: #a9c8ff;
  --success: #7cc9aa;
  --warning: #e1a95f;
  --danger: #ff8b7f;
  --focus: #9ec0ff;
  --shadow-soft: 0 18px 44px rgba(0, 0, 0, 0.28);
  --shadow-raised: 0 20px 46px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

a,
button,
textarea {
  min-width: 0;
  font: inherit;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.app-shell {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.68) inset;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.top-actions a,
.quota {
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, var(--canvas));
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.top-actions a:hover,
.quota:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 44px;
  align-items: end;
  margin-bottom: 22px;
}

.headline-block {
  display: grid;
  max-width: 660px;
  gap: 12px;
}

h1 {
  max-width: 690px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.04;
  font-weight: 760;
}

.headline-sub {
  max-width: 610px;
  margin: 0;
  color: var(--muted-strong);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 510;
}

.desktop-strip {
  display: grid;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--success);
  font-size: 12px;
  font-weight: 780;
  line-height: 1.25;
  text-transform: uppercase;
}

.desktop-lead {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
}

.instant-steps {
  display: grid;
  gap: 8px;
}

.instant-steps span {
  min-height: 34px;
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.35;
}

.extra-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--warning) 34%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, var(--warning));
  box-shadow: var(--shadow-soft);
}

.extra-panel[hidden] {
  display: none;
}

.extra-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 21px;
  line-height: 1.22;
  font-weight: 720;
}

.machine-line {
  margin: 1px 0 0;
  color: var(--warning);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 720;
}

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

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.download-shell {
  width: min(1040px, calc(100% - 48px));
}

.download-intro {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.download-workbench {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.download-primary {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding-right: 20px;
  border-right: 1px solid var(--line);
}

.download-primary h2,
.install-option h3 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.24;
  font-weight: 740;
}

.install-option h3 {
  font-size: 16px;
}

.download-primary p,
.install-option p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.5;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  width: fit-content;
  margin-top: 2px;
  border: 1px solid var(--accent-strong);
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 760;
}

.download-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.download-file {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 650;
}

.install-options {
  display: grid;
  min-width: 0;
}

.install-option {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding-bottom: 16px;
}

.install-option + .install-option {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.install-option:last-child {
  padding-bottom: 0;
}

.install-option pre {
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--field);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.install-option code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.install-option button {
  justify-self: start;
  min-width: 150px;
}

.editor {
  display: grid;
  min-width: 0;
  margin: 0;
}

.source-editor {
  grid-column: 1;
  grid-row: 1;
}

.result-editor {
  grid-column: 2;
  grid-row: 1;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.25;
}

.field-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

#charCount {
  margin-bottom: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

#charCount[data-kind="error"] {
  color: var(--danger);
}

textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 338px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  line-height: 1.58;
  caret-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.68) inset;
}

textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

textarea:focus {
  border-color: var(--focus);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--focus) 28%, transparent),
    0 1px 0 rgba(255, 255, 255, 0.68) inset;
}

.result-editor textarea {
  background: var(--surface-muted);
}

.primary-actions {
  display: grid;
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  margin: 0;
}

.secondary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  gap: 10px;
  margin: 0;
}

button {
  position: relative;
  min-height: 46px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface-muted) 70%, var(--surface));
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #ffffff;
}

button:not(:disabled):hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

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

.compliment-option {
  min-height: 44px;
  padding: 9px 11px;
  text-align: left;
  line-height: 1.35;
}

.compliment-option[data-selected="true"] {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 13%, var(--surface));
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:not(:disabled):active {
  transform: translateY(0);
}

a:focus-visible,
button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.status {
  grid-column: 1 / -1;
  grid-row: 3;
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
}

.status[data-kind="error"] {
  color: var(--danger);
}

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

body[data-busy="true"] button.primary {
  cursor: wait;
}

@media (max-width: 899px) {
  .intro,
  .workbench,
  .download-workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .download-primary {
    padding-right: 0;
    padding-bottom: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .source-editor,
  .result-editor,
  .primary-actions,
  .secondary-actions {
    grid-column: 1;
    grid-row: auto;
  }

  .status {
    grid-row: auto;
  }

  textarea {
    min-height: 260px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 24px, 1120px);
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .download-shell {
    width: min(100% - 24px, 1040px);
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
  }

  .intro {
    gap: 0;
    margin-bottom: 14px;
  }

  h1 {
    font-size: clamp(28px, 8vw, 34px);
  }

  .headline-sub,
  .desktop-strip {
    display: none;
  }

  .download-intro .headline-sub {
    display: block;
    font-size: 14px;
  }

  .workbench,
  .download-workbench {
    gap: 12px;
    padding: 12px;
  }

  .download-button,
  .install-option button {
    width: 100%;
  }

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

  textarea {
    min-height: 184px;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
