@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Atkinson+Hyperlegible:wght@400;700&display=swap');

:root {
  --night: #1b2440;      /* werpkist bij nacht */
  --blanket: #263257;    /* fleecedeken */
  --blanket-2: #303d68;
  --milk: #eef1f7;
  --mist: #9ba6c4;
  --live: #ff5d6c;
  --lamp: #f6c35b;       /* warmtelamp */
  --line: rgba(238, 241, 247, .12);
  --radius-lg: 22px;
  --radius-sm: 10px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--night);
  background-image: radial-gradient(1200px 600px at 15% -10%, rgba(246, 195, 91, .10), transparent 60%);
  color: var(--milk); font: 16px/1.55 var(--body); min-height: 100vh;
}
a { color: var(--lamp); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }

.btn {
  border: 0; border-radius: 999px; padding: .6rem 1.1rem; cursor: pointer;
  background: var(--lamp); color: #2a1f05; font-weight: 700;
}
.btn.ghost { background: transparent; color: var(--milk); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: transparent; color: var(--live); box-shadow: inset 0 0 0 1.5px rgba(255,93,108,.4); }
.btn.small { padding: .3rem .75rem; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: .9rem; color: var(--mist); }
.input, textarea.input, select.input {
  width: 100%; background: var(--night); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: .65rem .8rem;
}
.input:focus { border-color: var(--lamp); outline: none; }

/* --- kop --- */
.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem clamp(1rem, 3vw, 2.25rem);
}
.brand { display: flex; align-items: center; gap: .75rem; margin-right: auto; }
.brand svg { width: 40px; height: 40px; flex: none; }
.brand h1 {
  font: 800 clamp(1.4rem, 3.2vw, 2.1rem)/1 var(--display); margin: 0; letter-spacing: -.02em;
}
.live {
  display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; font-size: .95rem;
  padding: .3rem .75rem; border-radius: 999px; background: rgba(255, 93, 108, .14); color: var(--live);
}
.live::before { content: ''; width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.live.off { background: rgba(155,166,196,.14); color: var(--mist); }
.live:not(.off)::before { animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.viewers { color: var(--mist); font-size: .95rem; }

/* --- hoofdindeling --- */
.stage {
  display: grid; gap: clamp(1rem, 2vw, 1.5rem);
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas: "video chat" "nest chat";
  padding: 0 clamp(1rem, 3vw, 2.25rem) 2rem; align-items: start;
}
.video-wrap { grid-area: video; position: relative; border-radius: var(--radius-lg); overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.video-wrap video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.video-msg {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 1rem;
  color: var(--mist); background: rgba(0,0,0,.55);
}
.video-msg[hidden] { display: none; }
.unmute { position: absolute; left: 1rem; bottom: 1rem; }

/* --- het nest: halsbandjes --- */
.nest { grid-area: nest; }
.announce { margin: 0 0 1.25rem; max-width: 70ch; color: var(--milk); font-size: 1.05rem; }
.nest h2, .chat h2 { font: 700 1.3rem/1.2 var(--display); margin: 0 0 .75rem; }
.nest-count { color: var(--mist); font-weight: 400; font-family: var(--body); font-size: 1rem; margin-left: .4rem; }
.pups { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.pup {
  position: relative; background: var(--blanket); border-radius: 16px 16px 16px 4px;
  padding: 1rem 1rem .9rem; overflow: hidden;
}
.pup .collar {
  height: 14px; margin: -1rem -1rem .85rem; background: var(--c, var(--mist));
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
.pup .collar::after { content: ''; display: block; width: 14px; height: 14px; margin-left: 1.1rem; border-radius: 50%; background: #d9dde8; box-shadow: inset 0 0 0 3px rgba(0,0,0,.15); transform: translateY(5px); }
.pup b { font: 700 1.15rem/1.2 var(--display); display: block; }
.pup .meta { color: var(--mist); font-size: .9rem; }
.pup .note { font-size: .9rem; margin-top: .35rem; }
.empty-nest { grid-column: 1 / -1; background: var(--blanket); border-radius: var(--radius-lg); padding: 1.25rem; color: var(--mist); max-width: 60ch; }

/* --- chat --- */
.chat {
  grid-area: chat; background: var(--blanket); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 420px; position: sticky; top: 1rem;
}
.chat header { padding: 1rem 1.1rem .25rem; display: flex; align-items: baseline; justify-content: space-between; }
.chat header small { color: var(--mist); }
.msgs { flex: 1; overflow-y: auto; padding: .5rem 1.1rem; display: flex; flex-direction: column; gap: .55rem; }
.msg { line-height: 1.4; overflow-wrap: anywhere; }
.msg .who { font-weight: 700; margin-right: .4rem; }
.msg .who.is-admin { color: var(--lamp); }
.msg time { color: var(--mist); font-size: .75rem; margin-left: .35rem; }
.msg.system { background: rgba(246,195,91,.16); color: #fbe3a8; border-radius: 12px; padding: .55rem .75rem; }
.msg .del { background: none; border: 0; color: var(--mist); cursor: pointer; font-size: .8rem; margin-left: .3rem; }
.chat form { display: flex; gap: .5rem; padding: .85rem; border-top: 1px solid var(--line); }
.chat form .input { border-radius: 999px; }
.chat .notice { padding: .85rem 1.1rem; color: var(--mist); border-top: 1px solid var(--line); font-size: .95rem; }

@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "video" "chat" "nest"; }
  .chat { position: static; height: 55vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* --- login --- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card { width: min(400px, 100%); }
.login-card .brand { margin-bottom: 1.75rem; }
.login-card p { color: var(--mist); margin: 0 0 1.5rem; }
.error { color: var(--live); min-height: 1.5em; margin: 0 0 .75rem; }

/* --- beheer --- */
.admin { padding: 0 clamp(1rem, 3vw, 2.25rem) 3rem; display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.panel { background: var(--blanket); border-radius: var(--radius-lg); padding: 1.25rem 1.35rem; }
.panel h2 { font: 700 1.25rem/1.2 var(--display); margin: 0 0 1rem; }
.panel p.hint { color: var(--mist); font-size: .92rem; margin: -.5rem 0 1rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.row .field { flex: 1 1 120px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
td, th { text-align: left; padding: .5rem .25rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--mist); font-weight: 400; }
.cred { background: var(--night); border-radius: var(--radius-sm); padding: .8rem 1rem; margin-top: .5rem; white-space: pre-wrap; font-size: .95rem; }
.swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0,0,0,.2); }
.swatch[aria-pressed="true"] { outline: 3px solid var(--milk); outline-offset: 2px; }
.toggle { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.toggle input { width: 1.2rem; height: 1.2rem; accent-color: var(--lamp); }
@media (max-width: 520px) {
  .top { gap: .6rem; }
  .brand h1 { font-size: 1.3rem; }
  .brand img { width: 32px; height: 32px; }
  .chat form .btn { padding-inline: .9rem; }
}
.chat form .input { min-width: 0; }

/* --- statistieken --- */
.stats { grid-column: 1 / -1; }
.stats-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.stats-head h2 { margin: 0; }
.stats h3 { font: 700 1rem/1.2 var(--display); margin: 1.5rem 0 .6rem; color: var(--milk); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.tile { background: var(--night); border-radius: 14px; padding: .85rem 1rem; display: grid; gap: .15rem; }
.tile span { color: var(--mist); font-size: .9rem; }
.tile strong { font: 800 1.9rem/1.1 var(--display); }
.tile small { color: var(--mist); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart { position: relative; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; background: var(--night); border-radius: 12px; padding: 10px 10px 0; }
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar i { display: block; width: 100%; min-height: 2px; background: var(--lamp); border-radius: 3px 3px 0 0; }
.bar:hover i { background: var(--milk); }
.axis { display: flex; justify-content: space-between; color: var(--mist); font-size: .8rem; margin-top: .3rem; }
.axis-max { position: absolute; top: 6px; right: 12px; color: var(--mist); font-size: .8rem; }
.stats-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 2rem; }
.scroll { max-height: 360px; overflow-y: auto; }
.dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--live); vertical-align: middle; }
.bulk summary { cursor: pointer; color: var(--lamp); font-weight: 700; margin-top: 1rem; }
td.hint { color: var(--mist); }
.quality { position: absolute; top: .85rem; right: .85rem; display: flex; background: rgba(27,36,64,.82); border-radius: 999px; padding: 3px; backdrop-filter: blur(6px); }
.quality[hidden] { display: none; }
.quality button { border: 0; background: transparent; color: var(--milk); font-weight: 700; font-size: .85rem; padding: .3rem .75rem; border-radius: 999px; cursor: pointer; }
.quality button[aria-pressed="true"] { background: var(--lamp); color: #2a1f05; }
