/*
 * MailLogic Console. Built on the webmail's tokens, base and overlays
 * (src/shared/styles/): the same font, teal, buttons, menus, dialogs and
 * toasts, light and dark by the system setting. Added here: status colors
 * (the webmail has no "working" green), the page layout, domain sections,
 * DNS records and mailbox rows.
 *
 * A status is always shape + label + color: ● working, ▲ needs attention,
 * ✕ stopped, ○ not yet / unknown.
 */

:root {
  --console-w: 980px;

  --status-ok-fg: #05603a;
  --status-ok-bg: #ecfdf3;
  --status-ok-shape: #079455;
  --status-warn-fg: #7a4500;
  --status-warn-bg: #fff6e5;
  --status-warn-shape: #dc6803;
  --status-bad-fg: #b42318;
  --status-bad-bg: #fdeceb;
  --status-bad-shape: #d92d20;
  --status-idle-fg: #5f6368;
  --status-idle-bg: #eef1f4;
  --status-idle-shape: #6b7076;
}

@media (prefers-color-scheme: dark) {
  :root {
    --status-ok-fg: #75e0a7;
    --status-ok-bg: rgb(117 224 167 / 12%);
    --status-ok-shape: #47cd89;
    --status-warn-fg: #fcd34d;
    --status-warn-bg: rgb(250 176 5 / 12%);
    --status-warn-shape: #fdb022;
    --status-bad-fg: #fda29b;
    --status-bad-bg: rgb(249 112 102 / 14%);
    --status-bad-shape: #f97066;
    --status-idle-fg: #a0a4ab;
    --status-idle-bg: #23262b;
    --status-idle-shape: #90949b;
  }
}

body {
  background: var(--bg-app);
}

.app {
  min-height: 100%;
}

/* ---- top bar (the webmail's, src/styles/top-bar.css) ---- */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 12px 0 16px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--line);
}

.top-bar-start,
.top-bar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
}

.brand-mark .icon {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.brand-name {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-product {
  font-weight: 500;
  color: var(--fg-muted);
}

.top-bar .button {
  min-height: 36px;
  font-size: var(--text-sm);
}

.account {
  position: relative;
  margin-left: 4px;
}

.account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--hue-5-bg);
  color: var(--hue-5-fg);
  font-size: var(--text-xs);
  font-weight: 700;
}

.account-button:hover .account-avatar,
.account-button[aria-expanded="true"] .account-avatar {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.narrow-only {
  display: none !important;
}

/* ---- page ---- */

.console {
  padding: 24px 16px 48px;
}

.console:focus {
  outline: none;
}

.console-inner {
  max-width: var(--console-w);
  margin: 0 auto;
}

.banners {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.banners:not(:empty) {
  margin-bottom: 16px;
}

.banner p {
  margin: 0;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 16px;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.plan-line {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.plan-name {
  color: var(--fg);
  font-weight: 600;
}

.plan-part.is-full {
  color: var(--status-warn-fg);
  font-weight: 650;
}

.domains {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.muted {
  color: var(--fg-muted);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ---- status ---- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.status .status-shape {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}

.status.chip {
  padding: 3px 10px 3px 7px;
  border-radius: 999px;
}

.tone-ok {
  color: var(--status-ok-fg);
}
.tone-ok .status-shape {
  color: var(--status-ok-shape);
}
.tone-ok.chip {
  background: var(--status-ok-bg);
}

.tone-warn {
  color: var(--status-warn-fg);
}
.tone-warn .status-shape {
  color: var(--status-warn-shape);
}
.tone-warn.chip {
  background: var(--status-warn-bg);
}

.tone-bad {
  color: var(--status-bad-fg);
}
.tone-bad .status-shape {
  color: var(--status-bad-shape);
}
.tone-bad.chip {
  background: var(--status-bad-bg);
}

.tone-idle {
  color: var(--status-idle-fg);
}
.tone-idle .status-shape {
  color: var(--status-idle-shape);
}
.tone-idle.chip {
  background: var(--status-idle-bg);
}

@media (forced-colors: active) {
  .status .status-shape {
    color: CanvasText;
  }
}

/* ---- notes (inline messages) ---- */

.note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
}

.note .icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.note p {
  flex: 1 1 auto;
}

.note.tone-ok {
  background: var(--status-ok-bg);
}
.note.tone-warn {
  background: var(--status-warn-bg);
}
.note.tone-bad {
  background: var(--status-bad-bg);
}
.note.tone-idle {
  background: var(--bg-app);
  color: var(--fg-muted);
}

.request-id {
  color: var(--fg-muted);
  font-weight: 400;
}

.inline-error {
  color: var(--status-bad-fg);
  font-size: var(--text-sm);
}

/* ---- domain section ---- */

.domain {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
}

.domain-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 12px 14px 18px;
}

.domain-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  min-width: 0;
}

.domain-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.domain-name:focus {
  outline: none;
}

.domain-name:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-radius: 4px;
}

.domain-icon {
  color: var(--fg-subtle);
}

.domain-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.domain-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.checked-at {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.check-button[aria-disabled="true"] {
  opacity: 0.6;
  cursor: default;
}

.check-button .icon {
  width: 16px;
  height: 16px;
}

.menu-anchor {
  position: relative;
}

.domain-menu {
  left: auto;
  right: 0;
  min-width: 240px;
}

.menu-item.is-danger {
  color: var(--danger);
}

.menu-item.is-danger > .icon {
  color: currentColor;
}

.menu-item[aria-disabled="true"] {
  color: var(--fg-subtle);
  cursor: default;
}

.menu-item-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.menu-item-note {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.domain-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 18px 14px;
}

.note-slot:empty {
  display: none;
}

/* DNS records disclosure */

.dns {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dns-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
}

.dns-toggle:hover {
  background: var(--bg-hover);
}

.dns-toggle-label {
  font-weight: 600;
}

.dns-summary {
  margin-left: auto;
  white-space: normal;
  text-align: right;
}

.chevron {
  width: 16px;
  height: 16px;
  color: var(--fg-muted);
  transition: transform 120ms ease;
}

[aria-expanded="true"] > .chevron {
  transform: rotate(90deg);
}

.dns-panel {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--line);
}

/* set-up steps */

.setup {
  padding: 2px 18px 16px;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: 500;
}

.step-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: 700;
}

.step-mark .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.6;
}

.step.is-done {
  color: var(--status-ok-fg);
}

.step.is-done .step-mark {
  border-color: var(--status-ok-shape);
  background: var(--status-ok-shape);
  color: var(--bg-raised);
}

.step.is-current {
  color: var(--fg);
  font-weight: 650;
}

.step.is-current .step-mark {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-text {
  max-width: 70ch;
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

/* (domain connect) the DNS provider adds the step's records */

.connect-changes {
  max-width: 70ch;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-app);
}

.connect-heading {
  margin: 0 0 6px;
  font-size: var(--text-sm);
  font-weight: 650;
}

.connect-list {
  margin: 0;
  padding-left: 18px;
  font-size: var(--text-sm);
}

.connect-line + .connect-line {
  margin-top: 4px;
}

.connect-line.tone-warn {
  font-weight: 600;
}

.connect-line.tone-idle {
  color: var(--fg-muted);
}

.connect-ack {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 70ch;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

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

.connect-button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.connect-hint {
  max-width: 70ch;
  margin: 0;
}

/* records */

.records-wrap {
  overflow-x: auto;
}

.records {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.records th {
  padding: 8px 10px 6px 0;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

.records td {
  padding: 9px 10px 9px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.records tr:last-child td {
  border-bottom: 0;
}

.record-type {
  width: 108px;
}

.record-type-code {
  display: block;
  font-weight: 700;
}

.record-purpose,
.record-extra {
  display: block;
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.record-status {
  width: 160px;
}

.record-status .status {
  white-space: normal;
}

.record-found {
  display: block;
  margin-top: 4px;
  color: var(--status-warn-fg);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

.copyable {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.copyable-text {
  flex: 0 1 auto;
  min-width: 0;
  padding-top: 7px;
  /* Wraps at the <wbr> after a dot first (ui/parts.js); inside a label only when one is too long. */
  overflow-wrap: anywhere;
  user-select: all;
}

.copy-button {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
}

.copy-button .icon {
  width: 16px;
  height: 16px;
}

.copy-button.is-copied {
  color: var(--status-ok-shape);
}

.record-hints {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.record-hints li + li {
  margin-top: 4px;
}

.record-hints strong {
  color: var(--fg);
  font-weight: 600;
}

/* ---- mailboxes ---- */

.mailboxes {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

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

.mailbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px 0 6px;
}

.mailbox-toggle {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
}

.mailbox-toggle:hover {
  background: var(--bg-hover);
}

.mailbox-address {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* (display names) The sender name after the address: one line, cut short when there is no room. */
.mailbox-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-name {
  overflow-wrap: anywhere;
}

.sender-name-edit {
  align-self: flex-start;
}

.mailbox-meta {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
}

.mailbox-status {
  min-width: 128px;
}

.webmail-slot {
  width: 96px;
}

.webmail-link .icon {
  width: 16px;
  height: 16px;
}

.mailbox.is-open {
  background: var(--bg-app);
}

.mailbox.is-deleting .mailbox-address {
  color: var(--fg-muted);
}

.mailbox:last-child,
.mailbox:last-child.is-open {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.mailbox-details {
  padding: 4px 18px 16px 42px;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.detail dt {
  padding-top: 2px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.detail dd {
  margin: 0;
  min-width: 0;
  font-size: var(--text-sm);
}

.detail .copyable-text {
  padding-top: 6px;
}

.detail dd .copyable {
  margin-top: -6px;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-stack .status {
  white-space: normal;
}

.mailbox-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
  margin-top: 12px;
}

.mailbox-actions p {
  flex: 1 1 auto;
}

.button.is-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.mailboxes-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.mailboxes-empty.is-quiet {
  display: block;
}

/* ---- onboarding (no domains) ---- */

.onboarding {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 24px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.onboarding-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.onboarding-mark .icon {
  width: 24px;
  height: 24px;
}

.onboarding-title {
  font-size: var(--text-xl);
  font-weight: 700;
}

.onboarding-lead {
  color: var(--fg-muted);
}

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 760px;
  margin: 12px 0 8px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.onboarding-step {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.onboarding-step strong {
  display: block;
  color: var(--fg);
  font-weight: 650;
}

.onboarding-step.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.onboarding-step.is-current .step-mark {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.onboarding-step .step-mark {
  flex: 0 0 auto;
}

.onboarding-form {
  width: 100%;
  max-width: 460px;
  text-align: left;
}

.onboarding-plan {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form .text-input {
  flex: 1 1 auto;
}

/* ---- forms and dialogs ---- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}

.field-label {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
}

.onboarding-form .field-label {
  margin-bottom: 6px;
}

.field-hint {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.onboarding-form .field-hint {
  margin-top: 6px;
}

.field-hint.is-problem {
  color: var(--status-bad-fg);
}

.text-input,
.select-input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
}

.text-input:focus,
.select-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

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

.address-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.address-local {
  flex: 1 1 40%;
  min-width: 0;
}

.address-at {
  color: var(--fg-muted);
  font-weight: 600;
}

.address-domain {
  flex: 1 1 60%;
  min-width: 0;
}

.address-preview {
  min-height: 1.45em;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.console-dialog {
  max-width: 520px;
}

.console-dialog .dialog-message p + p {
  margin-top: 8px;
}

.dialog-note {
  margin-top: 12px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.form-error {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--status-bad-bg);
  color: var(--status-bad-fg);
  font-size: var(--text-sm);
}

.form-error .icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.form-error .link-button {
  margin-top: 4px;
}

.console-dialog.is-danger .dialog-title {
  color: var(--fg);
}

/* ---- loading, errors, spinner ---- */

.is-skeleton {
  padding-bottom: 12px;
}

.skeleton-rows {
  padding: 0 18px;
}

.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--fg-muted);
  text-align: center;
}

.boot-icon {
  width: 26px;
  height: 26px;
}

.boot-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
}

.boot-mark .icon {
  width: 26px;
  height: 26px;
}

.sign-in-page {
  min-height: 100vh;
  justify-content: center;
}

.boot-heading {
  color: var(--fg);
  font-size: var(--text-xl);
  font-weight: 650;
}

.boot-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.spinner {
  animation: spin 0.9s linear infinite;
}

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

/* ---- (legal) the links to the Terms of Service and the Privacy Policy, below every view ---- */

.console-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: var(--text-xs);
}

.console-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.console-footer a {
  color: var(--fg-muted);
}

.console-footer a:hover {
  color: var(--fg);
}

/* ---- development: the mock's scenarios ---- */

.mock-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 28px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.mock-scenarios {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mock-scenarios .is-current {
  color: var(--fg);
  font-weight: 700;
}

/* ---- (API keys) the section nav, and the API keys view ---- */

.section-nav {
  border-bottom: 1px solid var(--line);
  background: var(--bg-app);
}

.section-nav-inner {
  display: flex;
  gap: 4px;
  max-width: var(--console-w);
  margin: 0 auto;
  padding: 0 16px;
  overflow-x: auto;
}

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 8px;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.section-link .icon {
  width: 16px;
  height: 16px;
}

.section-link:hover {
  color: var(--fg);
}

.section-link[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--fg);
}

.section-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  border-radius: 4px;
}

.page-lead {
  max-width: 68ch;
  margin: -8px 0 16px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.keys {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.keys-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.keys-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.keys-reloading .icon {
  width: 14px;
  height: 14px;
}

.keys-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
}

.keys-wait {
  color: var(--status-warn-fg);
  font-size: var(--text-sm);
}

.keys-create[aria-disabled="true"] {
  opacity: 0.6;
  cursor: default;
}

.key-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.key {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
}

.key.is-skeleton {
  gap: 10px;
}

.key.is-revoked {
  background: var(--bg-app);
  box-shadow: none;
}

.key.is-revoked .key-label,
.key.is-revoked .key-meta dd {
  color: var(--fg-muted);
}

.key-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.key-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
}

.key-label {
  font-size: var(--text-lg);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.key-label:focus {
  outline: none;
}

.key-label:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-radius: 4px;
}

.key-label-text {
  unicode-bidi: isolate;
}

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

.key-meta-item dt {
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.key-meta-item dd {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.key-prefix {
  white-space: nowrap;
}

.key-scopes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scope-chip {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 600;
}

.scope-chip.is-send {
  background: var(--status-warn-bg);
  color: var(--status-warn-fg);
}

.scope-chip.is-danger {
  background: var(--status-bad-bg);
  color: var(--status-bad-fg);
}

.key.is-revoked .scope-chip {
  background: var(--status-idle-bg);
  color: var(--status-idle-fg);
}

.keys-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--fg-muted);
  text-align: center;
}

.keys-empty p {
  max-width: 52ch;
}

.keys-empty-mark .icon {
  width: 28px;
  height: 28px;
  color: var(--fg-subtle);
}

.keys-empty-title {
  color: var(--fg);
  font-weight: 650;
}

.keys-help {
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.keys-help p + p {
  margin-top: 8px;
}

.keys-help code,
.secret-dialog .dialog-note code {
  overflow-wrap: anywhere;
}

.keys-help-title {
  margin-bottom: 6px;
  color: var(--fg);
  font-size: var(--text-md);
  font-weight: 650;
}

/* the dialogs */

.key-dialog {
  max-width: 640px;
}

.key-dialog .dialog-form {
  max-height: min(70vh, 720px);
  overflow-y: auto;
  margin: 0 -22px;
  padding: 0 22px;
}

/* The form scrolls; its buttons stay in view. */
.key-dialog .dialog-form .dialog-actions {
  position: sticky;
  bottom: 0;
  margin-top: 12px;
  padding: 12px 0 2px;
  background: var(--bg-raised);
  border-top: 1px solid var(--line);
}

.key-fieldset,
.scope-group {
  margin: 16px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.key-fieldset legend {
  margin-bottom: 6px;
  padding: 0;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  font-size: var(--text-sm);
}

.choice > input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.choice-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.choice-note {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.key-mailbox {
  margin-top: 4px;
  max-width: 100%;
}

.key-scopes-field .field-hint {
  margin-top: -2px;
}

.scope-group {
  margin-top: 10px;
  padding: 10px 12px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.scope-group-title {
  padding: 0 4px;
  font-size: var(--text-sm);
  font-weight: 650;
}

.scope-group-note {
  margin: 0 0 4px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.scope-group-note.is-unavailable {
  color: var(--status-warn-fg);
  font-weight: 600;
}

.scope-group.is-unavailable .scope-option,
.scope-group.is-unavailable .scope-option .scope-name {
  color: var(--fg-subtle);
}

.scope-group.is-send {
  border-color: var(--status-warn-shape);
}

.scope-name {
  font-weight: 600;
}

.scope-code {
  color: var(--fg-subtle);
  font-size: var(--text-xs);
  font-weight: 400;
}

.scope-option.is-danger .scope-name {
  color: var(--status-bad-fg);
}

.key-send-warning {
  margin: 4px 0 6px;
}

.key-expiry {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.key-expiry .select-input {
  flex: 0 1 220px;
}

.key-expiry-preview.is-problem {
  color: var(--status-bad-fg);
}

.key-form-problem {
  min-height: 1.45em;
  margin-top: 12px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.secret-dialog .note {
  margin-top: 12px;
}

.secret-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
}

.secret-value {
  flex: 1 1 280px;
  min-width: 0;
  font-size: var(--text-md);
  line-height: 1.5;
  word-break: break-all;
  user-select: all;
}

.secret-copy-state {
  min-height: 1.45em;
  margin-top: 6px;
  color: var(--status-ok-fg);
  font-size: var(--text-sm);
}

.secret-advice {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: var(--text-sm);
}

.secret-advice li + li {
  margin-top: 4px;
}

.secret-summary,
.console-dialog .dialog-form > .detail-list {
  margin-top: 14px;
}

.secret-stored {
  margin-top: 12px;
  font-weight: 600;
}

.lost-keys {
  margin: 12px 0 0;
  padding-left: 20px;
  font-size: var(--text-sm);
}

/* ---- narrower screens ---- */

@media (max-width: 900px) {
  .top-add-domain,
  .top-webmail {
    display: none;
  }

  .narrow-only {
    display: flex !important;
  }

  .menu-separator.narrow-only {
    display: block !important;
  }
}

@media (max-width: 760px) {
  .console {
    padding: 16px 12px 40px;
  }

  .top-bar {
    padding: 0 8px 0 12px;
  }

  .brand-product {
    display: inline;
  }

  .top-add-mailbox {
    width: 36px;
    padding: 0;
  }

  .top-add-mailbox .top-label {
    display: none;
  }

  .page-title {
    font-size: var(--text-xl);
  }

  .domain-head {
    padding: 12px 10px 12px 14px;
  }

  .domain-actions {
    width: 100%;
    margin-left: 0;
  }

  .domain-actions .menu-anchor {
    margin-left: auto;
  }

  .domain-body,
  .setup {
    padding-left: 14px;
    padding-right: 14px;
  }

  /* Records become one card each: label, then value. */
  .records thead {
    display: none;
  }

  .records,
  .records tbody,
  .records tr,
  .records td {
    display: block;
    width: auto;
  }

  .records tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .records tr:last-child {
    border-bottom: 0;
  }

  .records td {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
    padding: 3px 0;
    border: 0;
  }

  .records td::before {
    content: attr(data-label);
    padding-top: 7px;
    color: var(--fg-muted);
    font-size: var(--text-xs);
    font-weight: 650;
  }

  .records td.record-status::before {
    padding-top: 0;
  }

  /* The record's kind heads its card ("TXT · SPF"), without a label. */
  .records td.record-type {
    display: block;
    padding-bottom: 4px;
  }

  .records td.record-type::before {
    content: none;
  }

  .record-type-code,
  .record-purpose {
    display: inline;
    font-size: var(--text-sm);
  }

  .record-purpose {
    color: var(--fg-muted);
  }

  .record-purpose::before {
    content: " · ";
  }

  .record-value .copyable,
  .record-value .record-extra,
  .record-value .record-found {
    grid-column: 2;
  }

  .domain-actions:has(> .menu-anchor:only-child) {
    position: absolute;
    top: 10px;
    right: 8px;
    width: auto;
  }

  .domain {
    position: relative;
  }

  .domain:has(.domain-actions > .menu-anchor:only-child) .domain-title {
    padding-right: 36px;
  }

  .mailbox-row {
    flex-wrap: wrap;
    gap: 0;
    padding: 6px 10px 8px 4px;
  }

  .mailbox-toggle {
    flex-basis: 100%;
  }

  .mailbox-meta {
    flex: 1 1 100%;
    justify-content: space-between;
    padding-left: 32px;
  }

  .mailbox-status {
    min-width: 0;
  }

  .mailbox-details {
    padding: 4px 14px 14px 14px;
  }

  .detail {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .onboarding {
    padding: 28px 16px 24px;
  }

  .onboarding-steps {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
  }

  .address-input {
    flex-wrap: wrap;
  }

  .address-local,
  .address-domain {
    flex-basis: 100%;
  }

  .address-at {
    display: none;
  }

  .console-dialog {
    width: 100vw;
    max-width: none;
    margin: auto 0 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  /* (API keys) */
  .section-nav-inner {
    padding: 0 8px;
  }

  .key {
    padding: 12px 12px 14px 14px;
  }

  .key-head .key-revoke {
    margin-left: auto;
  }

  .key-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .key-dialog .dialog-form {
    max-height: 72vh;
  }
}

@media (max-width: 400px) {
  .brand-product {
    display: none;
  }
}

.mailbox-name,
.sender-name {
  unicode-bidi: isolate;
}

/* ---- (authorized apps) the authorized apps view: the API keys view's cards, with details ---- */

.grant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.grant .key-label.is-unnamed .key-label-text {
  color: var(--fg-muted);
  font-style: italic;
}

.grant-identity {
  margin-top: -6px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.grant-identity code {
  font-size: inherit;
}

.scope-chip.is-sensitive {
  background: var(--status-warn-bg);
  color: var(--status-warn-fg);
}

.grant-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.grant-exact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.grant-exact code,
.grant-details .detail code {
  overflow-wrap: anywhere;
}

.grant-permissions-title {
  font-size: var(--text-sm);
  font-weight: 650;
}

.grant-permissions {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.grant-permission {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 2px 12px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--bg-app);
  font-size: var(--text-sm);
}

.grant-permission-name {
  font-weight: 600;
}

.grant-permission-scope {
  justify-self: end;
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.grant-permission-description {
  grid-column: 1 / -1;
  color: var(--fg-muted);
}

.grant-permission.is-send,
.grant-permission.is-sensitive {
  background: var(--status-warn-bg);
}

.grant-permission.is-danger {
  background: var(--status-bad-bg);
}

.key.is-revoked .grant-permission {
  background: var(--bg-raised);
}

.grant-permission-flag {
  font-weight: 600;
}

.grant-details-note {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.grant-dialog-scopes {
  margin: 0;
  padding-left: 18px;
}

.grant-dialog-scopes .is-sensitive {
  color: var(--status-warn-fg);
}

.grant-dialog-facts code {
  overflow-wrap: anywhere;
  font-size: var(--text-xs);
}

@media (max-width: 760px) {
  .grant-actions {
    width: 100%;
  }

  .grant-actions .grant-revoke {
    margin-left: auto;
  }

  .grant-permission {
    grid-template-columns: minmax(0, 1fr);
  }

  .grant-permission-scope {
    justify-self: start;
  }
}

/* ---- (subscription) the subscription view: the plan as a card, the return from Checkout, Free and Plus ---- */

.subscription {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subscription .banner {
  align-items: center;
}

.subscription .banner p {
  flex: 1;
}

.banner.is-ok {
  background: var(--status-ok-bg);
}

.subscription-confirming .spinner,
.subscription-confirming .icon {
  flex: none;
}

.plan-card .key-note + .key-note {
  margin-top: 8px;
}

.plan-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.plan-card-fineprint {
  margin: 10px 0 0;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.plan-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
  padding: 0;
  list-style: none;
}

.plan-option {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.plan-option.is-current {
  border-color: var(--accent, var(--line));
  box-shadow: inset 0 0 0 1px var(--accent, var(--line));
}

.plan-option-name {
  margin: 0;
  color: var(--fg);
  font-weight: 650;
}

.plan-option-price {
  color: var(--fg-muted);
  font-weight: 400;
}

.plan-option-limits {
  margin: 4px 0 0;
}

.plan-line .plan-name a {
  color: inherit;
}
