:root {
  --bg: #f1f4f9;
  --panel: #ffffff;
  --text: #1c2624;
  --muted: #5d6b68;
  --faint: #8a9794;
  --line: #e3e9e7;
  --hover: #eef3f2;
  --read-row: #f6f9f8;
  --accent: #0b2a5b;
  --accent-ink: #071d40;
  --accent-soft: #d6e2f3;
  --accent-softer: #eef3fa;
  --star: #e8a317;
  --danger: #c62828;
  --selected: #dce6f5;
  --shadow: 0 1px 2px rgba(20, 40, 36, .12), 0 2px 6px rgba(20, 40, 36, .08);
  --shadow-lg: 0 8px 28px rgba(20, 40, 36, .22);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
a { color: var(--accent); }

input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #cfd8d6; border-radius: 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 999px; border: 1px solid #cfd8d6; background: #fff; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.block { width: 100%; padding: 11px; }
.btn svg { width: 18px; height: 18px; }

.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: rgba(28, 38, 36, .07); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 18px; height: 18px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--danger); min-height: 1em; margin: 2px 0; font-size: 13px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); width: min(400px, 100%); padding: 36px 32px 28px; border-radius: 24px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-card h1 { margin: 12px 0 0; font-size: 26px; font-weight: 500; }
.login-card .muted { margin: 0 0 8px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 20px; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 600; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand .logo svg { width: 20px; height: 20px; }
.brand.big { font-size: 22px; }

/* ---------- Kerangka ---------- */
#app { display: grid; grid-template-columns: 256px 1fr; grid-template-rows: 64px 1fr; height: 100vh; }
#app.nav-collapsed { grid-template-columns: 76px 1fr; }

.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 10px; }
.topbar .brand { min-width: 200px; }
.search { flex: 1; max-width: 720px; display: flex; align-items: center; background: #e4ecea; border-radius: 999px; height: 48px; padding: 0 4px; margin-left: 24px; }
.search:focus-within { background: #fff; box-shadow: var(--shadow); }
.search input { border: 0; background: transparent; box-shadow: none !important; padding: 0 4px; height: 100%; font-size: 16px; }
.top-right { margin-left: auto; position: relative; display: flex; align-items: center; gap: 4px; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: 15px; background: var(--accent); flex: none; text-transform: uppercase; }
.avatar.lg { width: 72px; height: 72px; font-size: 30px; }
.popover { position: absolute; right: 0; top: 48px; z-index: 30; background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); padding: 22px; width: 300px; display: grid; justify-items: center; gap: 4px; text-align: center; }
.popover .p-name { font-size: 17px; font-weight: 500; margin-top: 6px; }
.popover .p-email { color: var(--muted); margin-bottom: 12px; word-break: break-all; }

/* ---------- Navigasi kiri ---------- */
.nav { padding: 8px 12px 16px 8px; overflow-y: auto; }
.compose-btn { display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 0 18px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 15px; margin: 0 0 16px 4px; box-shadow: none; transition: box-shadow .15s; }
.compose-btn:hover { box-shadow: var(--shadow); }
.compose-btn svg { width: 22px; height: 22px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 16px; height: 34px; padding: 0 12px 0 22px; border-radius: 0 999px 999px 0; color: var(--text); text-align: left; text-decoration: none; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--selected); color: var(--accent-ink); font-weight: 700; }
.nav-item svg { width: 20px; height: 20px; color: var(--muted); }
.nav-item.active svg { color: var(--accent-ink); }
.nav-item .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 12px; font-weight: 700; }
.nav-item.subtle { color: var(--muted); }
.nav-item .x { opacity: 0; color: var(--faint); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.nav-item:hover .x { opacity: 1; }
.nav-item .x:hover { background: rgba(0,0,0,.08); color: var(--danger); }
.nav-item .x svg { width: 16px; height: 16px; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-left: 5px; margin-right: 5px; }
.nav-item .warn { color: var(--danger); font-size: 12px; }
.nav-label { margin: 18px 0 4px 22px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
#app.nav-collapsed .nav .compose-btn span, #app.nav-collapsed .nav-item .lbl, #app.nav-collapsed .nav-item .count, #app.nav-collapsed .nav-item .warn, #app.nav-collapsed .nav-label, #app.nav-collapsed .nav-item .x { display: none; }
#app.nav-collapsed .compose-btn { padding: 0; width: 56px; justify-content: center; }
#app.nav-collapsed .nav-item { width: 48px; padding: 0; justify-content: center; border-radius: 999px; margin-left: 6px; }
.scrim { display: none; }

/* ---------- Panel utama ---------- */
.main { background: var(--panel); border-radius: var(--radius); margin: 0 16px 16px 0; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 2px; min-height: 48px; padding: 4px 8px 4px 12px; border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.toolbar .range { color: var(--muted); font-size: 12.5px; margin-right: 4px; white-space: nowrap; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.cb { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 50%; cursor: pointer; flex: none; }
.cb:hover { background: rgba(0,0,0,.06); }
.cb input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; padding: 0; box-shadow: none !important; }
.banner { background: #fdecea; color: #8a1c1c; padding: 8px 16px; font-size: 13px; border-bottom: 1px solid #f6d3cf; }
.banner.info { background: var(--accent-softer); color: var(--accent-ink); border-color: var(--accent-soft); }
.view { flex: 1; overflow-y: auto; min-height: 0; }

/* ---------- Daftar percakapan ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.trow { display: flex; align-items: center; height: 40px; padding: 0 12px 0 4px; border-bottom: 1px solid var(--line); cursor: pointer; background: var(--read-row); position: relative; }
.trow.unread { background: #fff; }
.trow:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); z-index: 1; }
.trow.selected { background: var(--selected); }
.trow .cb { width: 36px; height: 36px; }
.star { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: #b7c2bf; flex: none; }
.star:hover { background: rgba(0,0,0,.06); color: var(--muted); }
.star.on { color: var(--star); }
.star svg { width: 20px; height: 20px; }
.trow .who { width: 200px; flex: none; padding: 0 12px 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.trow .who .n { color: var(--muted); font-size: 12px; margin-left: 4px; font-weight: 400; }
.trow .what { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.trow .subj { color: var(--text); }
.trow.unread .who, .trow.unread .subj { font-weight: 700; }
.trow.unread .date { font-weight: 700; color: var(--text); }
.chip { display: inline-block; font-size: 11.5px; line-height: 18px; padding: 0 7px; border-radius: 6px; background: #e6ecea; color: var(--muted); margin-right: 6px; vertical-align: 1px; font-weight: 500; }
.chip.acc { background: var(--accent-softer); color: var(--accent-ink); }
.trow .att { width: 24px; color: var(--faint); display: grid; place-items: center; flex: none; }
.trow .att svg { width: 16px; height: 16px; transform: rotate(45deg); }
.trow .date { width: 72px; flex: none; text-align: right; font-size: 12.5px; color: var(--muted); }
.trow .quick { display: none; position: absolute; right: 8px; top: 0; bottom: 0; align-items: center; gap: 2px; background: inherit; padding-left: 8px; }
.trow:hover .quick { display: flex; }
.trow:hover .date { visibility: hidden; }
.empty { text-align: center; color: var(--faint); padding: 72px 16px; }
.empty svg { width: 56px; height: 56px; color: #c7d3d0; display: block; margin: 0 auto 10px; }
.foot { color: var(--faint); font-size: 12px; text-align: center; padding: 16px; }

/* ---------- Percakapan ---------- */
.thread { padding: 8px 24px 40px 72px; max-width: 1100px; }
.thread h1 { font-size: 22px; font-weight: 400; margin: 12px 0 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.msg { border-bottom: 1px solid var(--line); padding: 12px 0; }
.msg-head { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; position: relative; }
.msg .avatar { margin-left: -56px; margin-top: 2px; width: 40px; height: 40px; }
.msg-who { flex: 1; min-width: 0; }
.msg-who b { font-weight: 600; }
.msg-who .addr { color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.msg-who .to { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-meta { display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.msg-snip { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.collapsed .msg-body, .msg.collapsed .atts, .msg.collapsed .to { display: none; }
.msg:not(.collapsed) .msg-snip { display: none; }
.msg-body { margin-top: 12px; }
.msg-body iframe { width: 100%; border: 0; display: block; min-height: 60px; }
.msg-body .plain { white-space: pre-wrap; word-wrap: break-word; margin: 0; font: inherit; }
.msg-body .quote { color: var(--muted); }
.quote-toggle { display: inline-flex; align-items: center; height: 14px; padding: 0 6px; border-radius: 7px; background: #e6ecea; color: var(--muted); margin-top: 8px; }
.quote-toggle svg { width: 18px; height: 18px; }
.atts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.att-chip { display: inline-flex; align-items: center; gap: 10px; max-width: 260px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); background: #fff; }
.att-chip:hover { background: var(--hover); }
.att-chip svg { color: var(--accent); }
.att-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.att-chip .sz { color: var(--faint); font-size: 12px; }
.att-chip.off { opacity: .6; }
.thread-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Jendela tulis ---------- */
#composeDock { position: fixed; right: 24px; bottom: 0; z-index: 40; display: flex; align-items: flex-end; gap: 16px; pointer-events: none; }
.compose { pointer-events: auto; width: 540px; height: 560px; max-height: calc(100vh - 24px); background: #fff; border-radius: 12px 12px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.compose.min { height: 44px; width: 300px; }
.compose.max { position: fixed; inset: 5vh 8vw; width: auto; height: auto; max-height: none; border-radius: 12px; }
.c-head { height: 44px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 6px 0 16px; background: #e8efed; cursor: pointer; }
.c-head .c-title { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-head .icon-btn { width: 30px; height: 30px; }
.c-head .icon-btn svg { width: 17px; height: 17px; }
.compose.min form { display: none; }
.compose form { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 16px; }
.c-field { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); min-height: 40px; }
.c-field label { color: var(--muted); font-size: 13.5px; width: 52px; flex: none; }
.c-field input, .c-field select { border: 0; padding: 8px 0; border-radius: 0; box-shadow: none !important; }
.c-field .link { color: var(--muted); font-size: 13px; white-space: nowrap; }
.c-field .link:hover { text-decoration: underline; color: var(--text); }
.compose textarea { flex: 1; border: 0; resize: none; padding: 12px 0; box-shadow: none !important; border-radius: 0; min-height: 120px; line-height: 1.5; }
.c-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }
.c-att { display: inline-flex; align-items: center; gap: 6px; background: #eef3f2; border-radius: 6px; padding: 4px 4px 4px 10px; font-size: 12.5px; max-width: 100%; }
.c-att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 500; color: var(--accent-ink); }
.c-att .sz { color: var(--faint); }
.c-att button { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.c-att button:hover { background: rgba(0,0,0,.08); }
.c-att button svg { width: 15px; height: 15px; }
.c-foot { display: flex; align-items: center; gap: 4px; padding: 10px 0 12px; flex: none; }
.c-foot .btn.primary { padding: 9px 22px; }
.c-foot .err { flex: 1; margin: 0 6px; }
.c-foot label.icon-btn { cursor: pointer; }
.c-foot label.icon-btn svg { transform: rotate(45deg); }
.drop-hint { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 24px; bottom: 24px; z-index: 50; background: #26312f; color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 16px; max-width: calc(100vw - 48px); }
.toast button { color: #8fe0d4; font-weight: 600; }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: 20px; padding: 0; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(16, 28, 26, .45); }
.form { padding: 24px; display: grid; gap: 10px; width: 440px; max-width: 100%; }
.form h2 { margin: 0 0 4px; font-size: 20px; font-weight: 500; }
.form .row { display: flex; gap: 8px; align-items: center; }
.form .row .port { width: 90px; flex: none; }
.form .row.addr input { flex: 1 1 45%; min-width: 0; }
.form .row.addr select { flex: 1 1 55%; width: auto; min-width: 0; }
.form .row.pw input { flex: 1; min-width: 0; }
.form .at { color: var(--muted); }
.form .field { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.form .hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.form .steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.form code { background: #eef3f2; border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.form pre { background: #1c2624; color: #e6efed; border-radius: 8px; padding: 10px 12px; margin: 6px 0 0; font-size: 12.5px; overflow-x: auto; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- Layar kecil ---------- */
@media (max-width: 900px) {
  .trow .who { width: 140px; }
  .thread { padding: 8px 16px 40px; }
  .msg .avatar { margin-left: 0; }
}
@media (max-width: 760px) {
  #app, #app.nav-collapsed { grid-template-columns: 1fr; grid-template-rows: 60px 1fr; }
  .topbar { padding: 0 8px; gap: 4px; }
  .topbar .brand { display: none; }
  .search { margin-left: 0; height: 44px; }
  .nav { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; background: var(--bg); z-index: 35; transform: translateX(-100%); transition: transform .2s; padding-top: 16px; }
  #app.nav-open .nav { transform: none; box-shadow: var(--shadow-lg); }
  #app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 34; }
  #app.nav-collapsed .nav .compose-btn span, #app.nav-collapsed .nav-item .lbl, #app.nav-collapsed .nav-item .count, #app.nav-collapsed .nav-label { display: initial; }
  #app.nav-collapsed .nav-item { width: 100%; padding: 0 12px 0 22px; justify-content: flex-start; border-radius: 0 999px 999px 0; margin-left: 0; }
  #app.nav-collapsed .compose-btn { width: auto; padding: 0 24px 0 18px; }
  .main { margin: 0; border-radius: 16px 16px 0 0; }
  .trow { height: auto; padding: 10px 12px 10px 4px; align-items: flex-start; flex-wrap: wrap; }
  .trow .who { width: auto; flex: 1; padding-top: 6px; }
  .trow .date { width: auto; padding-top: 6px; margin-left: 8px; }
  .trow .what { order: 3; flex-basis: 100%; padding-left: 72px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .trow .att { display: none; }
  .trow:hover .quick { display: none; }
  .trow:hover .date { visibility: visible; }
  #composeDock { right: 0; left: 0; }
  .compose, .compose.max { position: fixed; inset: 0; width: auto; height: auto; max-height: none; border-radius: 0; }
  .compose.min { inset: auto 0 0 0; height: 44px; }
  .thread h1 { font-size: 19px; }
  .toolbar .range { display: none; }
}

/* Logo Rumpi */
.logo-img { height: 32px; width: auto; flex: none; }
.brand.big .logo-img { height: 48px; }

/* ---------- Avatar foto & halaman Profil (Webmail Rumpi) ---------- */
.avatar.photo { background-size: cover !important; background-position: center !important; color: transparent; }
.avatar.xl { width: 112px; height: 112px; font-size: 44px; box-shadow: var(--shadow); }
.popover .btn { width: 100%; }
.nav-item .x.edit:hover { color: var(--accent); }
.toolbar .tb-title { font-size: 16px; font-weight: 500; margin-left: 8px; }
.profile { max-width: 980px; padding: 16px 28px 56px; }
.profile h1 { font-size: 24px; font-weight: 500; margin: 8px 0 6px; }
.profile > .muted { color: var(--muted); margin: 0 0 8px; }
.pcard { display: grid; grid-template-columns: 260px 1fr; gap: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-top: 16px; }
.pcard-side h2 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.pcard-side p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.photo-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.photo-actions { display: grid; gap: 8px; justify-items: start; }
.photo-actions .hint, .pform .hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.pform { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.pform label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: var(--muted); }
.pform label input, .pform label textarea { font-weight: 400; color: var(--text); }
.pform input:disabled { background: #f3f6f5; color: var(--muted); }
.pform textarea { resize: vertical; min-height: 96px; }
.pform .wide { grid-column: 1 / -1; }
.pform-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pform-foot .err { flex: 1; }
@media (max-width: 760px) {
  .profile { padding: 8px 12px 40px; }
  .pcard { grid-template-columns: 1fr; gap: 12px; padding: 18px; }
  .pform { grid-template-columns: 1fr; }
}
