:root {
  color-scheme: light;
  --kumo-text-default: #18181b;
  --kumo-text-inverse: #f5f5f5;
  --kumo-text-strong: #525252;
  --kumo-text-subtle: #737373;
  --kumo-text-placeholder: #a1a1a1;
  --kumo-text-brand: #f6821f;
  --kumo-text-danger: #c10007;
  --kumo-canvas: #fbfbfb;
  --kumo-elevated: #f8f8f8;
  --kumo-recessed: #f2f2f2;
  --kumo-base: #ffffff;
  --kumo-control: #ffffff;
  --kumo-fill: #e5e5e5;
  --kumo-fill-hover: #f3f3f3;
  --kumo-brand: #056dff;
  --kumo-brand-hover: #1447e6;
  --kumo-hairline: #e9e9e9;
  --kumo-danger-tint: #ffe2e2;
  --kumo-font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --kumo-font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  --kumo-text-xs: 12px;
  --kumo-text-sm: 13px;
  --kumo-text-base: 14px;
  --kumo-text-lg: 16px;
  --kumo-radius: 8px;
  --kumo-radius-control: 6px;
  --kumo-radius-pill: 9999px;
  --kumo-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

:root[data-mode="dark"] {
  color-scheme: dark;
  --kumo-text-default: #f5f5f5;
  --kumo-text-inverse: #171717;
  --kumo-text-strong: #a1a1a1;
  --kumo-text-subtle: #a1a1a1;
  --kumo-text-placeholder: #737373;
  --kumo-text-brand: #f6821f;
  --kumo-text-danger: #ff6467;
  --kumo-canvas: #030303;
  --kumo-elevated: #060606;
  --kumo-recessed: #0b0b0b;
  --kumo-base: #0f0f0f;
  --kumo-control: #18181b;
  --kumo-fill: #262626;
  --kumo-fill-hover: #404040;
  --kumo-brand: #056dff;
  --kumo-brand-hover: #1447e6;
  --kumo-hairline: #262626;
  --kumo-danger-tint: #82181a;
  --kumo-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  display: flex;
  min-height: 100vh;
  margin: 0;
  flex-direction: column;
  color: var(--kumo-text-default);
  background: var(--kumo-canvas);
  font-family: var(--kumo-font);
  font-size: var(--kumo-text-base);
  line-height: 1.4286;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }

button { color: inherit; }

:focus-visible {
  outline: 2px solid var(--kumo-brand);
  outline-offset: 3px;
}

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

.app-header {
  display: flex;
  width: min(100% - 48px, 1120px);
  height: 64px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  color: var(--kumo-text-default);
  font-weight: 700;
  letter-spacing: -0.055em;
  text-decoration: none;
}

.wordmark__semicolon { color: var(--kumo-text-brand); }

.wordmark--small {
  font-size: var(--kumo-text-lg);
  letter-spacing: -0.04em;
}

.wordmark--hero {
  justify-content: center;
  margin: 0;
  font-size: clamp(44px, 7vw, 64px);
  line-height: 1;
  transition: font-size 300ms ease;
}

.theme-toggle {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  color: var(--kumo-text-strong);
  background: transparent;
  border: 0;
  border-radius: var(--kumo-radius-pill);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.theme-toggle:hover { color: var(--kumo-text-default); background: var(--kumo-recessed); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle__moon { display: none; }
[data-mode="dark"] .theme-toggle__sun { display: none; }
[data-mode="dark"] .theme-toggle__moon { display: block; }

.app-main {
  display: flex;
  width: 100%;
  flex: 1;
}

.workspace {
  width: min(100% - 48px, 780px);
  margin: auto;
  padding: clamp(56px, 10vh, 120px) 0 96px;
}

.intro {
  text-align: center;
  animation: settle 450ms ease both;
  transition: text-align 300ms ease;
}

.tagline {
  margin: 14px 0 0;
  color: var(--kumo-text-strong);
  font-size: var(--kumo-text-lg);
  font-weight: 500;
  letter-spacing: -0.015em;
}

.intro__copy {
  margin: 8px 0 0;
  color: var(--kumo-text-subtle);
  font-size: var(--kumo-text-sm);
}

.composer {
  position: relative;
  margin-top: 36px;
  animation: settle 450ms 70ms ease both;
  transition: margin 300ms ease;
}

.input-shell {
  display: flex;
  min-height: 64px;
  padding: 6px;
  align-items: center;
  gap: 8px;
  background: var(--kumo-base);
  border: 1px solid var(--kumo-hairline);
  border-radius: var(--kumo-radius);
  box-shadow: var(--kumo-shadow-xs);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.input-shell:focus-within {
  border-color: var(--kumo-brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--kumo-brand) 13%, transparent);
  transform: translateY(-1px);
}

.input-shell input:focus {
  outline: none;
}

.input-shell:focus-within .input-shell__play {
  fill: var(--kumo-text-brand);
}

[data-mode="dark"] .input-shell {
  border-color: color-mix(in srgb, var(--kumo-brand) 28%, var(--kumo-hairline));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--kumo-brand) 12%, transparent);
}

[data-mode="dark"] .input-shell:focus-within {
  border-color: var(--kumo-brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--kumo-brand) 24%, transparent), 0 0 10px color-mix(in srgb, var(--kumo-brand) 18%, transparent);
}

.input-shell__play {
  width: 20px;
  height: 20px;
  margin-left: 12px;
  flex: 0 0 auto;
  fill: var(--kumo-text-subtle);
  transition: fill 180ms ease;
}

input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 4px;
  color: var(--kumo-text-default);
  background: transparent;
  border: 0;
  font-size: var(--kumo-text-lg);
}

input::placeholder { color: var(--kumo-text-placeholder); }

#submit-button {
  display: inline-flex;
  min-width: 132px;
  height: 50px;
  padding: 0 16px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: var(--kumo-brand);
  border: 0;
  border-radius: var(--kumo-radius-control);
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease, opacity 150ms ease;
}

#submit-button:hover:not(:disabled) { background: var(--kumo-brand-hover); }
#submit-button:active:not(:disabled) { transform: translateY(1px); }
#submit-button:disabled { opacity: 0.38; cursor: not-allowed; }
#submit-button svg { width: 18px; height: 18px; }

.support-row {
  display: flex;
  margin-top: 10px;
  align-items: flex-start;
  justify-content: center;
}

.privacy-note {
  margin: 0;
  color: var(--kumo-text-subtle);
  font-size: var(--kumo-text-xs);
  text-align: center;
}

.turnstile { display: flex; justify-content: center; min-height: 0; }
.turnstile-error { margin: 10px 0 0; color: var(--kumo-text-danger); font-size: var(--kumo-text-sm); }

.status, .error {
  display: flex;
  margin-top: 32px;
  align-items: center;
}

.status[hidden], .error[hidden], .result[hidden] { display: none; }

.status {
  justify-content: center;
  gap: 12px;
  color: var(--kumo-text-strong);
}

.status strong, .status span, .error strong, .error span { display: block; }
.status strong { color: var(--kumo-text-default); font-size: var(--kumo-text-sm); font-weight: 600; }
.status div > span, .error span { margin-top: 1px; color: var(--kumo-text-subtle); font-size: var(--kumo-text-xs); }

.status__semicolon {
  color: var(--kumo-text-brand);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  animation: pulse 1.2s ease-in-out infinite;
}

.is-busy .wordmark--hero .wordmark__semicolon { animation: pulse 1.2s ease-in-out infinite; }

.error {
  padding: 12px 14px;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: var(--kumo-danger-tint);
  border-radius: var(--kumo-radius-control);
  color: var(--kumo-text-danger);
}

.error span { color: inherit; }

.result {
  margin-top: 64px;
  scroll-margin-top: 24px;
  animation: settle 350ms ease both;
}

.result__header {
  display: flex;
  padding-bottom: 24px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--kumo-hairline);
}

.result__header > div { min-width: 0; }

.result__meta {
  display: flex;
  margin: 0 0 8px;
  align-items: center;
  gap: 7px;
  color: var(--kumo-text-subtle);
  font-size: var(--kumo-text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  max-width: 660px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

h2, .result__meta, .result__summary { overflow-wrap: anywhere; }

.copy-button {
  min-width: 64px;
  min-height: 40px;
  padding: 0 12px;
  flex: 0 0 auto;
  color: var(--kumo-text-strong);
  background: transparent;
  border: 1px solid var(--kumo-hairline);
  border-radius: var(--kumo-radius-control);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.copy-button:hover { color: var(--kumo-text-default); background: var(--kumo-fill-hover); border-color: var(--kumo-fill); }
.copy-button:disabled { opacity: 0.5; cursor: not-allowed; }
.copy-button[aria-disabled="true"] { opacity: 0.5; }
.result__actions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.result-link { display: inline-block; margin-top: 12px; color: var(--kumo-text-default); text-underline-offset: 3px; }
.share-note { margin: 12px 0 0; color: var(--kumo-text-subtle); font-size: var(--kumo-text-xs); }
.share-note:empty { display: none; }
.action-status:not(.sr-only) { margin: 12px 0 0; color: var(--kumo-text-subtle); font-size: var(--kumo-text-xs); }
.result-link[hidden] { display: none; }
#copy-fallback { margin-top: 12px; }
#copy-text { width: 100%; margin-top: 6px; padding: 12px; resize: vertical; color: var(--kumo-text-default); background: var(--kumo-base); border: 1px solid var(--kumo-hairline); border-radius: var(--kumo-radius-control); }
#share-fallback { margin-top: 12px; }
#share-url { margin-top: 6px; padding: 8px; border: 1px solid var(--kumo-hairline); border-radius: var(--kumo-radius-control); }
.shared-home { display: none; }
[data-view="shared"] .shared-home { display: inline-block; }
[data-view="shared"] .composer { display: none; }
[data-view="shared"] .workspace { padding-top: 40px; }
[data-view="shared"] .intro { display: none; }
[data-view="shared"] .result { margin-top: 32px; }

.result__summary {
  padding: 32px 0 40px;
  color: var(--kumo-text-default);
  font-size: var(--kumo-text-base);
  line-height: 1.7;
}

.result__summary h3 {
  margin: 36px 0 12px;
  font-size: var(--kumo-text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.result__summary h3:first-child { margin-top: 0; font-size: 20px; }
.result__summary h4 { margin: 28px 0 10px; color: var(--kumo-text-strong); font-size: var(--kumo-text-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.055em; }
.result__summary p { margin: 0 0 16px; }
.result__summary ol { margin: 0; padding: 0; list-style: none; }
.result__summary li { position: relative; margin: 0; padding: 13px 0 13px 40px; border-top: 1px solid var(--kumo-hairline); }
.result__summary li::before { position: absolute; top: 14px; left: 0; color: var(--kumo-text-subtle); content: attr(data-index); font-family: var(--kumo-font-mono); font-size: var(--kumo-text-xs); }

.result__footer {
  display: flex;
  padding-top: 14px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--kumo-hairline);
  color: var(--kumo-text-subtle);
  font-size: var(--kumo-text-xs);
}

.has-result .workspace { padding-top: 40px; }
.has-result .wordmark--hero { font-size: 28px; }
.has-result .tagline, .has-result .intro__copy { display: none; }
.has-result .composer { margin-top: 20px; }

.page-footer {
  display: flex;
  width: min(100% - 48px, 1120px);
  min-height: 64px;
  margin: 0 auto;
  padding: 14px 0;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  color: var(--kumo-text-subtle);
  font-size: var(--kumo-text-xs);
}

.cloudflare-stack { position: relative; }
.cloudflare-stack summary { display: flex; min-height: 36px; padding: 0 8px; align-items: center; gap: 7px; border-radius: var(--kumo-radius-control); cursor: pointer; list-style: none; transition: color 150ms ease, background 150ms ease; }
.cloudflare-stack summary::-webkit-details-marker { display: none; }
.cloudflare-stack summary:hover { color: var(--kumo-text-default); background: var(--kumo-recessed); }

.cloudflare-dot {
  width: 7px;
  height: 7px;
  background: var(--kumo-text-brand);
  border-radius: var(--kumo-radius-pill);
}

.stack-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 10;
  width: 320px;
  padding: 16px;
  visibility: hidden;
  background: var(--kumo-base);
  border: 1px solid var(--kumo-hairline);
  border-radius: var(--kumo-radius);
  box-shadow: var(--kumo-shadow-xs);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
}

.cloudflare-stack[open] .stack-popover,
.cloudflare-stack:hover .stack-popover,
.cloudflare-stack:focus-within .stack-popover {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.stack-popover__title { margin: 0 0 10px; color: var(--kumo-text-default); font-weight: 600; }
.stack-popover dl { margin: 0; }
.stack-popover dl > div { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--kumo-hairline); }
.stack-popover dt { color: var(--kumo-text-default); font-weight: 600; }
.stack-popover dd { margin: 0; }
.stack-popover code { font-family: var(--kumo-font-mono); font-size: 0.92em; }

@keyframes settle {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse { 50% { opacity: 0.32; transform: translateY(-1px); } }

@media (max-width: 640px) {
  .app-header, .page-footer { width: min(100% - 32px, 1120px); }
  .workspace { width: min(100% - 32px, 780px); padding: 48px 0 72px; }
  .wordmark--hero { font-size: 48px; }
  .composer { margin-top: 30px; }
  .input-shell { min-height: 58px; padding: 5px; gap: 4px; }
  .input-shell__play { margin-left: 8px; }
  input { height: 46px; font-size: 16px; }
  textarea { font-size: 16px; }
  #submit-button { min-width: 48px; width: 48px; height: 46px; padding: 0; }
  #submit-button .button-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .result { margin-top: 48px; }
  .result__header { gap: 16px; flex-direction: column; }
  h2 { font-size: 20px; }
  .result__summary { padding-top: 24px; }
  .result__footer { align-items: flex-start; flex-direction: column; gap: 3px; }
  .page-footer { align-items: flex-start; flex-direction: column; gap: 4px; }
  .cloudflare-stack { align-self: flex-end; }
  .stack-popover { right: 0; width: min(320px, calc(100vw - 32px)); }
}

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