/* The web client. Same Abyss palette as the app, the site and the gateway
   console — three panes, and a layout that collapses to one on a phone. */

:root {
  --abyss: #03101B;
  --deep: #07202F;
  --midwater: #0A3B4E;
  --shallow: #0E5C6B;
  --cyan: #3FE0D0;
  --biolum: #7CF5FF;
  --goby: #FFB454;
  --coral: #FF6B7A;
  --kelp: #5AD68A;
  --anemone: #B98CFF;

  --ink: #EAF7FA;
  --ink-dim: rgba(234, 247, 250, .68);
  --ink-faint: rgba(234, 247, 250, .42);
  --hairline: rgba(255, 255, 255, .09);
  --rim: rgba(124, 245, 255, .22);
  --panel: rgba(8, 24, 36, .82);

  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bar-height: 58px;
}

* { box-sizing: border-box; }

/* An author rule that sets `display` beats the user agent's `[hidden]`,
   whatever the specificity. This puts `hidden` back in charge. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  color: var(--ink);
  background:
    radial-gradient(1100px 640px at 10% -8%, rgba(14, 92, 107, .45), transparent 60%),
    var(--abyss);
  overflow: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); margin: 22px 0 8px; }
code { font-family: var(--mono); font-size: .88em; color: var(--biolum); }
a { color: var(--cyan); }
:focus-visible { outline: 2px solid var(--biolum); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------------ mark */
.mark {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--shallow), var(--deep));
  border: 1px solid var(--rim); box-shadow: 0 0 24px rgba(63, 224, 208, .18);
}
.mark span { width: 15px; height: 15px; border-radius: 50%; background: var(--goby);
             box-shadow: 0 0 12px rgba(255, 180, 84, .7), inset -3px -3px 0 rgba(0, 0, 0, .35); }
.mark.small { width: 28px; height: 28px; border-radius: 9px; }
.mark.small span { width: 9px; height: 9px; }
.mark.big { width: 62px; height: 62px; border-radius: 19px; opacity: .5; }
.mark.big span { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ gate */
.gate { height: 100vh; display: grid; place-items: center; padding: 24px; overflow: auto; }
.gate-card {
  width: min(420px, 100%); padding: 32px; border-radius: 20px; text-align: center;
  background: var(--panel); border: 1px solid var(--hairline); backdrop-filter: blur(14px);
}
.gate-card .mark { margin: 0 auto 16px; }
.gate-card h1 { font-size: 22px; }
.gate-sub { color: var(--ink-dim); font-size: 14px; margin: 8px 0 24px; }
.gate-note {
  margin: 18px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  line-height: 1.5; text-align: left; white-space: pre-wrap;
  background: rgba(255, 107, 122, .12); border: 1px solid rgba(255, 107, 122, .3); color: #FFC9CF;
}

/* ----------------------------------------------------------------- forms */
.stack { display: grid; gap: 12px; text-align: left; }
label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-dim); }
label small { font-weight: 500; color: var(--ink-faint); font-size: 11.5px; }
label.inline { display: flex; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); width: 100%;
  padding: 9px 11px; border-radius: 9px;
  background: rgba(3, 16, 27, .6); border: 1px solid var(--hairline);
}
input[type="checkbox"] { width: auto; accent-color: var(--cyan); }
input:focus, select:focus, textarea:focus {
  border-color: var(--rim); outline: none; box-shadow: 0 0 0 3px rgba(63, 224, 208, .12);
}
select option { background: var(--deep); }
textarea { resize: vertical; line-height: 1.6; }

button {
  font: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
  padding: 8px 13px; border-radius: 9px; border: 1px solid transparent;
  transition: filter .15s, background .15s; white-space: nowrap;
}
button:hover { filter: brightness(1.12); }
.primary { background: var(--cyan); color: #03101B; }
.ghost { background: transparent; border-color: var(--hairline); color: var(--ink-dim); }
.ghost:hover { color: var(--ink); border-color: var(--rim); }
.danger { background: transparent; border-color: rgba(255, 107, 122, .35); color: #FFA8B2; }

/* ------------------------------------------------------------------- bar */
.bar {
  height: var(--bar-height); display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(3, 16, 27, .9); border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-text { font-weight: 800; font-size: 14px; }
.brand-text small { font-weight: 700; font-size: 10.5px; color: var(--ink-faint); margin-left: 3px; }
.search { flex: 1; max-width: 460px; margin-inline: auto; }
.search input { border-radius: 999px; padding: 8px 15px; }
.who { display: flex; align-items: center; gap: 7px; }
.only-narrow { display: none; }

/* ---------------------------------------------------------------- layout */
.layout {
  height: calc(100vh - var(--bar-height));
  display: grid; grid-template-columns: 216px minmax(300px, 400px) 1fr;
}
.rail { border-right: 1px solid var(--hairline); padding: 14px 10px; overflow-y: auto; }
.list { border-right: 1px solid var(--hairline); display: flex; flex-direction: column; min-width: 0; }
.reader { overflow-y: auto; min-width: 0; }

/* ----------------------------------------------------------------- rail */
.rail button {
  width: 100%; display: flex; align-items: center; gap: 9px; margin-bottom: 2px;
  background: transparent; color: var(--ink-dim); font-size: 13.5px; text-align: left;
}
.rail button:hover { background: rgba(255, 255, 255, .05); color: var(--ink); }
.rail button.on { background: rgba(63, 224, 208, .13); color: var(--biolum); }
.rail .count { margin-left: auto; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--ink-faint); }
.rail button.on .count { color: var(--biolum); }
.rail .count.unread { color: var(--goby); font-weight: 800; }

/* ----------------------------------------------------------------- list */
.list-head {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px solid var(--hairline); min-height: 46px;
}
#list-title { font-weight: 800; font-size: 13.5px; color: var(--ink); }
.bulk { display: flex; gap: 4px; margin-left: auto; }
.bulk button { padding: 5px 9px; font-size: 12px; }
.messages { flex: 1; overflow-y: auto; }

.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start;
  padding: 11px 14px; border-bottom: 1px solid var(--hairline); cursor: pointer;
}
.item:hover { background: rgba(255, 255, 255, .035); }
/* Grid children default to `min-width: auto`, which refuses to shrink below
   their content and pushes a long subject out past the pane. Set here rather
   than as a style attribute on the element: the page's policy is
   `style-src 'self'`, so attribute styles are dropped without a word. */
.item > * { min-width: 0; }
.item.on { background: rgba(63, 224, 208, .1); }
.item.unread .who-line { font-weight: 800; color: var(--ink); }
.item.unread .subject { color: var(--ink); }
.item .who-line { font-size: 13px; color: var(--ink-dim); font-weight: 600;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .subject { font-size: 13px; color: var(--ink-dim); margin-top: 1px;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .snippet { font-size: 12px; color: var(--ink-faint); margin-top: 2px;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .side { display: grid; gap: 3px; justify-items: end; }
.item .when { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--goby); }
.star { background: none; border: none; padding: 0; font-size: 13px; color: var(--ink-faint); cursor: pointer; }
.star.on { color: var(--goby); }

/* --------------------------------------------------------------- reader */
.reader-empty { height: 100%; display: grid; place-content: center; justify-items: center;
                gap: 12px; color: var(--ink-faint); font-size: 13.5px; }
#reader-body { padding: 20px 24px 60px; max-width: 860px; }
.reader-subject { font-size: 20px; font-weight: 800; letter-spacing: -.015em; margin-bottom: 12px; line-height: 1.3; }
.reader-meta { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
               padding-bottom: 14px; border-bottom: 1px solid var(--hairline); }
.reader-from { font-weight: 800; }
.reader-addr { font-size: 12.5px; color: var(--ink-faint); font-family: var(--mono); }
.reader-when { margin-left: auto; font-size: 12px; color: var(--ink-faint); }
.reader-to { font-size: 12.5px; color: var(--ink-faint); margin-top: 5px; width: 100%; }
.reader-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.reader-actions.verdicts { margin-top: -6px; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border-radius: 10px; margin: 12px 0; font-size: 12.5px;
  background: rgba(255, 180, 84, .1); border: 1px solid rgba(255, 180, 84, .28); color: #FFD79E;
}
.banner.bad { background: rgba(255, 107, 122, .1); border-color: rgba(255, 107, 122, .3); color: #FFC9CF; }
.banner button { padding: 4px 10px; font-size: 12px; margin-left: auto; }

.body-text {
  white-space: pre-wrap; word-wrap: break-word; font-family: var(--mono);
  font-size: 13px; line-height: 1.7; color: var(--ink-dim); margin: 16px 0;
}
/* A message's own HTML renders in here and nowhere else. The sandbox is the
   security boundary — see mail/src/mime.js. */
.body-frame {
  width: 100%; border: 0; background: #fff; border-radius: 12px; margin: 16px 0;
  display: block;
  /* Sized here rather than measured. The frame is sandboxed without
     `allow-same-origin`, so its document cannot be read from this side to find
     out how tall it wants to be, and it has no script of its own to report it.
     A tall box that scrolls internally is the honest trade. */
  height: 62vh; min-height: 320px;
}

.attachments { display: grid; gap: 6px; margin: 18px 0; }
.attachment {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--hairline);
  font-size: 13px; color: var(--ink-dim); text-decoration: none;
}
.attachment:hover { border-color: var(--rim); color: var(--ink); }
.attachment.compact { padding: 6px 11px; }
.attachment .size { margin-left: auto; font-size: 11.5px; color: var(--ink-faint); }

.thread { margin-top: 26px; border-top: 1px solid var(--hairline); padding-top: 14px; }
.thread-item { display: grid; gap: 2px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.thread-item:hover { background: rgba(255, 255, 255, .04); }
.thread-item.on { background: rgba(63, 224, 208, .1); }
.thread-item .t-from { font-size: 12.5px; font-weight: 700; }
.thread-item .t-snip { font-size: 12px; color: var(--ink-faint);
                       white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ pill */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px;
        font-size: 10.5px; font-weight: 800; letter-spacing: .03em;
        background: rgba(255, 255, 255, .07); color: var(--ink-dim); }
.pill.pass { background: rgba(90, 214, 138, .16); color: #9DE9BB; }
.pill.fail { background: rgba(255, 107, 122, .16); color: #FFA8B2; }
.pill.none { background: rgba(255, 255, 255, .06); color: var(--ink-faint); }
.pill.count { background: rgba(124, 245, 255, .13); color: var(--biolum); }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.hint { margin: 0 0 10px; font-size: 12.5px; line-height: 1.6; color: var(--ink-faint); }

/* ---------------------------------------------------------------- dialog */
dialog {
  border: 1px solid var(--hairline); border-radius: 18px; padding: 20px;
  background: #08192a; color: var(--ink); width: min(640px, calc(100% - 28px));
  max-height: calc(100vh - 60px); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(3, 16, 27, .74); backdrop-filter: blur(3px); }
.compose-head { display: flex; align-items: center; margin-bottom: 14px; }
.compose-head h2 { margin-right: auto; }
dialog menu { display: flex; gap: 8px; align-items: center; justify-content: flex-end;
              margin: 18px 0 0; padding: 0; }
dialog menu .hint { margin: 0 auto 0 0; }
.dialog-error {
  margin: 12px 0 0; padding: 9px 11px; border-radius: 9px; font-size: 12.5px; line-height: 1.5;
  background: rgba(255, 107, 122, .12); border: 1px solid rgba(255, 107, 122, .3); color: #FFC9CF;
}
.inline-form { grid-auto-flow: column; grid-auto-columns: 1fr; align-items: center; gap: 8px; }
.inline-form button { grid-column: auto; }
.setting-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--hairline); font-size: 13px;
}
.setting-row:first-child { border-top: none; }
.setting-row .grow { flex: 1; min-width: 0; }
.setting-row .sub { font-size: 11.5px; color: var(--ink-faint); }

/* ----------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  padding: 10px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 700;
  background: var(--deep); border: 1px solid var(--rim); box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.toast.bad { border-color: rgba(255, 107, 122, .45); color: #FFC9CF; }

/* --------------------------------------------------------------- narrow */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 180px 1fr; }
  .reader { display: none; }
  body.reading .list { display: none; }
  body.reading .reader { display: block; }
}
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .rail { display: none; }
  body.reading .only-narrow { display: inline-block; }
  .brand-text { display: none; }
  .who #settings-button { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
