:root {
  --bg0: #070b0a;
  --bg1: #0d1412;
  --panel: rgba(18, 28, 24, 0.72);
  --panel-solid: #121c18;
  --line: rgba(180, 210, 195, 0.12);
  --line-strong: rgba(180, 210, 195, 0.22);
  --text: #e8f0ea;
  --muted: #8aa093;
  --faint: #5f7267;
  --jade: #3dcf9a;
  --jade-dim: #1f7a5c;
  --mint: #a8f0d0;
  --gold: #d4b483;
  --rose: #ff8f8f;
  --ok: #3dcf9a;
  --off: #6b7a72;
  --bad: #ff8f8f;
  --radius: 20px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
body { padding-bottom: calc(28px + var(--safe-b)); overflow-x: hidden; }

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 207, 154, 0.16), transparent 55%),
    radial-gradient(900px 500px at 110% 20%, rgba(212, 180, 131, 0.1), transparent 50%),
    linear-gradient(180deg, #070b0a 0%, #0a100e 40%, #070b0a 100%);
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-a {
  width: 280px; height: 280px;
  left: -60px; top: 120px;
  background: rgba(61, 207, 154, 0.22);
}
.orb-b {
  width: 220px; height: 220px;
  right: -40px; top: 380px;
  background: rgba(212, 180, 131, 0.18);
  animation-delay: -6s;
}
.grid-fade {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(168, 240, 208, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 240, 208, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  opacity: 0.5;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-t)) 14px 0;
}

.level { display: none; animation: rise 0.38s ease both; }
.level.active { display: block; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.eyebrow {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.logo {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}
.top-actions { display: flex; gap: 8px; }

.icon-btn, .back-btn, .text-btn, .ghost, .cta, .cta-sm, .chip, .choice, .run-btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 999px;
  transition: 0.18s ease;
}
.icon-btn, .cta-sm {
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
}
.back-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
}
.text-btn {
  border: none;
  background: transparent;
  color: var(--jade);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 4px 0;
}
.icon-btn:active, .back-btn:active, .chip:active, .choice:active { transform: scale(0.97); }

.hero-card {
  position: relative;
  min-height: 220px;
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.hero-media {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, #16352c, #0c1a16 60%, #1a2a20);
  background-size: cover;
  background-position: center;
  transform: scale(1.04);
  animation: softZoom 12s ease-in-out infinite alternate;
}
.hero-fade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(7,11,10,0.55) 0%, rgba(7,11,10,0.15) 45%, rgba(7,11,10,0.8) 100%),
    linear-gradient(180deg, transparent 20%, rgba(7,11,10,0.85) 100%);
}
.hero-body {
  position: relative;
  z-index: 1;
  padding: 28px 22px 24px;
  max-width: 34rem;
}
.hero-praise {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 4.5vw, 1.75rem);
  line-height: 1.2;
  font-style: italic;
}
.hero-quote {
  margin: 0;
  color: rgba(232, 240, 234, 0.78);
  font-size: 0.86rem;
  line-height: 1.5;
}

.block {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.block-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}
.soft { color: var(--faint); font-size: 0.72rem; }

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.88rem;
}
.chip.on {
  background: linear-gradient(135deg, var(--jade-dim), #156b4f);
  border-color: rgba(61, 207, 154, 0.45);
  color: #04140e;
  color: #e8fff5;
  box-shadow: 0 0 0 1px rgba(61, 207, 154, 0.2), 0 8px 24px rgba(31, 122, 92, 0.35);
}

.cat-title {
  margin: 18px 0 8px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.cat-title:first-child { margin-top: 0; }

.bot-grid { display: grid; gap: 8px; }
.bot-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.025);
  border-radius: 16px;
  padding: 14px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.bot-card:active { transform: scale(0.985); }
.bot-card:hover { border-color: rgba(61, 207, 154, 0.35); background: rgba(61, 207, 154, 0.05); }
.bot-card h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 650; }
.bot-card p { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.pill.ok { background: rgba(61, 207, 154, 0.15); color: var(--ok); }
.pill.off { background: rgba(255,255,255,0.06); color: var(--off); }
.pill.bad { background: rgba(255, 143, 143, 0.12); color: var(--bad); }

.bot-hero { margin: 4px 0 18px; }
.bot-hero h1 {
  margin: 4px 0 8px;
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 400;
  line-height: 1.05;
}
.lede { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

.inst {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.2);
  margin-bottom: 8px;
}
.inst strong { display: block; font-size: 0.95rem; }
.inst span { color: var(--faint); font-size: 0.75rem; }
.inst-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.run-btn {
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 650;
}
.run-btn.primary {
  background: linear-gradient(135deg, #2aa876, #1a6b4f);
  border-color: transparent;
  color: #04140e;
  color: #f2fff9;
}
.run-btn.danger { color: var(--rose); border-color: rgba(255,143,143,0.3); }

.panel-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.ptab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.ptab.on {
  color: var(--text);
  border-color: rgba(61, 207, 154, 0.4);
  background: rgba(61, 207, 154, 0.1);
}

.panel-card { animation: rise 0.25s ease; }
.panel-card .sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}
.kind-tag {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 6px;
}

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 650;
  margin-bottom: 3px;
}
.field-help {
  display: block;
  color: var(--faint);
  font-size: 0.75rem;
  line-height: 1.35;
  margin-bottom: 7px;
}
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(0,0,0,0.28);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(61, 207, 154, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 207, 154, 0.12);
}
.field textarea { min-height: 88px; resize: vertical; }
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
}
.switch input {
  width: 42px;
  height: 24px;
  accent-color: var(--jade);
}

.cta {
  width: 100%;
  margin-top: 8px;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, #34c48f, #1b7a58);
  color: #04140e;
  box-shadow: 0 10px 30px rgba(31, 122, 92, 0.35);
}
.ghost {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: transparent;
}

.form-stack { padding-bottom: 20px; }

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.choice {
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 12px;
}
.choice.on {
  background: rgba(61, 207, 154, 0.16);
  border-color: rgba(61, 207, 154, 0.45);
  color: var(--mint);
}

.acc-card, .rt-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  backdrop-filter: blur(12px);
}
.acc-card h3, .rt-card h3 { margin: 0 0 4px; font-size: 1rem; }
.meta { color: var(--muted); font-size: 0.8rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.rt-card input {
  flex: 1;
  min-width: 140px;
  border: 1px solid var(--line-strong);
  background: rgba(0,0,0,0.28);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.logbox {
  margin: 0 0 20px;
  padding: 12px;
  border-radius: 14px;
  background: #040706;
  border: 1px solid var(--line);
  color: #b7d0c2;
  font-size: 0.7rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}

.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet[hidden] { display: none !important; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(4px); }
.sheet-card {
  position: absolute;
  left: 12px; right: 12px; bottom: calc(12px + var(--safe-b));
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 18px;
  animation: rise 0.25s ease;
}
.sheet-card h2 { margin: 0 0 12px; font-family: var(--serif); font-weight: 400; font-size: 1.6rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
}
.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--mint);
}
.stat span { color: var(--muted); font-size: 0.75rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 60;
  background: #102019;
  border: 1px solid rgba(61, 207, 154, 0.35);
  color: var(--mint);
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.86rem;
  font-weight: 600;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  animation: rise 0.2s ease;
}
.toast[hidden] { display: none !important; }
.toast.err { color: var(--rose); border-color: rgba(255,143,143,0.35); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { transform: translate(0, 0); }
  to { transform: translate(30px, 40px); }
}
@keyframes softZoom {
  from { transform: scale(1.02); }
  to { transform: scale(1.08); }
}
