:root {
  color-scheme: dark;
  --bg: #07100d;
  --panel: rgba(11, 24, 19, 0.78);
  --line: rgba(194, 232, 214, 0.15);
  --text: #eef7f1;
  --muted: #9eb1a7;
  --accent: #d6f7b4;
  --accent-2: #8cd6bf;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 0%, rgba(53, 96, 72, 0.28), transparent 38%),
    radial-gradient(circle at 85% 30%, rgba(36, 73, 72, 0.2), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
}

body { overflow-x: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 11px;
  letter-spacing: .18em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 68px);
  font-weight: 500;
  letter-spacing: -.035em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.controls { display: flex; gap: 8px; }

.ghost-button,
.sprout-button,
.word-form button {
  border: 1px solid rgba(210, 246, 225, 0.2);
  border-radius: 999px;
  background: rgba(238, 247, 241, 0.06);
  color: var(--text);
  padding: 9px 14px;
  transition: .18s ease;
}

.ghost-button:hover,
.sprout-button:hover,
.word-form button:hover {
  border-color: rgba(214, 247, 180, 0.55);
  background: rgba(214, 247, 180, 0.1);
}

.stage-wrap {
  position: relative;
  height: min(67vh, 680px);
  min-height: 460px;
  overflow: hidden;
  border: 1px solid rgba(200, 237, 220, .14);
  border-radius: 28px;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(43, 78, 61, .36), rgba(6, 14, 11, .82));
  background-size: 40px 40px, 40px 40px, auto;
  box-shadow: inset 0 0 90px rgba(0,0,0,.32), 0 30px 70px rgba(0,0,0,.18);
}

#terrarium {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hint {
  position: absolute;
  left: 22px;
  bottom: 18px;
  color: rgba(223, 240, 231, .52);
  font-size: 12px;
  pointer-events: none;
}

.inspector {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(330px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(210, 246, 225, 0.16);
  border-radius: 22px;
  background: rgba(6, 16, 12, .82);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: .18s ease;
}

.inspector.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.inspector-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
}

.inspector-kicker {
  margin: 0 0 5px;
  color: var(--accent-2);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.inspector h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 500;
}

.selected-note {
  color: var(--muted);
  line-height: 1.75;
  font-size: 13px;
}

.relation-list {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.relation {
  padding: 10px 12px;
  border-left: 2px solid rgba(214, 247, 180, .48);
  background: rgba(255,255,255,.035);
  color: #cad9d1;
  font-size: 12px;
  line-height: 1.55;
}

.relation b { color: var(--text); }
.sprout-button { width: 100%; }

.word-form {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(200, 237, 220, .12);
  border-radius: 22px;
  background: rgba(8, 20, 15, .52);
}

.word-form > label:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.input-row { display: flex; gap: 8px; }

.word-form input[type="text"],
.word-form input:not([type]) {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(210, 246, 225, .16);
  border-radius: 999px;
  outline: none;
  background: rgba(0,0,0,.16);
  color: var(--text);
  padding: 11px 16px;
}

.word-form input:focus {
  border-color: rgba(214, 247, 180, .62);
  box-shadow: 0 0 0 3px rgba(214, 247, 180, .06);
}

.word-form button:not(.secondary) {
  background: rgba(214, 247, 180, .9);
  color: #102017;
  border-color: transparent;
}

.word-form .secondary { color: var(--muted); }

.auto-grow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.auto-grow input { accent-color: #bde78f; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  color: rgba(194, 216, 205, .46);
  font-size: 11px;
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
  .topbar { align-items: start; flex-direction: column; }
  .stage-wrap { min-height: 520px; height: 62vh; border-radius: 22px; }
  .input-row { flex-wrap: wrap; }
  .word-form input { flex-basis: 100%; }
  .word-form button { flex: 1; }
  footer { flex-direction: column; }
}
