/* Majelis AI — monokrom, flat, hairline.
   Token: latar #000, panel #0A0A0A / #111 / #171717, garis #262626,
   teks #FFF, sekunder #A3A3A3, redup #737373. Tanpa warna, gradasi, glow. */

:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #111111;
  --panel-3: #171717;
  --line: #262626;
  --line-soft: #1c1c1c;
  --text: #ffffff;
  --text-2: #a3a3a3;
  --text-3: #737373;
  --hover: rgba(255, 255, 255, 0.06);
  --active: rgba(255, 255, 255, 0.09);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sidebar-w: 260px;
  --members-w: 240px;
  --head-h: 57px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 1.5px solid #fff; outline-offset: 2px; border-radius: 4px; }

svg { display: block; }

/* ---------- Layar muat ---------- */
.boot-screen {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center;
}
.boot-mark {
  width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; font-weight: 600;
}
.boot-text { margin: 0; color: var(--text-2); font-size: 14px; }
.boot-error { margin: 0; color: var(--text-2); font-size: 13px; max-width: 420px; }

/* ---------- Kerangka 3 kolom ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--members-w);
  height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head {
  height: var(--head-h); flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 16px; border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark, .head-mark {
  width: 32px; height: 32px; flex: none; border: 1px solid var(--line);
  border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 600; background: var(--panel-2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 600; font-size: 14px; }
.brand-sub { color: var(--text-3); font-size: 12px; }
.sidebar-close { display: none; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 16px 8px 24px; }
.side-section + .side-section { margin-top: 28px; }
.side-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 8px; color: var(--text-3); font-size: 12.5px; font-weight: 500;
}

.room-list { display: flex; flex-direction: column; gap: 2px; }
.room-item { border-radius: 8px; }
.room-head {
  width: 100%; display: flex; align-items: center; gap: 7px;
  padding: 8px; border-radius: 8px; text-align: left;
  transition: background-color 140ms ease;
}
.room-head:hover { background: var(--hover); }
.room-item.is-active > .room-head { background: var(--active); }
.room-hash { color: var(--text-3); font-size: 14px; flex: none; }
.room-item.is-active .room-hash { color: var(--text-2); }
.room-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item.is-active .room-name { color: #fff; }
.room-item:not(.is-active) .room-name { color: var(--text-2); }
.room-chev { flex: none; color: var(--text-3); transition: transform 140ms ease; }
.room-chev svg { width: 14px; height: 14px; }
.room-item.is-open .room-chev { transform: rotate(180deg); }
.busy-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #fff; flex: none;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.room-members { padding: 2px 8px 8px 30px; display: flex; flex-direction: column; gap: 1px; }
.room-member { display: flex; align-items: center; gap: 8px; padding: 3px 4px; font-size: 13px; color: var(--text-2); }
.room-member .mini-avatar { width: 20px; height: 20px; font-size: 9px; }

.seat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.seat-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 8px; border-radius: 8px; text-align: left;
  transition: background-color 140ms ease;
}
.seat-row:hover { background: var(--hover); }
.seat-meta { min-width: 0; line-height: 1.3; }
.seat-name { display: block; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-role { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.presence { width: 7px; height: 7px; border-radius: 50%; background: #fff; margin-left: auto; flex: none; opacity: .85; }

.sidebar-foot { flex: none; border-top: 1px solid var(--line-soft); padding: 8px; }
.side-foot-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 8px; border-radius: 8px; color: var(--text-2); font-size: 14px;
  transition: background-color 140ms ease, color 140ms ease;
}
.side-foot-btn:hover { background: var(--hover); color: #fff; }
.side-foot-btn svg { width: 18px; height: 18px; }

/* Avatar monogram */
.avatar, .mini-avatar {
  border: 1px solid var(--line); border-radius: 50%; background: var(--panel-2);
  display: grid; place-items: center; font-weight: 600; flex: none; color: #fff;
}
.avatar { width: 34px; height: 34px; font-size: 12px; }
.mini-avatar { width: 24px; height: 24px; font-size: 10px; }
.avatar.owner { background: #fff; color: #000; border-color: #fff; }

/* ---------- Kolom utama ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.chat-head {
  height: var(--head-h); flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 16px; border-bottom: 1px solid var(--line);
}
.head-menu { display: none; }
.head-title { flex: 1; min-width: 0; line-height: 1.25; }
.head-room { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { margin: 0; color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.head-members { display: none; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  display: grid; place-items: center; color: var(--text-2);
  transition: background-color 140ms ease, color 140ms ease;
}
.icon-btn:hover { background: var(--hover); color: #fff; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-sm svg { width: 15px; height: 15px; }

.pill-btn {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12.5px; font-weight: 500; color: var(--text);
  background: var(--panel-2); margin-right: 6px; white-space: nowrap;
  transition: background-color 140ms ease;
}
.pill-btn:hover { background: var(--panel-3); }

/* Strip kursi */
.member-strip {
  flex: none; display: flex; gap: 8px; overflow-x: auto;
  padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
  scrollbar-width: none;
}
.member-strip::-webkit-scrollbar { display: none; }
.strip-seat { display: flex; align-items: center; gap: 8px; flex: none; padding: 4px 10px 4px 4px; border: 1px solid var(--line-soft); border-radius: 999px; }
.strip-seat .mini-avatar { width: 22px; height: 22px; }
.strip-name { font-size: 12.5px; font-weight: 500; }
.strip-role { font-size: 12px; color: var(--text-3); }
.strip-dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; opacity: .85; }

/* Panel ringkasan tugas */
.task-panel {
  flex: none; margin: 12px 16px 0; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.task-panel-head { display: flex; align-items: center; gap: 10px; }
.task-panel-title { font-size: 13px; font-weight: 600; }
.task-status {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px;
}
.task-panel-head .icon-btn { margin-left: auto; }
.task-worker { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }
.task-excerpt { margin: 4px 0 0; font-size: 13.5px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Pesan ---------- */
.message-list {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 20px 16px 12px;
  display: flex; flex-direction: column;
}
.empty-state {
  margin: auto; max-width: 340px; text-align: center;
  color: var(--text-3); font-size: 14px; padding: 32px 0;
}
.msg { display: flex; gap: 12px; padding: 10px 8px; border-radius: 10px; }
.msg:hover { background: rgba(255,255,255,.02); }
.msg + .msg { margin-top: 2px; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-name { font-size: 14px; font-weight: 600; }
.msg-role { font-size: 12px; color: var(--text-3); }
.msg-time { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.msg-text { margin: 2px 0 0; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.msg.is-error .msg-text { color: var(--text-2); }
.msg-img { margin-top: 8px; max-width: 420px; width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
.msg-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 8px 4px; color: var(--text-2);
  font-size: 12.5px; font-weight: 600;
}
.msg-divider::before, .msg-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Composer ---------- */
.composer-wrap {
  flex: none; border-top: 1px solid var(--line);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.working-bar {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text-2); padding: 0 2px 10px;
}
.working-dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s ease-in-out infinite; flex: none; }

.chip-row { display: flex; gap: 8px; padding-bottom: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12.5px; font-weight: 500; color: var(--text-2);
  background: var(--panel); transition: background-color 140ms ease, color 140ms ease;
}
.chip:hover { background: var(--panel-3); color: #fff; }
.chip svg { width: 15px; height: 15px; }
.mention-wrap { position: relative; }
.mention-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 30;
  min-width: 210px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px;
}
.mention-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; border-radius: 8px; text-align: left; font-size: 13.5px;
}
.mention-item:hover { background: var(--hover); }
.mention-item .seat-role { margin-left: auto; }

.composer {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 8px 8px 8px 16px;
  transition: border-color 140ms ease;
}
.composer:focus-within { border-color: #3d3d3d; }
.composer textarea {
  flex: 1; min-width: 0; background: none; border: 0; resize: none;
  max-height: 140px; padding: 6px 0; font-size: 15px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer textarea:focus { outline: none; }
.send-btn {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: #fff; color: #000; display: grid; place-items: center;
  transition: opacity 140ms ease, background-color 140ms ease;
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn:disabled { background: var(--panel-3); color: var(--text-3); cursor: default; }
.send-error { margin: 8px 2px 0; font-size: 13px; color: var(--text-2); }

/* ---------- Panel anggota ---------- */
.members-panel {
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.members-head {
  height: var(--head-h); flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 16px; border-bottom: 1px solid var(--line-soft);
  font-size: 13px; font-weight: 600;
}
.members-close { display: none; }
.members-list { flex: 1; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.member-row:hover { background: var(--hover); }

/* ---------- Overlay & dialog ---------- */
[hidden] { display: none !important; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; }
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.66);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog {
  width: 100%; max-width: 460px; max-height: calc(100dvh - 40px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px;
}
.dialog-settings { max-width: 560px; }
.dialog-confirm { max-width: 380px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dialog-head h2, .dialog-confirm h2 { margin: 0; font-size: 16px; font-weight: 600; }
.dialog-sub { margin: 0 0 12px; color: var(--text-3); font-size: 13px; }
.confirm-body { color: var(--text-2); font-size: 14px; }

.field { display: block; margin-top: 14px; }
.field-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 7px; }
.field-count { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); font-weight: 400; }
.field input, .field textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus { outline: none; border-color: #3d3d3d; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.fieldset-reset { border: 0; padding: 0; margin-left: 0; margin-right: 0; }
.fieldset-reset legend { padding: 0; }

.check-list { display: flex; flex-direction: column; gap: 2px; }
.check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.check-item:hover { background: var(--hover); }
.check-item input { accent-color: #fff; width: 16px; height: 16px; flex: none; }
.check-item .seat-role { margin-left: auto; }

.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.dialog-spacer { flex: 1; }
.btn {
  border-radius: 999px; padding: 9px 18px; font-size: 13.5px; font-weight: 600;
  transition: background-color 140ms ease, opacity 140ms ease;
}
.btn-primary { background: #fff; color: #000; }
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-ghost { border: 1px solid var(--line); color: var(--text); background: var(--panel-2); }
.btn-ghost:hover { background: var(--panel-3); }
.btn-danger-ghost { border: 1px solid var(--line); color: var(--text-2); background: none; }
.btn-danger-ghost:hover { color: #fff; background: var(--panel-3); }
.form-error { margin: 12px 0 0; font-size: 13px; color: var(--text-2); }

/* Pengaturan */
.settings-block { padding: 14px 0 18px; border-bottom: 1px solid var(--line-soft); }
.settings-block:first-of-type { padding-top: 6px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-row + .setting-row { margin-top: 20px; }
.setting-row-stack { flex-direction: column; align-items: stretch; }
.setting-name { margin: 0; font-size: 14px; font-weight: 600; }
.setting-desc { margin: 3px 0 0; font-size: 13px; color: var(--text-3); }

.switch { position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.switch-track {
  display: block; width: 44px; height: 25px; border-radius: 999px;
  background: var(--panel-3); border: 1px solid var(--line);
  transition: background-color 150ms ease;
  position: relative; pointer-events: none;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%; background: var(--text-2);
  transition: transform 150ms ease, background-color 150ms ease;
}
.switch input:checked + .switch-track { background: #fff; border-color: #fff; }
.switch input:checked + .switch-track::after { transform: translateX(19px); background: #000; }
.switch input:focus-visible + .switch-track { outline: 1.5px solid #fff; outline-offset: 2px; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 10px; }
.segmented button {
  padding: 9px 4px; font-size: 13px; color: var(--text-2); background: var(--panel-2);
  transition: background-color 140ms ease, color 140ms ease;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-checked="true"] { background: #fff; color: #000; font-weight: 600; }

.gateway-test { display: flex; align-items: flex-start; gap: 12px; margin-top: 14px; }
.gateway-result { margin: 7px 0 0; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }

.seat-name-fields { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.seat-name-row { display: flex; align-items: center; gap: 12px; }
.seat-name-row .avatar { width: 30px; height: 30px; font-size: 11px; }
.seat-name-row input {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; font-size: 14px;
}
.seat-name-row input:focus { outline: none; border-color: #3d3d3d; }
.seat-name-role { font-size: 12px; color: var(--text-3); width: 108px; flex: none; }
.settings-actions { position: sticky; bottom: -20px; background: var(--panel); padding: 14px 0 2px; }
.saved-note { font-size: 13px; color: var(--text-2); }

/* Memori */
.memory-list { display: flex; flex-direction: column; }
.memory-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line-soft);
}
.memory-item:last-child { border-bottom: 0; }
.memory-text { flex: 1; min-width: 0; font-size: 14px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-time { display: block; font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: 4px; }
.memory-empty { color: var(--text-3); font-size: 14px; padding: 16px 0; margin: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 80;
  background: #fff; color: #000; font-size: 13.5px; font-weight: 500;
  border-radius: 999px; padding: 10px 18px; max-width: min(92vw, 440px);
  text-align: center;
}

/* ---------- Responsif ---------- */
@media (max-width: 1199px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .members-panel {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(300px, 86vw); z-index: 45;
    transform: translateX(100%); transition: transform 160ms ease;
  }
  .members-panel.is-open { transform: translateX(0); }
  .members-close { display: grid; }
  .head-members { display: grid; }
}

@media (max-width: 767px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); z-index: 45;
    transform: translateX(-100%); transition: transform 160ms ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .head-menu { display: grid; }
  .head-mark { display: none; }
  .chat-head { padding-left: 8px; }
  .message-list { padding: 14px 10px 8px; }
  .composer-wrap { padding-left: 12px; padding-right: 12px; }
  .task-panel { margin: 10px 12px 0; }
  .overlay { padding: 0; align-items: stretch; }
  .dialog { max-width: none; max-height: none; border: 0; border-radius: 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .seat-name-role { width: 84px; }
  .head-sub { font-size: 11px; }
  .msg-img { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
