:root {
  --terakota: #C8472B;
  --terakota-dark: #A83A21;
  --malam: #1B1A2E;
  --malam-2: #25243A;
  --malam-3: #32314A;
  --kunyit: #E8A33D;
  --pandan: #2F7D6D;
  --pandan-light: #3FA58F;
  --kapur: #FAF6F0;
  --batu: #6B6874;
  --batu-light: #B5B0BE;
  --garis: #E9E2D7;
  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); color: var(--malam); background: var(--kapur); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--kunyit); outline-offset: 2px; }
.muted { color: var(--batu); }
use { pointer-events: none; }

/* ---------- tombol umum ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: 999px; border: 2px solid transparent;
  font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-lg { min-height: 54px; font-size: 16px; }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: 14px; }
.btn-primary { background: var(--terakota); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--terakota-dark); }
.btn-ghost { border-color: var(--malam); color: var(--malam); background: transparent; }
.btn-ghost:hover { background: var(--malam); color: var(--kapur); }
.btn-ghost-light { border-color: var(--malam-3); color: var(--kapur); background: transparent; }
.btn-ghost-light:hover { background: var(--malam-3); }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--malam); }
.mark { width: 36px; height: 36px; }
.mark-lg { width: 84px; height: 84px; }
.wordmark { font-size: 24px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.wm-accent { color: var(--terakota); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--terakota); }

.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 26px; color: var(--malam); background: var(--kunyit);
  text-transform: uppercase; flex-shrink: 0;
}
.avatar-lg { width: 110px; height: 110px; font-size: 40px; }
.avatar-sm { width: 34px; height: 34px; font-size: 13px; }

/* ---------- beranda ---------- */
.view-home, .view-prejoin { min-height: 100%; display: flex; flex-direction: column; }
.home-top { display: flex; justify-content: space-between; align-items: center; padding: 22px 32px; }
.home-clock { text-align: right; }
#clock-time { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
#clock-date { font-size: 13px; color: var(--batu); font-weight: 500; }
.home-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px; padding: 24px 24px 80px; }
.home-intro { text-align: center; }
.home-intro h1 { font-size: clamp(36px, 6vw, 60px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.home-intro p { margin-top: 14px; color: var(--batu); font-size: 17px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; }
.home-tile { background: none; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 132px; padding: 0; }
.home-icon { width: 96px; height: 96px; border-radius: 28px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; transition: transform .15s, filter .15s; }
.home-icon svg { width: 40px; height: 40px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.home-tile:hover .home-icon { transform: translateY(-2px); filter: brightness(1.06); }
.tile-new .home-icon { background: var(--terakota); }
.tile-join .home-icon { background: var(--malam); }
.tile-schedule .home-icon { background: var(--pandan); }
.home-label { font-weight: 700; font-size: 16px; }
.home-sub { font-size: 13px; color: var(--batu); }
.join-form { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 10px; }
.join-form label, .prejoin-form label { font-weight: 700; font-size: 14px; }
.join-row { display: flex; gap: 10px; }
input[type="text"] {
  width: 100%; min-height: 50px; padding: 0 18px; border-radius: 14px;
  border: 2px solid var(--garis); background: #fff; font: 500 16px var(--font); color: var(--malam);
}
input[type="text"]:focus { outline: none; border-color: var(--terakota); }
.form-error { color: var(--terakota-dark); font-size: 14px; font-weight: 600; min-height: 1.2em; }

/* ---------- persiapan ---------- */
.prejoin-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 48px; align-items: center; max-width: 1180px; width: 100%; margin: 0 auto; padding: 16px 32px 64px; }
.preview { position: relative; aspect-ratio: 16 / 9; background: var(--malam); border-radius: 24px; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--batu-light); font-weight: 600; background: var(--malam); }
.preview-controls { position: absolute; left: 0; right: 0; bottom: 20px; display: flex; justify-content: center; gap: 14px; }
.round-btn { width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(27,26,46,.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.round-btn svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round-btn.off { background: var(--terakota); border-color: var(--terakota); }
.meter { position: absolute; left: 20px; bottom: 34px; width: 6px; height: 36px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; display: flex; align-items: flex-end; }
.meter i { width: 100%; height: 0; background: var(--pandan-light); transition: height .08s; }
.prejoin-form { display: flex; flex-direction: column; gap: 12px; }
.prejoin-form h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.prejoin-form label { margin-top: 12px; }
.prejoin-form .btn-lg { margin-top: 8px; }
.link-muted { color: var(--batu); font-size: 14px; font-weight: 600; text-align: center; }

/* ---------- ruang rapat ---------- */
.view-room { position: fixed; inset: 0; display: flex; flex-direction: column; background: #121120; color: var(--kapur); }
.room-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; }
.room-info, .room-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.secure svg { width: 20px; height: 20px; fill: none; stroke: var(--pandan-light); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.room-code { font-weight: 700; font-size: 15px; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--malam-3); background: var(--malam-2); color: var(--kapur); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--malam-3); }
.chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.timer { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; color: var(--batu-light); }

.room-body { flex: 1; display: flex; min-height: 0; position: relative; }
.stage { flex: 1; min-width: 0; position: relative; display: flex; gap: 10px; padding: 6px 12px 10px; }
.grid { flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 10px; min-width: 0; }
.spotlight { display: none; }
.stage.has-spotlight .spotlight { display: flex; flex: 1; min-width: 0; align-items: center; justify-content: center; }
.stage.has-spotlight .grid { flex: 0 0 220px; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-content: stretch; overflow-y: auto; }
.stage.has-spotlight .grid .tile { width: 100% !important; height: auto !important; aspect-ratio: 16 / 9; flex-shrink: 0; }
.spotlight .tile { width: 100%; height: 100%; }
.spotlight .tile video { object-fit: contain; background: #000; }

.tile { position: relative; background: var(--malam-2); border-radius: 14px; overflow: hidden; outline: 3px solid transparent; outline-offset: -3px; transition: outline-color .15s; }
.tile.speaking { outline-color: var(--kunyit); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--malam-2); }
.tile.local:not(.screen) video { transform: scaleX(-1); }
.tile-off { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: var(--malam-2); }
.tile.cam-off .tile-off { display: flex; }
.tile-label { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 8px; background: rgba(18,17,32,.75); font-size: 13px; font-weight: 600; }
.lbl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbl-mic { width: 15px; height: 15px; fill: none; stroke: #FF8A70; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; display: none; flex-shrink: 0; }
.tile.mic-off .lbl-mic { display: block; }
.tile-hand { position: absolute; top: 8px; left: 8px; width: 32px; height: 32px; border-radius: 10px; background: var(--kunyit); display: flex; align-items: center; justify-content: center; }
.tile-hand svg { width: 20px; height: 20px; fill: none; stroke: var(--malam); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile-conn { position: absolute; top: 8px; right: 8px; padding: 4px 9px; border-radius: 8px; background: rgba(18,17,32,.8); font-size: 12px; font-weight: 700; color: var(--kunyit); }
.tile.conn-failed .tile-conn { color: #FF8A70; }
.audio-unlock { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 20; min-height: 48px; padding: 0 22px; border: none; border-radius: 999px; background: var(--kunyit); color: var(--malam); font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.tile-reaction { position: absolute; right: 12px; bottom: 12px; font-size: 40px; pointer-events: none; }
.tile-reaction span { position: absolute; right: 0; bottom: 0; animation: floatUp 2.6s ease-out forwards; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(10px) scale(.6); } 15% { opacity: 1; transform: translateY(0) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-90px) scale(1); } }

/* panel samping */
.panel { width: 340px; flex-shrink: 0; background: var(--malam); border-left: 1px solid var(--malam-2); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--malam-2); }
.tabs { display: flex; gap: 4px; }
.tab { background: none; border: none; padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--batu-light); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--malam-2); color: var(--kapur); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: none; background: none; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--kapur); }
.icon-btn:hover { background: var(--malam-2); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; }
.people { list-style: none; margin: 0; padding: 0; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.person:hover { background: var(--malam-2); }
.person-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-name small { color: var(--batu-light); font-weight: 500; }
.person-icons { display: flex; gap: 6px; align-items: center; }
.person-icons svg { width: 18px; height: 18px; fill: none; stroke: var(--batu-light); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.person-icons .off { stroke: #FF8A70; }
.person-icons .hand { stroke: var(--kunyit); }
.person-actions { display: flex; gap: 4px; }
.mini-btn { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--malam-3); background: var(--malam-2); color: var(--kapur); font-size: 12px; font-weight: 700; cursor: pointer; }
.mini-btn:hover { background: var(--malam-3); }
.mini-btn.danger { color: #FF8A70; }
.host-tools { padding: 12px 8px; border-top: 1px solid var(--malam-2); margin-top: auto; }

.panel-chat { padding: 0; }
.messages { list-style: none; margin: 0; padding: 12px 14px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.msg-meta { font-size: 12px; color: var(--batu-light); font-weight: 600; margin-bottom: 3px; }
.msg-meta b { color: var(--kapur); }
.msg-text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.mine .msg-meta b { color: var(--kunyit); }
.chat-empty { color: var(--batu-light); font-size: 14px; text-align: center; margin: auto; padding: 24px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--malam-2); }
.chat-form input { min-height: 44px; border-radius: 12px; border-color: var(--malam-3); background: var(--malam-2); color: var(--kapur); font-size: 14px; }
.chat-form input:focus { border-color: var(--kunyit); }
.send { background: var(--terakota); flex-shrink: 0; width: 44px; height: 44px; }
.send:hover { background: var(--terakota-dark); }

/* toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--malam); border-top: 1px solid var(--malam-2); }
.tb-group { display: flex; gap: 4px; align-items: center; }
.tb-center { justify-content: center; }
.tb-end { justify-content: flex-end; }
.tb { position: relative; min-width: 76px; height: 58px; padding: 6px 8px; border: none; border-radius: 12px; background: none; color: var(--kapur); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; font-size: 12px; font-weight: 600; }
.tb:hover { background: var(--malam-2); }
.tb svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tb.off svg { stroke: #FF8A70; }
.tb.active { background: var(--malam-2); }
.tb.active svg { stroke: var(--kunyit); }
.tb-share svg { stroke: var(--pandan-light); }
.tb-share.active { background: var(--pandan); }
.tb-share.active svg { stroke: #fff; }
.count { position: absolute; top: 4px; right: 12px; font-size: 11px; color: var(--batu-light); }
.badge { position: absolute; top: 3px; right: 14px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--terakota); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.tb-wrap { position: relative; }
.btn-leave { background: var(--terakota); color: #fff; min-height: 40px; padding: 0 20px; }
.btn-leave:hover { background: var(--terakota-dark); }
.popover { position: absolute; bottom: calc(100% + 10px); background: var(--malam-2); border: 1px solid var(--malam-3); border-radius: 14px; padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.4); z-index: 5; }
.reactions { left: 50%; transform: translateX(-50%); display: flex; gap: 2px; }
.reactions button { width: 44px; height: 44px; border: none; background: none; border-radius: 10px; font-size: 24px; cursor: pointer; }
.reactions button:hover { background: var(--malam-3); }
.leave-menu { right: 0; display: flex; flex-direction: column; min-width: 240px; }
.leave-menu button { text-align: left; border: none; background: none; padding: 12px 14px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; }
.leave-menu button:hover { background: var(--malam-3); }
.leave-menu .danger { color: #FF8A70; }

/* selesai */
.view-ended { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.ended-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 460px; }
.ended-card h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin-top: 12px; }
.ended-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 12px; }

/* notifikasi */
.toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 50; pointer-events: none; }
.toast { background: var(--malam); color: var(--kapur); border: 1px solid var(--malam-3); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: toastIn .2s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- responsif ---------- */
@media (max-width: 900px) {
  .prejoin-main { grid-template-columns: 1fr; gap: 28px; padding: 8px 20px 40px; }
  .panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(360px, 100%); z-index: 10; }
  .room-body { position: relative; }
  .stage.has-spotlight { flex-direction: column; }
  .stage.has-spotlight .grid { flex: 0 0 110px; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .stage.has-spotlight .grid .tile { width: 180px !important; height: 100% !important; }
}
@media (max-width: 760px) {
  .home-top { padding: 16px 20px; }
  .tb { min-width: 54px; height: 54px; font-size: 10px; }
  .tb span { display: none; }
  .tb svg { width: 24px; height: 24px; }
  .tb-wrap:has(#tb-react), #tb-hand, #tb-share { display: none; }
  .toolbar { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .chip span, #btn-copy { font-size: 0; gap: 0; padding: 0 10px; }
  .timer { display: none; }
  .btn-leave { padding: 0 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .tile-reaction span { animation-duration: .01s; }
}
