/* ==========================================================================
   TeraMail — tema terang, satu kolom.
   Sengaja BUKAN tampilan emailqu (gelap, dua kolom, modal inbox): di sini
   alamat + OTP + kotak masuk tersusun vertikal, dan email dibaca lewat
   drawer yang meluncur dari kanan. Font memakai tumpukan sistem agar
   halaman tetap ringan tanpa dependensi CDN.
   ========================================================================== */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1b1a17;
  --ink-soft: #6b675f;
  --line: #e4e0d6;
  --brand: #1f6f4a;
  --brand-soft: #e6f2ea;
  --accent: #d97706;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 26, 23, 0.05), 0 8px 24px rgba(27, 26, 23, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  max-width: 880px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
}
.brand-name em { font-style: normal; font-weight: 400; color: var(--ink-soft); }

.topnav { display: flex; gap: 18px; }
.topnav a { color: var(--ink-soft); text-decoration: none; font-size: 14px; }
.topnav a:hover { color: var(--brand); }

/* ---------- Layout ---------- */
.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.spacer { flex: 1; }

.count {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip-lock { background: #fff4e5; color: var(--accent); }

.hint { margin: 6px 0 0; color: var(--ink-soft); font-size: 13px; }
.error { margin: 8px 0 0; min-height: 18px; color: var(--danger); font-size: 13px; }

/* ---------- Alamat ---------- */
.addr-row { display: flex; gap: 10px; }

.addr-value {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfaf7;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 600;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.btn {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #185a3c; border-color: #185a3c; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-danger { border-color: #f0c9c9; color: var(--danger); background: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.statusline { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--ink-soft); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 3px rgba(34, 160, 107, 0.15); }
.dot.paused { background: #b9b4a8; box-shadow: none; }

.toast {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

/* ---------- OTP ---------- */
.card-otp { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.otp-text .hint { margin-bottom: 0; }
.otp-row { display: flex; align-items: center; gap: 10px; }
.otp-value {
  padding: 8px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.otp-value.found { border-style: solid; border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- Daftar email ---------- */
.list { display: flex; flex-direction: column; }

.email-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 4px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.email-item:first-child { border-top: none; }
.email-item:hover { background: #fbfaf7; }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  text-transform: uppercase;
}

.email-main { flex: 1; min-width: 0; }
.email-sender { color: var(--ink-soft); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-preview { color: var(--ink-soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-time { flex: none; color: var(--ink-soft); font-size: 12px; padding-top: 2px; }

.otp-chip {
  margin-top: 8px;
  padding: 5px 10px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.empty { padding: 32px 8px; text-align: center; color: var(--ink-soft); }
.empty-art { font-size: 30px; opacity: 0.5; }
.empty p { margin: 8px 0 0; }

/* ---------- Drawer baca email ---------- */
.reader {
  position: fixed;
  top: 0; right: 0;
  width: min(560px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 40px rgba(27, 26, 23, 0.12);
  z-index: 40;
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.reader-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px; border-bottom: 1px solid var(--line); }
.reader-title { flex: 1; min-width: 0; }
.reader-title h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }

.otp-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 20px 0;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
}
.otp-banner-text b { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; }

.reader-body { flex: 1; overflow: auto; padding: 20px; overflow-wrap: anywhere; }
.reader-body img { max-width: 100%; height: auto; }
.reader-body a { color: var(--brand); }

.reader-foot { padding: 16px 20px; border-top: 1px solid var(--line); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(27, 26, 23, 0.45);
  z-index: 50;
}
.modal-card {
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }

.domains { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

.domain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.domain-item:hover { border-color: var(--brand); }
.domain-item.active { border-color: var(--brand); background: var(--brand-soft); }
.domain-name { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.domain-state { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.domain-state.ok { color: var(--brand); font-weight: 600; }
.domain-state.bad { color: var(--accent); }

/* ---------- Riwayat alamat ---------- */
.history-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; max-height: 50vh; overflow: auto; }
.history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.history-item:hover { border-color: var(--brand); }
.history-current { border-color: var(--brand); background: var(--brand-soft); }
.history-addr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; overflow-wrap: anywhere; }
.history-meta { font-size: 12px; color: var(--ink-soft); }

/* ---------- Modal nama sendiri ---------- */
.addr-form { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.addr-label { font-size: 13px; font-weight: 600; }
.addr-form input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfaf7;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
}
.addr-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.btn-block { width: 100%; margin-top: 6px; padding: 13px 14px; font-size: 15px; font-weight: 600; }

.domain-custom { display: flex; gap: 8px; margin-top: 14px; }
.domain-custom input,
.pin-input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf7;
  color: var(--ink);
  font: inherit;
}
.pin-input { width: 100%; margin-top: 14px; letter-spacing: 0.3em; text-align: center; font-size: 18px; }

/* ---------- Footer ---------- */
.foot {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 24px 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 12px;
}
.foot-links { display: flex; gap: 16px; }
.foot a { color: var(--ink-soft); }
.foot a:hover { color: var(--brand); }

/* ---------- Layar kecil ---------- */
@media (max-width: 620px) {
  .topbar { padding: 14px 16px; }
  .shell { padding: 0 16px 32px; }
  .card { padding: 16px; }
  .addr-row { flex-direction: column; }
  .addr-value { font-size: 14px; }
  .card-otp { align-items: stretch; }
  .email-time { display: none; }
  .foot { padding: 8px 16px 32px; }
}
