/* Palet diambil dari logo: hijau zamrud + emas */
:root {
  --bg: #04140e;
  --panel: #0a2419;
  --line: #17382a;
  --text: #f1ead6;
  --muted: #93ab9d;
  --accent: #d9b44a;
  --me: #0f4a33;
  --brand: #062d20;
  color-scheme: dark;
}

/* ---------- Layar pembuka ---------- */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at 50% 40%, #12573d 0%, var(--brand) 55%, #021710 100%);
  transition: opacity .5s ease, visibility .5s;
}
#splash img {
  width: min(42vw, 220px);
  filter: drop-shadow(0 12px 32px #0008);
  animation: muncul .9s cubic-bezier(.2, .8, .2, 1) both, napas 2.4s ease-in-out .9s infinite;
}
#splash p { margin: 0; color: var(--accent); letter-spacing: .2em; font-size: .8rem; text-transform: uppercase; opacity: .8; }
#splash.hilang { opacity: 0; visibility: hidden; }
@keyframes muncul { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes napas { 50% { transform: scale(1.03); filter: drop-shadow(0 12px 40px #d9b44a33); } }
@media (prefers-reduced-motion: reduce) { #splash img { animation: none; } }

.brand-logo { width: 26px; height: 26px; vertical-align: -7px; margin-right: 8px; border-radius: 6px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; }
.brand small { color: var(--muted); font-weight: 400; margin-left: 4px; }

.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
}
.dot.ok { background: #3ecf8e; }
.dot.listening { background: var(--accent); box-shadow: 0 0 0 4px #f2b33d33; }

.dot.off { background: #e5534b; }

.actions { display: flex; align-items: center; gap: 12px; }
.siaga { color: var(--muted); font-size: .9rem; cursor: pointer; }
.siaga[hidden] { display: none; }
.icon {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
}

/* ---------- Pengaturan ---------- */
dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 20px;
}
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
dialog section { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
dialog section[hidden] { display: none; }
dialog label { font-weight: 600; font-size: .95rem; }
dialog input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
dialog select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
dialog input[type="range"] { padding: 0; accent-color: var(--accent); }
dialog output { color: var(--muted); font-weight: 400; margin-left: 6px; }
dialog button {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #111;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
dialog code { font-size: .85em; }
dialog button.secondary { width: 100%; background: var(--line); color: var(--text); }
dialog .baris { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 400; }
dialog .baris input[type="time"] { padding: 6px 8px; }
dialog .baris input[type="number"] { width: 5em; padding: 6px 8px; }
dialog summary { cursor: pointer; }
.catatan { list-style: none; margin: 8px 0 0; padding: 0; font: .78rem/1.4 ui-monospace, monospace; color: var(--muted); max-height: 30vh; overflow-y: auto; }
#set-memories { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
#set-memories li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; }
#set-memories li small { color: var(--muted); }
#set-memories li button { flex: none; padding: 6px 10px; background: #e5534b; color: #fff; font-size: .85rem; }
#set-devices, #set-catatan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#set-devices li, #set-catatan li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; }
#set-catatan li { flex-wrap: wrap; }
#set-catatan li .tombol { display: flex; gap: 6px; flex: none; }
.catatan-isi { flex-basis: 100%; overflow-x: auto; font-size: .82rem; }
.catatan-isi table { border-collapse: collapse; width: 100%; }
.catatan-isi th, .catatan-isi td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; white-space: nowrap; }
.catatan-isi th { color: var(--muted); font-weight: 600; }
#set-catatan li small { color: var(--muted); }
#set-catatan li button { flex: none; padding: 6px 10px; font-size: .85rem; }
#set-devices li button { padding: 6px 10px; background: #e5534b; color: #fff; font-size: .85rem; }
.muted { color: var(--muted); font-size: .85rem; margin: 0; }
.set-msg { color: var(--accent); margin: 0; min-height: 1.2em; font-size: .9rem; }
#set-login-form { display: flex; flex-direction: column; gap: 8px; }
#set-login-form[hidden], #set-logout[hidden] { display: none; }

main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--panel);
  white-space: pre-wrap;
}
.msg.me { align-self: flex-end; background: var(--me); }
.msg.berpikir { color: var(--muted); font-style: italic; }
.msg.berpikir::after { content: '…'; animation: pulse 1s ease-in-out infinite; }
.msg .meta { display: block; font-size: .75rem; color: var(--muted); margin-top: 4px; }

.banner {
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}
.banner[hidden] { display: none; }

.alarm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent);
  color: #111;
  font-weight: 600;
  text-align: left;
  animation: pulse 1.2s ease-in-out infinite;
}
.alarm button {
  flex: none;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font: inherit;
  cursor: pointer;
}
@keyframes pulse { 50% { opacity: .75; } }

.update {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  text-align: left;
}
.update button {
  flex: none;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #111;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.update button:disabled { opacity: .5; cursor: default; }

.hint { margin: 0; padding: 0 16px; min-height: 1.4em; color: var(--accent); font-size: .9rem; }

#form {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

#text {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
#text:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.round {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.round.active { background: var(--accent); color: #111; border-color: var(--accent); }
