:root {
  --bg: #f4f6f4;
  --card: #ffffff;
  --ink: #1b2420;
  --muted: #667066;
  --border: #e0e6e0;
  --accent: #2f8f5b;
  --accent-dim: #cfe8db;
  --danger: #b3441e;
  --tank-empty: #e3ece4;
  --tank-fill: #3aa16d;
  --mono: "SFMono-Regular", Consolas, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121813;
    --card: #1a221b;
    --ink: #eef2ee;
    --muted: #93a093;
    --border: #2a352b;
    --accent: #4cb87f;
    --accent-dim: #1f3a2b;
    --danger: #e0784f;
    --tank-empty: #22301f;
    --tank-fill: #3aa16d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.topbar h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.conn-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
}

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

.dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot.off { background: var(--danger); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  padding: 24px 28px 40px;
  align-items: start;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

/* Device cards sit side by side and wrap when the row gets narrow. */
.pots-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  align-items: start;
}

.pot-card, .side-card > div {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.pot-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.pot-header h2 { margin: 0; font-size: 16px; }
.topic-base {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.side-card { display: flex; flex-direction: column; gap: 20px; }

.pot-visual { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.led-row {
  display: flex;
  align-items: center;
  gap: 12px;
  align-self: flex-start;
}

.led {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s, box-shadow 0.2s;
}

.led.on {
  background: var(--accent);
  box-shadow: 0 0 12px 3px var(--accent);
}

.label { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }
.value { font-size: 18px; font-weight: 600; }

.tank {
  position: relative;
  width: 140px;
  height: 220px;
  border-radius: 10px;
  border: 3px solid var(--border);
  background: var(--tank-empty);
  overflow: hidden;
}

.tank-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: var(--tank-fill);
  transition: height 0.4s ease;
}

.tank-gridlines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to top,
    transparent 0,
    transparent calc(5% - 1px),
    rgba(0, 0, 0, 0.08) calc(5% - 1px),
    rgba(0, 0, 0, 0.08) 5%
  );
  pointer-events: none;
}

.tank-readout { text-align: center; }
.tank-readout .ml { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.controls {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--muted);
}

.control-group .hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

.row { display: flex; gap: 8px; align-items: center; }
.row + button { margin-top: 8px; }

input[type="range"] { flex: 1; }

input[type="number"] {
  width: 100px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent-dim);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }

.log-box .hint { font-size: 12px; color: var(--muted); margin-bottom: 6px; word-break: break-all; }

h2 { margin: 0 0 4px; font-size: 14px; }

.log {
  margin-top: 10px;
  height: 260px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
