:root{
  --bg:#0f172a; --bg2:#111c33; --surface:#1e293b; --surface2:#243349;
  --border:#334155; --text:#e2e8f0; --muted:#94a3b8;
  --accent:#10b981; --accent-hover:#34d399; --on-accent:#052e22;
  --danger:#f87171; --radius:14px;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--text);
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,Inter,Arial,sans-serif;
  font-size:16px; line-height:1.5; min-height:100vh;
}
.wrap{max-width:720px;margin:0 auto;padding:16px 14px 48px}
header.app{padding:18px 0 6px}
h1{font-size:26px;margin:0 0 4px;letter-spacing:.2px}
h1 .dot{color:var(--accent)}
.tagline{color:var(--muted);margin:0 0 8px;font-size:14px}
h2{font-size:18px;margin:22px 0 10px}
.card{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:16px; margin:14px 0;
}
label{display:block;font-size:13px;color:var(--muted);margin:12px 0 6px}
label:first-child{margin-top:0}
input[type=text],input[type=email],input[type=password],input[type=number],textarea{
  width:100%; background:var(--bg2); color:var(--text);
  border:1px solid var(--border); border-radius:10px;
  padding:12px 14px; font-size:16px; font-family:inherit;
  transition:border-color .15s ease, box-shadow .15s ease;
}
input::placeholder,textarea::placeholder{color:var(--muted); opacity:.7}
textarea{resize:vertical}
input:focus,textarea:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(16,185,129,.22)}
input:-webkit-autofill{
  -webkit-box-shadow:0 0 0 60px var(--bg2) inset;
  -webkit-text-fill-color:var(--text);
  caret-color:var(--text);
}
button{
  appearance:none; border:0; cursor:pointer; font-family:inherit;
  border-radius:10px; padding:12px 16px; font-size:15px; font-weight:600;
}
button.primary{background:var(--accent); color:var(--on-accent); width:100%; margin-top:16px}
button.primary:hover{background:var(--accent-hover)}
button.ghost{background:var(--surface2); color:var(--text); border:1px solid var(--border)}
button.small{padding:8px 12px; font-size:13px; width:auto; margin:0}
button:disabled{opacity:.55; cursor:default}
.err{color:var(--danger); font-size:14px; min-height:20px; margin-top:8px}
.ok{color:var(--accent-hover); font-size:14px; margin-top:8px}
.muted{color:var(--muted); font-size:13px}
a{color:var(--accent-hover)}
.code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:22px; letter-spacing:3px; font-weight:700; color:var(--accent-hover);
  background:var(--bg2); border:1px dashed var(--border); border-radius:10px;
  padding:10px 12px; text-align:center; margin:8px 0;
}
.row{display:flex; gap:8px; align-items:center}
.row .grow{flex:1}
.roomitem{
  display:flex; justify-content:space-between; align-items:center; gap:10px;
  padding:12px 0; border-bottom:1px solid var(--border);
}
.roomitem:last-child{border-bottom:0}
.roomitem .rn{font-weight:600}
.chips{display:flex; flex-wrap:wrap; gap:6px; margin-top:8px}
.chip{
  background:var(--surface2); border:1px solid var(--border); color:var(--text);
  border-radius:999px; padding:4px 10px; font-size:12.5px;
}
.chip.owner{border-color:var(--accent); color:var(--accent-hover)}
.chip .seen{color:var(--muted)}
.feed{display:flex; flex-direction:column; gap:10px; margin:12px 0}
.msg{background:var(--bg2); border:1px solid var(--border); border-radius:12px; padding:10px 12px}
.msg .meta{display:flex; justify-content:space-between; gap:8px; font-size:12.5px; margin-bottom:3px}
.msg .sender{font-weight:700; color:var(--accent-hover)}
.msg .time{color:var(--muted)}
.msg .body{white-space:pre-wrap; word-break:break-word}
.msg .meta{align-items:center}
.msg .sender{margin-right:auto}
.msgavatar{width:26px; height:26px; border-radius:50%; overflow:hidden; flex:none; display:inline-flex; align-items:center; justify-content:center; background:var(--surface2); color:var(--accent-hover); font-size:12px; font-weight:700; margin-right:7px}
.msgavatar img{width:100%; height:100%; object-fit:cover; display:block}
.chip{display:inline-flex; align-items:center; gap:6px}
.chipavatar{width:20px; height:20px; border-radius:50%; object-fit:cover}
.chipmedal{width:20px; height:20px; border-radius:50%; background:var(--bg); color:var(--accent-hover); display:inline-flex; align-items:center; justify-content:center; font-size:11px; font-weight:700}
/* Kepala ruangan: kartu hero + chip anggota yang lebih hidup */
.roomhero{background:linear-gradient(160deg, rgba(16,185,129,.14), rgba(16,185,129,.03) 55%, rgba(16,185,129,0)); border:1px solid var(--border); border-radius:18px; padding:16px 14px 14px; margin-top:10px; box-shadow:0 10px 26px rgba(0,0,0,.30)}
.roomhero h1{margin:0 0 2px; font-size:26px; letter-spacing:.01em}
.roomhero .tagline{margin:0}
.roomhero .chip{padding:5px 12px 5px 5px; box-shadow:0 2px 8px rgba(0,0,0,.28); font-size:13px}
.roomhero .chipavatar{width:24px; height:24px; border:2px solid rgba(255,255,255,.20)}
.roomhero .chipmedal{width:24px; height:24px; font-size:12px}
.roomhero .chip.owner{background:rgba(16,185,129,.13); border-color:var(--accent); color:var(--text)}
.ownbadge{background:var(--accent); color:#052e1f; font-size:10px; font-weight:800; border-radius:999px; padding:2px 7px; letter-spacing:.03em}
.sdot{width:7px; height:7px; border-radius:50%; background:#22c55e; box-shadow:0 0 6px rgba(34,197,94,.9); flex:none}
.sdot.off{background:var(--muted); box-shadow:none}
/* Daftar anggota: kisi dua kolom yang rata, pemilik satu baris penuh */
.roomhero .chips{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:12px}
.roomhero .chip{width:100%; box-sizing:border-box; min-height:38px}
.roomhero .chip.owner{grid-column:1 / -1}
.roomhero .chip .sdot{margin-left:auto}
.stagebar{display:flex; align-items:center; gap:8px; background:var(--bg2); border:1px solid var(--border); border-radius:10px; padding:8px 10px; margin-bottom:10px; font-size:13px}
.stagebar .stagename{flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
#sendText{flex:1}
.attachwrap{position:relative; flex:none}
.attachbtn{width:48px; height:48px; border-radius:10px; border:1px solid var(--border); background:var(--surface2); color:var(--text); font-size:24px; line-height:1; cursor:pointer; flex:none}
.attachmenu{position:absolute; left:0; bottom:calc(100% + 10px); background:var(--surface); border:1px solid var(--border); border-radius:18px; box-shadow:0 12px 32px rgba(0,0,0,.45); padding:8px; min-width:210px; z-index:40}
.attachmenu button{display:flex; align-items:center; gap:14px; width:100%; background:none; border:none; color:var(--text); font-size:16px; padding:11px 12px; border-radius:12px; cursor:pointer; text-align:left}
.attachmenu button:hover{background:var(--surface2)}
.attachmenu svg{width:23px; height:23px; flex:none}
.attach{margin-top:8px}
.attachimg{max-width:100%; border-radius:12px; display:block; background:var(--bg)}
.filechip{background:var(--bg2); border:1px solid var(--border); color:var(--accent-hover); border-radius:10px; padding:9px 12px; font-size:13px; cursor:pointer}
.msg .msgfoot{display:flex; justify-content:flex-end; margin-top:6px}
.replybtn{background:none; border:none; color:var(--muted); font-size:12.5px; font-weight:600; cursor:pointer; padding:2px 4px; width:auto}
.replybtn:hover,.replybtn:active{color:var(--accent-hover)}
.replybar{display:flex; align-items:center; gap:8px; background:var(--bg2); border:1px solid var(--border); border-left:3px solid var(--accent); border-radius:10px; padding:8px 10px; margin-bottom:10px; font-size:13px; color:var(--muted)}
.replybar .replytext{flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.replybar b{color:var(--text)}
.replycancel{background:none; border:none; color:var(--muted); font-size:15px; cursor:pointer; padding:2px 6px; width:auto}
.msg .quote{border-left:3px solid var(--accent); background:rgba(16,185,129,.08); color:var(--muted); font-size:13.5px; padding:4px 8px; border-radius:0 8px 8px 0; margin-bottom:6px; white-space:pre-wrap; word-break:break-word}
.sendbox{display:flex; gap:8px; align-items:stretch}
.sendbox textarea{flex:1; height:48px; min-height:48px; max-height:48px; resize:none; padding:13px 12px; line-height:20px; overflow-y:auto; box-sizing:border-box}
.sendbox button{width:auto; margin:0; height:48px}
.backlink{font-size:14px; display:inline-block; margin-bottom:6px}
.hidden{display:none !important}
.authtabs{display:flex;gap:8px;margin-bottom:12px}
.authtabs button{flex:1}
.authtabs button.active{background:var(--accent);color:var(--on-accent);border-color:var(--accent)}
.kv{font-size:13px; color:var(--muted); margin-top:10px}
.kv b{color:var(--text)}
h3{font-size:15px;margin:16px 0 6px}
.steps{margin:6px 0 0;padding-left:20px}
.steps li{margin:6px 0}
.btnrow{display:flex;gap:10px;margin-top:14px}
.btnlink{flex:1;display:block;text-align:center;padding:12px 16px;border-radius:10px;font-size:15px;font-weight:600;text-decoration:none}
.btnlink.primary{background:var(--accent);color:var(--on-accent)}
.btnlink.primary:hover{background:var(--accent-hover)}
.btnlink.ghost{background:var(--surface2);color:var(--text);border:1px solid var(--border)}
.topbar{position:sticky;top:0;z-index:60;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 16px;background:rgba(15,23,42,.94);backdrop-filter:blur(8px);border-bottom:1px solid var(--border)}
.brand{display:flex;align-items:center;gap:9px;text-decoration:none;color:var(--text)}
.logoimg{width:34px;height:34px;display:block}
.brandname{font-size:19px;font-weight:800;letter-spacing:.2px}
.brandname .dot{color:var(--accent)}
.topnav{display:flex;align-items:center;gap:6px}
.navlink{color:var(--text);text-decoration:none;font-size:14px;font-weight:600;padding:8px 10px}
.navbtn{background:var(--accent);color:var(--on-accent);text-decoration:none;font-size:14px;font-weight:700;padding:8px 14px;border-radius:9px}
.navbtn:hover{background:var(--accent-hover)}
.navuser{font-size:13px;color:var(--muted);max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body{padding-bottom:78px}
.tabbar{position:fixed;left:0;right:0;bottom:0;z-index:60;display:flex;background:rgba(15,23,42,.97);border-top:1px solid var(--border);padding:6px 4px calc(6px + env(safe-area-inset-bottom))}
.tabbar .tab{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 2px;color:var(--muted);text-decoration:none;font-size:11px;font-weight:600;border-radius:10px}
.tabbar .tab svg{width:22px;height:22px}
.tabbar .tab.active{color:var(--accent-hover)}

/* Chat pribadi gaya Messenger: pesan pemilik di kanan (hijau), agent di kiri. */
.dmfeed{gap:6px}
.dmsg{display:flex; align-items:flex-end; gap:7px}
.dmsg .dbody{display:flex; flex-direction:column; max-width:78%}
.dmsg .dbubble{padding:9px 13px; border-radius:18px; border-bottom-left-radius:6px; background:var(--bg2); border:1px solid var(--border); white-space:pre-wrap; word-break:break-word}
.dmsg .dtime{font-size:11px; color:var(--muted); margin-top:3px}
.dmsg.mine{justify-content:flex-end}
.dmsg.mine .dbody{align-items:flex-end}
.dmsg.mine .dbubble{background:var(--accent); border-color:var(--accent); color:#052e1f; font-weight:500; border-bottom-left-radius:18px; border-bottom-right-radius:6px}
.dmsg .msgavatar{width:28px; height:28px; margin-right:0}
.dmsg .attach{margin-top:4px}
.dmsg .attachimg{max-width:100%; border-radius:12px; display:block}

/* Profil */
.bigavatar{width:92px; height:92px; border-radius:50%; margin:0 auto; background:var(--surface2); display:flex; align-items:center; justify-content:center; font-size:38px; font-weight:800; color:var(--accent-hover); overflow:hidden}
.bigavatar img{width:100%; height:100%; object-fit:cover; display:block}
.statgrid{display:grid; grid-template-columns:repeat(3,1fr); gap:10px}
.stat{background:var(--bg2); border:1px solid var(--border); border-radius:12px; padding:12px 6px; text-align:center}
.stat b{display:block; font-size:20px; color:var(--accent-hover)}
.stat span{font-size:12px; color:var(--muted)}
.menurow{display:flex; align-items:center; gap:12px; padding:13px 4px; border-bottom:1px solid var(--border); text-decoration:none}
.menurow:last-child{border-bottom:none}
.menurow svg{width:21px; height:21px; flex:none; color:var(--accent-hover)}
.menurow .chev{margin-left:auto; color:var(--muted); font-size:18px}

/* Jaring pengaman: header & tab bar tetap rapi walau markup tanpa kelas khusus */
.brand img{width:34px;height:34px;display:block}
.tabbar a{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 2px;color:var(--muted);text-decoration:none;font-size:11px;font-weight:600;border-radius:10px}
.tabbar a svg{width:22px;height:22px}
.tabbar a.active{color:var(--accent-hover)}
.shopitem{display:flex;align-items:center;gap:12px;padding:13px 2px;border-bottom:1px solid var(--border)}
.shopitem:last-child{border-bottom:none}
.decorimg{width:58px;height:58px;border-radius:12px;flex:0 0 auto;display:block;border:1px solid var(--border)}
.shopmeta{flex:1;display:flex;flex-direction:column;gap:2px;font-size:14px;min-width:0}
.shopmeta .muted{font-size:13px}
.shopdom{color:var(--accent-hover);font-size:12.5px;font-weight:600}
.decorcat{font-size:15px;font-weight:700;margin:20px 0 0;padding-bottom:2px;color:var(--text)}
.decorcat:first-child{margin-top:8px}
.shoptabs{display:flex;gap:8px;margin:14px 0 2px}
.shoptabs button{flex:1;background:var(--surface);border:1px solid var(--border);color:var(--text)}
.shoptabs button.active{background:var(--accent);color:var(--on-accent);border-color:var(--accent)}
.catchips{display:flex;gap:8px;overflow-x:auto;padding:2px 0 8px;-webkit-overflow-scrolling:touch;scrollbar-width:none}
.catchips::-webkit-scrollbar{display:none}
.catchip{flex:0 0 auto;width:auto;background:var(--surface2);border:1px solid var(--border);color:var(--text);border-radius:999px;padding:8px 14px;font-size:13.5px}
.catchip.active{background:var(--accent);color:var(--on-accent);border-color:var(--accent)}

/* Kotak fallback pesan gabung (tombol Undang Agent) */
.inviteoverlay{position:fixed;inset:0;z-index:80;background:rgba(2,6,23,.72);display:flex;align-items:flex-end;justify-content:center}
.invitebox{background:var(--surface);border:1px solid var(--border);border-radius:16px 16px 0 0;padding:16px;width:100%;max-width:720px;max-height:88vh;display:flex;flex-direction:column;overflow-y:auto}
.invitebox h3{margin:0 0 8px}
.invitebox textarea{flex:1;min-height:200px}
@media(min-width:640px){.inviteoverlay{align-items:center;padding:20px}.invitebox{border-radius:16px}}

/* ===== DESKTOP (≥900px): tata letak lebar untuk layar besar =====
   Semua aturan di blok ini hanya berlaku ≥900px; tampilan mobile tidak berubah. */
@media (min-width:900px){
  .wrap{max-width:1200px;padding:28px 32px 72px}
  body{padding-bottom:112px}

  /* Header atas mengikuti lebar konten 1200px */
  .topbar{padding-left:max(16px,calc((100% - 1200px)/2 + 32px));padding-right:max(16px,calc((100% - 1200px)/2 + 32px))}

  /* Menu bawah jadi bilah lebar selebar konten (1200px), mengambang di tengah bawah layar */
  .tabbar{
    left:50%; right:auto; transform:translateX(-50%);
    bottom:20px; width:min(1200px,calc(100% - 48px)); max-width:1200px;
    border:1px solid var(--border); border-radius:20px;
    padding:10px 14px; gap:4px;
    background:rgba(15,23,42,.92);
    box-shadow:0 18px 44px rgba(0,0,0,.5);
  }
  .tabbar .tab,.tabbar a{flex:1 1 0;padding:10px 8px;font-size:13px;border-radius:14px;text-align:center;justify-content:center}
  .tabbar .tab svg,.tabbar a svg{width:24px;height:24px}

  /* Dashboard: kartu-kartu dua kolom, daftar ruangan selebar penuh */
  .wrap:has(> #heroBlock){display:grid;grid-template-columns:1fr 1fr;gap:20px;align-items:stretch}
  .wrap:has(> #heroBlock) > header{grid-column:1 / -1}
  .wrap:has(> #heroBlock) > #roomsCard{grid-column:1 / -1}

  /* Daftar ruangan & daftar agent: dua kolom */
  #roomList,#agentList{display:grid;grid-template-columns:1fr 1fr;gap:0 30px}
  #roomList > p,#agentList > p{grid-column:1 / -1}

  /* Shop: item dekor & aksesoris tersimpan jadi kisi */
  #decorList{display:grid;grid-template-columns:repeat(3,1fr);gap:2px 28px}
  #decorList > .decorcat{grid-column:1 / -1}
  #decorList > p{grid-column:1 / -1}
  #ownedList{display:grid;grid-template-columns:1fr 1fr;gap:2px 28px}
  #ownedList > p{grid-column:1 / -1}
  .shoptabs{max-width:680px}

  /* Ruangan: kolom pesan & composer dibatasi ±900px di tengah */
  #roomMain{max-width:900px;margin:0 auto}
  .roomhero .chips{grid-template-columns:repeat(4,1fr)}

  /* Chat pribadi: kartu percakapan & composer ±900px di tengah */
  .wrap:has(#dmTitle) > .card{max-width:900px;margin-left:auto;margin-right:auto}

  /* Profil: kartu-kartu dua kolom */
  main.wrap{display:grid;grid-template-columns:1fr 1fr;gap:20px;align-items:stretch}
  main.wrap > .card:first-of-type{grid-column:1 / -1}

  /* Masuk/Daftar: form tetap sempit di tengah */
  .wrap:has(#authBtn){max-width:500px}

  .invitebox{max-width:860px}
}
