:root {
  --ink: #172a38;
  --muted: #536977;
  --blue: #0876a7;
  --blue-dark: #075d85;
  --line: #dce5eb;
  --input-line: #b6c8d3;
  --panel: #f7fafc;
  --selected: #e7f4fb;
  --error: #9c3227;
  --mono: Consolas, monospace;
  color: var(--ink);
  background: #fff;
  font: 16px/1.5 "Segoe UI", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
h1 { font-size: clamp(26px, 3vw, 36px); letter-spacing: -.035em; line-height: 1.2; }
h2 { font-size: 21px; line-height: 1.3; overflow-wrap: anywhere; }
label { display: block; font-size: 14px; font-weight: 600; }
input, select, textarea {
  min-width: 0;
  border: 1px solid var(--input-line);
  border-radius: 7px;
  padding: 8px 11px;
  background-color: #fff;
}
input, textarea { width: 100%; }
textarea { display: block; resize: vertical; }
.mono { font-family: var(--mono); overflow-wrap: anywhere; }
.muted, .empty { color: var(--muted); }
.error, .status { font-size: 14px; overflow-wrap: anywhere; }
.error { color: var(--error); }
.status { color: var(--blue-dark); }

.button, .text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 13px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
}
.button:hover:not(:disabled) { background: var(--panel); border-color: var(--input-line); }
.button.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.button.primary:hover:not(:disabled) { border-color: var(--blue-dark); background: var(--blue-dark); }
.text-button { padding-inline: 5px; border-color: transparent; background: transparent; color: var(--blue-dark); }
.text-button:hover:not(:disabled) { text-decoration: underline; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: -.035em; }
.brandmark { display: grid; place-items: center; flex: none; width: 35px; height: 35px; border-radius: 9px; background: var(--blue); }
.brandmark i { display: block; position: relative; width: 18px; height: 13px; overflow: hidden; border: 1.5px solid white; border-radius: 3px; }
.brandmark i::after { content: ""; position: absolute; top: -5px; left: 3px; width: 10px; height: 10px; border: solid white; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }

.auth-shell { display: grid; align-content: center; justify-items: center; gap: 14px; min-height: 100vh; padding: 24px; background: var(--panel); }
.auth-shell > p, noscript { color: var(--muted); font-size: 14px; }
.auth-card, dialog { width: min(100%, 410px); padding: 28px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.auth-card .brand { margin-bottom: 27px; }
.auth-card h1 { font-size: 27px; }
.auth-card label, dialog label { margin: 15px 0 5px; }
.auth-card .button { width: 100%; margin-top: 20px; }
.auth-card .error, dialog .error, .reply-form .error { margin-top: 10px; }
.auth-link { display: block; margin: 12px auto -5px; }
.enrollment-hint { margin-top: 6px; color: var(--muted); font-size: 13px; }
#enrollment-qr { display: block; max-width: 100%; height: auto; margin: 6px auto; }
.manual-key { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.manual-key dd { margin: 3px 0 0; }
.manual-key code { display: block; padding: 8px; border-radius: 6px; background: var(--panel); color: var(--ink); user-select: all; }

.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); padding: 22px 14px; background: var(--panel); }
.sidebar .brand { padding: 0 7px; }
.sidebar nav { display: grid; gap: 4px; padding-top: 34px; }
.sidebar nav button { padding: 9px 11px; border: 0; border-radius: 7px; background: transparent; text-align: left; color: var(--muted); font-size: 14px; font-weight: 600; }
.sidebar nav button:hover { background: #eef4f7; }
.sidebar nav button[aria-current="page"] { background: var(--selected); color: var(--blue-dark); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 65px; padding: 8px clamp(18px, 4vw, 55px); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.profile { display: flex; align-items: center; gap: 9px; min-width: 0; }
#user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { max-width: 1500px; margin-inline: auto; padding: 30px clamp(18px, 4vw, 55px) 40px; }
.page-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 22px; }
.page-head button { flex: none; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#test-address { margin-top: 6px; font-size: 14px; }
.toolbar, .box-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.box-controls { margin-right: auto; min-width: 0; }
.box-controls select { max-width: 100%; font-size: 14px; }
.mail-search { display: flex; flex: 1 1 220px; align-items: center; gap: 6px; min-width: 0; }
.mail-search input { width: auto; flex: 1; min-width: 0; font-size: 14px; }
.mail-search input::-webkit-search-cancel-button { appearance: none; }
.toolbar { margin-bottom: 14px; }
.content > .error, .content > .status { margin: 0 0 14px; }

.mail { display: grid; grid-template-columns: minmax(220px, .75fr) minmax(0, 1.25fr); min-height: 350px; border: 1px solid var(--line); border-radius: 12px; }
.message-list { min-width: 0; padding: 8px; border-right: 1px solid var(--line); }
.message-list > .empty { padding: 13px 10px; font-size: 14px; }
.message-list ul { margin: 0; padding: 0; list-style: none; }
.message-list li + li { margin-top: 2px; }
.message-more { margin: 8px 0 2px; }
.message-row { display: grid; gap: 2px; width: 100%; padding: 9px 11px; border: 0; border-radius: 7px; background: #fff; text-align: left; }
.message-row:hover { background: var(--panel); }
.message-row[aria-pressed="true"] { background: var(--selected); }
.message-row strong, .message-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row strong { font-size: 14px; }
.message-row small { color: var(--muted); font-size: 13px; }
.message-row.unread strong::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #1986b7; vertical-align: middle; }
.message-row, .button, .text-button { transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease; }
.message-row:hover, .message-row:focus-visible { background: #eef8fd; }
.button:focus-visible, .text-button:focus-visible { box-shadow: 0 0 0 3px #dceffa; }
.message-row[aria-pressed="true"], .message-entry:has(:checked) { background: #e4f3fc; }
.message-entry { display: flex; align-items: center; gap: 5px; border-radius: 7px; }
.message-entry .message-row { min-width: 0; }
.message-entry .check-label { flex: 0 0 24px; justify-content: center; }
.check-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check-label input { width: 16px; height: 16px; flex: none; margin: 0; accent-color: var(--blue); }
.list-controls, .message-batch, .reader-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.list-controls:not(:has(> :not([hidden]))) { display: none; }
.list-controls, .message-batch { padding: 5px 8px; font-size: 13px; }
.message-batch { margin-bottom: 4px; background: #f0f8fc; border-radius: 7px; }
.message-location { margin-top: 6px; font-size: 13px; overflow-wrap: anywhere; }
.reader { min-width: 0; padding: 22px; }
.reader > .empty { font-size: 14px; }
.message-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 9px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.message-details dd { margin: 0; overflow-wrap: anywhere; }
.message-body { margin: 18px 0; padding-top: 18px; border-top: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; }
.message-body.rich-message { white-space: normal; }
.rich-message :is(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, pre, blockquote) { margin: 0 0 .75em; }
.rich-message h1 { font-size: 1.55em; }
.rich-message h2 { font-size: 1.35em; }
.rich-message :is(h3, h4, h5, h6) { font-size: 1.1em; }
.rich-message img { max-width: 100%; height: auto; vertical-align: middle; }
.rich-message a[href] { color: var(--blue-dark); text-decoration: underline; }
.rich-message pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.rich-message blockquote { margin-inline: 0; padding-inline-start: 12px; border-inline-start: 2px solid var(--line); }
.rich-mail-table { max-width: 100%; overflow-x: auto; }
.rich-mail-table table { border-collapse: collapse; }
.remote-image-placeholder { display: inline-block; max-width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); font-size: 13px; }
#load-remote-images { margin-top: 10px; white-space: normal; }
.message-detail-status { margin-top: 14px; font-size: 14px; }
#retry-message { margin-top: 8px; }
.reply-form { padding-top: 12px; border-top: 1px solid var(--line); }
.reply-form .message-details { margin: 0 0 12px; }
.reply-form textarea { margin-top: 6px; }
.back { display: none; }

dialog { max-width: calc(100vw - 32px); color: var(--ink); }
dialog::backdrop { background: rgb(21 44 59 / 26%); }
#compose-dialog { width: min(100%, 550px); }
#compose-from { width: 100%; }
.compose-hint { margin-top: 6px; font-size: 13px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.address-input { display: flex; align-items: baseline; border: 1px solid var(--input-line); border-radius: 7px; }
.address-input input { border: 0; }
.address-input span { padding-right: 9px; color: var(--muted); font-size: 13px; }

.access-layout { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: start; gap: 16px; }
.access-panel { padding: 19px; border: 1px solid var(--line); border-radius: 11px; }
.access-panel label { margin: 12px 0 5px; }
.access-panel form .button, .invite-issued .button { margin-top: 13px; }
.access-panel .error, .access-panel .empty { margin-top: 10px; }
.invite-issued { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.invite-issued .status { margin-top: 7px; }
.access-list-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.invitation-list { padding: 0; margin: 0; list-style: none; }
.invitation-row { display: flex; align-items: start; justify-content: space-between; gap: 8px; padding: 11px 0; border-top: 1px solid var(--line); }
.invitation-row:first-child { margin-top: 11px; }
.invitation-row:last-child { padding-bottom: 0; }
.invitation-person { min-width: 0; overflow-wrap: anywhere; }
.invitation-meta { margin-top: 2px; color: var(--muted); font-size: 13px; }
.invitation-row .button { flex: none; }
.scope-button[aria-pressed="true"] { background: var(--selected); color: var(--blue-dark); }
.mailbox-list { padding: 0; margin: 0; list-style: none; }
.mailbox-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 0; border-top: 1px solid var(--line); }
.mailbox-row:first-child { padding-top: 0; border: 0; }
.mailbox-row:last-child { padding-bottom: 0; }
.mailbox-info { min-width: 0; }
.mailbox-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button.danger { color: var(--error); }
#delete-mailbox-note { margin-top: 13px; font-size: 14px; }
#delete-mailbox-tester-note { margin-top: 6px; font-size: 14px; }
.domain-quota { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 15px; font-size: 14px; }
.domain-quota progress { width: 130px; height: 10px; accent-color: #1b89bc; }
.limit-preview { margin-top: 12px; font-size: 14px; }
#limits-address { margin-top: 5px; font-size: 14px; }
dialog[open] { animation: dialogue-appear 140ms ease-out; }

@keyframes dialogue-appear {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .message-row, .button, .text-button { transition: none; }
  dialog[open] { animation: none; }
}

@media (max-width: 980px) {
  .access-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .mail-search { flex-basis: 100%; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "sidebar" "page"; }
  .sidebar { grid-area: sidebar; padding: 12px 16px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; flex-wrap: wrap; padding-top: 9px; }
  .sidebar nav button { padding: 8px; }
  .topbar { min-height: 45px; padding-block: 4px; }
  .content { padding-top: 22px; }
  .page-head { flex-wrap: wrap; margin-bottom: 15px; }
  .mail { grid-template-columns: minmax(0, 1fr); min-height: 175px; }
  .message-list { border: 0; }
  .mail:not(.reading) .reader, .mail.reading .message-list { display: none; }
  .reader { padding: 15px; }
  .back { display: inline-block; margin: -4px 0 7px -6px; }
}
