/* Kuvert — interface styles. No external fonts or assets are loaded. */

:root {
  --bg: #eef2f0;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --surface-3: #e8eeeb;
  --ink: #15201d;
  --ink-2: #3f4b47;
  --muted: #6b7773;
  --line: #dce3e0;
  --line-strong: #c5cfcb;
  --accent: #17695a;
  --accent-hover: #11574a;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --accent-text: #125a4d;
  --danger: #b3261e;
  --danger-soft: #f9e3e1;
  --warn: #7a5200;
  --warn-soft: #fff1d6;
  --focus: #2a8f7b;
  --shadow-pop: 0 1px 2px rgb(21 32 29 / 0.06), 0 12px 32px rgb(21 32 29 / 0.14);
  --shadow-sheet: 0 2px 6px rgb(21 32 29 / 0.08), 0 24px 60px rgb(21 32 29 / 0.22);

  --font-ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-letter: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1412;
    --surface: #151d1a;
    --surface-2: #1a2420;
    --surface-3: #22302b;
    --ink: #e4ebe8;
    --ink-2: #bcc7c3;
    --muted: #8b9893;
    --line: #26322e;
    --line-strong: #34433e;
    --accent: #5cc2a8;
    --accent-hover: #74d1b9;
    --accent-ink: #06221b;
    --accent-soft: #173a31;
    --accent-text: #7fd6c0;
    --danger: #f2867d;
    --danger-soft: #3a1c1a;
    --warn: #f3c86b;
    --warn-soft: #34290f;
    --focus: #7fd6c0;
    --shadow-pop: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.5);
    --shadow-sheet: 0 2px 6px rgb(0 0 0 / 0.4), 0 24px 60px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1412;
  --surface: #151d1a;
  --surface-2: #1a2420;
  --surface-3: #22302b;
  --ink: #e4ebe8;
  --ink-2: #bcc7c3;
  --muted: #8b9893;
  --line: #26322e;
  --line-strong: #34433e;
  --accent: #5cc2a8;
  --accent-hover: #74d1b9;
  --accent-ink: #06221b;
  --accent-soft: #173a31;
  --accent-text: #7fd6c0;
  --danger: #f2867d;
  --danger-soft: #3a1c1a;
  --warn: #f3c86b;
  --warn-soft: #34290f;
  --focus: #7fd6c0;
  --shadow-pop: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.5);
  --shadow-sheet: 0 2px 6px rgb(0 0 0 / 0.4), 0 24px 60px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent-text);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

svg.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}

.btn.danger:hover {
  background: var(--danger-soft);
}

.btn.quiet {
  border-color: transparent;
  background: transparent;
}

.btn.quiet:hover {
  background: var(--surface-3);
}

.btn.block {
  width: 100%;
}

.btn.large {
  min-height: 46px;
  font-size: 15px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.icon-btn[aria-pressed="true"] {
  color: var(--accent-text);
}

.icon-btn.starred {
  color: #c98a00;
}

.icon-btn.starred svg {
  fill: currentColor;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-text);
  cursor: pointer;
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------------- forms */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field > label,
.field-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
}

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

.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.input-group {
  position: relative;
  display: flex;
}

.input-group .input {
  padding-right: 44px;
}

.input-group .icon-btn {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
}

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 110px 140px;
  gap: 10px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  flex: none;
}

.form-error {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 500;
  margin-bottom: 16px;
}

.form-error svg {
  margin-top: 1px;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--ink);
  margin-bottom: 16px;
}

.notice.warn {
  background: var(--warn-soft);
}

.notice svg {
  color: var(--accent-text);
  margin-top: 1px;
}

.notice.warn svg {
  color: var(--warn);
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 6px;
}

details.advanced {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin: 4px 0 16px;
}

details.advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-2);
  list-style: none;
}

details.advanced summary::before {
  content: "+ ";
  color: var(--muted);
}

details.advanced[open] summary::before {
  content: "– ";
}

details.advanced .advanced-body {
  margin-top: 14px;
}

/* strength meter */
.meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  height: 4px;
}

.meter span {
  border-radius: 2px;
  background: var(--surface-3);
  transition: background-color 0.2s;
}

.meter[data-score="1"] span:nth-child(-n + 1) {
  background: var(--danger);
}

.meter[data-score="2"] span:nth-child(-n + 2) {
  background: #c98a00;
}

.meter[data-score="3"] span:nth-child(-n + 3),
.meter[data-score="4"] span {
  background: var(--accent);
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- auth screens */

.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(440px, 100%);
}

.auth-card.wide {
  width: min(560px, 100%);
}

.auth-head {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 14px;
  margin-bottom: 28px;
}

.wordmark {
  font-family: var(--font-letter);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: -0.01em;
  line-height: 1;
}

.auth-head p {
  margin: 0;
  color: var(--muted);
  max-width: 34ch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px;
}

.panel h2 {
  font-size: 19px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.panel .lede {
  margin: 0 0 22px;
  color: var(--muted);
}

.auth-foot {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.seal {
  width: 76px;
  height: 76px;
  color: var(--accent);
}

.seal text {
  font-family: var(--font-letter);
  font-weight: 600;
}

.seal.breaking {
  animation: seal-open 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes seal-open {
  40% {
    transform: scale(1.06) rotate(-4deg);
  }
  100% {
    transform: scale(0.6) rotate(18deg);
    opacity: 0;
  }
}

/* steps (setup is a real sequence) */
.steps {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 22px;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.steps li + li::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--line-strong);
}

.steps .num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-weight: 600;
  font-size: 12px;
}

.steps li[aria-current="step"] {
  color: var(--ink);
  font-weight: 600;
}

.steps li[aria-current="step"] .num {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.steps li.done .num {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}

.steps .label {
  display: none;
}

@media (min-width: 600px) {
  .steps .label {
    display: inline;
  }
}

/* OTP boxes */
.otp {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 6px 0 20px;
}

.otp input {
  width: 48px;
  height: 58px;
  text-align: center;
  font: 600 24px/1 var(--font-mono);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  caret-color: var(--accent);
}

.otp input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.otp .gap {
  width: 8px;
}

.otp[aria-invalid="true"] input {
  border-color: var(--danger);
}

@media (max-width: 380px) {
  .otp input {
    width: 40px;
    height: 52px;
  }
}

/* QR + secret */
.qr-block {
  display: grid;
  grid-template-columns: 172px 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

.qr-block img {
  width: 172px;
  height: 172px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: #fff;
  image-rendering: pixelated;
}

.secret {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.04em;
  word-break: break-all;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: var(--r-md);
  margin: 8px 0;
}

@media (max-width: 520px) {
  .qr-block {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

.codes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  padding: 16px 18px;
  margin: 0 0 16px;
  list-style: none;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font: 600 15px/1.6 var(--font-mono);
  letter-spacing: 0.05em;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.generated {
  display: flex;
  gap: 8px;
  align-items: center;
}

.generated .secret {
  flex: 1;
  margin: 0;
}

ol.instructions {
  margin: 8px 0 0;
  padding-left: 20px;
}

ol.instructions li + li {
  margin-top: 4px;
}

/* ---------------------------------------------------------------- app shell */

.shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 240px minmax(320px, 400px) 1fr;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 12px 12px;
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 16px;
}

.brand .seal {
  width: 30px;
  height: 30px;
}

.brand .wordmark {
  font-size: 21px;
}

.compose-btn {
  margin: 0 4px 16px;
  min-height: 44px;
  border-radius: 12px;
}

.folders {
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.folders ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.folder {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
}

.folder:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.folder[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 650;
}

.folder .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder .count {
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.folder.nested {
  padding-left: 30px;
}

.folders-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 8px;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 10px 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-foot .who {
  flex: 1;
  min-width: 0;
  padding: 0 6px;
}

.who .addr {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who .name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- list pane */

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.list-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.list-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.list-title h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-title .menu-btn {
  display: none;
}

.search {
  position: relative;
}

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search .input {
  padding-left: 36px;
  min-height: 38px;
  background: var(--surface-2);
  border-color: transparent;
}

.search .input:focus {
  background: var(--surface);
}

.filters {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}

.filters .spacer {
  flex: 1;
}

.bulkbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
}

.bulkbar .count {
  flex: 1;
  font-weight: 600;
  padding-left: 6px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

.msg {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 2px 12px;
  padding: 12px 14px 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  outline: none;
}

.msg:hover {
  background: var(--surface-2);
}

.msg[aria-selected="true"] {
  background: var(--accent-soft);
}

.msg:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.msg.unread::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 21px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.avatar {
  grid-row: span 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 13.5px;
  color: #fff;
  user-select: none;
  position: relative;
}

.avatar input {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.avatar .tick {
  display: none;
}

.msg:hover .avatar .initials,
.msg.checked .avatar .initials {
  display: none;
}

.msg:hover .avatar,
.msg.checked .avatar {
  background: var(--surface) !important;
  border: 1.5px solid var(--line-strong);
  color: var(--accent-text);
}

.msg.checked .avatar {
  background: var(--accent) !important;
  border-color: var(--accent);
  color: var(--accent-ink);
}

.msg:hover .avatar .tick,
.msg.checked .avatar .tick {
  display: block;
}

.msg:not(.checked):hover .avatar .tick {
  opacity: 0.3;
}

.msg .from {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

.msg.unread .from,
.msg.unread .subject {
  color: var(--ink);
  font-weight: 650;
}

.msg .date {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.msg.unread .date {
  color: var(--accent-text);
  font-weight: 600;
}

.msg .subject {
  grid-column: 2 / 4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

.msg .snippet {
  grid-column: 2 / 3;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.msg .marks {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
}

.msg .marks svg {
  width: 15px;
  height: 15px;
}

.msg .marks .star {
  color: #c98a00;
}

.msg .marks .star svg {
  fill: currentColor;
}

.list-more {
  padding: 14px;
  display: flex;
  justify-content: center;
}

.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 56px 24px;
  color: var(--muted);
}

.empty strong {
  color: var(--ink);
  font-size: 15px;
}

.empty svg {
  width: 28px;
  height: 28px;
  color: var(--line-strong);
  margin-bottom: 4px;
}

.skeleton {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.skeleton span {
  height: 10px;
  border-radius: 4px;
  background: var(--surface-3);
}

.skeleton span:nth-child(1) {
  width: 40%;
}

.skeleton span:nth-child(2) {
  width: 75%;
}

.skeleton span:nth-child(3) {
  width: 60%;
}

/* ---------------------------------------------------------------- reader */

.reader {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 53px;
}

.toolbar .sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 6px;
}

.toolbar .spacer {
  flex: 1;
}

.toolbar .back {
  display: none;
}

.letter {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.letter-head {
  padding: 26px 32px 18px;
  max-width: 920px;
  width: 100%;
}

.letter-subject {
  font-family: var(--font-letter);
  font-size: 26px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0 0 20px;
  overflow-wrap: anywhere;
}

.sender {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 0 12px;
  align-items: center;
}

.sender .avatar {
  width: 40px;
  height: 40px;
  grid-row: span 2;
}

.sender .who-line {
  overflow-wrap: anywhere;
}

.sender .who-line strong {
  font-weight: 650;
}

.sender .who-line .addr {
  color: var(--muted);
  font-size: 13px;
}

.sender .when {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  align-self: start;
}

.sender .recips {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.banners {
  padding: 0 32px;
  max-width: 920px;
  display: grid;
  gap: 8px;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.banner p {
  margin: 0;
  flex: 1;
}

.banner.warn {
  background: var(--warn-soft);
  border-color: transparent;
}

.banner.warn svg {
  color: var(--warn);
}

.banner .actions {
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 32px 0;
  max-width: 920px;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 280px;
  padding: 8px 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.attachment:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.attachment .file-type {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}

.attachment .meta {
  min-width: 0;
}

.attachment .fname {
  font-weight: 550;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment .fsize {
  font-size: 12px;
  color: var(--muted);
}

.letter-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 32px 32px;
  min-height: 360px;
  max-width: 920px;
  width: 100%;
}

.letter-body.html {
  padding: 4px 12px 16px;
}

.letter-body iframe {
  display: block;
  width: 100%;
  height: calc(100dvh - 120px);
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
}

.plain {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.6;
  max-width: 72ch;
}

.plain .quote {
  display: block;
  color: var(--muted);
  border-left: 3px solid var(--line-strong);
  padding-left: 12px;
  margin: 4px 0;
}

.reader-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.reader-empty .seal {
  width: 64px;
  height: 64px;
  opacity: 0.18;
  margin: 0 auto 12px;
}

/* ---------------------------------------------------------------- compose */

.compose {
  position: fixed;
  right: 24px;
  bottom: 0;
  width: min(580px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-sheet);
  z-index: 30;
  animation: rise 0.18s ease-out;
}

.compose.maximized {
  right: 50%;
  bottom: 50%;
  transform: translate(50%, 50%);
  width: min(920px, calc(100vw - 48px));
  height: min(820px, calc(100dvh - 48px));
  border-radius: var(--r-lg);
  border-bottom: 1px solid var(--line);
  animation: none;
}

@keyframes rise {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
}

.compose-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.compose-head h2 {
  flex: 1;
  margin: 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-fields {
  border-bottom: 1px solid var(--line);
}

.cfield {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
}

.cfield:last-child {
  border-bottom: 0;
}

.cfield > label {
  width: 52px;
  flex: none;
  color: var(--muted);
  font-size: 13px;
}

.cfield .bare {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 0;
  outline: none;
}

.cfield .from-value {
  flex: 1;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipients {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  position: relative;
  min-width: 0;
}

.recipients input {
  flex: 1;
  min-width: 140px;
  border: 0;
  outline: none;
  background: transparent;
  padding: 4px 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 4px 2px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 13px;
}

.pill.invalid {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.pill button:hover {
  background: var(--line-strong);
}

.pill svg {
  width: 13px;
  height: 13px;
}

.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  list-style: none;
  margin: 2px 0 0;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  max-height: 220px;
  overflow-y: auto;
}

.suggest li {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.suggest li[aria-selected="true"],
.suggest li:hover {
  background: var(--accent-soft);
}

.suggest .addr {
  color: var(--muted);
  font-size: 12.5px;
}

.compose-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.compose-body textarea {
  flex: 1;
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  padding: 16px 18px;
  background: transparent;
  font-size: 15px;
  line-height: 1.55;
}

.compose-body.dragging::after {
  content: "Drop files to attach";
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  color: var(--accent-text);
  font-weight: 650;
}

.compose-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
}

.compose-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.compose-foot .spacer {
  flex: 1;
}

.compose-foot .hint {
  margin-right: 8px;
}

.cc-toggles {
  display: flex;
  gap: 2px;
}

.cc-toggles button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
}

.cc-toggles button:hover {
  color: var(--ink);
  background: var(--surface-3);
}

/* ---------------------------------------------------------------- dialogs, menus, toasts */

dialog {
  border: 0;
  padding: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sheet);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
}

dialog::backdrop {
  background: rgb(14 20 18 / 0.45);
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 18px 12px 24px;
}

.dialog-head h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
}

.dialog-body {
  padding: 4px 24px 24px;
  overflow-y: auto;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
}

dialog.settings {
  width: min(760px, calc(100vw - 32px));
  height: min(760px, calc(100dvh - 48px));
}

dialog.settings[open] {
  display: flex;
  flex-direction: column;
}

.settings-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 190px 1fr;
  border-top: 1px solid var(--line);
}

.settings-nav {
  padding: 12px;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: start;
  gap: 2px;
}

.settings-nav button {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-2);
}

.settings-nav button:hover {
  background: var(--surface-3);
}

.settings-nav button[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 650;
}

.settings-pane {
  overflow-y: auto;
  padding: 20px 26px 28px;
}

.settings-pane h3 {
  font-size: 16px;
  margin: 0 0 4px;
}

.setting {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.setting:first-child {
  padding-top: 4px;
}

.setting:last-child {
  border-bottom: 0;
}

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

.setting-row > div {
  min-width: 0;
  flex: 1 1 260px;
}

.setting .desc {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.setting form {
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.setting form .field:last-of-type {
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  gap: 2px;
}

.segmented button {
  white-space: nowrap;
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}

.events {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.events li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.events li:last-child {
  border-bottom: 0;
}

.events .ok {
  color: var(--accent-text);
}

.events .fail {
  color: var(--danger);
}

.events .when {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.events .sub {
  color: var(--muted);
  font-size: 12.5px;
}

.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 16px;
  margin: 10px 0 0;
  font-size: 13.5px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.menu {
  position: fixed;
  z-index: 50;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}

.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.menu button:hover,
.menu button:focus-visible {
  background: var(--surface-3);
  outline: none;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
  max-width: calc(100vw - 32px);
  padding: 11px 12px 11px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: rise 0.18s ease-out;
}

.toast p {
  flex: 1;
  margin: 0;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast button {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.shortcuts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 18px;
  margin: 0;
}

.shortcuts dt {
  text-align: right;
}

.shortcuts dd {
  margin: 0;
  color: var(--ink-2);
}

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 600 12px/1.6 var(--font-mono);
  text-align: center;
}

.drawer-scrim {
  display: none;
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: minmax(300px, 380px) 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-sheet);
    visibility: hidden;
  }

  .shell.drawer-open .sidebar {
    transform: none;
    visibility: visible;
  }

  .shell.drawer-open .drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(14 20 18 / 0.4);
  }

  .list-title .menu-btn {
    display: inline-grid;
  }

  .list-pane {
    border-left: 0;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 15px;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .shell .reader {
    display: none;
  }

  .shell.reading .reader {
    display: flex;
  }

  .shell.reading .list-pane {
    display: none;
  }

  .list-pane {
    border-right: 0;
  }

  .toolbar .back {
    display: inline-grid;
  }

  .toolbar .hide-sm {
    display: none;
  }

  .letter-head {
    padding: 18px 18px 14px;
  }

  .letter-subject {
    font-size: 22px;
  }

  .sender {
    grid-template-columns: 40px 1fr;
  }

  .sender .who-line .addr {
    display: block;
  }

  .sender .when,
  .sender .recips {
    grid-column: 2;
  }

  .banners,
  .attachments {
    padding-left: 18px;
    padding-right: 18px;
  }

  .letter-body {
    padding: 14px 12px 24px;
  }

  .compose,
  .compose.maximized {
    inset: 0;
    transform: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
  }

  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .settings-nav {
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px;
  }

  .settings-nav button {
    white-space: nowrap;
  }

  .settings-pane {
    padding: 16px 18px 24px;
  }

  dialog.settings {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100vw;
    border-radius: 0;
  }

  .row-2 {
    grid-template-columns: 1fr 1fr;
  }

  .row-2 > :first-child {
    grid-column: 1 / -1;
  }

  .panel {
    padding: 22px 18px;
  }

  .fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    box-shadow: var(--shadow-pop);
    padding: 0;
  }

  .fab .label {
    display: none;
  }
}

@media (min-width: 761px) {
  .fab {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- security keys and passkeys ---- */
.auth-alt {
  display: flex;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.auth-alt:has(> :only-child) {
  justify-content: center;
}

.factor-key {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  margin-bottom: 6px;
}

.factor-key svg {
  flex: none;
  color: var(--accent-text);
  margin-top: 1px;
}

.factor-key p {
  margin: 0;
  font-size: 14px;
}

.factor .link-btn {
  font-size: 13px;
}

.keys {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.keys > li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
}

.keys > li + li {
  border-top: 1px solid var(--line);
}

.keys .key-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.keys .key-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.keys .key-meta {
  font-size: 13px;
  color: var(--muted);
}

.keys .key-actions {
  display: flex;
  gap: 4px;
}

.keys .key-form {
  grid-column: 1 / -1;
}

.keys-empty {
  margin: 12px 0 0;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 14px;
}

.key-add {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--bg);
}

.key-add ol {
  margin: 0 0 12px;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  font-size: 14px;
}

.key-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.key-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: start;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.key-choice:hover {
  border-color: var(--accent);
}

.key-choice svg {
  grid-row: span 2;
  color: var(--accent-text);
  margin-top: 2px;
}

.key-choice strong {
  font-weight: 600;
}

.key-choice span {
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 520px) {
  .keys > li {
    grid-template-columns: 36px 1fr;
  }

  .keys .key-actions {
    grid-column: 2;
  }
}

.btn.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.btn.danger-text {
  color: var(--danger);
}

.steps .label {
  white-space: nowrap;
}

.steps li + li::before {
  width: 16px;
}
