:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e3e5ea;
  --accent: #e5484d;
  --accent-text: #ffffff;
  --accent-soft: #fde8e9;
  --row-hover: #f7f8fa;
  --row-active: #fff1f1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --text: #e8eaee;
    --muted: #8b93a1;
    --border: #262a33;
    --accent: #f2555a;
    --accent-soft: #3a1d20;
    --row-hover: #1c2028;
    --row-active: #2a1a1d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); font-size: 16px;
}

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
  cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--row-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--row-hover); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--accent); }

/* Header */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar form { margin: 0; }

.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }

/* Kartu umum */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}

.input {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  padding: 9px 12px; outline: 0; min-width: 0;
}
.input:focus { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }

/* Generator */
.generator { padding: 16px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.generator p { grid-column: 1 / -1; margin: 0; }
.gen-block { margin: 0; min-width: 0; }
.gen-block label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.gen-row { display: flex; gap: 8px; }
.gen-row .input { flex: 1; }
.gen-row .count-input { flex: 0 0 84px; text-align: center; }
.address-field {
  flex: 1; display: flex; align-items: center; min-width: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); padding: 0 12px;
}
.address-field:focus-within { border-color: var(--accent); }
.address-field input {
  flex: 1; min-width: 40px; border: 0; outline: 0; background: transparent;
  padding: 9px 0; font-weight: 600; text-align: right;
}
.domain { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Daftar alamat */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 22px 0 10px; }
.list-head h2 { margin: 0; font-size: 17px; }
.list-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.addr-list { overflow: hidden; }
.addr-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.addr-row:last-child { border-bottom: 0; }
.addr-row:hover, .addr-row:focus-visible { background: var(--row-hover); outline: 0; }
.addr-main { display: flex; align-items: center; min-width: 0; font-size: 15px; }
.addr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-domain { color: var(--muted); white-space: nowrap; }
.new-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; }
.addr-info { display: flex; align-items: center; gap: 10px; }
.addr-info .otp-badge { margin-left: 0; cursor: copy; }
.count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.count.has { color: var(--text); font-weight: 600; }
.addr-info .time { min-width: 90px; text-align: right; }
.addr-actions { display: flex; gap: 4px; }

/* Header inbox */
a.brand { color: inherit; text-decoration: none; }
.inbox-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.inbox-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.inbox-title b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #30a46c; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Layout list + detail */
.layout { display: grid; grid-template-columns: 380px 1fr; gap: 14px; align-items: start; }
.list, .detail {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.list { max-height: calc(100vh - 260px); min-height: 200px; overflow-y: auto; }
.detail { min-height: 400px; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.row {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  border-bottom: 1px solid var(--border); padding: 12px 16px; cursor: pointer;
}
.row:hover { background: var(--row-hover); }
.row.active { background: var(--row-active); box-shadow: inset 3px 0 0 var(--accent); }
.row-top { display: flex; justify-content: space-between; gap: 8px; }
.from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.subject { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-bottom { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.row-bottom:empty { display: none; }
.to { font-size: 12px; color: var(--muted); }
.otp-badge {
  margin-left: auto; font: 600 13px/1 ui-monospace, Consolas, monospace; letter-spacing: 1px;
  background: var(--accent-soft); color: var(--accent); padding: 4px 8px; border-radius: 6px;
}

/* Detail */
.detail-actions { display: flex; justify-content: space-between; padding: 10px 12px 0; }
.detail-actions .back { visibility: hidden; }
.detail-head { padding: 4px 20px 14px; border-bottom: 1px solid var(--border); }
.detail-head h2 { margin: 0 0 6px; font-size: 20px; line-height: 1.3; }
.meta { display: flex; flex-direction: column; color: var(--muted); font-size: 13px; word-break: break-all; }

.otp-box {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 16px 20px; padding: 14px 18px; border-radius: 12px;
  background: var(--accent-soft);
}
.otp-box > div:first-child { margin-right: auto; }
.otp-code {
  font: 700 34px/1.1 ui-monospace, Consolas, monospace; letter-spacing: 6px;
  color: var(--accent); cursor: pointer;
}

.mail-frame { display: block; width: 100%; height: 70vh; border: 0; background: #fff; }
.mail-text { margin: 0; padding: 20px; white-space: pre-wrap; word-break: break-word; font: 14px/1.6 ui-monospace, Consolas, monospace; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px);
}

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.login-card p { margin: 0; }
.login-card input {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); outline: 0;
}
.login-card input:focus { border-color: var(--accent); }
.login-card form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.notice { background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.back-link { color: var(--muted); text-align: center; text-decoration: none; }
.back-link:hover { color: var(--text); }
.error { color: var(--accent); font-size: 14px; }

/* HP */
@media (max-width: 800px) {
  .generator { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .list { max-height: none; }
  body.reading .list, body.reading .inbox-head { display: none; }
  body:not(.reading) .detail { display: none; }
  .detail-actions .back { visibility: visible; }
  .address-field input, .input { font-size: 16px; } /* cegah auto-zoom iOS */
  .otp-code { font-size: 28px; }
  .live { display: none; }

  .addr-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .addr-info { grid-column: 1; grid-row: 2; }
  .addr-info .time { min-width: 0; text-align: left; }
  .addr-actions { grid-column: 2; grid-row: 1 / 3; }
  .addr-domain { display: none; }
}
