:root {
  --yellow: #ffd400;
  --yellow-deep: #f0b400;
  --black: #111111;
  --ink: #1c1c1c;
  --paper: #fffaf0;
  --green: #22b14c;
  --green-deep: #178a39;
  --red: #e8332a;
  --red-deep: #b8241d;
  --muted: #6b6b60;
  --radius: 18px;
  --shadow: 0 6px 0 var(--black);
  --font: "Fredoka", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--yellow);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.12) 1.5px, transparent 0);
  background-size: 22px 22px;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h1 { font-size: 2.6rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.screen { max-width: 640px; margin: 0 auto; padding: 1rem; }

/* ---- Buttons ---- */
.btn {
  font: inherit; font-weight: 700; font-size: 1.05rem;
  border: 3px solid var(--black); border-radius: 999px;
  padding: 0.75rem 1.4rem; cursor: pointer; color: #fff;
  box-shadow: var(--shadow); transition: transform 0.08s, box-shadow 0.08s;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--black); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.big { font-size: 1.3rem; padding: 1rem 2rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--ink); text-decoration: underline; font: inherit; cursor: pointer; }

/* ---- Gate ---- */
.gate { text-align: center; padding-top: 10vh; }
.gate .sub { font-size: 1.1rem; margin: 0 0 1.5rem; }
.gate form { display: flex; flex-direction: column; gap: 0.8rem; align-items: center; }
.gate input {
  font: inherit; font-size: 1.5rem; text-align: center; letter-spacing: 0.3em;
  width: min(320px, 90vw); padding: 0.7rem; border: 3px solid var(--black);
  border-radius: var(--radius); background: var(--paper);
}
.error { color: var(--red-deep); font-weight: 600; }

.postie {
  width: 140px; height: 140px; margin: 0 auto 1rem; position: relative;
  background: var(--yellow); border: 5px solid var(--black); border-radius: 50%;
  box-shadow: var(--shadow); animation: bob 3s ease-in-out infinite;
}
.postie .eye {
  position: absolute; top: 42px; width: 26px; height: 26px; border-radius: 50%; background: var(--black);
  animation: blink 5s infinite;
}
.postie .eye::after { content: ""; position: absolute; left: 6px; top: 5px; width: 8px; height: 8px; background: #fff; border-radius: 50%; }
.postie .eye.left { left: 34px; } .postie .eye.right { right: 34px; }
.postie .mouth {
  position: absolute; left: 50%; bottom: 30px; width: 50px; height: 24px; margin-left: -25px;
  border: 5px solid var(--black); border-top: 0; border-radius: 0 0 50px 50px;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@media (prefers-reduced-motion: reduce) { .postie, .postie .eye, .rec.recording .rec-ring { animation: none !important; } }

/* ---- App layout ---- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0.25rem 0 1rem; }
.brand { font-weight: 700; font-size: 1.4rem; display: flex; align-items: center; gap: 0.5rem; }
.brand .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--black); display: inline-block; }
.who label { font-weight: 600; margin-right: 0.4rem; }
select, input[type="time"], input[type="number"], input[type="text"], input:not([type]) {
  font: inherit; padding: 0.45rem 0.7rem; border: 3px solid var(--black); border-radius: 12px; background: var(--paper);
}

.card {
  background: var(--paper); border: 3px solid var(--black); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}

/* ---- Devices strip ---- */
.devices { display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 1rem; }
.device {
  flex: 0 0 auto; background: var(--black); color: var(--yellow); border-radius: 12px;
  padding: 0.5rem 0.8rem; font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem;
}
.device .led { width: 10px; height: 10px; border-radius: 50%; background: #777; }
.device.online .led { background: var(--green); box-shadow: 0 0 8px var(--green); }
.device .name { font-weight: 700; text-transform: capitalize; }

/* ---- Send ---- */
.to { display: flex; gap: 0.6rem; margin-bottom: 1rem; }
.to button {
  flex: 1; font: inherit; font-weight: 700; font-size: 1.1rem; padding: 0.8rem 0.5rem;
  border: 3px solid var(--black); border-radius: 14px; background: #fff; cursor: pointer; text-transform: capitalize;
}
.to button[aria-checked="true"] { background: var(--black); color: var(--yellow); }

.record-row { display: flex; align-items: center; gap: 1rem; }
.rec {
  position: relative; width: 140px; height: 140px; border-radius: 50%; flex: 0 0 auto;
  background: var(--green); border: 5px solid var(--black); color: #fff; font: inherit; font-weight: 700;
  font-size: 1.05rem; line-height: 1.1; box-shadow: 0 8px 0 var(--black); cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
}
.rec:active, .rec.recording { transform: translateY(6px); box-shadow: 0 2px 0 var(--black); background: var(--red); }
.rec-label { position: relative; z-index: 1; }
.rec-ring { position: absolute; inset: -14px; border-radius: 50%; border: 4px solid var(--red); opacity: 0; }
.rec.recording .rec-ring { animation: pulse 1s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(1.25); opacity: 0; } }
.rec-meta { flex: 1; font-size: 1rem; }
.timer { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.preview { margin-top: 1rem; padding: 0.8rem; background: #fff; border: 3px dashed var(--black); border-radius: 14px; }
.preview audio { width: 100%; margin-bottom: 0.6rem; }
.preview-actions { display: flex; gap: 0.6rem; }
.preview-actions .btn { flex: 1; }

.text-send { margin-top: 1rem; }
.text-send summary { cursor: pointer; font-weight: 600; }
.text-send form { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.text-send input { flex: 1; }

.stickers { margin-top: 1rem; }
.sticker-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sticker-list button {
  font: inherit; font-weight: 600; padding: 0.5rem 0.9rem; border: 3px solid var(--black);
  border-radius: 999px; background: var(--yellow); cursor: pointer; text-transform: capitalize;
}
.status { min-height: 1.4em; font-weight: 600; margin: 0.8rem 0 0; }
.status.ok { color: var(--green-deep); } .status.bad { color: var(--red-deep); }

/* ---- Inbox ---- */
.inbox-head { display: flex; justify-content: space-between; align-items: baseline; }
.filter { font-weight: 600; }
.day { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--muted); margin: 1rem 0 0.4rem; }
.msg {
  display: grid; grid-template-columns: 56px 1fr; gap: 0.7rem; align-items: start;
  padding: 0.7rem 0; border-top: 2px solid rgba(0, 0, 0, 0.08);
}
.msg .play {
  width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--black); background: var(--green);
  color: #fff; font-size: 1.4rem; cursor: pointer; box-shadow: 0 4px 0 var(--black);
}
.msg .play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--black); }
.msg .play.playing { background: var(--red); }
.msg.postie .play { background: var(--yellow); color: var(--black); }
.msg .from { font-weight: 700; text-transform: capitalize; }
.msg .meta { font-size: 0.8rem; color: var(--muted); }
.msg .transcript { margin: 0.2rem 0 0; font-size: 1.05rem; }
.msg .flags { font-size: 0.75rem; color: var(--muted); }

/* ---- Schedules ---- */
.sched { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.5rem 0; border-top: 2px solid rgba(0,0,0,0.08); }
.sched .desc { flex: 1; }
.sched .desc small { display: block; color: var(--muted); }
.sched .del { background: none; border: 0; color: var(--red-deep); font: inherit; font-weight: 700; cursor: pointer; }
.sched-form { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.sched-form .row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.sched-form label { display: flex; flex-direction: column; font-size: 0.8rem; font-weight: 600; gap: 0.2rem; }
.sched-form label.grow { flex: 1; }
.foot { text-align: center; padding: 1rem 0 2rem; }

@media (max-width: 480px) {
  h1 { font-size: 2.1rem; }
  .record-row { flex-direction: column; text-align: center; }
}
