:root {
  --card: rgba(255,255,255,.92);
  --panel: #ffffff;
  --soft-panel: rgba(248,250,252,.92);
  --text: #111827;
  --muted: #64748b;
  --line: #dbe3ef;
  --purple: #7c3aed;
  --pink: #ec4899;
  --danger: #fb7185;
  --shadow: 0 24px 70px rgba(49,46,129,.20);
}

html.dark {
  --card: rgba(15,23,42,.82);
  --panel: rgba(15,23,42,.78);
  --soft-panel: rgba(2,6,23,.32);
  --text: #f8fafc;
  --muted: #9fb0d1;
  --line: rgba(148,163,184,.24);
  --shadow: 0 28px 80px rgba(0,0,0,.46);
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(88,28,135,.18), transparent 34%),
    radial-gradient(circle at 100% 100%, rgba(249,115,22,.13), transparent 34%),
    linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
html.dark body {
  background:
    radial-gradient(circle at 10% 0%, rgba(88,28,135,.42), transparent 33%),
    radial-gradient(circle at 100% 100%, rgba(127,29,29,.28), transparent 34%),
    linear-gradient(145deg, #030712 0%, #020617 55%, #120b18 100%);
}

button, input { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.hidden { display: none !important; }

.page-glow { position: fixed; width: 420px; height: 420px; border-radius: 50%; filter: blur(70px); opacity: .22; pointer-events: none; }
.page-glow-one { top: -170px; left: -120px; background: #7c3aed; }
.page-glow-two { right: -130px; bottom: -160px; background: #f97316; }

.top-actions { position: fixed; top: 16px; right: 16px; z-index: 50; }
.theme-toggle {
  width: 48px; height: 48px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(30,41,59,.78); color: white; font-size: 20px; cursor: pointer;
  box-shadow: 0 14px 35px rgba(0,0,0,.28); backdrop-filter: blur(14px);
}

.buyer-shell { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.buyer-card {
  width: 520px; max-width: 100%; padding: 48px 40px; border-radius: 24px; background: var(--card);
  box-shadow: var(--shadow); text-align: center; border: 1px solid var(--line); backdrop-filter: blur(18px);
}
.brand-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.brand-mark { width: 34px; height: 24px; border-radius: 3px; background: var(--purple); display: inline-block; }
h1 { margin: 0; font-size: clamp(32px, 7vw, 38px); color: var(--purple); line-height: 1.05; }
.subtitle { margin: 14px 0 28px; color: var(--muted); font-size: 16px; }
.service-box { margin: 0 auto 30px; max-width: 440px; padding: 22px; border-radius: 16px; background: rgba(34,197,94,.14); color: #86efac; display: grid; gap: 4px; }
html:not(.dark) .service-box { background: #dcfce7; color: #166534; }
.service-box strong { font-weight: 800; }
label { display: block; margin: 0 0 12px; font-weight: 700; color: var(--text); }
#emailInput {
  width: 100%; height: 52px; border: 2px solid var(--line); border-radius: 12px; padding: 0 18px;
  background: var(--panel); color: var(--text); font-size: 16px; outline: none;
}
#emailInput:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(124,58,237,.12); }
.primary-btn, .back-btn { display: block; margin: 16px auto 0; border: 0; border-radius: 12px; cursor: pointer; font-weight: 800; }
.primary-btn { padding: 14px 34px; color: white; background: linear-gradient(135deg, #667eea, #764ba2); }
.back-btn { padding: 14px 32px; color: white; background: #4b5563; }

.gmail-page { width: min(1180px, 100%); min-height: calc(100vh - 64px); padding-bottom: 0; }
.gmail-topbar {
  height: 72px; display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.icon-btn { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 20px; cursor: pointer; display: grid; place-items: center; }
.mail-title { flex: 1; display: grid; gap: 2px; min-width: 0; }
.mail-title span { color: var(--muted); font-size: 13px; font-weight: 800; }
.mail-title strong { overflow-wrap: anywhere; font-size: 18px; }

.gmail-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; }
.gmail-sidebar, .mail-panel { background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.gmail-sidebar { padding: 22px; min-height: 430px; }
.sidebar-logo { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(135deg, var(--purple), var(--pink)); font-size: 30px; margin-bottom: 24px; }
.gmail-sidebar nav { display: grid; gap: 10px; }
.nav-link {
  width: 100%; min-height: 48px; border: 0; border-radius: 14px; background: transparent; color: var(--muted);
  display: flex; align-items: center; gap: 12px; padding: 0 16px; cursor: pointer; font-weight: 800; font-size: 15px; text-align: left; position: relative;
}
.nav-link:hover { background: rgba(124,58,237,.08); color: var(--text); }
.nav-link.active { background: linear-gradient(135deg, var(--purple), var(--pink)); color: white; }
.nav-icon { width: 24px; min-width: 24px; display: inline-grid; place-items: center; }
.nav-badge, .mobile-badge {
  min-width: 24px; height: 24px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: linear-gradient(135deg, #f43f5e, #ec4899); color: #fff; font-size: 11px; font-weight: 900;
}
.nav-badge { margin-left: auto; }

.mail-panel { overflow: hidden; min-height: 500px; }
.mail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 24px; border-bottom: 1px solid var(--line); }
.mail-toolbar h2 { margin: 0; font-size: 26px; line-height: 1.1; }
.mail-toolbar p { margin: 7px 0 0; color: var(--muted); }
.mail-toolbar button { border: 1px solid rgba(251,113,133,.65); color: var(--danger); background: rgba(251,113,133,.08); border-radius: 12px; padding: 10px 18px; font-weight: 800; cursor: pointer; }
.inbox-list { display: grid; gap: 12px; padding: 16px; }
.empty-state { min-height: 330px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 22px; background: rgba(2,6,23,.12); }
.empty-state div { font-size: 56px; }
.empty-state strong { color: var(--text); font-size: 20px; }

.mail-item {
  display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 14px; padding: 16px; border: 1px solid var(--line);
  border-radius: 18px; background: var(--soft-panel); box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.avatar { 
  width: 48px; 
  height: 48px; 
  border-radius: 50%; 
  display: grid; 
  place-items: center; 
  background: linear-gradient(135deg, var(--purple), var(--pink)); 
  color: #fff; 
  font-weight: 900; 
  font-size: 20px; 
}

.mail-content { min-width: 0; }

.mail-row { 
  display: flex; 
  justify-content: space-between; 
  gap: 12px; 
  align-items: flex-start; 
}

.mail-row > div:first-child {
  min-width: 0;
  flex: 1;
}

.mail-subject { 
  font-weight: 900; 
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-from {
  color: var(--muted); 
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-time {
  color: var(--muted); 
  font-size: 13px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.mail-preview { 
  color: var(--muted); 
  font-size: 13px;
  margin-top: 6px; 
  line-height: 1.45; 
  max-height: 40px; 
  overflow: hidden; 
}

/* === OTP COMPACT === */
.otp-box { 
  margin-top: 10px; 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  flex-wrap: wrap; 
}

.otp-box span { 
  color: var(--muted); 
  font-weight: 600; 
  font-size: 14px; 
}

/* kotak OTP */
.otp-box b { 
  background: linear-gradient(135deg, #7c3aed, #6d28d9); 
  color: #fff; 
  padding: 6px 12px; 
  border-radius: 10px; 
  font-size: 16px; 
  font-weight: 700; 
  letter-spacing: 1px; 
}

/* tombol copy kecil */
.copy-otp { 
  border: 0; 
  background: #16a34a; 
  color: #fff; 
  border-radius: 10px; 
  width: 34px; 
  height: 34px; 
  font-size: 16px; 
  cursor: pointer; 
  display: grid; 
  place-items: center; 
}

/* efek klik */
.copy-otp:active {
  transform: scale(0.92);
}

.mail-detail {
  margin-top: 16px;
}

.mail-detail summary {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
}

.mail-body { 
  margin-top: 10px; 
  background: #fff; 
  color: #111827; 
  border: 1px solid #e5e7eb; 
  border-radius: 14px; 
  padding: 14px; 
  overflow-x: auto; 
}

.mail-body img, 
.mail-body table { max-width: 100%; }

.toast { 
  position: fixed; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%) scale(.9); 
  z-index: 9999; 
  padding: 15px 20px; 
  border-radius: 16px; 
  background: rgba(15,23,42,.95); 
  color: white; 
  box-shadow: 0 20px 60px rgba(0,0,0,.5); 
  font-weight: 800; 
  opacity: 0; 
  pointer-events: none; 
  transition: .25s ease; 
}

.toast.show { 
  opacity: 1; 
  transform: translate(-50%, -50%) scale(1); 
}

.mobile-bottom-nav { display: none; }

@media (max-width: 820px) {
  .top-actions {
    top: 20px;
    right: 18px;
  }

  .buyer-shell {
    padding: 84px 14px 112px;
    align-items: start;
    display: block;
  }

  .buyer-card {
    margin: 0 auto;
    padding: 36px 24px;
  }

  .gmail-page {
    min-height: auto;
    padding-bottom: 104px;
  }

  .gmail-layout {
    grid-template-columns: 1fr;
  }

  .gmail-sidebar {
    display: none;
  }

  .gmail-topbar {
    height: auto;
    min-height: 76px;
    border-radius: 20px;
    margin-bottom: 16px;
  }

  .mail-panel {
    border-radius: 22px;
    min-height: 520px;
  }

  .mail-toolbar {
    padding: 24px 20px;
  }

  .inbox-list {
    padding: 14px;
  }

  .empty-state {
    min-height: 420px;
    padding: 28px;
  }

  .mail-item {
    grid-template-columns: 48px minmax(0, 1fr);
    padding: 14px;
  }

  .mail-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
  }

  .mail-row > div:first-child {
    min-width: 0;
    flex: 1;
  }

  .mail-time {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .mail-clock {
  display: inline-block;
  transform: translateY(3px);
}

  .mail-subject,
  .mail-from {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 18px;
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    border-radius: 24px;
    background: rgba(15, 23, 42, .86);
    border: 1px solid rgba(148, 163, 184, .24);
    box-shadow: 0 18px 45px rgba(0, 0, 0, .4);
    backdrop-filter: blur(18px);
  }

  html:not(.dark) .mobile-bottom-nav {
    background: rgba(255, 255, 255, .92);
  }

  .bottom-link {
    position: relative;
    min-height: 64px;
    border: 0;
    border-radius: 18px;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    cursor: pointer;
  }

  .bottom-link.active {
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: #fff;
  }

  .bottom-icon {
    font-size: 22px;
  }

  .mobile-badge {
    position: absolute;
    top: 6px;
    right: 22px;
  }
}

@media (max-width: 420px) {
  .buyer-shell { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 32px; }
  .mail-toolbar h2 { font-size: 24px; }
  .mail-title strong { font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; }
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.toolbar-actions button {
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

/* tombol tandai */
.toolbar-actions button:first-child {
  background: rgba(34,197,94,0.15);
  color: #4ade80;
  border: 1px solid rgba(34,197,94,0.4);
}

/* tombol clear */
.toolbar-actions button:last-child {
  background: rgba(251,113,133,0.1);
  color: #fb7185;
  border: 1px solid rgba(251,113,133,0.4);
}
/* === MOBILE ONLY: FIX TOOLBAR BUTTON ALIGN === */
@media (max-width: 520px) {
  .mail-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
  }

  .mail-toolbar > div:first-child {
    max-width: 48%;
    min-width: 0;
  }

  .mail-toolbar h2 {
    font-size: 30px;
    line-height: 1.1;
  }

  .mail-toolbar p {
    font-size: 15px;
    line-height: 1.35;
  }

  .toolbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
  }

  .toolbar-actions button {
    width: 92px;
    min-height: 72px;
    padding: 8px;
    font-size: 13px;
    line-height: 1.25;
    text-align: center;
  }
}

/* FIX: samakan font email dengan UI */
.mail-body,
.mail-body * {
  font-family: 'Poppins', sans-serif !important;
}

.mail-body {
  line-height: 1.6;
  font-size: 14px;
}
/* === FIX FONT BIAR KONSISTEN === */
html,
body,
button,
input,
textarea,
select,
.mail-panel,
.mail-panel * {
  font-family: 'Poppins', Arial, sans-serif !important;
}

/* samakan tampilan empty vs isi */
.empty-state strong {
  font-weight: 800;
}

.mail-subject {
  font-weight: 800;
}

.mail-from {
  font-weight: 400;
}
/* === FIX HEADER (EMAIL TITLE) === */
.mail-title span {
  font-family: 'Poppins', sans-serif !important;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.mail-title strong {
  font-family: 'Poppins', sans-serif !important;
  font-weight: 700; /* sebelumnya terlalu tipis / beda */
  font-size: 18px;
  line-height: 1.2;
}
/* === FIX PANAH + POSISI ATAS === */

/* besarin tombol panah */
.icon-btn {
  width: 54px !important;
  height: 54px !important;
  font-size: 30px !important;
  border-radius: 16px;
}

/* naikin posisi layout biar ga turun */
@media (max-width: 820px) {
  .buyer-shell {
    padding: 60px 14px 112px !important;
  }
}

/* mobile kecil juga tetap besar */
@media (max-width: 420px) {
  .icon-btn {
    width: 54px !important;
    height: 54px !important;
    font-size: 24px !important;
  }
}

/* optional: naikin topbar dikit biar lebih rapih */
.gmail-topbar {
  margin-top: 25px;
}
/* === FORCE FIX OTP CARD COMPACT === */
.mail-item .otp-box {
  margin-top: 8px !important;
  gap: 7px !important;
  align-items: center !important;
}

.mail-item .otp-box span {
  font-size: 13px !important;
  font-weight: 600 !important;
}

.mail-item .otp-box b {
  padding: 5px 10px !important;
  border-radius: 3px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1.1 !important;
  letter-spacing: .8px !important;
}

.mail-item .copy-otp {
  width: 25px !important;
  height: 25px !important;
  border-radius: 3px !important;
  font-size: 13px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
}
.mail-detail {
  margin-top: 12px !important;
  margin-left: 0;
  grid-column: 2;
}

.mail-detail summary {
  display: inline-flex !important;
  align-items: center;
  margin-top: 4px;
}

.otp-box {
  margin-bottom: 10px !important;
}

.mail-detail {
  margin-top: 6px !important;
}

.delete-mail-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 2px 11px;
  border-radius: 999px; /* pill */
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
  transition: 0.2s;
}

.delete-mail-btn:hover {
  background: #dc2626;
  transform: scale(1.05);
}