:root {
  --bg: #FAF7F2;
  --card: #FFFFFF;
  --ink: #1F2430;
  --muted: #7A736A;
  --line: #EDE4D3;
  --teal: #0E7C7B;
  --teal-dark: #0A5E5D;
  --teal-soft: #E6F4F3;
  --amber: #F59E0B;
  --amber-soft: #FEF3C7;
  --amber-ink: #92400E;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(31, 36, 48, 0.05), 0 10px 30px rgba(31, 36, 48, 0.05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--teal); color: #fff; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 247, 242, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.brand-tag { font-size: 12.5px; color: var(--muted); }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.icon-btn:hover { border-color: var(--teal); }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 8px;
}

.current-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.current-address {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(17px, 3.4vw, 24px);
  font-weight: 700;
  word-break: break-all;
}

.current-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-amber { background: var(--amber); color: #231a03; }
.btn-amber:hover { background: #D97706; color: #fff; }
.btn-soft { background: var(--teal-soft); color: var(--teal-dark); }
.btn-soft:hover { background: #D3ECEB; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: #FBDADA; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

.qr-panel {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border: 1px dashed var(--teal);
  border-radius: 14px;
  text-align: center;
}
.qr-box { display: inline-block; background: #fff; padding: 10px; border-radius: 10px; }
.qr-box svg { width: 180px; height: 180px; display: block; }
.qr-caption { margin-top: 8px; font-size: 13px; color: var(--muted); }

.tabs-row { margin-top: 18px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 8px 7px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.tab.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.tab .tab-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 0;
  background: rgba(31, 36, 48, 0.08);
  color: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.tab.active .tab-x { background: rgba(255, 255, 255, 0.25); }

.addr-form {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.input {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
#nameInput { flex: 1 1 180px; }
#domainSelect { flex: 0 1 210px; }

.hint { font-size: 13px; color: var(--muted); margin: 12px 0 0; }

.layout { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(330px, 5fr) 7fr; align-items: start; }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.card-head h2 { font-size: 18px; margin: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.updated-note { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-block;
  background: var(--amber);
  color: #231a03;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 9px;
  vertical-align: middle;
}

.warn {
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: var(--amber-ink);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 12px;
}

.inbox-list { display: flex; flex-direction: column; }

.msg-row {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.msg-row:last-child { border-bottom: 0; }
.msg-row:hover { background: var(--bg); }
.msg-row.selected { background: var(--teal-soft); }
.msg-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.msg-from { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg-subject { font-size: 14px; margin-top: 1px; }
.msg-snippet { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.msg-tools { display: flex; gap: 8px; align-items: center; margin-top: 7px; }

.otp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: var(--amber-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  font-size: 13px;
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
}
.otp-chip:hover { background: #FDE9BD; }

.row-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 8px;
}
.row-del:hover { color: var(--danger); background: var(--danger-soft); }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14.5px; }
.reader-empty .empty-logo { opacity: 0.85; }

.reader-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.reader-head h2 { font-size: 19px; margin: 0; word-break: break-word; }
.reader-meta { margin: 10px 0 4px; font-size: 13.5px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.meta-label { color: var(--muted); display: inline-block; min-width: 48px; }

.otp-block {
  margin: 14px 0;
  background: var(--amber-soft);
  border: 1.5px solid var(--amber);
  border-radius: 14px;
  padding: 14px 16px;
}
.otp-label { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber-ink); }
.otp-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.otp-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(30px, 6vw, 42px);
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--ink);
}

.reader-body {
  margin-top: 12px;
  font-size: 15px;
  word-break: break-word;
  overflow-x: auto;
}
.reader-body img { max-width: 100%; height: auto; }
.reader-body a { color: var(--teal); }
.reader-body pre { white-space: pre-wrap; }

.saved-list { display: flex; flex-direction: column; }
.saved-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}
.saved-row:last-child { border-bottom: 0; }
.saved-addr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; flex: 1 1 auto; word-break: break-all; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(31, 36, 48, 0.3);
  z-index: 50;
  max-width: 92vw;
  text-align: center;
}

.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinning { animation: spin 0.8s linear infinite; display: inline-block; }
