:root {
  color-scheme: light;
  --ink: #201d32;
  --muted: #615d73;
  --muted-deep: #4e4962;
  --border: #e5e1ee;
  --paper: #fff;
  --canvas: #f6f6fb;
  --accent: #5135a8;
  --accent-dark: #402788;
  --accent-wash: #f1ecfd;
  --danger: #a11f45;
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
button:focus-visible, input:focus-visible { outline: 3px solid #9179d8; outline-offset: 2px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 4.5vw, 3.05rem); letter-spacing: -.055em; line-height: 1.12; }
h2 { font-size: 1.05rem; letter-spacing: -.015em; }
label { display: block; margin-bottom: .45rem; font-weight: 650; font-size: .9rem; }
input { min-width: 0; width: 100%; padding: .72rem .88rem; color: var(--ink); background: var(--paper); border: 1px solid #dcd7e7; border-radius: .65rem; }
.muted { color: var(--muted); }
.shell { width: min(100% - 2rem, 1140px); margin-inline: auto; }

.topbar { background: var(--paper); border-bottom: 1px solid var(--border); }
.topbar-inner, .brand, .address-controls, .mailbox-title, .sync { display: flex; align-items: center; }
.topbar-inner { justify-content: space-between; min-height: 4.45rem; gap: 1rem; }
.brand { gap: .65rem; font-size: 1.2rem; font-weight: 750; letter-spacing: -.045em; }
.brand-mark { display: grid; place-items: center; width: 2.15rem; height: 2.15rem; background: var(--accent); color: white; border-radius: .67rem; }
.envelope { display: block; width: 1.06rem; height: .77rem; border: 1.5px solid currentColor; border-radius: .2rem; position: relative; overflow: hidden; }
.envelope::after { content: ""; position: absolute; top: -.47rem; left: .11rem; width: .62rem; height: .62rem; transform: rotate(45deg); border: solid currentColor; border-width: 0 1.5px 1.5px 0; }
.domain { color: var(--muted-deep); font-size: .86rem; overflow-wrap: anywhere; }

.button { border: 1px solid transparent; border-radius: .65rem; padding: .67rem .9rem; font-size: .9rem; font-weight: 650; line-height: 1.45; white-space: nowrap; }
.button.primary { color: white; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.primary span { margin-inline: 0 .3rem; }
.button.secondary { color: var(--accent-dark); background: var(--accent-wash); }
.button.secondary:hover { background: #e9e0fb; }
.button.ghost { color: var(--muted-deep); background: var(--paper); border-color: var(--border); }
.button.ghost:hover { background: #f6f3fc; }

.error { color: var(--danger); margin-top: .65rem; font-size: .9rem; }

.inbox { padding: clamp(1.8rem, 6vw, 3.7rem) 0 3rem; }
.heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.55rem; }
.heading p { margin-top: .55rem; }
.address-panel, .mailbox { background: var(--paper); border: 1px solid var(--border); border-radius: 1rem; }
.address-panel { padding: 1.15rem; margin-bottom: 1.25rem; }
.address-controls { gap: .6rem; }
.address-controls input, .otp-code { font-family: ui-monospace, Consolas, monospace; }

.mailbox { overflow: hidden; }
.mailbox-header, .mailbox-footer { display: flex; justify-content: space-between; align-items: center; gap: .65rem; padding: .75rem 1rem; }
.mailbox-header { border-bottom: 1px solid var(--border); }
.mailbox-title, .sync { gap: .55rem; }
.mailbox-title { min-width: 0; overflow-wrap: anywhere; }
.count { background: var(--accent-wash); color: var(--accent-dark); border-radius: 1rem; padding: .1rem .5rem; font-size: .76rem; font-weight: 700; }
.sync-status, .mailbox-footer, .date { color: var(--muted); font-size: .8rem; }
.sync-status[data-error] { color: var(--danger); }
.mailbox-grid { display: grid; grid-template-columns: minmax(260px, 36%) 1fr; min-height: 366px; }
.message-list { background: #fcfbfe; border-right: 1px solid var(--border); max-height: 34rem; overflow-y: auto; }
.message-row { display: grid; gap: .25rem; width: 100%; padding: .9rem 1rem; text-align: left; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--border); }
.message-row:hover, .message-row[aria-current="true"] { background: var(--accent-wash); }
.message-row:focus-visible { outline-offset: -3px; }
.message-row-top { display: flex; gap: .65rem; align-items: baseline; justify-content: space-between; }
.message-row-subject { font-size: .92rem; font-weight: 700; }
.message-row-subject, .message-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-preview { font-size: .81rem; color: var(--muted); }
.message-row .date { white-space: nowrap; }
.message-detail { min-width: 0; padding: clamp(1rem, 3vw, 1.6rem); }
.message-detail h3 { margin: 0 0 .65rem; font-size: 1.3rem; line-height: 1.3; overflow-wrap: anywhere; }
.message-meta { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.otp-panel { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; justify-content: space-between; margin-top: 1.15rem; padding: .8rem; background: var(--accent-wash); border-radius: .8rem; }
.otp-label { font-size: .76rem; color: var(--accent-dark); }
.otp-code { font-weight: 750; font-size: 1.28rem; letter-spacing: .11em; color: var(--accent-dark); }
.message-body { margin-top: 1.15rem; font-size: .93rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.placeholder { padding: 1.25rem .7rem; text-align: center; color: var(--muted); overflow-wrap: anywhere; }
.placeholder strong { display: block; color: var(--ink); margin-bottom: .25rem; }
.message-detail .placeholder { margin-top: 3.5rem; }
.mailbox-footer { border-top: 1px solid var(--border); background: #fcfbfe; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 1; background: var(--ink); color: white; border-radius: .65rem; font-size: .86rem; }
.toast:not(:empty) { padding: .65rem .95rem; }

@media (max-width: 680px) {
  .heading { align-items: start; flex-direction: column; }
  .address-controls { flex-wrap: wrap; }
  .address-controls input { flex: 0 0 100%; }
  .mailbox-grid { grid-template-columns: 1fr; min-height: auto; }
  .message-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 18rem; }
  .message-detail { min-height: 160px; }
  .message-detail .placeholder { margin-top: 1rem; }
}

@media (max-width: 400px) {
  .topbar .domain, .sync-status:not([data-error]) { display: none; }
}
