@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg: #f4f7f3;
  --bg-strong: #e8efe2;
  --card: #ffffff;
  --ink: #142216;
  --muted: #4a5f4f;
  --accent: #e1692d;
  --accent-2: #0f7a68;
  --ok: #12805b;
  --warn: #ba3f1e;
  --neutral: #45525a;
  --line: #d5dfd0;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: radial-gradient(circle at 10% 10%, #fff9ea 0%, transparent 35%),
              radial-gradient(circle at 95% 15%, #e6fff5 0%, transparent 40%),
              linear-gradient(160deg, var(--bg) 0%, var(--bg-strong) 100%);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  z-index: 0;
  filter: blur(2px);
}

.bg-shape-a {
  width: 260px;
  height: 260px;
  top: -70px;
  right: -70px;
  background: rgba(225, 105, 45, 0.14);
}

.bg-shape-b {
  width: 320px;
  height: 320px;
  left: -120px;
  bottom: -120px;
  background: rgba(15, 122, 104, 0.12);
}

.hero {
  position: relative;
  z-index: 1;
  padding: 28px 22px 12px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.3vw, 2.1rem);
  letter-spacing: 0.02em;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  gap: 16px;
  padding: 16px 22px 28px;
}

.card {
  background: color-mix(in oklab, var(--card) 96%, #f9fff8 4%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(20, 34, 22, 0.06);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.02rem;
}

label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92rem;
}

input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  background: #ffffff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.csv-row {
  margin-top: 8px;
}

.csv-label {
  margin-bottom: 6px;
}

.csv-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.csv-template-link {
  text-decoration: none;
  text-align: center;
}

.csv-status {
  margin-top: 6px;
  font-size: 0.84rem;
  color: var(--muted);
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

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

#run_btn {
  margin-top: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #f08f4b 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(225, 105, 45, 0.28);
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

#run_btn.loading {
  opacity: 0.92;
  cursor: wait;
}

.loader {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.chip {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.83rem;
  border: 1px solid transparent;
}

.chip.neutral {
  background: #eef3ef;
  border-color: #d8e1db;
  color: var(--neutral);
}

.chip.ok {
  background: #e6f8ef;
  border-color: #bde8d6;
  color: var(--ok);
}

.chip.error {
  background: #ffe8df;
  border-color: #ffc6b3;
  color: var(--warn);
}

.error-box {
  margin-top: 8px;
  margin-bottom: 10px;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid #ffd2bf;
  background: #fff1ea;
  color: #8f2e15;
  white-space: pre-wrap;
}

.hidden {
  display: none;
}

.output {
  min-height: 110px;
  max-height: 320px;
  overflow: auto;
  border: 1px dashed #cbd8c9;
  border-radius: 10px;
  padding: 10px;
  background: #f8fbf8;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0;
}

.raw {
  margin-top: 8px;
}

details {
  margin-top: 12px;
  padding-top: 2px;
}

summary {
  cursor: pointer;
  color: var(--accent-2);
  font-weight: 700;
}

.history-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfffb;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.history-body {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  font-family: var(--mono);
  line-height: 1.45;
}

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

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 10px 14px 18px;
  }

  .hero {
    padding: 18px 14px 8px;
  }
}
