*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f8fafc;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --text-sub: #64748b;
  --primary:  #6366f1;
  --primary-h:#4f46e5;
  --danger:   #ef4444;
  --success:  #22c55e;
  --radius:   14px;
  --shadow:      0 2px 10px rgba(15,23,42,.05);
  --shadow-hover:0 10px 28px -8px rgba(99,102,241,.20);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #0f172a;
    --surface:  #1e293b;
    --border:   #334155;
    --text:     #f1f5f9;
    --text-sub: #94a3b8;
    --shadow:      0 2px 10px rgba(0,0,0,.3);
    --shadow-hover:0 10px 28px -8px rgba(99,102,241,.32);
  }
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px; height: 56px;
}
.topbar-logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.topbar-back {
  display: flex; align-items: center; gap: 5px;
  color: var(--text-sub); font-size: 13px; text-decoration: none;
  padding: 5px 8px; border-radius: 6px; transition: background .15s;
}
.topbar-back:hover { background: var(--border); color: var(--text); }
.topbar-sep { color: var(--border); font-size: 16px; }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-spacer { flex: 1; }
.btn-sm {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: background .15s, transform .1s;
}
.btn-sm:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }

/* ── Layout ── */
.page { max-width: 720px; margin: 0 auto; padding: 24px 20px 60px; }

/* ── Section header ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-sub); text-transform: uppercase; letter-spacing: .05em; }

/* ── TempMail card ── */
.tempmail-card {
  background: linear-gradient(135deg, var(--primary), #818cf8); color: #fff; border-radius: var(--radius);
  box-shadow: 0 16px 40px -16px rgba(99,102,241,.45);
  padding: 22px 24px; margin-bottom: 28px;
}
.tempmail-card-top {
  display: flex; align-items: stretch; gap: 22px; flex-wrap: wrap;
}
.tempmail-card-main { flex: 1; min-width: 220px; }
.tempmail-heading { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.tempmail-address-box {
  display: inline-flex; align-items: center; max-width: 100%;
  background: #fff; color: #1e293b; border-radius: 8px; padding: 10px 14px;
}
.tempmail-address { font-size: 16px; font-weight: 700; word-break: break-all; }

.tempmail-toolbar {
  display: flex; gap: 6px;
  border-left: 1px solid rgba(255,255,255,.25); padding-left: 22px;
}
.tempmail-tool-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-width: 64px; padding: 10px 12px; border: none; border-radius: 8px;
  background: rgba(255,255,255,.14); color: #fff; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.tempmail-tool-btn:hover { background: rgba(255,255,255,.26); }
.tempmail-tool-btn.copied { background: rgba(34,197,94,.4); }

/* ── Custom name row (inside the same card) ── */
.tempmail-custom-row {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.22);
}
.tempmail-custom-field { flex: 1; min-width: 200px; }
.tempmail-custom-field label {
  display: block; font-size: 12px; font-weight: 600; color: rgba(255,255,255,.85); margin-bottom: 6px;
}
.tempmail-custom-group {
  display: flex; align-items: center;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28); border-radius: 7px; overflow: hidden;
}
.tempmail-custom-group input {
  flex: 1; min-width: 0; border: none; background: transparent; outline: none;
  color: #fff; padding: 9px 12px; font-size: 14px;
}
.tempmail-custom-group input::placeholder { color: rgba(255,255,255,.55); }
.tempmail-custom-domain {
  padding: 9px 12px; font-size: 13px; color: rgba(255,255,255,.75); white-space: nowrap;
  border-left: 1px solid rgba(255,255,255,.28);
}
.tempmail-custom-hint { font-size: 11px; color: rgba(255,255,255,.65); margin-top: 6px; }
.tempmail-custom-btn {
  padding: 9px 22px; border: none; border-radius: 7px; font-size: 13px; font-weight: 700;
  background: #fff; color: var(--primary); cursor: pointer; transition: opacity .15s;
}
.tempmail-custom-btn:hover:not(:disabled) { opacity: .88; }
.tempmail-custom-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Inbox ── */
.inbox-list { display: flex; flex-direction: column; gap: 8px; }
.inbox-empty {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-sub); font-size: 14px; padding: 48px 20px;
}
.inbox-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.inbox-item:hover { box-shadow: var(--shadow-hover); }
.inbox-item:has(.inbox-body.open) { border-color: var(--primary); }

.inbox-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; cursor: pointer; user-select: none; flex-wrap: wrap;
}
.inbox-info { min-width: 0; }
.inbox-from    { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-subject { font-size: 13px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.inbox-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.inbox-time { font-size: 12px; color: var(--text-sub); white-space: nowrap; }

.code-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 10px; border-radius: 20px;
  background: #eef2ff; color: var(--primary);
  font-size: 13px; font-weight: 700; letter-spacing: .05em; font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) { .code-chip { background: #1e1b4b; } }
.code-copy {
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(99,102,241,.15); color: inherit; transition: background .15s;
}
.code-copy:hover { background: rgba(99,102,241,.3); }
.code-copy.copied { color: var(--success); background: transparent; }

.inbox-body { display: none; border-top: 1px solid var(--border); padding: 14px; }
.inbox-body.open { display: block; }
.inbox-frame { width: 100%; height: 340px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.inbox-text { white-space: pre-wrap; word-break: break-word; font-size: 13px; font-family: inherit; color: var(--text); }

/* ── Spinner ── */
.spinner-muted {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #f1f5f9; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .tempmail-card-top { flex-direction: column; }
  .tempmail-toolbar {
    border-left: none; padding-left: 0;
    border-top: 1px solid rgba(255,255,255,.25); padding-top: 16px;
  }
  .tempmail-tool-btn { flex: 1; }
  .tempmail-custom-btn { width: 100%; }
  .inbox-header { flex-direction: column; align-items: flex-start; }
}
