:root {
  --ink: #132019;
  --muted: #607066;
  --paper: #f4f1e9;
  --card: #fffdf8;
  --line: #dcd8cc;
  --accent: #195f43;
  --accent-strong: #0e4a33;
  --accent-soft: #dceee4;
  --highlight: #e4b55f;
  --danger: #a53b32;
  --shadow: 0 22px 60px rgba(34, 48, 39, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 5%, rgba(228, 181, 95, 0.18), transparent 25rem),
    radial-gradient(circle at 95% 35%, rgba(25, 95, 67, 0.10), transparent 28rem),
    var(--paper);
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: #fff;
  background: var(--accent);
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(25, 95, 67, 0.23);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: 0; }
.brand small { color: var(--muted); margin-top: 2px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.72);
  font-size: 13px;
  backdrop-filter: blur(8px);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b1a99a;
}

.status-pill.is-ready .status-dot { background: #2d9a65; box-shadow: 0 0 0 4px rgba(45, 154, 101, 0.12); }
.status-pill.is-error .status-dot { background: var(--danger); }

.hero {
  width: 100%;
  padding: 56px 0 36px;
}

.eyebrow {
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 64px;
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: 0;
  white-space: nowrap;
}

.hero p {
  max-width: 1120px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
  white-space: nowrap;
}

.workspace, .result-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.workspace { padding: 28px; }

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.mode-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  transition: 160ms ease;
}

.mode-button:hover { border-color: #a8b9ae; color: var(--ink); transform: translateY(-1px); }
.mode-button.is-active { border-color: var(--accent); color: #fff; background: var(--accent); }
.mode-button span { font-size: 17px; }

label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 800;
}

.input-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  transition: 160ms ease;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(25, 95, 67, 0.10);
}

textarea {
  display: block;
  width: 100%;
  min-height: 145px;
  resize: vertical;
  padding: 18px 18px 10px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
  line-height: 1.55;
}

textarea::placeholder { color: #9b9d96; }

.input-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 18px 14px;
  color: #92988f;
  font-size: 12px;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 15px;
}

.examples > span { margin-right: 3px; color: var(--muted); font-size: 13px; }
.example-chip {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}
.example-chip:hover { color: var(--accent); border-color: #a8b9ae; background: var(--accent-soft); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.primary-button, .secondary-button, .copy-button {
  border-radius: 12px;
  font-weight: 800;
  transition: 160ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 166px;
  padding: 13px 17px;
  border: 1px solid var(--accent);
  color: #fff;
  background: var(--accent);
}
.primary-button:hover { background: var(--accent-strong); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: 0.62; transform: none; }
.button-icon { font-size: 19px; }

.secondary-button, .copy-button {
  padding: 12px 15px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}
.secondary-button:hover, .copy-button:hover { color: var(--ink); border-color: #a8b9ae; background: #fff; }

.form-error { margin: 12px 0 0; color: var(--danger); font-size: 14px; }

.result-card {
  min-height: 310px;
  margin-top: 22px;
  padding: 28px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.result-kicker { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.result-header h2 { margin: 5px 0 0; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }

.empty-state {
  display: grid;
  place-items: center;
  min-height: 205px;
  color: var(--muted);
  text-align: center;
}
.empty-state p { max-width: 390px; margin: 10px auto 0; line-height: 1.5; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px; color: var(--accent); background: var(--accent-soft); font-size: 24px; }

.loading-state {
  align-items: center;
  gap: 16px;
  min-height: 205px;
}
.loading-state:not([hidden]) { display: flex; }
.loading-state p { margin: 5px 0 0; color: var(--muted); }

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.answer {
  margin: 0;
  padding: 24px 0 10px;
  border: 0;
  color: #26362d;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 24px 0 10px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-weight: 600;
  line-height: 1.25;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body h4:first-child,
.markdown-body h5:first-child,
.markdown-body h6:first-child {
  margin-top: 0;
}

.markdown-body h1 { font-size: 30px; }
.markdown-body h2 { font-size: 26px; }
.markdown-body h3 { font-size: 24px; }
.markdown-body h4 { font-size: 20px; }
.markdown-body h5 { font-size: 18px; }
.markdown-body h6 { font-size: 16px; }

.markdown-body p {
  margin: 0 0 13px;
}

.markdown-body ol,
.markdown-body ul {
  margin: 0 0 16px;
  padding-left: 24px;
}

.markdown-body li {
  margin: 0 0 9px;
  padding-left: 4px;
}

.markdown-body li > p {
  margin: 0;
}

.markdown-body strong {
  color: #18251e;
  font-weight: 800;
}

.markdown-body em {
  color: var(--muted);
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 6px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 0.92em;
}

.markdown-body pre {
  overflow-x: auto;
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.markdown-body pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.markdown-body table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  color: var(--ink);
  background: var(--accent-soft);
}

.result-meta { padding-top: 16px; color: #8d948d; font-size: 12px; }

.benefits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 22px;
}

.benefits article {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.58);
}
.benefits article > span { color: var(--highlight); font-family: Georgia, serif; font-size: 22px; }
.benefits h3 { margin: 24px 0 8px; font-size: 16px; }
.benefits p { margin: 0; color: var(--muted); line-height: 1.55; }
.benefits code { padding: 1px 4px; border-radius: 4px; background: var(--accent-soft); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 2px 0;
  color: #818980;
  font-size: 12px;
}

[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .hero h1 {
    font-size: 54px;
    white-space: normal;
  }

  .hero p {
    max-width: 820px;
    white-space: normal;
  }
}

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 1180px); }
  .topbar { align-items: flex-start; }
  .brand small { display: none; }
  .status-pill { max-width: 150px; text-align: right; }
  .hero { padding: 36px 0 28px; }
  .hero h1 {
    font-size: 42px;
    line-height: 1.12;
    white-space: normal;
  }
  .hero p {
    font-size: 16px;
    line-height: 1.55;
    white-space: normal;
  }
  .workspace, .result-card { padding: 18px; border-radius: 19px; }
  .mode-row { display: grid; grid-template-columns: 1fr 1fr; }
  .mode-button { justify-content: center; }
  .examples { display: none; }
  .form-actions { justify-content: stretch; }
  .form-actions button { flex: 1; }
  .result-header h2 { font-size: 23px; }
  .benefits { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

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