:root {
  color-scheme: dark;
  --ink: #0d1211;
  --ink-soft: #141b19;
  --card: #161e1b;
  --edge: #27322d;
  --paper: #e6ddc6;
  --paper-dim: #a7a391;
  --moss: #7fa06a;
  --water: #5f8fa0;
  --ember: #d08a52;
  --warn: #c6705e;
  --voice: ui-serif, Iowan Old Style, Palatino, Georgia, serif;
  --read: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--voice);
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(120% 70% at 50% -10%, #1b2420 0%, transparent 60%),
    linear-gradient(180deg, #0d1211 0%, #0b0f0e 100%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.masthead {
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 20px 10px;
  position: relative;
}

.masthead h1 {
  font-size: clamp(2.3rem, 7vw, 3.4rem);
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.masthead h1::after {
  content: "";
  display: block;
  width: 58px;
  height: 2px;
  margin-top: 10px;
  background: linear-gradient(90deg, var(--moss), transparent);
}

.tagline {
  margin: 12px 0 0;
  color: var(--paper-dim);
  font-size: 1rem;
  max-width: 46ch;
}

.status {
  position: absolute;
  top: 40px;
  right: 20px;
  font-family: var(--read);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px currentColor;
  color: var(--warn);
}

.dot.live { background: var(--moss); color: var(--moss); animation: pulse 3.2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.valley {
  position: sticky;
  top: 18px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  overflow: hidden;
  background: #0a0f0d;
  box-shadow: 0 20px 50px -30px #000;
}

.valley canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}

.valley-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-top: 1px solid var(--edge);
  font-family: var(--read);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-dim);
  background: #0c1210;
}

.sep { opacity: 0.4; }

.panel { display: flex; flex-direction: column; gap: 16px; }

.card {
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--card), var(--ink-soft));
  padding: 16px 18px;
}

.card h2 {
  margin: 0 0 10px;
  font-family: var(--read);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-dim);
  font-weight: 500;
}

.voice { border-color: #34412f; }

.thought {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.thought.fresh { animation: settle 0.9s ease-out; }

@keyframes settle {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.thought-meta, .notice, .knows {
  font-family: var(--read);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--paper-dim);
  margin: 10px 0 0;
}

.mood { margin: 0 0 14px; font-size: 1.02rem; }
.mood em { color: var(--moss); font-style: normal; }

.needs { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }

.needs li {
  display: grid;
  grid-template-columns: 5.6rem 1fr 2.1rem;
  align-items: center;
  gap: 10px;
  font-family: var(--read);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--paper-dim);
}

.meter {
  height: 5px;
  border-radius: 3px;
  background: #222b27;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--moss);
  transition: width 1.2s linear, background-color 1.2s linear;
}

.needs li.low .meter span { background: var(--warn); }
.needs li.middling .meter span { background: var(--ember); }
.needs li b { color: var(--paper); font-weight: 500; text-align: right; }

.goal {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--edge);
  font-size: 0.95rem;
  color: var(--paper-dim);
}

.goal em { color: var(--paper); font-style: italic; }

form { display: grid; gap: 8px; }

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

input, button {
  font-family: var(--read);
  font-size: 0.82rem;
  border-radius: 8px;
  border: 1px solid var(--edge);
  padding: 10px 12px;
  background: #0d1312;
  color: var(--paper);
}

input { flex: 1; min-width: 0; }
input::placeholder { color: #6d7a72; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--moss); outline-offset: 1px; }

button {
  cursor: pointer;
  background: #1d2723;
  border-color: #33413a;
  transition: background-color 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

button:hover:not(:disabled) { background: #273430; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; }

.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.actions button { flex: 1 1 auto; }

.notice[data-tone="bad"] { color: var(--warn); }
.notice[data-tone="good"] { color: var(--moss); }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; max-height: 320px; overflow-y: auto; }

.feed li {
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  gap: 10px;
  font-size: 0.93rem;
  color: #cfc8b3;
  padding-bottom: 9px;
  border-bottom: 1px solid #1d2622;
}

.feed li:last-child { border-bottom: 0; padding-bottom: 0; }

.feed time {
  font-family: var(--read);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: #6d7a72;
  padding-top: 3px;
}

.feed li[data-kind="talk"], .feed li[data-kind="said"] { color: var(--paper); }
.feed li[data-kind="gift"] time, .feed li[data-kind="pet"] time, .feed li[data-kind="visitor_join"] time { color: var(--moss); }

footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 60px;
  color: #6d7a72;
  font-size: 0.86rem;
}

footer p { max-width: 62ch; }

@media (max-width: 860px) {
  main { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 10px; }
  .valley { position: static; }
  .masthead { padding-top: 24px; }
  .status { position: static; margin-top: 14px; }
  .feed { max-height: none; }
  .needs li { grid-template-columns: 5.2rem 1fr 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .dot.live { animation: none; }
  .thought.fresh { animation: none; }
}
