/* Tokens and controls follow permail.app. */
:root {
  --bg-window: #f2f2f2; --bg-sidebar: #f2f2f2; --bg-content: #fafafa; --bg-raised: #ffffff;
  --bg-hover: #0000000d; --bg-selection: #00000014;
  --text: #000000eb; --text-secondary: #00000094; --text-tertiary: #00000059;
  --accent: #000000eb; --on-accent: #ffffff; --danger: #c4513c; --focus: #6f8fe0; --icon-fill: #9ebaed;
  --hairline: #00000014; --strong: #00000026;
  --primary-fill: linear-gradient(to top, #000000eb, #000000b3); --primary-edge: #000;
  --ease-out: cubic-bezier(0, 0, .2, 1); --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-window: #1c1c1c; --bg-sidebar: #1c1c1c; --bg-content: #212121; --bg-raised: #282828;
    --bg-hover: #ffffff0d; --bg-selection: #ffffff14;
    --text: #ffffffed; --text-secondary: #ffffff99; --text-tertiary: #ffffff54;
    --accent: #ffffffed; --on-accent: #ffffffed; --danger: #f0937e; --focus: #9db7ff; --icon-fill: #4d515a;
    --hairline: #ffffff14; --strong: #ffffff30;
    --primary-fill: linear-gradient(to top, #ffffff26, #ffffff08); --primary-edge: #ffffff30;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg-window); color: var(--text); font: 13px/1.45 var(--ui); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
#app { height: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; border: 0; background: none; border-radius: 999px; padding: 6px 14px;
  font-weight: 500; color: var(--text); text-decoration: none; white-space: nowrap;
  box-shadow: inset 0 0 0 .5px var(--strong);
  transition: background-color .12s var(--ease-out), transform .12s var(--ease-out);
}
button:hover, .button:hover { background: var(--bg-hover); }
button:active, .button:active { background: var(--bg-selection); transform: scale(.97); }
button.primary, .button.primary {
  position: relative; isolation: isolate; overflow: hidden;
  color: var(--on-accent); background: var(--primary-fill); box-shadow: 0 0 0 .5px var(--primary-edge);
}
button.primary::after, .button.primary::after { content: ""; position: absolute; inset: 0; z-index: -1; transition: background-color .12s var(--ease-out); }
button.primary:hover::after, .button.primary:hover::after { background: #ffffff14; }
button.link { box-shadow: none; border-radius: 4px; padding: 0; color: var(--text-secondary); text-decoration: underline; text-decoration-color: var(--strong); text-underline-offset: 3px; }
button.link:hover { background: none; color: var(--text); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; transform: none; }
input, textarea, select { width: 100%; color: var(--text); font-size: 13px; border: 0; box-shadow: inset 0 0 0 .5px var(--strong); background: var(--bg-raised); border-radius: 8px; padding: 8px 10px; }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
input:focus, textarea:focus, select:focus, button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
label { display: grid; gap: 4px; color: var(--text-secondary); font-size: 12px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
a { color: inherit; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
p.small, p.muted { margin: 0; }
.error { color: var(--danger); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.spacer { flex: 1; }

/* Brand and footer */
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.logo-mark {
  position: relative; flex: none; width: 28px; height: 28px; border-radius: 7px; overflow: hidden;
  background: var(--icon-fill); box-shadow: 0 0 0 .5px var(--strong), 0 1px 2px #0000001a;
}
.logo-mark img { position: absolute; inset: 0; width: 100%; height: 100%; }
.only-dark { display: none; }
@media (prefers-color-scheme: dark) { .only-light { display: none; } .only-dark { display: block; } }
.logo-name { font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.site-footer { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; font-size: 12px; line-height: 16px; color: var(--text-tertiary); }
.site-footer .links { display: flex; gap: 14px; }
.text-link {
  --rail: var(--strong);
  color: var(--text-secondary); text-decoration: none; padding-bottom: 2px;
  background-image: linear-gradient(var(--text), var(--text)), linear-gradient(var(--rail), var(--rail));
  background-repeat: no-repeat; background-position: 100% 100%, 0 100%; background-size: 0 1px, 100% 1px;
  transition: background-size .28s var(--ease-in-out), color .12s var(--ease-out);
}
.text-link:hover, .text-link:focus-visible { color: var(--text); background-position: 0 100%, 0 100%; background-size: 100% 1px, 100% 1px; transition-duration: .18s; }

/* Sign-in */
.center { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px 16px; font-size: 14px; line-height: 20px; }
.center > * { width: min(380px, 100%); }
.card { background: var(--bg-raised); border-radius: 16px; padding: 28px; display: grid; gap: 14px; box-shadow: 0 0 0 .5px var(--hairline), 0 1px 2px #0000000a, 0 8px 24px #0000000d; }
.card h1 { font-size: 20px; line-height: 26px; }
.card .small, .card label { font-size: 12px; line-height: 16px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-tertiary); font-size: 11px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--hairline); }
.card button, .card .button { width: 100%; height: 36px; }

/* Mail */
.shell { display: grid; grid-template-columns: 220px 340px 1fr; height: 100%; }
.sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--hairline); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.sidebar .brand { padding: 2px 6px 14px; }
.sidebar .identity { display: grid; min-width: 0; }
.sidebar .who { font-size: 12px; line-height: 16px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .compose { margin: 0 4px 12px; }
.sidebar .heading { padding: 14px 8px 4px; font-size: 11px; color: var(--text-tertiary); font-weight: 600; }
.sidebar .site-footer { flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 8px 2px; margin-top: 10px; border-top: 1px solid var(--hairline); font-size: 11px; }
.nav { display: block; box-shadow: none; text-align: left; border-radius: 8px; padding: 5px 8px; width: 100%; font-weight: 400; }
.nav:active { transform: none; }
.nav[aria-current="true"] { background: var(--bg-selection); font-weight: 600; }
.list { border-right: 1px solid var(--hairline); background: var(--bg-content); overflow: auto; }
.list header { position: sticky; top: 0; background: var(--bg-content); padding: 16px 16px 10px; border-bottom: 1px solid var(--hairline); display: flex; align-items: baseline; gap: 8px; }
.list header h2 { font-size: 18px; }
.item { display: grid; gap: 2px; padding: 10px 16px; box-shadow: none; border-bottom: 1px solid var(--hairline); border-radius: 0; width: 100%; text-align: left; font-weight: 400; white-space: normal; }
.item:active { transform: none; }
.item[aria-current="true"] { background: var(--bg-selection); }
.item .top { display: flex; gap: 8px; font-size: 12px; }
.item .from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .date { color: var(--text-tertiary); font-size: 11px; }
.item .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.item.unread .from, .item.unread .subject { font-weight: 600; color: var(--text); }
.item.unread .from::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--focus); margin-right: 6px; vertical-align: middle; }
.empty { padding: 32px 16px; color: var(--text-tertiary); text-align: center; }
.reader { background: var(--bg-content); display: flex; flex-direction: column; min-width: 0; }
.reader .toolbar { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--hairline); flex-wrap: wrap; }
.reader .meta { padding: 18px 24px 12px; display: grid; gap: 4px; }
.reader .meta h1 { font-size: 22px; }
.reader .body { flex: 1; min-height: 0; overflow: auto; padding: 0 24px 24px; }
.reader .text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.reader iframe { width: 100%; height: 100%; min-height: 420px; border: 0; background: #fff; border-radius: 10px; }
.attachments { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 24px 12px; }
.attachments a { color: inherit; box-shadow: inset 0 0 0 .5px var(--strong); border-radius: 999px; padding: 4px 10px; font-size: 12px; text-decoration: none; }
.attachments a:hover { background: var(--bg-hover); }

/* Settings & admin */
.page { grid-column: 2 / 4; background: var(--bg-content); overflow: auto; padding: 28px 32px; }
.page > .stack { max-width: 640px; gap: 28px; }
.page h1 { font-size: 22px; }
.section { display: grid; gap: 10px; }
.section h2 { font-size: 12px; line-height: 16px; letter-spacing: .01em; font-weight: 500; color: var(--text-secondary); }
.notice { border-radius: 12px; padding: 12px 14px; background: var(--bg-raised); box-shadow: inset 3px 0 0 var(--danger), 0 0 0 .5px var(--hairline); color: var(--text-secondary); }
.notice strong { color: var(--text); font-weight: 600; }
.panel { border-radius: 12px; background: var(--bg-raised); box-shadow: 0 0 0 .5px var(--hairline), 0 1px 2px #0000000a; }
.panel > * + * { border-top: 1px solid var(--hairline); }
.panel .line { display: flex; gap: 10px; align-items: center; padding: 10px 14px; flex-wrap: wrap; }
.panel .line .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
code, .mono { font-family: var(--mono); font-size: 12px; }

dialog { border: 0; border-radius: 16px; background: var(--bg-raised); color: var(--text); padding: 20px; width: min(640px, calc(100% - 32px)); box-shadow: 0 0 0 .5px var(--strong), 0 16px 48px #00000033; }
dialog::backdrop { background: #0000002e; }
dialog textarea { min-height: 240px; resize: vertical; font-size: 14px; }

.back { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .shell.menu .sidebar { display: flex; }
  .shell.menu .list, .shell.menu .reader, .shell.menu .page { display: none; }
  .shell.open .list { display: none; }
  .shell:not(.open) .reader { display: none; }
  .page { grid-column: 1; padding: 20px 16px; }
  .back { display: inline-flex; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
p:empty { display: none; }
