:root {
  --bg0: #e8efe9;
  --bg1: #f4f7f2;
  --ink: #1c2a22;
  --muted: #5b6b61;
  --line: #c5d2c8;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --accent: #1f6f5b;
  --accent-ink: #ffffff;
  --accent-soft: #d7eee6;
  --warn: #8a5a12;
  --shadow: 0 18px 50px rgba(28, 42, 34, 0.08);
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

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

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

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d7ebe2 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0e6d4 0%, transparent 45%),
    linear-gradient(160deg, var(--bg0), var(--bg1));
  line-height: 1.45;
}

.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
}

.hero {
  margin-bottom: 1.75rem;
}

.hero-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}

.hero-title-row h1 {
  margin: 0;
}

.hero-edit-btn {
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.lead {
  margin: 0.85rem 0 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 1.1rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(197, 210, 200, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1.25rem;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: #edf1ee;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ready {
  background: var(--accent-soft);
  color: var(--accent);
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.mode-field {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
  min-inline-size: 0;
}

.mode-field .label {
  padding: 0;
  margin-bottom: 0.15rem;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

@media (max-width: 520px) {
  .mode-switch {
    grid-template-columns: 1fr;
  }
}

.mode-option {
  position: relative;
  display: block;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-solid);
  font-weight: 650;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.mode-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.mode-option input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.15);
}

.label {
  font-size: 0.9rem;
  font-weight: 650;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-solid);
  color: var(--ink);
  font: inherit;
  padding: 0.75rem 0.85rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  resize: vertical;
  min-height: 7rem;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.15);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.primary-btn,
.ghost-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  padding: 0.7rem 1rem;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
}

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

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.7);
}

.status {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
}

.prompt-box {
  margin: 0;
  max-height: min(70vh, 640px);
  overflow: auto;
  padding: 1rem;
  border-radius: 14px;
  background: #15231d;
  color: #e7f2ec;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.footer {
  margin-top: 1.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 46rem;
}

.footer p {
  margin: 0;
}

.footer-meta {
  margin-top: 0.65rem !important;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  font-size: 0.82rem;
}

.footer-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

@media (max-width: 860px) {
  .page {
    width: min(100% - 1.25rem, 1120px);
    padding-top: 1.5rem;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .prompt-box {
    max-height: 50vh;
  }
}

/* Admin */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 1rem 0 0;
}

.admin-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mode-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.admin-hint {
  margin: 0 0 0.85rem;
}

.admin-hint code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

#template-editor {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.admin-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.versions-block {
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.versions-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.versions-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 320px;
  overflow: auto;
}

.version-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.version-row.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.version-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.version-meta span {
  color: var(--muted);
  font-size: 0.82rem;
}

.version-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.login-panel {
  max-width: 420px;
}

.admin-user {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.password-panel {
  margin-bottom: 1rem;
}

@media (max-width: 860px) {
  .admin-meta-row {
    grid-template-columns: 1fr;
  }
}
