/* Jekardah Chat — tata letak terinspirasi WhatsApp Web */
:root {
  --green: #00a884;
  --green-dark: #008069;
  --badge: #25d366;
  --rail: #f0f2f5;
  --panel: #ffffff;
  --head: #f0f2f5;
  --border: #e9edef;
  --text: #111b21;
  --text-2: #667781;
  --text-3: #8696a0;
  --icon: #54656f;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --search: #f0f2f5;
  --chat-bg: #efeae2;
  --in: #ffffff;
  --out: #d9fdd3;
  --chip: #f0f2f5;
  --chip-active: #e7fce3;
  --chip-active-text: #008069;
  --day-chip: #ffffff;
  --tick: #8696a0;
  --tick-read: #53bdeb;
  --danger: #ea0038;
  --shadow: 0 1px .5px rgba(11, 20, 26, .13);
  --menu-shadow: 0 2px 5px 0 rgba(11, 20, 26, .26), 0 2px 10px 0 rgba(11, 20, 26, .16);
  --intro-bg: #f0f2f5;
  --intro-screen: #dfe5e7;
  --login-bg: #eae6df;
  --overlay: rgba(255, 255, 255, .85);
  --font: "Segoe UI", "Helvetica Neue", Helvetica, "Lucida Grande", Arial, Ubuntu, Cantarell, "Fira Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --rail: #202c33;
    --panel: #111b21;
    --head: #202c33;
    --border: #222d34;
    --text: #e9edef;
    --text-2: #8696a0;
    --text-3: #8696a0;
    --icon: #aebac1;
    --hover: #202c33;
    --active: #2a3942;
    --search: #202c33;
    --chat-bg: #0b141a;
    --in: #202c33;
    --out: #005c4b;
    --chip: #202c33;
    --chip-active: #0a332c;
    --chip-active-text: #00a884;
    --day-chip: #182229;
    --tick: #8696a0;
    --shadow: 0 1px .5px rgba(11, 20, 26, .3);
    --menu-shadow: 0 2px 5px 0 rgba(0, 0, 0, .4), 0 2px 10px 0 rgba(0, 0, 0, .3);
    --intro-bg: #222e35;
    --intro-screen: #2a3942;
    --login-bg: #111b21;
    --overlay: rgba(11, 20, 26, .85);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14.2px;
  color: var(--text);
  background: var(--panel);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
svg { display: block; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--icon); flex-shrink: 0;
  transition: background-color .15s;
}
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn:hover, .icon-btn.active { background: rgba(11, 20, 26, .08); }
@media (prefers-color-scheme: dark) { .icon-btn:hover, .icon-btn.active { background: rgba(255, 255, 255, .1); } }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 20px; height: 20px; }

/* ---------- Loading ---------- */
.loading-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--intro-bg); gap: 18px; color: var(--text-2);
}
.loading-logo { width: 72px; height: 72px; opacity: .55; }
.loading-bar { width: 320px; max-width: 70vw; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.loading-bar span { display: block; height: 100%; width: 40%; background: var(--green); animation: load 1.2s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.loading-title { font-size: 17px; color: var(--text); }
.loading-sub { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; background: var(--login-bg); overflow: auto; }
.login-band { height: 222px; background: var(--green); }
@media (prefers-color-scheme: dark) { .login-band { background: #00a884; } }
.login-brand {
  max-width: 1000px; margin: 0 auto; padding: 28px 16px 0;
  display: flex; align-items: center; gap: 14px; color: #fff; font-size: 14px; font-weight: 500; letter-spacing: .4px;
}
.login-brand img { filter: brightness(0) invert(1); }
.login-card {
  position: relative; max-width: 1000px; margin: -130px auto 40px; background: var(--panel);
  border-radius: 3px; box-shadow: 0 17px 50px 0 rgba(11, 20, 26, .19), 0 12px 15px 0 rgba(11, 20, 26, .24);
}
.login-main { display: flex; gap: 40px; padding: 64px 60px 56px; }
.login-text { flex: 1; }
.login-text h1 { font-size: 28px; font-weight: 300; margin: 0 0 40px; color: var(--text); }
.login-text ol { margin: 0; padding-left: 22px; color: var(--text); font-size: 18px; line-height: 28px; }
.login-text li { margin-bottom: 18px; padding-left: 6px; }
.login-text b { font-weight: 500; }
.login-action { width: 300px; display: flex; flex-direction: column; gap: 20px; }
.login-google-box {
  border: 1px solid var(--border); border-radius: 12px; padding: 32px 20px; display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.gbtn { min-height: 44px; display: flex; justify-content: center; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin: 0; }
.login-note { color: var(--text-2); font-size: 13px; text-align: center; margin: 0; line-height: 1.5; }
.login-note code { background: var(--search); padding: 1px 5px; border-radius: 4px; }
.login-foot {
  border-top: 1px solid var(--border); background: var(--rail); padding: 26px 60px; color: var(--text-2);
  display: flex; align-items: center; gap: 10px; font-size: 14px; border-radius: 0 0 3px 3px;
}
.dev-login { display: flex; flex-direction: column; gap: 8px; border: 1px dashed var(--text-3); border-radius: 12px; padding: 14px; }
.dev-title { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; }
.dev-login input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); outline: none; }
.dev-login input:focus { border-color: var(--green); }
.dev-login button { padding: 9px; border-radius: 20px; background: var(--green); color: #fff; font-weight: 500; }
@media (max-width: 860px) {
  .login-band { height: 160px; }
  .login-card { margin: -80px 12px 24px; }
  .login-main { flex-direction: column; padding: 32px 22px; gap: 28px; }
  .login-text h1 { font-size: 22px; margin-bottom: 20px; }
  .login-text ol { font-size: 15px; line-height: 22px; }
  .login-action { width: 100%; }
  .login-foot { padding: 18px 22px; }
}

/* ---------- Layout ---------- */
.app { position: fixed; inset: 0; display: flex; background: var(--panel); }
.rail {
  width: 64px; flex-shrink: 0; background: var(--rail); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 8px;
}
.rail-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--icon);
}
.rail-btn svg { width: 24px; height: 24px; fill: currentColor; }
.rail-btn:hover { background: rgba(11, 20, 26, .08); }
.rail-btn.active { background: rgba(11, 20, 26, .1); }
@media (prefers-color-scheme: dark) { .rail-btn:hover, .rail-btn.active { background: rgba(255, 255, 255, .1); } }
.rail-badge {
  position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--badge); color: #fff; font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--rail);
}
.rail-spacer { flex: 1; }
.rail-avatar { overflow: hidden; }
.rail-avatar .avatar { width: 32px; height: 32px; }

.side {
  position: relative; width: 30%; min-width: 340px; max-width: 460px; flex-shrink: 0;
  border-right: 1px solid var(--border); background: var(--panel); overflow: hidden;
}
.panel { position: absolute; inset: 0; display: flex; flex-direction: column; }
.side-head { height: 64px; padding: 10px 12px 0 20px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.side-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.head-actions { display: flex; gap: 6px; align-items: center; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 44px; z-index: 50; min-width: 200px; padding: 9px 0; border-radius: 3px;
  background: var(--panel); box-shadow: var(--menu-shadow); transform-origin: top right; animation: pop .12s ease-out;
}
@media (prefers-color-scheme: dark) { .menu { background: #233138; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.menu button { display: block; width: 100%; text-align: left; padding: 0 24px; height: 40px; font-size: 14.5px; color: var(--text); }
.menu button:hover { background: var(--hover); }
@media (prefers-color-scheme: dark) { .menu button:hover { background: #182229; } }

.search { padding: 6px 12px 8px; flex-shrink: 0; }
.search-box {
  display: flex; align-items: center; gap: 14px; height: 38px; background: var(--search); border-radius: 8px; padding: 0 14px; cursor: text;
}
.search-box svg { width: 20px; height: 20px; fill: var(--icon); flex-shrink: 0; }
.search-box input { flex: 1; border: 0; outline: none; background: transparent; font-size: 15px; min-width: 0; }
.search-box input::placeholder { color: var(--text-2); }
.search-box input::-webkit-search-cancel-button { filter: grayscale(1); }

.chips { display: flex; gap: 8px; padding: 0 14px 8px; flex-shrink: 0; }
.chip { height: 32px; padding: 0 13px; border-radius: 16px; background: var(--chip); color: var(--text-2); font-size: 14.5px; }
.chip:hover { filter: brightness(.97); }
.chip.active { background: var(--chip-active); color: var(--chip-active-text); }

.notif-banner {
  display: flex; gap: 14px; align-items: center; margin: 0 0 4px; padding: 14px 16px; background: #53bdeb;
  color: #fff; flex-shrink: 0;
}
@media (prefers-color-scheme: dark) { .notif-banner { background: #182229; color: var(--text); } }
.notif-icon { width: 46px; height: 46px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { width: 24px; height: 24px; fill: #53bdeb; }
.notif-title { font-size: 16px; }
.link { color: inherit; font-size: 14px; opacity: .9; padding: 2px 0; }
.link:hover { text-decoration: underline; }

/* ---------- Daftar chat ---------- */
.chat-list { flex: 1; overflow-y: auto; overflow-x: hidden; }
.chat-item {
  display: flex; align-items: center; width: 100%; height: 72px; padding: 0 0 0 13px; text-align: left; position: relative;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .avatar-wrap { padding-right: 13px; }
.chat-item .body {
  flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center;
  border-top: 1px solid var(--border); padding-right: 15px;
}
.chat-item:first-child .body { border-top-color: transparent; }
.chat-item:hover .body, .chat-item.active .body, .chat-item:hover + .chat-item .body, .chat-item.active + .chat-item .body { border-top-color: transparent; }
.row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row + .row { margin-top: 2px; }
.chat-name { flex: 1; font-size: 17px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.chat-item.unread .chat-time { color: var(--badge); }
.chat-preview {
  flex: 1; display: flex; align-items: center; gap: 3px; font-size: 14px; color: var(--text-2); min-width: 0;
}
.chat-preview .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-preview .typing { color: var(--green); }
.chat-preview .tick { flex-shrink: 0; }
.unread-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--badge); color: #fff;
  font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
@media (prefers-color-scheme: dark) { .unread-badge { color: #111b21; } }
.pill-pending { font-size: 11px; color: var(--text-2); border: 1px solid var(--border); border-radius: 10px; padding: 1px 7px; flex-shrink: 0; }
.list-empty { padding: 40px 30px; text-align: center; color: var(--text-2); line-height: 1.6; font-size: 14px; }
.list-empty .btn-primary { margin-top: 16px; }
.start-email .avatar { background: var(--green); }
.start-email .avatar svg { fill: #fff; }

.avatar {
  width: 49px; height: 49px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: #dfe5e7;
  display: flex; align-items: center; justify-content: center; position: relative;
}
@media (prefers-color-scheme: dark) { .avatar { background: #6a7175; } }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar svg { width: 72%; height: 72%; fill: #fff; margin-top: 18%; }
@media (prefers-color-scheme: dark) { .avatar svg { fill: #cfd4d6; } }
.avatar .initial { color: #fff; font-weight: 500; font-size: 40%; }
.avatar-wrap { position: relative; }
.online-dot {
  position: absolute; right: 13px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--badge);
  border: 2px solid var(--panel);
}

/* ---------- Drawer ---------- */
.drawer {
  position: absolute; inset: 0; background: var(--panel); display: flex; flex-direction: column; z-index: 10;
  transform: translateX(-100%); transition: transform .25s cubic-bezier(.1, .82, .25, 1); visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head {
  height: 108px; display: flex; align-items: flex-end; gap: 22px; padding: 0 20px 14px; flex-shrink: 0;
  background: var(--panel); color: var(--text);
}
.drawer-head h2 { margin: 0 0 8px; font-size: 19px; font-weight: 500; }
.drawer-head.flat { height: 60px; align-items: center; background: var(--head); padding: 0 16px; }
.drawer-head.flat h2 { margin: 0; font-size: 16px; font-weight: 400; }
.new-chat-form { padding: 6px 28px 22px; border-bottom: 1px solid var(--border); }
.field-label { font-size: 14px; color: var(--green-dark); margin-bottom: 10px; }
@media (prefers-color-scheme: dark) { .field-label { color: var(--green); } }
.email-field { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--green); padding: 6px 0; }
.email-field svg { width: 20px; height: 20px; fill: var(--icon); }
.email-field input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; padding: 4px 0; }
.field-hint { font-size: 13px; color: var(--text-2); line-height: 1.5; margin: 12px 0 0; }
.field-error { font-size: 13px; color: var(--danger); margin: 10px 0 0; }
.btn-primary {
  margin-top: 18px; height: 40px; padding: 0 22px; border-radius: 20px; background: var(--green); color: #fff; font-weight: 500;
}
.btn-primary:hover { background: var(--green-dark); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #111b21; } .btn-primary:hover { background: #06cf9c; } }
.btn-primary:disabled { opacity: .6; cursor: default; }
.section-title { padding: 24px 28px 12px; color: var(--green-dark); font-size: 15px; }
@media (prefers-color-scheme: dark) { .section-title { color: var(--green); } }

.profile-body { flex: 1; overflow-y: auto; background: var(--rail); }
@media (prefers-color-scheme: dark) { .profile-body { background: var(--panel); } }
.profile-photo { display: flex; justify-content: center; padding: 28px 0; }
.profile-photo .avatar { width: 200px; height: 200px; }
.profile-field { background: var(--panel); padding: 14px 30px 10px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(11, 20, 26, .08); }
.editable { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid transparent; }
.editable:focus-within { border-bottom-color: var(--green); }
.editable input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; padding: 8px 0; }
.profile-email { font-size: 16px; padding: 8px 0; word-break: break-all; }
.btn-danger { display: block; margin: 24px auto; color: var(--danger); padding: 10px 26px; border-radius: 20px; border: 1px solid var(--border); background: var(--panel); }
.btn-danger:hover { background: var(--hover); }

/* ---------- Area utama ---------- */
.main { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.intro {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: var(--intro-bg); border-bottom: 6px solid var(--green); padding: 28px; color: var(--text-2);
}
.intro-art svg { width: 320px; max-width: 70vw; height: auto; }
.intro h1 { font-size: 32px; font-weight: 300; color: var(--text); margin: 28px 0 12px; }
.intro p { font-size: 14px; line-height: 20px; margin: 0; max-width: 520px; }
.intro-foot { margin-top: 60px; font-size: 13px; display: flex; align-items: center; gap: 6px; color: var(--text-3); }

.conv { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.conv-head {
  height: 60px; background: var(--head); display: flex; align-items: center; padding: 0 16px; gap: 6px; flex-shrink: 0;
  border-left: 1px solid var(--border); z-index: 2;
}
.back-btn { display: none; margin-left: -8px; }
.conv-peer { flex: 1; min-width: 0; display: flex; align-items: center; gap: 15px; text-align: left; height: 100%; }
.conv-peer .avatar { width: 40px; height: 40px; }
.conv-peer-text { display: flex; flex-direction: column; min-width: 0; }
.conv-name { font-size: 16px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-status { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv-status.typing { color: var(--green); }

.messages {
  flex: 1; overflow-y: auto; position: relative;
  background: var(--chat-bg) url('/img/pattern-light.svg') repeat; background-size: 360px;
}
@media (prefers-color-scheme: dark) { .messages { background-image: url('/img/pattern-dark.svg'); } }
.messages-inner { position: relative; padding: 12px 6% 8px; display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
.load-more { align-self: center; margin: 4px 0 10px; font-size: 12.5px; color: var(--text-2); }

.day-sep { align-self: center; margin: 10px 0 8px; position: sticky; top: 8px; z-index: 1; }
.day-sep span {
  display: inline-block; padding: 5px 12px 6px; border-radius: 7.5px; background: var(--day-chip); color: var(--text-2);
  font-size: 12.5px; box-shadow: var(--shadow); text-transform: uppercase;
}
.sys-note {
  align-self: center; max-width: 90%; text-align: center; margin: 4px 0 10px; padding: 6px 12px; border-radius: 7.5px;
  background: #ffeecd; color: #54656f; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .sys-note { background: #182229; color: #ffd279; } }
.sys-note svg { display: inline-block; vertical-align: -2px; width: 12px; height: 12px; fill: currentColor; margin-right: 4px; }
.sys-note button { color: var(--green-dark); font-weight: 600; margin-left: 4px; }
@media (prefers-color-scheme: dark) { .sys-note button { color: var(--green); } }

.msg-row { display: flex; margin-bottom: 2px; padding: 0 9px; }
.msg-row.first { margin-top: 10px; }
.msg-row.out { justify-content: flex-end; }
.bubble {
  position: relative; max-width: 65%; padding: 6px 7px 8px 9px; border-radius: 7.5px; box-shadow: var(--shadow);
  background: var(--in); color: var(--text); font-size: 14.2px; line-height: 19px; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg-row.out .bubble { background: var(--out); }
.msg-row.in.first .bubble { border-top-left-radius: 0; }
.msg-row.out.first .bubble { border-top-right-radius: 0; }
.msg-row.first .bubble::before {
  content: ''; position: absolute; top: 0; width: 8px; height: 13px;
}
.msg-row.in.first .bubble::before { left: -8px; background: var(--in); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg-row.out.first .bubble::before { right: -8px; background: var(--out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.bubble .text { white-space: pre-wrap; }
.bubble .text::after { content: ''; display: inline-block; width: 52px; height: 1px; }
.msg-row.out .bubble .text::after { width: 72px; }
.bubble a { color: #027eb5; text-decoration: none; }
.bubble a:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { .bubble a { color: #53bdeb; } }
.bubble .big-emoji { font-size: 40px; line-height: 48px; }
.meta {
  position: absolute; right: 7px; bottom: 3px; display: flex; align-items: center; gap: 3px;
  font-size: 11px; line-height: 15px; color: var(--text-2); white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .msg-row.out .meta { color: rgba(233, 237, 239, .6); } }
.tick { width: 16px; height: 16px; fill: var(--tick); flex-shrink: 0; }
.tick.read { fill: var(--tick-read); }
.tick.clock { width: 14px; height: 14px; }
.tick.fail { fill: var(--danger); width: 15px; height: 15px; }
.bubble.failed { cursor: pointer; }
.bubble.has-img { padding: 3px 3px 5px; }
.bubble.has-img .text { display: block; padding: 6px 4px 0 6px; }
.msg-img { display: block; max-width: 330px; width: 100%; max-height: 340px; min-height: 80px; object-fit: cover; border-radius: 6px; cursor: zoom-in; background: rgba(0, 0, 0, .05); }
.bubble.has-img.no-caption .meta {
  right: 9px; bottom: 9px; color: #fff; padding: 1px 6px; border-radius: 10px;
  background: linear-gradient(to top, rgba(11, 20, 26, .5), rgba(11, 20, 26, .3));
}
.bubble.has-img.no-caption .tick { fill: #fff; }
.bubble.has-img.no-caption .tick.read { fill: var(--tick-read); }

.scroll-down {
  position: absolute; right: 18px; bottom: 76px; width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel); box-shadow: var(--menu-shadow); display: flex; align-items: center; justify-content: center; z-index: 3;
}
.scroll-down svg { width: 26px; height: 26px; fill: var(--icon); }
.scroll-down .badge {
  position: absolute; top: -6px; left: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--badge); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center;
}

.composer {
  min-height: 62px; background: var(--head); display: flex; align-items: flex-end; gap: 4px; padding: 10px 16px; flex-shrink: 0; z-index: 2;
}
.composer .icon-btn { margin-bottom: 1px; }
.composer-input { flex: 1; min-width: 0; background: var(--panel); border-radius: 8px; padding: 9px 12px; margin: 0 6px; }
@media (prefers-color-scheme: dark) { .composer-input { background: #2a3942; } }
.composer-input textarea {
  display: block; width: 100%; border: 0; outline: none; resize: none; background: none; font-size: 15px; line-height: 20px;
  max-height: 120px; overflow-y: auto; padding: 0;
}
.composer-input textarea::placeholder { color: var(--text-2); }
.send-btn { color: var(--icon); }
.send-btn.ready { color: var(--green); }

.emoji-panel {
  height: 280px; background: var(--head); border-top: 1px solid var(--border); overflow-y: auto; padding: 10px 14px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); align-content: start; gap: 2px; z-index: 2;
}
.emoji-panel button { font-size: 26px; height: 42px; border-radius: 6px; }
.emoji-panel button:hover { background: rgba(11, 20, 26, .08); }

.media-preview {
  position: absolute; inset: 0; z-index: 20; background: var(--rail); display: flex; flex-direction: column;
}
.mp-head { height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 16px; font-size: 16px; }
.mp-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.mp-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: var(--menu-shadow); }
.mp-foot { display: flex; align-items: center; gap: 16px; padding: 16px 6% 28px; }
.mp-foot input { flex: 1; height: 42px; border: 0; outline: none; border-radius: 8px; padding: 0 14px; background: var(--panel); font-size: 15px; }
.mp-send { width: 60px; height: 60px; border-radius: 50%; background: var(--green); display: flex; align-items: center; justify-content: center; box-shadow: var(--menu-shadow); }
.mp-send svg { width: 26px; height: 26px; fill: #fff; margin-left: 3px; }
.mp-send:disabled { opacity: .6; }

/* ---------- Info kontak ---------- */
.info-panel { width: 30%; min-width: 320px; max-width: 440px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--rail); display: flex; flex-direction: column; }
@media (prefers-color-scheme: dark) { .info-panel { background: var(--panel); } }
.info-body { flex: 1; overflow-y: auto; }
.info-card { background: var(--panel); padding: 28px 30px 20px; text-align: center; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(11, 20, 26, .08); }
.info-card .avatar { width: 200px; height: 200px; margin: 0 auto 16px; }
.info-card h3 { margin: 0; font-size: 24px; font-weight: 400; word-break: break-word; }
.info-card .sub { color: var(--text-2); font-size: 16px; margin-top: 4px; word-break: break-all; }
.info-section { background: var(--panel); padding: 16px 30px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(11, 20, 26, .08); }
.info-section .label { color: var(--text-2); font-size: 14px; margin-bottom: 8px; }
.info-section .value { font-size: 15px; line-height: 1.5; word-break: break-word; }
.info-section .btn-primary { margin-top: 12px; }

/* ---------- Overlay ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 60px 20px 20px; backdrop-filter: blur(2px); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: var(--menu-shadow); }
.lightbox .icon-btn { position: absolute; top: 12px; right: 16px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; background: #303b41; color: #fff;
  padding: 12px 22px; border-radius: 6px; font-size: 14px; box-shadow: var(--menu-shadow); max-width: calc(100vw - 32px);
}

/* Scrollbar tipis seperti WA */
.chat-list::-webkit-scrollbar, .messages::-webkit-scrollbar, .emoji-panel::-webkit-scrollbar, .info-body::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb, .emoji-panel::-webkit-scrollbar-thumb, .info-body::-webkit-scrollbar-thumb { background: rgba(11, 20, 26, .2); }
@media (prefers-color-scheme: dark) {
  .chat-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb, .emoji-panel::-webkit-scrollbar-thumb, .info-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); }
}

/* ---------- Responsif ---------- */
@media (max-width: 1100px) {
  .info-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--menu-shadow); }
}
@media (max-width: 760px) {
  .rail { display: none; }
  .side { width: 100%; max-width: none; min-width: 0; border-right: 0; }
  .main { display: none; }
  .app.show-conv .side { display: none; }
  .app.show-conv .main { display: flex; }
  .back-btn { display: inline-flex; }
  .conv-head { padding: 0 8px; border-left: 0; }
  .composer { padding: 8px; }
  .messages-inner { padding: 10px 2% 8px; }
  .bubble { max-width: 85%; }
  .info-panel { width: 100%; min-width: 0; max-width: none; }
  .scroll-down { right: 12px; }
}

/* ---------- Lampiran & dokumen ---------- */
.attach-wrap { position: relative; }
.attach-menu {
  position: absolute; left: 0; bottom: 52px; z-index: 30; min-width: 190px; padding: 8px 0; border-radius: 16px;
  background: var(--panel); box-shadow: var(--menu-shadow); transform-origin: bottom left; animation: pop .12s ease-out;
}
@media (prefers-color-scheme: dark) { .attach-menu { background: #233138; } }
.attach-menu button { display: flex; align-items: center; gap: 14px; width: 100%; height: 44px; padding: 0 18px; font-size: 15px; color: var(--text); }
.attach-menu button:hover { background: var(--hover); }
@media (prefers-color-scheme: dark) { .attach-menu button:hover { background: #182229; } }
.am-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.am-icon svg { width: 22px; height: 22px; }
.am-icon.doc svg { fill: #7f66ff; }
.am-icon.img svg { fill: #007bfc; }

.doc-icon {
  width: 30px; height: 38px; border-radius: 4px; flex-shrink: 0; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 5px; color: #fff; font-size: 9px; font-weight: 700; letter-spacing: .3px; position: relative;
  clip-path: polygon(0 0, 70% 0, 100% 24%, 100% 100%, 0 100%);
}
.doc-icon::after { content: ''; position: absolute; top: 0; right: 0; width: 30%; height: 24%; background: rgba(255, 255, 255, .35); }

.bubble.has-doc { padding: 3px 3px 7px; }
.bubble.has-doc.no-caption { padding-bottom: 22px; }
.bubble.has-doc .text { display: block; padding: 6px 4px 0 6px; }
.doc-card {
  display: flex; align-items: center; gap: 12px; width: 300px; max-width: 100%; padding: 12px; border-radius: 6px;
  background: rgba(11, 20, 26, .05); color: inherit; text-decoration: none !important;
}
.msg-row.out .doc-card { background: rgba(11, 20, 26, .06); }
@media (prefers-color-scheme: dark) { .doc-card, .msg-row.out .doc-card { background: rgba(0, 0, 0, .18); } }
a.doc-card:hover { background: rgba(11, 20, 26, .09); }
.doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-name { font-size: 14.2px; color: var(--text); line-height: 19px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.doc-sub { font-size: 12px; color: var(--text-2); }
.doc-dl {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--text-3); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.doc-dl svg { width: 18px; height: 18px; fill: var(--icon); }
.doc-dl:hover { background: rgba(11, 20, 26, .06); }

.mp-doc {
  display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 40px 48px; border-radius: 12px;
  background: var(--panel); box-shadow: var(--menu-shadow); max-width: 420px; text-align: center;
}
.mp-doc .doc-icon { width: 64px; height: 80px; font-size: 15px; padding-bottom: 10px; }
.mp-doc-name { font-size: 17px; color: var(--text); word-break: break-word; }
.mp-doc-meta { font-size: 13px; color: var(--text-2); }

/* ---------- Balas pesan ---------- */
:root { --q-own: #06a884; --q-peer: #7f66ff; }
@media (prefers-color-scheme: dark) { :root { --q-own: #06cf9c; --q-peer: #a791ff; } }

.quote {
  display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 6px 10px 7px 10px; border-radius: 7.5px;
  border-left: 4px solid var(--q-color, var(--q-own)); background: rgba(11, 20, 26, .05); overflow: hidden;
}
@media (prefers-color-scheme: dark) { .quote { background: rgba(0, 0, 0, .2); } }
.quote.own { --q-color: var(--q-own); }
.quote.peer { --q-color: var(--q-peer); }
.quote.deleted { --q-color: var(--text-3); font-style: italic; }
.q-name { font-size: 12.8px; font-weight: 600; color: var(--q-color); line-height: 18px; }
.q-text {
  font-size: 13.2px; color: var(--text-2); line-height: 18px; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.q-ic { display: inline-block; width: 15px; height: 15px; fill: currentColor; vertical-align: -3px; margin-right: 3px; }

.bubble .quote { margin: -2px -3px 5px -5px; cursor: pointer; }
.bubble .quote.deleted { cursor: default; }
.bubble .quote:hover { filter: brightness(.97); }
.bubble.has-reply { min-width: 180px; }
.bubble.has-img .quote, .bubble.has-doc .quote { margin: 0 0 3px; }

.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px 0 70px; background: var(--head); z-index: 2; }
.reply-bar .reply-slot { flex: 1; min-width: 0; }
.reply-bar .quote { background: var(--panel); }
@media (prefers-color-scheme: dark) { .reply-bar .quote { background: #1d282f; } }
.reply-bar + .composer { padding-top: 6px; }
@media (max-width: 760px) { .reply-bar { padding-left: 10px; } }

.msg-more {
  position: absolute; top: 2px; right: 2px; width: 28px; height: 24px; border-radius: 0 6px 0 12px;
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .12s; z-index: 1;
  background: radial-gradient(at top right, var(--in) 60%, transparent 100%);
}
.msg-row.out .msg-more { background: radial-gradient(at top right, var(--out) 60%, transparent 100%); }
.msg-more svg { width: 20px; height: 20px; fill: var(--text-3); }
.bubble:hover .msg-more, .msg-more:focus-visible { opacity: 1; }
@media (hover: none) { .msg-more { display: none; } }
.bubble.has-img .msg-more { background: radial-gradient(at top right, rgba(11, 20, 26, .45), transparent 70%); }
.bubble.has-img .msg-more svg { fill: #fff; }

.msg-menu {
  position: fixed; z-index: 60; min-width: 150px; padding: 8px 0; border-radius: 3px; background: var(--panel);
  box-shadow: var(--menu-shadow); animation: pop .12s ease-out;
}
@media (prefers-color-scheme: dark) { .msg-menu { background: #233138; } }
.msg-menu button { display: block; width: 100%; height: 40px; padding: 0 24px; text-align: left; font-size: 14.5px; color: var(--text); }
.msg-menu button:hover { background: var(--hover); }
@media (prefers-color-scheme: dark) { .msg-menu button:hover { background: #182229; } }

.msg-row { position: relative; }
.msg-row.swipe-ready::before {
  content: ''; position: absolute; left: -26px; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%;
  background: rgba(11, 20, 26, .12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2354656f' d='M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z'/%3E%3C/svg%3E") center/16px no-repeat;
}
@keyframes flash { 0%, 60% { background: rgba(0, 168, 132, .18); } 100% { background: transparent; } }
.msg-row.flash { animation: flash 1.6s ease-out; border-radius: 8px; }

/* ---------- Menu chat & dialog konfirmasi ---------- */
.menu button.danger { color: var(--danger); }
.modal {
  position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(11, 20, 26, .45);
}
@media (prefers-color-scheme: dark) { .modal { background: rgba(0, 0, 0, .6); } }
.modal-box {
  width: 100%; max-width: 480px; background: var(--panel); border-radius: 8px; padding: 22px 24px 18px;
  box-shadow: 0 17px 50px 0 rgba(11, 20, 26, .19), 0 12px 15px 0 rgba(11, 20, 26, .24); animation: pop .15s ease-out;
}
@media (prefers-color-scheme: dark) { .modal-box { background: #3b4a54; } }
.modal-box h3 { margin: 0 0 12px; font-size: 20px; font-weight: 400; color: var(--text); line-height: 1.35; word-break: break-word; }
.modal-box p { margin: 0; font-size: 14.2px; line-height: 1.5; color: var(--text-2); }
@media (prefers-color-scheme: dark) { .modal-box p { color: #d1d7db; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.modal-actions .btn-primary { margin-top: 0; }
.btn-ghost {
  height: 40px; padding: 0 22px; border-radius: 20px; border: 1px solid var(--border); color: var(--green-dark); font-weight: 500;
}
.btn-ghost:hover { background: var(--hover); }
@media (prefers-color-scheme: dark) { .btn-ghost { color: var(--green); border-color: #8696a0; } .btn-ghost:hover { background: rgba(255, 255, 255, .06); } }

/* ---------- Grup ---------- */
.avatar.group, .avatar.group-new { background: #b6c2c9; }
.avatar.group svg, .avatar.group-new svg { width: 62%; height: 62%; margin-top: 0; fill: #fff; }
@media (prefers-color-scheme: dark) { .avatar.group { background: #5b6a73; } }
.avatar.group-new { background: var(--green); }
.new-group-row { margin: 4px 0 6px; }
.new-group-row .body { border-top: 0; }
.avatar.group.big { width: 120px; height: 120px; margin: 8px auto 22px; }

.prev-sender { flex-shrink: 0; }
.bubble .sender-name { display: block; font-size: 12.8px; font-weight: 600; line-height: 19px; margin-bottom: 1px; }
.bubble.has-img .sender-name, .bubble.has-doc .sender-name { padding: 3px 6px 2px; }
.sys-row { align-self: center; margin: 8px 0; max-width: 85%; text-align: center; }
.sys-row span {
  display: inline-block; padding: 5px 12px 6px; border-radius: 7.5px; background: var(--day-chip); color: var(--text-2);
  font-size: 12.5px; line-height: 1.4; box-shadow: var(--shadow);
}

.chips-field {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 24px 6px; padding: 6px 0 8px;
  border-bottom: 2px solid var(--green);
}
.chips-field input { flex: 1; min-width: 180px; border: 0; outline: none; background: none; font-size: 15px; padding: 6px 2px; }
.chip-member {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 12px; border-radius: 14px;
  background: var(--chip); color: var(--text); font-size: 13.5px; max-width: 100%;
}
.chip-member span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-member button { width: 20px; height: 20px; border-radius: 50%; font-size: 15px; line-height: 18px; color: var(--text-2); }
.chip-member button:hover { background: rgba(11, 20, 26, .1); }
#drawerGroup .field-error { margin: 6px 24px 0; }
#groupStep1 { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
#groupStep1.hidden, #groupStep2.hidden { display: none; }
#groupStep2 { flex: 1; position: relative; }
.group-name-box { padding: 10px 28px; text-align: center; }
.group-name-box .email-field input { text-align: left; }
.chat-item.picked { background: var(--active); }
.pick-check {
  position: absolute; right: 10px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%; background: var(--green); color: #fff;
  font-size: 11px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--panel);
}
.fab {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); display: flex; align-items: center; justify-content: center; box-shadow: var(--menu-shadow); z-index: 2;
}
.fab svg { width: 26px; height: 26px; fill: #fff; }
.fab:hover { background: var(--green-dark); }
.fab:disabled { opacity: .6; }

.group-title-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.group-title-row .title-input { font-size: 22px; text-align: center; border: 0; border-bottom: 2px solid var(--green); outline: none; background: none; width: 100%; padding: 4px 0; }
.info-section.members { padding-left: 0; padding-right: 0; }
.info-section.members > .label { padding: 0 30px; }
.add-member { display: flex; gap: 8px; padding: 4px 30px 12px; }
.add-member input { flex: 1; min-width: 0; border: 0; border-bottom: 2px solid var(--border); outline: none; background: none; font-size: 14.5px; padding: 6px 2px; }
.add-member input:focus { border-bottom-color: var(--green); }
.add-member .btn-primary { margin-top: 0; height: 34px; padding: 0 16px; }
.member-row { display: flex; align-items: center; gap: 14px; padding: 9px 20px 9px 30px; }
.member-row:hover { background: var(--hover); }
.member-row .avatar { width: 40px; height: 40px; }
.member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.member-name { font-size: 15.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-tag { font-size: 11.5px; color: var(--green-dark); background: var(--chip-active); padding: 2px 8px; border-radius: 4px; flex-shrink: 0; }
@media (prefers-color-scheme: dark) { .admin-tag { color: var(--green); } }
.member-more { opacity: .7; }
.msg-menu button.danger { color: var(--danger); }
