:root {
  --bg: #f6f5f4;
  --card: #ffffff;
  --text: #221c1c;
  --muted: #7a706e;
  --muted-2: #a39895;
  --line: #ece5e3;
  --line-strong: #ddd2cf;
  --brand: #c9241f;
  --brand-dark: #a11c18;
  --brand-soft: #fbeceb;
  --shadow: 0 18px 55px rgba(45, 20, 18, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgba(201, 36, 31, 0.08), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(201, 36, 31, 0.22);
  outline-offset: 2px;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 88px;
  display: flex;
  align-items: center;
}

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

.brand-mark {
  height: 34px;
  width: auto;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
}

.brand strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.73rem;
}

.main {
  width: min(760px, calc(100% - 32px));
  margin: 8px auto 0;
  flex: 1;
}

.hero {
  text-align: center;
  margin: 14px 0 22px;
}

.hero h1 {
  margin: 0 auto 10px;
  max-width: 700px;
  font-size: clamp(1.2rem, 3.6vw, 2.07rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

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

.hero p {
  max-width: 630px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.app-card,
.result-card {
  background: var(--card);
  border: 1px solid rgba(221, 210, 207, 0.75);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.app-card {
  padding: 24px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  margin-bottom: 16px;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.field label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.84rem;
  font-weight: 750;
}

.field-header label {
  margin-bottom: 0;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 13px 14px;
  background: #fbfbfa;
  color: var(--text);
  line-height: 1.5;
  transition: 160ms ease;
}

.field textarea {
  min-height: 220px;
  resize: vertical;
}

.field textarea.textarea-sm {
  min-height: 90px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a89e9b;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  background: white;
  box-shadow: 0 0 0 4px rgba(201, 36, 31, 0.08);
  outline: 0;
}

.char-count {
  color: var(--muted-2);
  font-size: 0.7rem;
}

.api-key-row {
  display: flex;
  gap: 8px;
}

.api-key-row input {
  flex: 1;
}

.ghost-button {
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0 16px;
  background: #fbfbfa;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: 160ms ease;
}

.ghost-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.checkbox-label input {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}

.field-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--muted-2);
  line-height: 1.5;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  margin-top: 6px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--brand);
  box-shadow: 0 10px 25px rgba(201, 36, 31, 0.2);
  font-weight: 800;
  cursor: pointer;
  transition: 160ms ease;
}

.primary-button:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.button-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.primary-button.is-loading .button-label {
  display: none;
}

.spinner {
  width: 19px;
  height: 19px;
  margin: auto;
  display: block;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.status-message {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #a11c18;
  background: var(--brand-soft);
  border: 1px solid #f3c8c6;
}

.status-message.is-info {
  color: #2a5f56;
  background: #eaf5f2;
  border-color: #cbe6df;
}

.result-card {
  margin-top: 18px;
  padding: 24px;
  scroll-margin-top: 18px;
}

.result-kicker {
  color: var(--brand);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  margin: 0;
}

.result-card h2 {
  margin: 4px 0 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.result-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.result-links {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.result-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  transition: 160ms ease;
}

.result-link:hover {
  border-color: var(--brand);
  background: #fffaf9;
  transform: translateY(-1px);
}

.result-link-icon {
  min-width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
}

.result-link-copy {
  display: flex;
  flex-direction: column;
}

.result-link-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

footer {
  width: min(760px, calc(100% - 32px));
  margin: 45px auto 0;
  min-height: 76px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted-2);
  font-size: 0.68rem;
}

footer span:first-child {
  color: var(--muted);
  font-weight: 800;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 620px) {
  .site-header {
    min-height: 72px;
  }

  .brand small {
    display: none;
  }

  .main {
    width: min(100% - 22px, 760px);
  }

  .hero {
    margin: 8px 5px 16px;
  }

  .hero h1 {
    font-size: clamp(1.2rem, 6.6vw, 1.62rem);
  }

  .hero p {
    font-size: 0.82rem;
  }

  .app-card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .result-card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  footer {
    min-height: 65px;
    margin-top: 32px;
  }

  footer span:last-child {
    display: none;
  }
}

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