/* ==========================================================================
   TempMail — Material Design 3 design system (dark only, teal seed #006A60)
   Spec: https://m3.material.io — color: tonal palette / elevation: surface
   containers / shape: 4·8·12·16·28·full / type: Roboto M3 scale / motion:
   emphasized easing. No Tailwind, no glassmorphism, no gradients.
   ========================================================================== */

/* ─── 1. Design tokens ─────────────────────────────────────────────────── */
:root {
  /* Color — M3 dark scheme derived from seed #006A60 (teal) */
  --md-primary: #4FDBCE;
  --md-on-primary: #003832;
  --md-primary-container: #005048;
  --md-on-primary-container: #6FF7EA;

  --md-secondary: #B4CCC7;
  --md-on-secondary: #1F3531;
  --md-secondary-container: #354B47;
  --md-on-secondary-container: #D0E8E3;

  --md-tertiary: #B8C8E5;
  --md-on-tertiary: #223148;
  --md-tertiary-container: #38485F;
  --md-on-tertiary-container: #D5E4FF;

  --md-error: #FFB4AB;
  --md-on-error: #690005;
  --md-error-container: #93000A;
  --md-on-error-container: #FFDAD6;

  --md-background: #191C1B;
  --md-on-background: #E0E3E1;
  --md-surface: #191C1B;
  --md-on-surface: #E0E3E1;
  --md-surface-variant: #BCC8C5;
  --md-on-surface-variant: #BCC8C5;

  --md-surface-container-lowest: #111413;
  --md-surface-container-low: #1D201F;
  --md-surface-container: #212423;
  --md-surface-container-high: #2B2E2D;
  --md-surface-container-highest: #363A39;
  --md-surface-dim: #141716;
  --md-surface-bright: #3A3D3C;

  --md-outline: #86938F;
  --md-outline-variant: #3B4845;

  --md-inverse-surface: #E0E3E1;
  --md-inverse-on-surface: #2C312F;
  --md-inverse-primary: #006A60;

  --md-scrim: #000000;

  /* Elevation — M3 maps levels to surface containers (dark) + subtle shadow */
  --md-e1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-e2: 0 1px 2px rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  --md-e3: 0 1px 3px rgba(0, 0, 0, 0.30), 0 4px 8px 3px rgba(0, 0, 0, 0.15);
  --md-e4: 0 2px 3px rgba(0, 0, 0, 0.30), 0 6px 10px 4px rgba(0, 0, 0, 0.15);
  --md-e5: 0 4px 4px rgba(0, 0, 0, 0.30), 0 8px 12px 6px rgba(0, 0, 0, 0.15);

  /* Shape scale */
  --md-shape-xs: 4px;
  --md-shape-sm: 8px;
  --md-shape-md: 12px;
  --md-shape-lg: 16px;
  --md-shape-xl: 28px;
  --md-shape-full: 9999px;

  /* States */
  --md-state-hover: 0.08;
  --md-state-focus: 0.1;
  --md-state-pressed: 0.1;
  --md-state-disabled: 0.38;
  --md-state-placeholder: 0.6;

  /* Motion — M3 easing & duration tokens */
  --md-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --md-ease-emphasized-decel: cubic-bezier(0.05, 0.7, 0.1, 1);
  --md-ease-emphasized-accel: cubic-bezier(0.3, 0, 0.8, 0.15);
  --md-dur-short: 200ms;
  --md-dur-medium: 300ms;
  --md-dur-long: 500ms;

  /* Spacing scale (M3 = 4/8dp unit) */
  --md-sp-1: 4px;
  --md-sp-2: 8px;
  --md-sp-3: 12px;
  --md-sp-4: 16px;
  --md-sp-5: 24px;
  --md-sp-6: 32px;
  --md-sp-7: 48px;

  --md-drawer-w: 288px;
  --md-appbar-h: 64px;
}

/* ─── 2. Base ──────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scrollbar-color: var(--md-surface-container-highest) transparent; }

body {
  /* intentional: Roboto is Material Design 3's native typeface; the brief pins
     the M3 system (m3.material.io), so its type scale ships with its own face */
  font-family: "Roboto", "Helvetica Neue", Arial, sans-serif;
  background: var(--md-background);
  color: var(--md-on-surface);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--md-primary); color: var(--md-on-primary); }
input, textarea { caret-color: var(--md-primary); }

[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--md-surface-container-highest);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--md-outline);
  border: 3px solid transparent;
  background-clip: content-box;
}

a { color: var(--md-primary); text-decoration: none; }

/* Material Symbols Rounded — M3's icon font */
.msyr {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-variation-settings: "FILL" 0 "wght" 400 "GRAD" 0 "opsz" 24;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
.msyr.filled { font-variation-settings: "FILL" 1 "wght" 400 "GRAD" 0 "opsz" 24; }

/* ─── 3. M3 type scale ─────────────────────────────────────────────────── */
.t-display-lg   { font-size: 57px; line-height: 64px; font-weight: 400; letter-spacing: -0.25px; }
.t-display-md   { font-size: 45px; line-height: 52px; font-weight: 400; }
.t-display-sm   { font-size: 36px; line-height: 44px; font-weight: 400; }
.t-headline-lg  { font-size: 32px; line-height: 40px; font-weight: 400; }
.t-headline-md  { font-size: 28px; line-height: 36px; font-weight: 400; }
.t-headline-sm  { font-size: 24px; line-height: 32px; font-weight: 400; }
.t-title-lg     { font-size: 22px; line-height: 28px; font-weight: 400; }
.t-title-md     { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: 0.15px; }
.t-title-sm     { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; }
.t-body-lg      { font-size: 16px; line-height: 24px; font-weight: 400; letter-spacing: 0.5px; }
.t-body-md      { font-size: 14px; line-height: 20px; font-weight: 400; letter-spacing: 0.25px; }
.t-body-sm      { font-size: 12px; line-height: 16px; font-weight: 400; letter-spacing: 0.4px; }
.t-label-lg     { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; }
.t-label-md     { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.5px; }
.t-label-sm     { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: 0.5px; }

.mono { font-family: "Roboto Mono", monospace; font-size: 13px; letter-spacing: 0; }

/* Utility text colors */
.c-on-surface-variant { color: var(--md-on-surface-variant); }
.c-outline { color: var(--md-outline); }
.c-error { color: var(--md-error); }
.c-primary { color: var(--md-primary); }

/* ─── 4. Interaction primitives: state layer + ripple ─────────────────── */
.m3-interactive {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  isolation: isolate;
}
.m3-interactive::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-dur-short) var(--md-ease-standard);
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
}
.m3-interactive:hover::before { opacity: var(--md-state-hover); }
.m3-interactive:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}
.m3-interactive:focus-visible::before { opacity: var(--md-state-focus); }
.m3-interactive:active::before { opacity: var(--md-state-pressed); }
.m3-interactive:disabled,
.m3-interactive[aria-disabled="true"] {
  pointer-events: none;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.12;
  transform: scale(0);
  pointer-events: none;
  z-index: 0;
  animation: ripple-grow 450ms var(--md-ease-emphasized-decel) forwards;
}
@keyframes ripple-grow {
  to { transform: scale(2.6); opacity: 0.05; }
}

/* >2 levels never happen: buttons keep children above state layer */
.m3-interactive > :not(.ripple) { position: relative; z-index: 1; }

/* ─── 5. Buttons (M3 button hierarchy) ─────────────────────────────────── */
.m3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border: none;
  border-radius: var(--md-shape-full);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow var(--md-dur-short) var(--md-ease-standard);
}
.m3-btn .msyr { font-size: 18px; }
.m3-btn > span:not(.msyr) { position: relative; z-index: 1; }

.m3-btn.filled {
  background: var(--md-primary);
  color: var(--md-on-primary);
}
.m3-btn.filled:disabled {
  background: rgba(224, 227, 225, 0.12);
  color: rgba(224, 227, 225, var(--md-state-disabled));
}

.m3-btn.tonal {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.m3-btn.destructive {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
}
.m3-btn.text {
  background: transparent;
  color: var(--md-primary);
  padding: 0 12px;
}
.m3-btn.outlined {
  background: transparent;
  color: var(--md-primary);
  border: 1px solid var(--md-outline);
}

/* Icon button (M3 standard) */
.m3-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0; /* target sentuh tidak boleh dipampatkan oleh fleks */
  border: none;
  border-radius: var(--md-shape-full);
  background: transparent;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  font-family: inherit;
}
.m3-icon-btn .msyr { font-size: 22px; }

/* Extended FAB */
.m3-fab-extended {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 20px 0 16px;
  border: none;
  border-radius: var(--md-shape-lg);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  box-shadow: var(--md-e3);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  width: 100%;
  justify-content: flex-start;
  transition: box-shadow var(--md-dur-short) var(--md-ease-standard);
}
.m3-fab-extended:hover { box-shadow: var(--md-e4); }
.m3-fab-extended:disabled {
  background: rgba(224, 227, 225, 0.12);
  color: rgba(224, 227, 225, var(--md-state-disabled));
  box-shadow: none;
}
.m3-fab-extended .msyr { font-size: 24px; }
.m3-fab-extended > :not(.ripple) { position: relative; z-index: 1; }

/* ─── 6. Chips (M3 assist chip family) ─────────────────────────────────── */
.m3-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--md-shape-sm);
  border: 1px solid var(--md-outline-variant);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
}
.m3-chip .msyr { font-size: 18px; }
.m3-chip.tonal {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border-color: transparent;
}
.m3-chip.accent {
  background: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
  border-color: transparent;
}
.m3-chip.err {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
  border-color: transparent;
}
.m3-chip.ok {
  border-color: transparent;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}
.m3-chip.dim {
  opacity: 0.6;
}

/* M3 badge (small) */
.m3-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--md-shape-xs);
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-size: 11px;
  font-weight: 500;
}

/* ─── 7. Progress indicators ──────────────────────────────────────────── */
.m3-progress-circular {
  width: 20px;
  height: 20px;
  animation: pc-rotate 1.4s linear infinite;
}
.m3-progress-circular svg { display: block; }
.m3-progress-circular circle {
  fill: none;
  stroke: var(--md-primary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 90, 150;
  stroke-dashoffset: 0;
  animation: pc-dash 1.4s var(--md-ease-standard) infinite;
}
.m3-progress-circular.small { width: 18px; height: 18px; }
.m3-progress-circular.small circle { stroke-width: 5; }
@keyframes pc-rotate { to { transform: rotate(360deg); } }
@keyframes pc-dash {
  0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90, 200; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 200; stroke-dashoffset: -124; }
}

/* ─── 8. App bar (small, M3) ──────────────────────────────────────────── */
.m3-appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--md-appbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 var(--md-sp-4) 0 12px;
  background: var(--md-surface-container);
}
.m3-appbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-left: 8px;
}
.m3-appbar .brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.m3-appbar .brand-title {
  font-size: 22px;
  line-height: 28px;
  font-weight: 500;
  color: var(--md-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m3-appbar .spacer { flex: 1; }
.m3-appbar .avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--md-shape-full);
  background: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  margin-left: 8px;
  flex-shrink: 0;
}

/* ─── 9. Layout shell ─────────────────────────────────────────────────── */
.m3-shell {
  display: flex;
  min-height: calc(100vh - var(--md-appbar-h));
}

.m3-drawer {
  width: var(--md-drawer-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: var(--md-sp-3);
  background: var(--md-surface-container-low);
  overflow-y: auto;
}

.m3-content {
  flex: 1;
  min-width: 0;
  padding: var(--md-sp-5) var(--md-sp-6) 96px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--md-sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--md-sp-5);
}
.page-header h2 { color: var(--md-on-surface); }
.page-header .sub {
  color: var(--md-on-surface-variant);
  margin-top: 2px;
}
.refresh-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--md-on-surface-variant);
  padding-bottom: 6px;
}
.refresh-hint .msyr { font-size: 16px; }

/* Nav destinations */
.m3-nav { display: flex; flex-direction: column; gap: 2px; }
.m3-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  border: none;
  border-radius: var(--md-shape-full);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.m3-nav-item .msyr { font-size: 24px; }
.m3-nav-item.active {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-weight: 500;
}
.m3-nav-item.active .m3-badge {
  background: var(--md-primary);
  color: var(--md-on-primary);
}
.m3-nav-item .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Drawer footer */
.drawer-footer {
  margin-top: auto;
  padding: var(--md-sp-4) 16px var(--md-sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--md-sp-3);
}
.drawer-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--md-shape-md);
  background: var(--md-surface-container);
  color: var(--md-on-surface-variant);
}
.drawer-status .msyr { font-size: 18px; color: var(--md-primary); }
.drawer-status.offline .msyr { color: var(--md-error); }
.drawer-credit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--md-shape-sm);
  color: var(--md-outline);
}
.drawer-credit:hover { color: var(--md-on-surface-variant); }
.drawer-credit .msyr { font-size: 14px; }

/* Scrim for modal drawer */
.m3-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--md-scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-dur-medium) var(--md-ease-standard);
}
.m3-scrim.open { opacity: 0.4; pointer-events: auto; }

/* ─── 10. Filled card (M3) ────────────────────────────────────────────── */
.inbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--md-sp-4);
}

.inbox-card {
  background: var(--md-surface-container-highest);
  border-radius: var(--md-shape-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 380px;
  max-height: 580px;
  animation: card-in var(--md-dur-long) var(--md-ease-emphasized-decel) both;
}
.inbox-card.removing {
  animation: card-out var(--md-dur-medium) var(--md-ease-emphasized-accel) forwards;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes card-out {
  to { opacity: 0; transform: scale(0.96) translateY(-8px); }
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--md-sp-3) var(--md-sp-2) var(--md-sp-3) var(--md-sp-4);
  flex-shrink: 0;
}
.card-head .mail-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-head .who { min-width: 0; flex: 1; }
.card-head .email-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.card-head .email {
  color: var(--md-on-surface);
  font-family: "Roboto Mono", monospace;
  font-size: 13px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-head .domain {
  color: var(--md-on-surface-variant);
  font-size: 12px;
  line-height: 16px;
  margin-top: 1px;
}
.card-head .tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.card-head .tools .m3-icon-btn { width: 36px; height: 36px; }
.card-head .tools .m3-icon-btn .msyr { font-size: 20px; }
.card-head .tools .m3-icon-btn.delete { color: var(--md-error); }
.card-head .sync-slot { width: 24px; display: flex; justify-content: center; }

.card-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-sp-2);
  padding: var(--md-sp-2) var(--md-sp-4);
  border-top: 1px solid var(--md-outline-variant);
  color: var(--md-on-surface-variant);
  flex-shrink: 0;
}
.card-subhead .left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.card-subhead .msyr { font-size: 16px; }
.card-subhead button.m3-btn { height: 32px; padding: 0 12px; font-size: 12px; }
.card-subhead .subhead-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.card-subhead .state-line { transition: color var(--md-dur-short) var(--md-ease-standard); }
.card-subhead .state-line.warn { color: var(--md-tertiary); }
.card-subhead .state-line.down { color: var(--md-error); }
.card-subhead .state-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-subhead .move-btn { color: var(--md-primary); }

/* Baris status antrean di header halaman */
.queue-status {
  color: var(--md-outline);
  margin-top: 6px;
  min-height: 16px;
}
.drawer-status.degraded .msyr { color: var(--md-tertiary); }

/* Card content area */
.card-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--md-outline-variant);
}
.message-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  list-style: none;
}
.message-list.with-preview { flex: 0 0 auto; max-height: 55%; }

/* ─── 11. List items (M3 list, two-line) ──────────────────────────────── */
.msg-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px var(--md-sp-4);
  cursor: pointer;
  border-radius: var(--md-shape-full);
  margin: 2px var(--md-sp-2);
}
.msg-item + .msg-item .msg-body { border-top: 1px solid transparent; }
.msg-item .avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 16px;
  flex-shrink: 0;
}
.msg-item .msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
}
.msg-item .line1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.msg-item .sender {
  font-size: 14px;
  line-height: 20px;
  color: var(--md-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}
.msg-item .subject {
  flex: 1;
  font-size: 14px;
  line-height: 20px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-item .intro {
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-item .time {
  font-size: 12px;
  line-height: 16px;
  color: var(--md-on-surface-variant);
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}
.msg-item.unread .sender,
.msg-item.unread .subject { color: var(--md-on-surface); font-weight: 500; }
.msg-item.unread .time { color: var(--md-primary); font-weight: 500; }
.msg-item.selected { background: var(--md-secondary-container); }
.msg-item.selected .sender,
.msg-item.selected .subject,
.msg-item.selected .intro,
.msg-item.selected .time { color: var(--md-on-secondary-container); }
.msg-item.selected .time { font-weight: 500; }
.msg-item.arriving {
  animation: msg-in 400ms var(--md-ease-emphasized-decel) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}

/* Avatar tonal cycle (seed-derived, stays in the tonal system) */
.av-0 { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.av-1 { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.av-2 { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }

/* Empty list state inside a card */
.list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  height: 100%;
  min-height: 200px;
  padding: var(--md-sp-5);
}
.list-empty .glyph {
  width: 56px;
  height: 56px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container);
  color: var(--md-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--md-sp-3);
}
.list-empty .glyph .msyr { font-size: 28px; }

/* ─── 12. Preview panel ───────────────────────────────────────────────── */
.preview-panel {
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  flex: 1;
  border-top: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-low);
}
.preview-panel.active {
  display: flex;
  animation: preview-in var(--md-dur-medium) var(--md-ease-emphasized-decel);
}
@keyframes preview-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.preview-head {
  display: flex;
  align-items: center;
  gap: var(--md-sp-2);
  padding: var(--md-sp-1) var(--md-sp-2) var(--md-sp-1) var(--md-sp-3);
  flex-shrink: 0;
}
.preview-head .title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--md-on-surface-variant);
}
.preview-head .m3-icon-btn { width: 36px; height: 36px; }
.preview-head .m3-icon-btn .msyr { font-size: 20px; }
.preview-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: var(--md-sp-3) var(--md-sp-4) var(--md-sp-4);
}
.preview-meta { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.preview-meta .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--md-sp-2);
}
.preview-subject {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--md-on-surface);
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--md-outline-variant);
}
.preview-text {
  font-size: 14px;
  line-height: 20px;
  color: var(--md-on-surface-variant);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 14;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── 13. Dialog (M3) ─────────────────────────────────────────────────── */
.m3-dialog-surface {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--md-sp-4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--md-dur-short) var(--md-ease-standard),
    visibility 0s linear var(--md-dur-short);
}
.m3-dialog-surface.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity var(--md-dur-short) var(--md-ease-standard),
    visibility 0s;
}
.m3-dialog-surface > .scrim {
  position: absolute;
  inset: 0;
  background: var(--md-scrim);
  opacity: 0;
  transition: opacity var(--md-dur-medium) var(--md-ease-standard);
}
.m3-dialog-surface.open > .scrim { opacity: 0.4; }

.m3-dialog {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  border-radius: var(--md-shape-xl);
  box-shadow: var(--md-e3);
  transform: scale(0.92);
  transition: transform var(--md-dur-medium) var(--md-ease-emphasized-decel);
  overflow: hidden;
}
.m3-dialog-surface.open .m3-dialog { transform: scale(1); }

.m3-dialog.compact { max-width: 400px; text-align: center; }
.m3-dialog .icon {
  margin: 24px auto 0;
  width: 24px;
  height: 24px;
  color: var(--md-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
}
.m3-dialog .icon .msyr { font-size: 24px; }
.m3-dialog .headline {
  font-size: 24px;
  line-height: 32px;
  font-weight: 400;
  padding: 16px 24px 0;
}
.m3-dialog.compact .headline { padding: 16px 24px 0; }
.m3-dialog .body {
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--md-on-surface-variant);
  padding: 16px 24px 0;
  overflow-y: auto;
}
.m3-dialog.compact .body { padding: 16px 24px 24px; }
.m3-dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 24px;
  flex-shrink: 0;
}
.m3-dialog.compact .actions { padding: 0 24px 24px; justify-content: center; }
.m3-dialog .actions .m3-btn + .m3-btn { margin-left: 0; }

/* Message viewer dialog */
.msg-dialog { max-width: 720px; }
.msg-dialog .m3-dialog { max-width: 720px; }
.msg-viewer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 88vh;
  min-height: 0;
}
.msg-viewer .viewer-bar {
  display: flex;
  align-items: center;
  gap: var(--md-sp-2);
  padding: var(--md-sp-2) var(--md-sp-2) var(--md-sp-2) var(--md-sp-3);
  flex-shrink: 0;
}
.msg-viewer .viewer-bar .title {
  flex: 1;
  font-size: 22px;
  line-height: 28px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-viewer .viewer-scroll { overflow-y: auto; padding: 0 24px 24px; }
.msg-viewer .subject {
  font-size: 28px;
  line-height: 36px;
  padding: var(--md-sp-2) 0 var(--md-sp-4);
  overflow-wrap: anywhere;
}
.msg-viewer .sender-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--md-outline-variant);
}
.msg-viewer .sender-row .avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 16px;
  flex-shrink: 0;
}
.msg-viewer .sender-row .info { min-width: 0; flex: 1; }
.msg-viewer .sender-row .info .name {
  font-weight: 500;
  color: var(--md-on-surface);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-viewer .sender-row .info .addr {
  font-size: 12px;
  line-height: 16px;
  color: var(--md-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-viewer .sender-row .date {
  font-size: 12px;
  line-height: 16px;
  color: var(--md-on-surface-variant);
  flex-shrink: 0;
  text-align: right;
}
.msg-viewer .frame-wrap {
  background: var(--md-surface-container-lowest);
  border-radius: var(--md-shape-md);
  overflow: hidden;
  min-height: 320px;
}
.msg-viewer iframe {
  display: block;
  width: 100%;
  min-height: 420px;
  max-height: 52vh;
  border: none;
  background: #fff;
}
.msg-viewer .text-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--md-on-surface);
}
.viewer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-sp-3);
  padding: 64px 0;
  color: var(--md-on-surface-variant);
}
.viewer-loading .m3-progress-circular { width: 32px; height: 32px; }

/* ─── 14. Snackbar (M3) ───────────────────────────────────────────────── */
.m3-snackbar-host {
  position: fixed;
  left: calc(var(--md-drawer-w) + 16px);
  bottom: 16px;
  z-index: 35; /* M3 layering: above content, below modal drawer + scrim */
  display: flex;
  flex-direction: column-reverse;
  gap: var(--md-sp-2);
  pointer-events: none;
}
.m3-snackbar {
  display: flex;
  align-items: center;
  gap: var(--md-sp-4);
  min-height: 48px;
  padding: 8px 4px 8px 16px;
  border-radius: var(--md-shape-xs);
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  box-shadow: var(--md-e3);
  max-width: min(640px, calc(100vw - 32px));
  pointer-events: auto;
  transform: translateY(16px);
  opacity: 0;
  animation: sb-in 250ms var(--md-ease-emphasized-decel) forwards;
}
.m3-snackbar.out { animation: sb-out 150ms var(--md-ease-emphasized-accel) forwards; }
@keyframes sb-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes sb-out {
  from { transform: none; opacity: 1; }
  to { transform: translateY(8px); opacity: 0; }
}
.m3-snackbar .text {
  flex: 1;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
}
.m3-snackbar .m3-btn.text {
  color: var(--md-inverse-primary);
  flex-shrink: 0;
}

/* ─── 15. Radio & single-select list (settings) ───────────────────────── */
.opt-list { display: flex; flex-direction: column; }
.opt-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  cursor: pointer;
  text-align: left;
  border: none;
  background: transparent;
  font-family: inherit;
  color: var(--md-on-surface);
  width: 100%;
}
.opt-item .radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--md-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--md-dur-short) var(--md-ease-standard);
}
.opt-item .radio::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--md-primary);
  transform: scale(0);
  transition: transform var(--md-dur-short) var(--md-ease-emphasized-decel);
}
.opt-item.selected .radio { border-color: var(--md-primary); }
.opt-item.selected .radio::after { transform: scale(1); }
.opt-item:disabled,
.opt-item.unavailable {
  cursor: not-allowed;
  color: var(--md-on-surface-variant);
}
.opt-item.unavailable .opt-main > .name { color: rgba(224, 227, 225, var(--md-state-disabled)); }
.opt-item .opt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.opt-item .opt-main .name { font-weight: 500; font-size: 16px; line-height: 24px; letter-spacing: 0.15px; }
.opt-item .opt-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── 16. Global empty state ──────────────────────────────────────────── */
.global-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 96px var(--md-sp-5) 48px;
  max-width: 480px;
  margin: 0 auto;
}
.global-empty .glyph {
  width: 96px;
  height: 96px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container);
  color: var(--md-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--md-sp-5);
}
.global-empty .glyph .msyr { font-size: 44px; }
.global-empty h3 { margin-bottom: var(--md-sp-2); }
.global-empty p {
  color: var(--md-on-surface-variant);
  margin-bottom: var(--md-sp-5);
  max-width: 40ch;
}
.global-empty .m3-btn { align-self: center; }

/* ─── 17. Responsive ─────────────────────────────────────────────────── */
@media (min-width: 1100px) {
  .inbox-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1500px) {
  .inbox-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 999px) {
  .m3-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform var(--md-dur-medium) var(--md-ease-emphasized-accel),
      visibility 0s linear var(--md-dur-medium);
    box-shadow: var(--md-e4);
    background: var(--md-surface-container-low);
  }
  .m3-drawer.open {
    transform: translateX(0);
    visibility: visible;
    transition:
      transform var(--md-dur-medium) var(--md-ease-emphasized-decel),
      visibility 0s;
  }
  .m3-content { padding: var(--md-sp-4) var(--md-sp-4) 88px; }
  .m3-appbar .brand-title { font-size: 18px; }
  .msg-dialog { padding: 0; }
  .msg-dialog .m3-dialog {
    max-width: none;
    max-height: none;
    height: 100%;
    width: 100%;
    border-radius: 0;
  }
  .msg-viewer { height: 100%; }
  .msg-viewer .viewer-scroll { flex: 1; min-height: 0; }
  .msg-viewer iframe { min-height: 60vh; max-height: none; }
}
@media (min-width: 1000px) {
  #drawer-close, #menu-toggle { display: none; }
  .m3-appbar { padding-left: var(--md-sp-4); }
}

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

/* ══════════════════════════════════════════════════════════════════════
   18. Touch & mobile-first
   Input dideteksi lewat pointer/hover, bukan lewat ukuran layar: ponsel
   besar bisa memakai mouse (tetap dapat hover), tablet bisa memakai stylus
   (tetap dapat hover). Yang penting: tidak ada fungsi yang hanya hidup di
   hover, dan setiap target sentuh minimal 48dp saat pointer kasar.
   ══════════════════════════════════════════════════════════════════════ */

/* Hover bukan input yang bisa diandalkan di layar sentuh */
@media (hover: none) {
  .m3-interactive:hover::before { opacity: 0; }
  .m3-interactive:focus-visible:hover::before { opacity: var(--md-state-focus); }
  .m3-interactive:active::before { opacity: var(--md-state-pressed); }
}

@media (pointer: coarse) {
  /* M3: touch target minimum 48dp walau container visualnya 40dp */
  .m3-icon-btn { width: 48px; height: 48px; }
  .m3-icon-btn .msyr { font-size: 24px; }
  .m3-btn { min-height: 48px; }
  .card-head .tools .m3-icon-btn { width: 46px; height: 46px; }
  .card-head .tools .m3-icon-btn .msyr { font-size: 22px; }
  .preview-head .m3-icon-btn { width: 46px; height: 46px; }
  .card-subhead button.m3-btn { min-height: 46px; padding: 0 16px; }
  .card-subhead .state-text { white-space: normal; }
  .card-subhead { flex-wrap: wrap; }
  .drawer-credit { min-height: 44px; padding: 0 8px; }
  .m3-snackbar .m3-btn { min-height: 44px; padding: 0 16px; }
  .opt-item { min-height: 56px; }
  .drawer-status { min-height: 48px; }
  /* halaman aplikasi: tanpadelay tap ganda, tanpa seleksi teks tak sengaja */
  .m3-interactive,
  .m3-btn,
  .m3-icon-btn,
  .m3-fab-extended,
  .m3-nav-item,
  .opt-item {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }
  /* daftar pesan hanya boleh digulir vertikal, ripple tidak boleh memicu scroll */
  .msg-item { touch-action: pan-y; }
}

/* Notch, rounded corner, dan home indicator.
   Padding body berlaku untuk elemen in-flow; overlay fixed butuh inset sendiri. */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.m3-appbar {
  height: calc(var(--md-appbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}
.m3-shell { min-height: calc(100vh - var(--md-appbar-h)); }
@supports (height: 100dvh) {
  .m3-shell { min-height: calc(100dvh - var(--md-appbar-h)); }
}
.m3-drawer {
  padding-bottom: calc(var(--md-sp-3) + env(safe-area-inset-bottom));
  padding-left: calc(var(--md-sp-3) + env(safe-area-inset-left));
}
.m3-content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.m3-snackbar-host {
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: calc(var(--md-drawer-w) + 16px + env(safe-area-inset-left));
}
@media (max-width: 999px) {
  .m3-snackbar-host { left: calc(16px + env(safe-area-inset-left)); }
}
@media (max-width: 599px) {
  .m3-snackbar-host {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
  }
}
.m3-dialog-surface {
  padding-left: calc(var(--md-sp-4) + env(safe-area-inset-left));
  padding-right: calc(var(--md-sp-4) + env(safe-area-inset-right));
}
.msg-viewer .viewer-bar { padding-top: calc(var(--md-sp-2) + env(safe-area-inset-top)); }
.msg-viewer .viewer-scroll {
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
}

/* Browser chrome tidak boleh mengambil alih scroll area aplikasi */
html,
body { overscroll-behavior-y: none; }
.m3-content,
.m3-drawer,
.message-list,
.preview-body,
.m3-dialog .body,
.msg-viewer .viewer-scroll {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* FAB utama tampil di layar (jangkauan ibu jari) saat drawer jadi modal */
.m-mobile-fab { display: none; }
@media (max-width: 999px) {
  .m-mobile-fab {
    display: inline-flex;
    position: fixed;
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 28;
    width: auto;
    justify-content: center;
  }
}

/* Layar sempit: alamat email membungkus penuh, domain yang berduplikat disembunyikan,
   slot spinner di header dihapus (sudah ada tombol Refresh di subhead) */
@media (max-width: 480px) {
  .m3-drawer { width: min(var(--md-drawer-w), 84vw); }
  .card-head { flex-wrap: wrap; }
  .card-head .sync-slot { display: none; }
  .card-head .domain { display: none; }
  .card-head .email-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .card-head .email {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    line-height: 18px;
  }
  .inbox-card { min-height: 340px; max-height: min(580px, 76dvh); }
}
@supports not (height: 76dvh) {
  @media (max-width: 480px) {
    .inbox-card { max-height: 76vh; }
  }
}
