:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --navy: #10243e;
  --navy-deep: #071d35;
  --navy-soft: #16385e;
  --blue: #2f6fed;
  --blue-soft: #eaf3ff;
  --canvas: #f6f8fb;
  --surface: #ffffff;
  --border: #d8e0ea;
  --text: #152033;
  --muted: #637083;
  --amber: #e9a51d;
  --danger: #b42318;
  --shadow: 0 18px 44px rgb(16 36 62 / 12%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.button {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
}

.button-primary, .compose-button {
  background: var(--blue);
  color: white;
}

.button-secondary {
  background: #edf1f6;
  color: var(--text);
}

.brand {
  display: grid;
  gap: 3px;
  color: white;
}

.brand strong { font-size: 19px; letter-spacing: -.5px; }
.brand span { color: #91a8c2; font-size: 17px; }
.brand-dark strong { color: var(--navy); }

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f7f9fc 0%, #eaf0f7 100%);
}

.auth-panel {
  width: min(100%, 430px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 34px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-copy { margin: 38px 0 24px; }
h1, h2, p { margin: 0; }
.auth-copy h1 { font-size: 27px; letter-spacing: -.8px; }
.auth-copy p { margin-top: 8px; color: var(--muted); font-size: 14px; }
.auth-form { display: grid; gap: 16px; }
.auth-method {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #f8fbff;
}
.auth-method legend { padding: 0 5px; color: #435169; font-size: 12px; font-weight: 800; }
.auth-method label { display: flex; align-items: center; gap: 8px; }
.auth-method input { width: auto; }
.auth-link { justify-self: center; }
label { display: grid; gap: 7px; color: #435169; font-size: 12px; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid #cbd6e2;
  border-radius: 5px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
  font-size: 14px;
}
input:focus, textarea:focus { border-color: var(--blue); outline: 3px solid #dceaff; }
.form-error { min-height: 18px; color: var(--danger); font-size: 12px; }
.session-timeout { min-height: 18px; color: #6a4a08; font-size: 12px; }
.totp-setup { display: grid; justify-items: center; gap: 12px; padding: 14px; border: 1px solid #d7e3f2; background: #f4f8fd; text-align: center; }
.totp-setup p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.totp-qr { width: 196px; height: 196px; border: 8px solid white; box-shadow: 0 1px 4px rgb(16 36 62 / 15%); }
.totp-manual { width: 100%; text-align: left; }
.totp-manual summary { color: #435169; font-size: 12px; font-weight: 700; cursor: pointer; }
.totp-setup code { display: block; margin-top: 8px; overflow-wrap: anywhere; color: var(--navy); font-size: 12px; }

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 255px 410px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 28px 20px 22px;
  background: var(--navy-deep);
}

.compose-button { margin: 36px 0 22px; font-size: 15px; }
.compose-button span { margin-right: 7px; font-size: 21px; font-weight: 400; vertical-align: -1px; }
.folder-button, .sign-out-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  border: 0;
  padding: 13px 10px;
  background: transparent;
  color: #c5d5e7;
  font-size: 14px;
  text-align: left;
}
.folder-button:hover, .folder-button.is-active { background: var(--navy-soft); color: white; }
.folder-button.is-active { border-left: 3px solid var(--blue); padding-left: 7px; }
.folder-button[data-mailbox="quarantine"] small { color: var(--amber); }
.folder-button small { font-size: 11px; }
.security-button { margin-top: auto; }
.sign-out-button { border-top: 1px solid #24415f; padding-top: 20px; }

.message-column { display: grid; min-height: 100vh; grid-template-rows: auto auto 1fr auto; border-right: 1px solid var(--border); background: white; }
.column-header, .reader-header {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.column-header h1 { font-size: 23px; letter-spacing: -.6px; }
.column-header p { margin-top: 5px; color: var(--blue); font-size: 13px; }
.icon-button, .text-button { border: 0; background: transparent; color: #40516a; font-size: 12px; font-weight: 700; }
.icon-button:hover, .text-button:hover { color: var(--blue); }
.message-filter { padding: 14px 22px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.message-list { min-height: 0; overflow-y: auto; }
.message-row { display: grid; gap: 8px; padding: 17px 22px; border: 0; border-bottom: 1px solid var(--border); background: white; text-align: left; }
.message-row:hover { background: #f7faff; }
.message-row.is-selected { border-left: 3px solid var(--blue); padding-left: 19px; background: var(--blue-soft); }
.message-row-top { display: flex; justify-content: space-between; gap: 16px; }
.message-row strong, .message-row time { font-size: 13px; }
.message-row time { color: var(--muted); white-space: nowrap; }
.message-row h3 { overflow: hidden; margin: 0; color: var(--text); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.message-row p { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.message-row.is-unread strong, .message-row.is-unread h3 { font-weight: 800; }
.message-footer { display: grid; min-height: 58px; place-items: center; border-top: 1px solid var(--border); }

.reader { min-width: 0; background: var(--canvas); }
.reader-empty { display: grid; min-height: 100vh; place-content: center; gap: 8px; padding: 28px; text-align: center; }
.reader-empty h2 { font-size: 22px; }
.reader-empty p { color: var(--muted); font-size: 14px; }
.reader-content { padding: 38px 44px; }
.reader-content h2 { font-size: 25px; letter-spacing: -.8px; }
.reader-meta { display: grid; gap: 6px; margin: 30px 0 22px; padding-bottom: 22px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.reader-meta strong { color: var(--text); }
.security-note { padding: 12px 14px; border: 1px solid #ccd8e6; background: white; color: #40516a; font-size: 12px; }
.reader-text { min-height: 360px; margin: 0; padding: 20px; border: 1px solid #ccd8e6; border-top: 0; background: white; color: #223047; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; line-height: 1.65; white-space: pre-wrap; }

.compose-dialog { width: min(92vw, 620px); border: 0; border-radius: 9px; padding: 0; box-shadow: var(--shadow); }
.compose-dialog::backdrop { background: rgb(7 29 53 / 46%); }
.compose-dialog form { display: grid; gap: 16px; padding: 20px; }
.compose-dialog header, .compose-dialog footer { display: flex; align-items: center; justify-content: space-between; }
.compose-dialog h2 { font-size: 19px; }
.compose-dialog header p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.compose-dialog footer { justify-content: flex-end; gap: 10px; }
.passkey-list { display: grid; gap: 10px; }
.passkey-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; background: #f8fbff; }
.passkey-row p, .security-empty { margin-top: 4px; color: var(--muted); font-size: 12px; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 220px 350px minmax(0, 1fr); }
  .reader-content { padding: 28px; }
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding: 18px 8px; }
  .brand strong { font-size: 0; }
  .brand strong::first-letter { font-size: 19px; }
  .brand span { display: none; }
  .compose-button { overflow: hidden; padding: 0; font-size: 0; }
  .compose-button span { margin: 0; font-size: 24px; }
  .folder-button { justify-content: center; overflow: hidden; font-size: 0; }
  .folder-button::before { content: "•"; font-size: 22px; }
  .folder-button small { display: none; }
  .sign-out-button { justify-content: center; overflow: hidden; font-size: 0; }
  .sign-out-button::before { content: "×"; font-size: 20px; }
  .reader { display: none; }
}
