/* mail-panel UI. Light theme by default, dark via prefers-color-scheme. No inline styles anywhere (strict CSP). */

:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --surface-hover: #f2f4f8;
  --border: #e6e8ef;
  --border-strong: #d6d9e2;
  --text: #1f2430;
  --text-2: #3f4655;
  --muted: #6b7280;
  --faint: #9aa1ad;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-soft-hover: #e0e7ff;
  --primary-text: #4338ca;
  --on-primary: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --success-text: #15803d;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --warning-border: #fcd34d;
  --warning-text: #92400e;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fee2e2;
  --danger-text: #b91c1c;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --info-text: #0369a1;
  --neutral-soft: #f1f3f7;
  --neutral-text: #4b5563;
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.28);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.28);
  --backdrop: rgba(17, 20, 32, 0.48);
  --skeleton: #eceef3;
  --skeleton-shine: #f6f7fa;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Cascadia Code", Consolas, "Liberation Mono", "PingFang SC", "Microsoft YaHei", monospace;
  --sidebar-w: 248px;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1b1f2a;
    --surface-hover: #212634;
    --border: #272c39;
    --border-strong: #353b4b;
    --text: #e7e9ef;
    --text-2: #c5cad6;
    --muted: #9aa1b1;
    --faint: #6c7486;
    --primary: #6366f1;
    --primary-hover: #7477f5;
    --primary-soft: rgba(99, 102, 241, 0.16);
    --primary-soft-hover: rgba(99, 102, 241, 0.26);
    --primary-text: #a5b4fc;
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.14);
    --success-text: #4ade80;
    --warning: #d97706;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(245, 158, 11, 0.35);
    --warning-text: #fbbf24;
    --danger: #dc2626;
    --danger-hover: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.14);
    --danger-text: #f87171;
    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, 0.12);
    --info-text: #7dd3fc;
    --neutral-soft: #232836;
    --neutral-text: #aab1c0;
    --ring: 0 0 0 3px rgba(129, 140, 248, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.65);
    --backdrop: rgba(3, 5, 10, 0.66);
    --skeleton: #222734;
    --skeleton-shine: #2b3141;
  }
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, ol, ul, dl, dd {
  margin: 0;
}

a {
  color: var(--primary-text);
  text-decoration: none;
}

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

[hidden] {
  display: none !important;
}

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

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

.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }
.text-neutral { color: var(--muted); }
.spacer { flex: 1 1 auto; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.inline-code {
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--neutral-soft);
  color: var(--text-2);
  white-space: nowrap;
}

.link {
  font-weight: 500;
  margin-left: 8px;
}
.link:hover { text-decoration: underline; }

.noscript {
  margin: 40px auto;
  max-width: 420px;
  text-align: center;
}

.boot,
.page-loading {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}
.boot { min-height: 100vh; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn:disabled:active { transform: none; }
.btn.is-busy { opacity: 0.8; cursor: progress; }
.btn.is-busy > .icon { display: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); box-shadow: none; }
.btn-soft:hover { background: var(--primary-soft-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger-text); box-shadow: none; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-danger-outline { color: var(--danger-text); }
.btn-danger-outline:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--border-strong)); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(0.94); }

.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; gap: 6px; }
.btn-sm:not(:has(.btn-label)) { width: 36px; padding: 0; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { height: 40px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 22px; height: 22px; border-width: 2.5px; color: var(--primary); }

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

/* ---------- form controls ---------- */

.input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-sm { height: 36px; font-size: 14px; }
.input-mono { font-family: var(--mono); font-size: 14px; }
.input-code { font-family: var(--mono); font-size: 18px; letter-spacing: 0.35em; height: 40px; }
.input-code::placeholder { font-family: var(--font); font-size: 15px; letter-spacing: normal; }

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

.textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  line-height: 1.65;
  resize: vertical;
}
.textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.textarea-mono { font-family: var(--mono); font-size: 13px; }

.input-group { position: relative; }
.input-group .input { padding-right: 44px; }
.input-addon {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.input-addon:hover { color: var(--text); background: var(--surface-hover); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--muted); line-height: 1.5; }
.field-error { font-size: 13px; color: var(--danger-text); }

.form { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.pp-hints { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.pp-hint { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.pp-hint .icon { width: 15px; height: 15px; }
.pp-ok { color: var(--success-text); }
.pp-bad { color: var(--danger-text); }

/* ---------- badges, chips, tags ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--neutral-text);
}
.badge .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  padding: 0 4px 0 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
}
.chip-x {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}
.chip-x .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.chip-x:hover:not(:disabled) { opacity: 1; background: var(--primary-soft-hover); }
.chip-x:disabled { opacity: 0.3; cursor: not-allowed; }
.chip-x.is-busy > .icon { display: none; }
.chip-x .spinner { width: 11px; height: 11px; }

/* ---------- cards, notes, empty, skeleton ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 22px 24px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-title { font-size: 16px; font-weight: 650; }
.section-sub { font-size: 13.5px; color: var(--muted); }

.note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.55;
  background: var(--info-soft);
  color: var(--info-text);
}
.note-icon { width: 17px; height: 17px; margin-top: 2px; }
.note-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--text-2); }
.note-body strong { color: var(--text); }
.note-extra { color: var(--muted); font-size: 13px; }
.note-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.note-warning { background: var(--warning-soft); color: var(--warning); }
.note-danger { background: var(--danger-soft); color: var(--danger-text); }
.note-success { background: var(--success-soft); color: var(--success-text); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary-text);
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty-icon.tone-danger { background: var(--danger-soft); color: var(--danger-text); }
.empty-text { max-width: 380px; }

.skeleton {
  display: block;
  height: 12px;
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-shine) 50%, var(--skeleton) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton-lg { height: 26px; }
.skeleton-pill { height: 22px; border-radius: 999px; }
.skeleton-btn { height: 36px; width: 72px; border-radius: var(--radius-sm); margin-left: auto; }
.w-40 { width: 40%; }
.w-50 { width: 50%; }
.w-60 { width: 60%; }
.w-70 { width: 70%; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* ---------- toasts ---------- */

/* below the top layer on purpose: an open modal dialog always covers the toasts, never the other way round */
.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.22s ease-out;
}
.toast.is-leaving { animation: toast-out 0.2s ease-in forwards; }
.toast-icon { width: 19px; height: 19px; margin-top: 1px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }
.toast-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.toast-text { flex: 1; font-size: 14px; line-height: 1.5; color: var(--text); }
.toast-close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.toast-close .icon { width: 15px; height: 15px; }
.toast-close:hover { color: var(--text); background: var(--surface-hover); }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- dialogs ---------- */

.dialog {
  padding: 0;
  width: calc(100vw - 32px);
  max-width: 560px;
  max-height: calc(100vh - 48px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; animation: dialog-in 0.18s ease-out; }
.dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); animation: fade-in 0.18s ease-out; }
.dialog-sm { max-width: 460px; }
.dialog-lg { max-width: 680px; }

.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 0 24px; }
.dialog-titles { flex: 1; min-width: 0; padding-top: 4px; }
.dialog-title { font-size: 17px; font-weight: 650; line-height: 1.4; word-break: break-word; }
.dialog-desc { margin-top: 4px; font-size: 14px; color: var(--muted); }
.dialog-x { margin: -2px -4px 0 0; }
.dialog-body { display: flex; flex-direction: column; gap: 16px; padding: 18px 24px 22px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.dialog-text { color: var(--text-2); }
.dialog-lead { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.dialog-lead .icon { width: 16px; height: 16px; color: var(--primary); }

@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }

.mini-steps { padding-left: 22px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }

.result-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.result {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.result-icon { width: 20px; height: 20px; margin-top: 1px; }
.result-ok .result-icon { color: var(--success); }
.result-bad { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); background: var(--danger-soft); }
.result-bad .result-icon { color: var(--danger); }
.result-note .result-icon { color: var(--warning); }
.result-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.result-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.result-text { color: var(--text-2); font-size: 14px; line-height: 1.6; word-break: break-word; }

.tech { font-size: 13px; color: var(--muted); }
.tech summary { cursor: pointer; width: fit-content; }
.tech-pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--neutral-soft);
  font: 12.5px/1.55 var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--neutral-soft);
  align-self: flex-start;
}
.seg {
  height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.seg:hover { color: var(--text); }
.seg[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab-panel { display: flex; flex-direction: column; gap: 12px; }
.tab-help { font-size: 13.5px; color: var(--muted); }
.copy-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.copy-status { font-size: 13px; color: var(--success-text); }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.choice:hover { background: var(--surface-hover); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); flex: none; }
.choice-body { display: flex; flex-direction: column; min-width: 0; }
.choice-name { font-weight: 600; }
.choice-id { font-size: 12.5px; color: var(--muted); word-break: break-all; }

.help { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.help-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary-text);
  cursor: pointer;
  list-style: none;
}
.help-summary::-webkit-details-marker { display: none; }
.help-chevron { margin-left: auto; transition: transform 0.15s; color: var(--muted); }
.help[open] .help-chevron { transform: rotate(180deg); }
.help-body { display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 16px; font-size: 14px; color: var(--text-2); }
.help-steps { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.perm-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.perm {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--border);
}
.perm-scope { font-size: 12px; color: var(--muted); }
.perm-name { font-weight: 500; color: var(--text); }
.perm-level { font-size: 12.5px; font-weight: 600; color: var(--primary-text); }

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

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar { border-right: 1px solid var(--border); background: var(--surface); }
.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 14px 16px;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 18px; color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #6d6af7 0%, #4f46e5 55%, #4338ca 100%);
  color: #fff;
  box-shadow: 0 4px 10px -2px rgba(79, 70, 229, 0.45);
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; }
.brand-mark-lg .icon { width: 28px; height: 28px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 15px; font-weight: 650; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.nav-item .icon { color: var(--muted); transition: color 0.15s; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav-item[aria-current="page"] .icon { color: var(--primary-text); }
.nav-item.is-busy > .icon { display: none; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.hub-info { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px 6px; min-width: 0; }
.hub-label { font-size: 12px; color: var(--muted); }
.hub-host { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-logout { width: 100%; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.tabbar { display: none; }
.main { flex: 1; }
.main-inner { width: 100%; max-width: 1180px; margin: 0 auto; padding: 30px 36px 56px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-heading { min-width: 0; }
.page-title { font-size: 25px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.page-sub { margin-top: 4px; color: var(--muted); font-size: 14.5px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page { display: flex; flex-direction: column; gap: 20px; }

.sync-btn.has-dot::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid var(--bg);
}

.health {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s;
}
.health:hover { background: var(--surface-hover); }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.health-ok .health-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.health-down .health-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.health-checking .health-dot { animation: pulse 1s ease-in-out infinite; }
.health-label { color: var(--muted); }
.health-word { font-weight: 600; color: var(--text); }
.health-ok .health-word { color: var(--success-text); }
.health-down .health-word { color: var(--danger-text); }
.health-ms { color: var(--faint); font-size: 12.5px; }

@keyframes pulse { 50% { opacity: 0.35; } }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  background: var(--warning-soft);
  color: var(--warning-text);
}
.banner-icon { width: 20px; height: 20px; color: var(--warning); }
.banner-text { flex: 1; font-size: 14.5px; font-weight: 500; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar-text { color: var(--muted); font-size: 14px; }
.toolbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }

.search { position: relative; flex: 0 1 320px; min-width: 200px; }
.search-icon { position: absolute; left: 12px; top: 11px; color: var(--faint); pointer-events: none; }
.input-search { padding-left: 38px; }

.notices { display: flex; flex-direction: column; gap: 10px; }
.notices:empty { display: none; }

/* ---------- overview ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px 18px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.stat-label { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stat-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; }
.stat-icon .icon { width: 18px; height: 18px; }
.tone-primary { background: var(--primary-soft); color: var(--primary-text); }
.tone-success { background: var(--success-soft); color: var(--success-text); }
.tone-info { background: var(--info-soft); color: var(--info-text); }
.tone-danger { background: var(--danger-soft); color: var(--danger-text); }
.tone-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; min-height: 36px; display: flex; align-items: center; }
.stat-total { font-size: 18px; font-weight: 500; color: var(--faint); margin-left: 2px; }
.stat-sub { font-size: 13px; color: var(--muted); min-height: 21px; overflow: hidden; text-overflow: ellipsis; }
.stat-progress { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.health-word.text-success { color: var(--success-text); }
.health-word.text-danger { color: var(--danger-text); }
.stat .health-word { font-size: 26px; }

.progress { display: block; height: 6px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.progress-bar { display: block; height: 100%; border-radius: inherit; background: var(--success); transition: width 0.3s ease; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.howto { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.howto-item { display: flex; gap: 14px; }
.howto-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 14px;
  font-weight: 700;
}
.howto-title { font-weight: 600; margin-bottom: 2px; }
.howto-text { color: var(--text-2); font-size: 14px; }

.quick-list { display: flex; flex-direction: column; gap: 4px; margin: 0 -10px; }
.quick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}
.quick-item:hover { background: var(--surface-hover); }
.quick-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--neutral-soft); color: var(--text-2); }
.quick-item:hover .quick-icon { background: var(--primary-soft); color: var(--primary-text); }
.quick-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.quick-title { font-weight: 600; font-size: 14.5px; }
.quick-desc { font-size: 13px; color: var(--muted); }
.quick-arrow { color: var(--faint); width: 16px; height: 16px; }
.quick-item.is-busy > .quick-icon { display: none; }
.quick-item > .spinner { width: 18px; height: 18px; margin: 0 9px; color: var(--primary); }

/* ---------- assistants ---------- */

.grid-assistants { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.a-card { display: flex; flex-direction: column; }
.a-head { display: flex; align-items: center; gap: 14px; padding: 20px 20px 16px; }
.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
}
.av-0 { background: #eef2ff; color: #4338ca; }
.av-1 { background: #ecfdf5; color: #047857; }
.av-2 { background: #fff7ed; color: #c2410c; }
.av-3 { background: #fdf2f8; color: #be185d; }
.av-4 { background: #f0f9ff; color: #0369a1; }
.av-5 { background: #f5f3ff; color: #6d28d9; }
.a-title { min-width: 0; }
.a-name { font-size: 17px; font-weight: 650; line-height: 1.3; }
.a-key { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 13px; color: var(--muted); }
.a-key .icon { width: 14px; height: 14px; }
.a-key code { color: var(--text-2); letter-spacing: 0.04em; }
.a-section { display: flex; flex-direction: column; gap: 10px; padding: 0 20px 18px; flex: 1; }
.a-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.prefix-add { display: flex; gap: 8px; }
.prefix-add .input { flex: 1; min-width: 0; }
.a-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- domains ---------- */

.dtable { overflow: hidden; }
.drow {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.8fr) minmax(0, 0.85fr) minmax(0, 1.75fr) 150px;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  min-height: 60px;
  border-top: 1px solid var(--border);
  transition: background-color 0.15s, opacity 0.2s;
}
.drow:hover:not(.dhead) { background: var(--surface-2); }
.dhead { min-height: 44px; border-top: 0; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dcell { min-width: 0; padding: 10px 0; }
.dcell-domain { display: flex; flex-direction: column; gap: 1px; }
.domain-name { font-weight: 600; word-break: break-all; }
.domain-sub { font-size: 12.5px; color: var(--warning-text); }
.dcell-action { display: flex; justify-content: flex-end; }
.cell-note { font-size: 13px; color: var(--faint); text-align: right; }
.dest { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dest-text { font-size: 14px; color: var(--text-2); word-break: break-word; }
.dest-text.muted { color: var(--muted); font-size: 13px; }
.drow.is-stale { opacity: 0.55; }
.drow-error { display: block; padding: 0 20px; background: var(--danger-soft); }
.drow-error:hover { background: var(--danger-soft) !important; }
.dcell-full { display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.drow-error-text { flex: 1; display: flex; flex-direction: column; font-size: 14px; color: var(--text-2); min-width: 0; }
.drow-error-text strong { color: var(--danger-text); }
.dtable .empty { border-top: 1px solid var(--border); }

/* ---------- accounts ---------- */

.grid-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); gap: 16px; align-items: start; }
.acct { display: flex; flex-direction: column; transition: opacity 0.2s; }
.acct.is-stale .acct-body { opacity: 0.55; }
.acct-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px 14px; }
.acct-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 11px; background: var(--info-soft); color: var(--info-text); }
.acct-icon.is-hub { background: var(--primary-soft); color: var(--primary-text); }
.acct-icon .icon { width: 21px; height: 21px; }
.acct-title { flex: 1; min-width: 0; }
.acct-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-name { font-size: 17px; font-weight: 650; line-height: 1.3; word-break: break-all; }
.acct-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-token { font-size: 12.5px; color: var(--muted); white-space: nowrap; align-self: flex-start; margin-top: 4px; }
.acct-body { display: flex; flex-direction: column; gap: 12px; padding: 0 20px 18px; flex: 1; transition: opacity 0.2s; }
.acct-skel { display: flex; flex-direction: column; gap: 14px; padding: 6px 0 4px; }
.kv-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; }
.kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.kv:first-child { border-top: 0; }
.kv-label { font-size: 13px; color: var(--muted); padding-top: 2px; }
.kv-value { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 14px; min-width: 0; }
.kv-note { font-size: 13px; color: var(--muted); }
.kv-note.text-warning { color: var(--warning-text); }
.kv-note.text-danger { color: var(--danger-text); }
.addr-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; width: 100%; }
.addr { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.addr-email { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.acct-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.foot-note { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 13px; color: var(--muted); }
.foot-note .icon { width: 15px; height: 15px; }

/* ---------- settings ---------- */

.settings-section { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 32px; padding: 26px 28px; }
.settings-side { display: flex; flex-direction: column; gap: 6px; }
.settings-icon { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 6px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-text); }
.settings-title { font-size: 16px; font-weight: 650; }
.settings-desc { font-size: 14px; color: var(--muted); }
.settings-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.section-foot { display: flex; justify-content: flex-end; padding-top: 4px; }
.row-actions { display: flex; }
.email-list { display: flex; flex-direction: column; gap: 10px; }
.email-row { display: flex; align-items: center; gap: 8px; position: relative; }
.email-row .input { padding-left: 38px; }
.email-icon { position: absolute; left: 12px; top: 11px; color: var(--faint); pointer-events: none; }
.sec-list { display: flex; flex-direction: column; }
.sec-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.sec-row:first-child { border-top: 0; padding-top: 2px; }
.sec-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--neutral-soft); color: var(--text-2); }
.sec-text { flex: 1; min-width: 0; }
.sec-title { font-weight: 600; }
.sec-desc { font-size: 13.5px; color: var(--muted); }

/* ---------- login and setup ---------- */

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(700px 420px at 105% 105%, rgba(16, 185, 129, 0.1), transparent 60%),
    var(--bg);
}
.auth-inner { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px; display: flex; flex-direction: column; gap: 20px; box-shadow: var(--shadow-md); }
.auth-card-wide { max-width: 620px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth-brand .brand-mark { margin-bottom: 4px; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.auth-sub { color: var(--muted); font-size: 14.5px; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-form .btn-lg { margin-top: 4px; }
.auth-foot { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-foot .icon { width: 14px; height: 14px; }
.auth-actions { display: flex; justify-content: center; }
.fatal { align-items: center; text-align: center; }

.setup-form { display: flex; flex-direction: column; gap: 4px; }
.setup-step { display: flex; gap: 16px; padding: 18px 0; border-top: 1px solid var(--border); }
.setup-step:first-child { border-top: 0; padding-top: 4px; }
.step-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.step-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.step-title { font-size: 16px; font-weight: 650; padding-top: 2px; }
.step-text { font-size: 14px; color: var(--text-2); }
.setup-form > .note { margin: 4px 0 8px; }
.setup-form > .btn-lg { margin-top: 10px; }
.qr-row { display: flex; gap: 20px; align-items: flex-start; }
.qr-box {
  display: grid;
  place-items: center;
  width: 188px;
  height: 188px;
  flex: none;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.qr-img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.qr-skel { width: 100%; height: 100%; border-radius: 6px; }
.qr-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.qr-help { font-size: 13.5px; color: var(--muted); }
.secret-box { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.secret {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--neutral-soft);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.7;
  word-spacing: 0.2em;
  word-break: break-word;
}
.only-mobile { display: none; }

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

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-section { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

@media (max-width: 1040px) {
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .drow { grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 0.9fr) minmax(0, 1.4fr) 136px; gap: 12px; }
}

@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 56px;
    padding: 0 10px 0 16px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
  }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .topbar .brand-mark .icon { width: 17px; height: 17px; }
  .topbar .brand-sub { display: none; }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
  }
  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    position: relative;
  }
  .tab-item .icon { width: 22px; height: 22px; }
  .tab-item[aria-current="page"] { color: var(--primary-text); }
  .tab-item[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--primary);
  }
  .main-inner { padding: 20px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 18px; gap: 14px; }
  .page-title { font-size: 22px; }
  .page-sub { font-size: 14px; }
  .page-actions { width: 100%; }
  .page-actions .sync-btn { margin-left: auto; }
  .toasts { left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); }

  .dtable { background: transparent; border: 0; box-shadow: none; overflow: visible; display: flex; flex-direction: column; gap: 12px; }
  .drow.dhead { display: none; }
  .drow {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 14px 16px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .drow:hover:not(.dhead) { background: var(--surface); }
  .dcell { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; }
  .dcell[data-label]::before { content: attr(data-label); flex: none; font-size: 13px; color: var(--muted); }
  .dcell[data-label] > * { text-align: right; justify-content: flex-end; }
  .dcell[data-label] { align-items: flex-start; }
  .dcell[data-label]::before { padding-top: 2px; }
  .dest { flex-direction: column; align-items: flex-end; gap: 4px; }
  .dcell-domain { display: flex; flex-direction: column; align-items: flex-start; padding: 0 0 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
  .domain-name { font-size: 16px; }
  .dcell-action { padding: 10px 0 0; }
  .dcell-action .btn { width: 100%; height: 40px; }
  .dcell-action .btn-ghost { border-color: var(--border-strong); background: var(--surface); }
  .dcell-action .cell-note { width: 100%; text-align: center; }
  .dcell-action .skeleton-btn { width: 100%; height: 40px; }
  .drow-error { padding: 4px 16px; border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
  .dcell-full { flex-wrap: wrap; }
  .dtable .empty { border: 1px dashed var(--border-strong); border-radius: var(--radius); }
  .search { flex: 1 1 100%; }
  .search + .toolbar-actions { margin-left: 0; width: 100%; justify-content: space-between; }
}

@media (max-width: 600px) {
  body { font-size: 15px; }
  .stats { gap: 12px; }
  .stat { padding: 14px 14px 16px; }
  .stat-icon { width: 30px; height: 30px; }
  .stat-value { font-size: 26px; min-height: 32px; }
  .stat .health-word { font-size: 22px; }
  .card-pad { padding: 18px 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-section { padding: 20px 16px; }
  .sec-row { flex-wrap: wrap; row-gap: 10px; }
  .sec-text { flex: 1 1 200px; }
  .sec-row .btn { margin-left: 50px; }
  .banner { flex-wrap: wrap; padding: 12px 14px; }
  .banner .btn { width: 100%; }
  .kv { grid-template-columns: 76px minmax(0, 1fr); padding: 10px 12px; }
  .acct-head { padding: 16px 16px 12px; }
  .acct-body { padding: 0 16px 16px; }
  .acct-token { display: none; }
  .acct-foot .foot-note { order: -1; width: 100%; padding: 2px 4px 6px; }
  .a-head { padding: 16px 16px 14px; }
  .a-section { padding: 0 16px 16px; }

  .dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
  }
  .dialog[open] { animation: sheet-in 0.22s ease-out; }
  .dialog-head { padding: 18px 14px 0 18px; }
  .dialog-body { padding: 16px 18px 20px; }
  .dialog-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .dialog-foot > .btn { flex: 1; }
  .copy-row .btn { width: 100%; }
  .copy-status:empty { display: none; }

  .auth { align-items: flex-start; padding: 24px 12px; }
  .auth-card { padding: 24px 18px; }
  .qr-row { flex-direction: column; align-items: center; }
  .qr-side { width: 100%; }
  .only-mobile { display: inline-flex; }
  .only-mobile[hidden] { display: none; }
  .setup-step { gap: 12px; }
}

@keyframes sheet-in { from { transform: translateY(24px); opacity: 0.6; } }

@media (prefers-color-scheme: dark) {
  .av-0 { background: rgba(99, 102, 241, 0.18); color: #a5b4fc; }
  .av-1 { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
  .av-2 { background: rgba(249, 115, 22, 0.16); color: #fdba74; }
  .av-3 { background: rgba(236, 72, 153, 0.16); color: #f9a8d4; }
  .av-4 { background: rgba(14, 165, 233, 0.16); color: #7dd3fc; }
  .av-5 { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
  .brand-mark { box-shadow: 0 4px 14px -2px rgba(99, 102, 241, 0.5); }
  .auth {
    background:
      radial-gradient(900px 500px at 12% -8%, rgba(99, 102, 241, 0.2), transparent 60%),
      radial-gradient(700px 420px at 105% 105%, rgba(16, 185, 129, 0.08), transparent 60%),
      var(--bg);
  }
}

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