:root {
  --bg: #f3f6f1;
  --ink: #1c2620;
  --muted: #56655b;
  --line: #d3ddd4;
  --accent: #3c7a32;
  --accent-ink: #ffffff;
  --error: #b3261e;
  --field: #ffffff;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111813;
    --ink: #e3ece5;
    --muted: #9cab9f;
    --line: #2a372e;
    --accent: #7bc46b;
    --accent-ink: #0f1a10;
    --error: #f2928b;
    --field: #182019;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 4rem 1.5rem 5rem;
}

h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0.75rem 0 1rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

p { margin: 0 0 1rem; }

.lead { color: var(--muted); }

code, .readings dd {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

code { font-size: 0.92em; }

/* Status koneksi: satu-satunya animasi di halaman */
.connection {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  margin: 0;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--muted);
}

.connection[data-state="ok"] .dot {
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

.connection[data-state="error"] .dot { background: var(--error); }
.connection[data-state="error"] { color: var(--error); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  50% { box-shadow: 0 0 0 0.45rem color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* Data dari server */
.readings {
  margin: 2rem 0 1rem;
  border-top: 1px solid var(--line);
}

.readings div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}

.readings dt { color: var(--muted); }

.readings dd {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 500;
  text-align: right;
}

/* Tombol dan input */
button, input {
  font: inherit;
  border-radius: 0.5rem;
}

button {
  cursor: pointer;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 400;
}

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
}

.try { margin-top: 3.5rem; }

.row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.reply { min-height: 1.6em; font-weight: 600; }
.reply.error { color: var(--error); font-weight: 400; }

.next {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.next h2 { color: var(--ink); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 30rem) {
  main { padding-top: 2.5rem; }
  .row { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .connection[data-state="ok"] .dot { animation: none; }
}
