:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-soft: #f7f9f6;
  --text: #20252b;
  --muted: #616861;
  --border: #d9ded7;
  --accent: #355248;
  --accent-hover: #263d36;
  --chip: #f2f5ef;
  --shadow: 0 12px 28px rgba(46, 35, 18, 0.08);
  --shadow-strong: 0 18px 42px rgba(15, 23, 42, 0.14);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --page-width: 1120px;
  --font-ui: "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 10px 18px 32px;
}

.admin-page {
  max-width: 980px;
  margin: 24px auto;
  padding: 0 16px 32px;
}

.hero {
  background:
    radial-gradient(circle at top right, rgba(113, 164, 116, 0.18), transparent 24%),
    linear-gradient(180deg, #171713 0%, #1d1c18 100%);
  border: 1px solid rgba(217, 202, 179, 0.12);
  border-radius: var(--radius-xl);
  padding: 16px 18px 16px;
  box-shadow: var(--shadow-strong);
  margin-bottom: 12px;
  color: #f7efe4;
}

.hero-topline,
.hero-brand,
.hero-meta,
.hero-main {
  display: flex;
}

.hero-topline {
  justify-content: flex-start;
  align-items: center;
}

.hero-brand {
  align-items: center;
}

.hero-logo {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(233, 220, 199, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff8ef;
}

.hero-stat-grid span {
  color: #cdbfa8;
}

.hero-stat-grid span {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: none;
}

.hero-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
  margin: 18px 0 0;
}

.hero-copy {
  min-width: 0;
  max-width: 540px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3.55vw, 2.95rem);
  line-height: 1.02;
  letter-spacing: -0.018em;
  font-weight: 700;
  color: #fff8ef;
}

.hero-copy p {
  max-width: 540px;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
  color: #d9cec0;
}

.hero-kicker {
  margin: 0 0 6px;
  color: #f0e5d3;
  font-size: 0.9rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.hero-stat-grid {
  width: 360px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(233, 220, 199, 0.1);
  background: rgba(255, 255, 255, 0.03);
  margin-top: -8px;
}

.hero-stat-grid article {
  min-height: 78px;
  padding: 12px 14px 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-right: 1px solid rgba(233, 220, 199, 0.1);
  border-bottom: 1px solid rgba(233, 220, 199, 0.1);
}

.hero-stat-grid article:nth-child(2n) {
  border-right: none;
}

.hero-stat-grid article:nth-last-child(-n + 2) {
  border-bottom: none;
}

.hero-stat-grid strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.24rem;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.012em;
  color: #fff8ef;
}

.hero-stat-grid span {
  display: block;
  line-height: 1.35;
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}

@media (max-width: 900px) {
  .hero h1 {
    font-size: clamp(1.9rem, 7vw, 2.5rem);
  }

  .hero-copy p {
    font-size: 0.98rem;
  }
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.label-tip-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.section-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading .section-label {
  margin-bottom: 0;
}

.ask-heading {
  display: block;
  margin-bottom: 12px;
}

.small {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.card,
.admin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 20px rgba(23, 32, 40, 0.05);
  padding: 23px;
  margin-bottom: 18px;
}

.question-card {
  padding: 20px;
}

.question-card .section-heading {
  margin-bottom: 10px;
}

.template-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.question-card .examples {
  gap: 10px;
}

.question-card .ex {
  min-height: 48px;
  padding: 11px 13px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.context-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  background: #ffffff;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(53, 82, 72, 0.12);
}

@keyframes input-loaded {
  0%   { border-color: var(--accent); box-shadow: 0 0 0 5px rgba(53, 82, 72, 0.32); background: #f0f7f4; }
  60%  { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(53, 82, 72, 0.18); background: #f7fbf9; }
  100% { border-color: var(--border); box-shadow: none; background: #ffffff; }
}

input.q-loaded {
  animation: input-loaded 0.9s ease-out forwards;
}

button {
  border: 1px solid #d8dfd4;
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:hover {
  background: #e9efe6;
  transform: translateY(-1px);
}

button.secondary {
  border-radius: var(--radius-sm);
  background: #f6f8f4;
  color: var(--text);
}

button.secondary:hover {
  background: #edf2ea;
}

#askBtn,
#reloadBtn,
#ingestBtn,
#ingestStarBtn {
  border: none;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 700;
  box-shadow: 0 10px 18px rgba(53, 82, 72, 0.18);
}

#askBtn:hover,
#reloadBtn:hover,
#ingestBtn:hover,
#ingestStarBtn:hover {
  background: var(--accent-hover);
  box-shadow: 0 12px 22px rgba(53, 82, 72, 0.24);
}

.ask-footer {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.option-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.ex {
  display: block;
  min-height: 54px;
  border-radius: var(--radius-md);
  padding: 13px 15px;
  text-align: left;
  background: #fffdfa;
  border: 1px solid #dde3db;
  line-height: 1.35;
  font-size: 14px;
}

.ex:hover {
  background: #f3f6f1;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  font-style: normal;
  cursor: help;
  flex: 0 0 auto;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  width: min(280px, 68vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: #2d2a23;
  color: #f7f1e8;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.option-row {
  gap: 14px;
  align-items: flex-start;
}

.option-row .label-tip-group {
  gap: 5px;
}

.checkbox-label {
  margin-top: 1px;
}

.info-tip:hover::after,
.info-tip:focus-visible::after {
  opacity: 1;
}

#pretty,
#out {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 160px;
  white-space: pre-wrap;
  line-height: 1.6;
}

@keyframes km-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

#pretty.is-loading {
  color: var(--muted);
  animation: km-pulse 1.4s ease-in-out infinite;
}

.followups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.followups .ex {
  border-radius: var(--radius-md);
  padding: 11px 13px;
  background: #f5f8f3;
  border: 1px solid #d8e1d6;
  color: #395a41;
  text-align: left;
}

.followups .ex:hover {
  background: #e4f2ea;
}

.answer-header {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 14px;
}

.answer-actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.followup-section {
  margin-top: 14px;
}

.ask-note {
  margin-top: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-line,
.status-chip {
  color: var(--muted);
  font-size: 13px;
}

.status-line:empty {
  display: none;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
}

.footer-note,
.tip {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.admin-card h1,
.admin-card h2 {
  margin: 0 0 10px;
}

.admin-card h2 {
  font-size: 18px;
}

.admin-section {
  margin-bottom: 24px;
}

.site-footer {
  margin: 10px 0 0;
  padding: 10px 4px 0;
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.admin-footer {
  padding-top: 2px;
}

@media (max-width: 720px) {
  .context-row {
    grid-template-columns: 1fr;
  }

  .hero-topline,
  .hero-main {
    display: block;
  }

  .hero-main {
    margin-top: 20px;
  }

  .hero-meta {
    margin-top: 16px;
  }

  .hero-stat-grid {
    grid-template-columns: 1fr 1fr;
    width: 100%;
    margin-top: 20px;
    flex-basis: auto;
  }

  .hero-stat-grid article {
    min-height: 0;
    border-right: none;
  }

  .hero-stat-grid article:nth-last-child(-n + 2) {
    border-bottom: 1px solid rgba(233, 220, 199, 0.1);
  }

  .hero-stat-grid article:last-child {
    border-bottom: none;
  }

  .ask-footer,
  .answer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .option-row {
    align-items: flex-start;
  }

  #askBtn,
  #reloadBtn,
  #ingestBtn,
  #ingestStarBtn {
    width: 100%;
  }
}
