:root {
  --bg: #eef3ef;
  --bg-accent: #d8e5db;
  --surface: #fbfdfb;
  --ink: #1a2e22;
  --muted: #4d6356;
  --line: #c5d4c9;
  --brand: #1f5c40;
  --brand-deep: #143d2b;
  --accent: #c45c26;
  --ok: #2f6b45;
  --warn: #9a6b16;
  --err: #9b2c2c;
  --shadow: 0 18px 50px rgba(20, 61, 43, 0.08);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9eadc 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #e7efe4 0%, transparent 50%),
    linear-gradient(180deg, #f4f7f4 0%, var(--bg) 40%, #e7eee8 100%);
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 2rem 100px 3rem;
  box-sizing: border-box;
}

.hero {
  margin-bottom: 1.75rem;
}

.eyebrow {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--brand-deep);
}

.lede {
  margin: 0.9rem 0 0;
  max-width: none;
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--muted);
}

.launch-config {
  margin-top: 1.15rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem 1.5rem;
  margin-bottom: 1.25rem;
}

.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--brand-deep);
}

.launch-form label {
  display: block;
  margin: 1rem 0 0.45rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.row input:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 35%, white);
  border-color: var(--brand);
}

.hint {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.error {
  margin: 0.85rem 0 0;
  color: var(--err);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.15rem;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--brand);
  color: #f7fbf8;
  white-space: nowrap;
}

.btn.primary:hover {
  background: var(--brand-deep);
}

.btn.secondary {
  background: #e7f0ea;
  color: var(--brand-deep);
  border: 1px solid var(--line);
}

.btn.secondary:hover {
  background: #d7e8dd;
}

.btn.danger {
  background: #9b2c2c;
  color: #fff8f8;
  white-space: nowrap;
}

.btn.danger:hover {
  background: #7f2222;
}

.danger-text {
  color: var(--err);
}

.btn.ghost {
  background: transparent;
  color: var(--brand-deep);
  border: 1px solid var(--line);
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
}

.btn.ghost:hover {
  background: #e7f0ea;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.badge.cancelling,
.badge.cancelled {
  background: #f4e4d8;
  color: #8a4b1f;
}

.progress-head,
.result-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  background: #eef4c8;
  color: var(--warn);
}

.badge.running {
  background: #eef4c8;
  color: var(--warn);
}

.badge.done {
  background: #d9efe0;
  color: var(--ok);
}

.badge.error {
  background: #f8dede;
  color: var(--err);
}

.log-view {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  padding: 1rem;
  border-radius: 12px;
  background: #14261c;
  color: #d7e8db;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.synthese-view {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  max-height: 70vh;
  overflow: auto;
}

.prose h1,
.prose h2,
.prose h3 {
  font-family: var(--font-display);
  color: var(--brand-deep);
  line-height: 1.25;
}

.prose h1 { font-size: 1.7rem; }
.prose h2 { font-size: 1.3rem; margin-top: 1.4rem; }
.prose h3 { font-size: 1.1rem; margin-top: 1.1rem; }

.prose p,
.prose li {
  line-height: 1.55;
  color: var(--ink);
}

.prose blockquote {
  margin: 0.8rem 0;
  padding: 0.65rem 0.9rem;
  border-left: 3px solid var(--brand);
  background: #f1f6f2;
  color: var(--muted);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  text-align: left;
}

.prose th {
  background: #eaf2ec;
}

.footer {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

body.modal-open {
  overflow: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 38, 28, 0.52);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-bottom: none;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--brand-deep);
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.modal-body {
  padding: 0.4rem 1.2rem 1.1rem;
  overflow: auto;
}

.modal-body h3 {
  margin-top: 1.15rem;
}

.modal-body code {
  font-size: 0.88em;
  background: #eaf2ec;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-deep);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #f7fbf8;
}

.tab-panel h2 {
  margin-top: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.field-grid label,
.theme-card label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.keyword-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.keyword-field-label {
  font-weight: 600;
  font-size: 0.92rem;
}

.keyword-editor {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 8rem;
  max-height: 28rem;
  overflow: auto;
}

.keyword-items {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1 1 auto;
}

.keyword-row,
.keyword-add-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.keyword-input,
.keyword-add-input,
.theme-title {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-weight: 400;
  background: #fff;
  color: var(--ink);
}

.keyword-input:focus,
.keyword-add-input:focus,
.theme-title:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 35%, white);
  border-color: var(--brand);
}

.keyword-remove {
  flex: 0 0 auto;
  min-width: 2.2rem;
  padding: 0.45rem 0.55rem;
  font-size: 1.25rem;
  line-height: 1;
}

.keyword-add-btn {
  flex: 0 0 auto;
  padding: 0.55rem 0.85rem;
  white-space: nowrap;
}

.theme-title {
  font-weight: 600;
}

.themes-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.themes-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.theme-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: #f7fbf8;
}

.theme-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.actions-bar {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 1rem 0 2rem;
}

.status-bar {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-weight: 600;
}

.status-bar.ok {
  background: #d9efe0;
  color: var(--ok);
}

.status-bar.info {
  background: #eef4c8;
  color: var(--warn);
}

.status-bar.error {
  background: #f8dede;
  color: var(--err);
}

.theme-card-off {
  opacity: 0.62;
  background: #f2f2f2;
}

.switch-label {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
}

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

@media (max-width: 720px) {
  .page {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .themes-list {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
  }

  .progress-head,
  .result-head,
  .hero-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .themes-head,
  .actions-bar,
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
