/* WireShock — single stylesheet. Light/dark via [data-theme], density via [data-density]. */

:root {
  --bg: #ffffff;
  --surface: #f6f7fb;
  --surface-2: #eef0f6;
  --raised: #ffffff;
  --border: #e6e8f0;
  --border-strong: #d6d9e4;
  --text: #0f1222;
  --text-2: #2c3145;
  --muted: #5b6275;
  --faint: #8a90a2;
  --accent: #6d5cff;
  --accent-hover: #5b4bf0;
  --accent-text: #5b4bf0;
  --accent-soft: rgba(109, 92, 255, 0.09);
  --accent-softer: rgba(109, 92, 255, 0.05);
  --on-accent: #ffffff;
  --blue: #3b82f6;
  --spark: #ffd23f;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #e5484d;
  --warning-soft: #fff6e5;
  --danger-soft: #fdecec;
  --success-soft: #e9f7ee;
  --inverse: #161922;
  --on-inverse: #eceef5;
  --shadow-sm: 0 1px 2px rgba(15, 18, 34, 0.06), 0 1px 1px rgba(15, 18, 34, 0.03);
  --shadow-md: 0 4px 14px rgba(15, 18, 34, 0.08), 0 1px 3px rgba(15, 18, 34, 0.05);
  --shadow-lg: 0 18px 48px rgba(15, 18, 34, 0.16), 0 4px 12px rgba(15, 18, 34, 0.06);
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --row-h: 92px;
  --head-h: 48px;
  --side-w: 252px;
  --list-w: 400px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e1016;
  --surface: #13161e;
  --surface-2: #1b1f2a;
  --raised: #161922;
  --border: #252a36;
  --border-strong: #323848;
  --text: #eceef5;
  --text-2: #cfd3e0;
  --muted: #9aa1b5;
  --faint: #6f768a;
  --accent: #7a6bff;
  --accent-hover: #8b7dff;
  --accent-text: #a79dff;
  --accent-soft: rgba(122, 107, 255, 0.16);
  --accent-softer: rgba(122, 107, 255, 0.08);
  --warning-soft: rgba(217, 119, 6, 0.14);
  --danger-soft: rgba(229, 72, 77, 0.14);
  --success-soft: rgba(22, 163, 74, 0.14);
  --inverse: #eceef5;
  --on-inverse: #0f1222;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[data-density="compact"] {
  --row-h: 64px;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
}

::selection {
  background: rgba(109, 92, 255, 0.24);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: var(--accent-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

button {
  font: inherit;
  color: inherit;
}

kbd {
  font: 600 11px/1 var(--font);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  background: var(--raised);
  color: var(--muted);
}

code {
  font: 13px/1.4 var(--mono);
}

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

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

/* ----------------------------------------------------------------- icons */
.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-raw {
  width: 18px;
  height: 18px;
  flex: none;
}

/* ------------------------------------------------------------- boot/splash */
.boot,
.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.boot-logo,
.splash-logo {
  width: 56px;
  height: 56px;
  animation: pulse 1.6s var(--ease) infinite;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.94);
    opacity: 0.75;
  }
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font-weight: 560;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(91, 75, 240, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}
.btn.danger:hover {
  background: var(--danger-soft);
}
.btn.sm {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  gap: 6px;
}
.btn.sm .i {
  width: 16px;
  height: 16px;
}
.btn.lg {
  height: 46px;
  font-size: 15px;
  padding: 0 18px;
}
.btn.block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  background: transparent;
}
.icon-btn.active {
  color: var(--accent-text);
  background: var(--accent-soft);
}
.icon-btn.sm {
  width: 30px;
  height: 30px;
}
.icon-btn.sm .i {
  width: 16px;
  height: 16px;
}
.spin .i,
.i.spin,
.ptr-icon.spin {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-text);
  font-weight: 560;
  cursor: pointer;
  text-decoration: none;
}
.link:hover {
  text-decoration: underline;
}
.link.sm {
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 540;
  color: var(--text-2);
}
.chip.draft {
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  background: var(--danger-soft);
  color: var(--danger);
}
.chip.warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
  display: inline-block;
}

.avatar {
  --h: 250;
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: hsl(var(--h) 55% 34%);
  background: hsl(var(--h) 70% 93%);
  user-select: none;
}
[data-theme="dark"] .avatar {
  color: hsl(var(--h) 75% 82%);
  background: hsl(var(--h) 30% 22%);
}

/* ------------------------------------------------------------------- form */
.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 560;
  color: var(--text-2);
}
.field em {
  font-style: normal;
  font-weight: 450;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="datetime-local"],
select,
textarea {
  font: 15px/1.3 var(--font);
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  height: 42px;
  padding: 0 12px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a90a2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  width: auto;
  min-width: 140px;
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 520;
  margin-top: 12px;
}
.form-error .i {
  margin-top: 1px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r);
  background: var(--surface-2);
}
.seg button {
  border: 0;
  background: transparent;
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 560;
  color: var(--muted);
  cursor: pointer;
}
.seg button.on {
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.switch {
  appearance: none;
  width: 42px;
  height: 25px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background 0.2s var(--ease);
  margin: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.22s var(--ease);
}
.switch:checked {
  background: var(--accent);
}
.switch:checked::after {
  transform: translateX(17px);
}

/* ------------------------------------------------------------------ shell */
.app {
  display: grid;
  grid-template-columns: var(--side-w) var(--list-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-left: var(--sal);
  padding-right: var(--sar);
}
.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--r);
}
.skip-link:focus {
  top: 12px;
}
.pane {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.settings.pane,
.onboard.pane {
  grid-column: 2 / -1;
}
.scrim {
  display: none;
}

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--sat);
}
.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 10px 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand-logo {
  width: 28px;
  height: 28px;
}
.compose-btn {
  margin: 6px 14px 10px;
  height: 42px;
  justify-content: flex-start;
  padding: 0 14px;
}
.compose-btn span {
  flex: 1;
  text-align: left;
}
.compose-btn kbd {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}
.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
}
.nav-group {
  padding: 6px 0;
}
.nav-group + .nav-group {
  margin-top: 4px;
}
.nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 520;
  font-size: 14px;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item .i {
  color: var(--muted);
}
.nav-item:hover {
  background: var(--surface-2);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-item.active .i {
  color: var(--accent-text);
}
.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-count {
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.nav-count.muted {
  color: var(--faint);
  font-weight: 520;
}
.nav-item.active .nav-count {
  color: var(--accent-text);
}
.acc-nav {
  position: relative;
}
.nav-item.acc {
  padding-right: 36px;
}
.nav-item.acc .dot {
  width: 10px;
  height: 10px;
  margin: 0 4px;
}
.acc-nav > .chev {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  color: var(--faint);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.acc-nav > .chev:hover {
  background: var(--border);
  color: var(--text);
}
.chev .i {
  width: 15px;
  height: 15px;
  transition: transform 0.2s var(--ease);
}
.acc-nav > .chev.open .i {
  transform: rotate(90deg);
}
.chev.open .i {
  transform: rotate(180deg);
}
.warn-ic {
  color: var(--warning);
  display: inline-flex;
}
.warn-ic .i {
  color: var(--warning);
  width: 15px;
  height: 15px;
}
.folder-list {
  padding: 2px 0 4px;
}
.nav-item.folder {
  height: 32px;
  font-size: 13.5px;
  padding-left: calc(32px + var(--depth, 0) * 14px);
}
.nav-item.folder .i {
  width: 16px;
  height: 16px;
}
.side-foot {
  border-top: 1px solid var(--border);
  padding: 8px 10px calc(8px + var(--sab));
}
.sync-state {
  padding: 6px 10px 2px;
  font-size: 12px;
  color: var(--faint);
}
.sync-state .state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sync-state .i {
  width: 13px;
  height: 13px;
}
.sync-state .ok .i {
  color: var(--success);
}
.sync-state .off {
  color: var(--warning);
}
.sync-state .demo .i {
  color: var(--accent-text);
}

/* -------------------------------------------------------------- list pane */
.list-pane {
  border-right: 1px solid var(--border);
  background: var(--bg);
  position: relative;
}
.list-head {
  padding: calc(14px + var(--sat)) 16px 10px 20px;
  flex: none;
}
.list-head-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}
.list-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.list-title h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.025em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-sub {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.search {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 6px 0 12px;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--faint);
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.search:focus-within {
  background: var(--raised);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input {
  border: 0;
  background: transparent;
  height: 100%;
  padding: 0;
  font-size: 14px;
  box-shadow: none !important;
  min-width: 0;
}
.search input::-webkit-search-cancel-button {
  display: none;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: var(--r);
  font-size: 13px;
  line-height: 1.35;
  flex: none;
}
.banner span {
  flex: 1;
}
.banner.offline {
  background: var(--surface-2);
  color: var(--text-2);
}
.banner.warn {
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 70%, var(--text));
}
.banner.warn .i {
  color: var(--warning);
}

.local-drafts {
  margin: 0 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  flex: none;
}
.ld-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
}
.ld-head .i {
  width: 14px;
  height: 14px;
}
.ld-item {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-right: 6px;
}
.ld-open {
  flex: 1;
  min-width: 0;
  display: grid;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.ld-open:hover {
  background: var(--accent-softer);
}
.ld-subj {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ld-to {
  font-size: 12.5px;
  color: var(--muted);
}

.ptr {
  height: 0;
  flex: none;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--faint);
  transition: height 0.2s var(--ease);
}
.ptr.armed {
  color: var(--accent-text);
}
.scroller {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  position: relative;
  contain: strict;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(88px + var(--sab));
}
.scroller:focus {
  outline: none;
}
.vlist {
  position: relative;
  width: 100%;
}
.list-foot {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

.sec-head {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--head-h);
  display: flex;
  align-items: flex-end;
  padding: 0 12px 6px 12px;
  gap: 6px;
}
.sec-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
}
.sec-toggle:hover {
  background: var(--surface);
}
.sec-ic {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
}
.sec-ic .i {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}
.sec-0 {
  background: color-mix(in srgb, var(--spark) 28%, transparent);
  color: #8a6400;
}
[data-theme="dark"] .sec-0 {
  color: var(--spark);
}
.sec-1 {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.sec-2 {
  background: color-mix(in srgb, #f59e0b 16%, transparent);
  color: #b45309;
}
.sec-3 {
  background: color-mix(in srgb, #14b8a6 16%, transparent);
  color: #0f766e;
}
[data-theme="dark"] .sec-2 {
  color: #fbbf24;
}
[data-theme="dark"] .sec-3 {
  color: #2dd4bf;
}
.sec-label {
  font-weight: 650;
  font-size: 13.5px;
  color: var(--text);
}
.sec-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.sec-preview {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sec-chev {
  margin-left: auto;
  color: var(--faint);
  display: grid;
}
.sec-chev .i {
  width: 15px;
  height: 15px;
  transition: transform 0.2s var(--ease);
}
.sec-head.collapsed .sec-chev .i {
  transform: rotate(-90deg);
}
.sec-markall {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
  cursor: pointer;
  margin-bottom: 2px;
  white-space: nowrap;
}
.sec-markall .i {
  width: 14px;
  height: 14px;
}
.sec-markall:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.row-wrap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--row-h);
  overflow: hidden;
  contain: layout paint;
}
.row {
  position: relative;
  display: flex;
  gap: 12px;
  height: 100%;
  padding: 13px 16px 0 22px;
  background: var(--bg);
  color: inherit;
  text-decoration: none;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  border-radius: 0;
  transition: background 0.12s;
}
.row::after {
  content: "";
  position: absolute;
  left: 74px;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border);
  opacity: 0.7;
}
.row:hover {
  background: var(--surface);
}
.row.open {
  background: var(--accent-soft);
}
.row.open::after {
  opacity: 0;
}
.row:focus-visible {
  outline-offset: -2px;
  border-radius: var(--r-sm);
}
.row.settle {
  transition: transform 0.28s var(--ease), background 0.12s;
}
.row-unread {
  position: absolute;
  left: 8px;
  top: 28px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
}
.row.unread .row-unread {
  background: var(--accent);
}
.row .avatar {
  width: 40px !important;
  height: 40px !important;
  font-size: 15px !important;
  margin-top: 1px;
}
.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 21px;
}
.row-who {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.row.unread .row-who {
  font-weight: 680;
  color: var(--text);
}
.row-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.row-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  color: var(--faint);
}
.row-meta time {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row.unread .row-meta time {
  color: var(--accent-text);
  font-weight: 600;
}
.meta-ic,
.queued {
  display: inline-flex;
}
.meta-ic .i,
.queued .i {
  width: 14px;
  height: 14px;
}
.meta-ic.pin {
  color: #c99700;
}
[data-theme="dark"] .meta-ic.pin {
  color: var(--spark);
}
.queued {
  color: var(--warning);
}
.row-subject {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 21px;
  line-height: 21px;
}
.row.unread .row-subject {
  font-weight: 620;
  color: var(--text);
}
.row-snippet {
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 21px;
  line-height: 21px;
}
[data-density="compact"] .row {
  padding-top: 11px;
  gap: 10px;
}
[data-density="compact"] .row .avatar {
  width: 32px !important;
  height: 32px !important;
  font-size: 12px !important;
}
[data-density="compact"] .row::after {
  left: 64px;
}
[data-density="compact"] .row-unread {
  top: 23px;
}
[data-density="compact"] .row-snippet {
  display: none;
}
[data-density="compact"] .row-who {
  font-size: 14px;
}

.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 26px;
  color: #fff;
  font-weight: 650;
  font-size: 14px;
  transition: opacity 0.1s;
}
.swipe-bg.left {
  justify-content: flex-start;
}
.swipe-bg.right {
  justify-content: flex-end;
}
.swipe-bg .i {
  width: 22px;
  height: 22px;
  transition: transform 0.2s var(--ease);
}
.swipe-bg.armed .i {
  transform: scale(1.18);
}
.sw-archive {
  background: #10b981;
}
.sw-trash {
  background: var(--danger);
}
.sw-read {
  background: var(--blue);
}
.sw-pin {
  background: #e3a700;
}
.sw-none {
  background: var(--surface-2);
  color: var(--muted);
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 36px 96px;
  gap: 10px;
}
.empty h2 {
  font-size: 18px;
}
.empty p {
  color: var(--muted);
  max-width: 300px;
  line-height: 1.5;
}
.empty .btn {
  margin-top: 8px;
}
.empty-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: color-mix(in srgb, var(--spark) 22%, transparent);
  color: #9a7000;
  margin-bottom: 6px;
}
.empty-mark .i {
  width: 28px;
  height: 28px;
}
.empty-mark.muted {
  background: var(--surface-2);
  color: var(--faint);
}
[data-theme="dark"] .empty-mark {
  color: var(--spark);
}
.empty-logo {
  width: 64px;
  height: 64px;
}
.empty-mark:has(.empty-logo) {
  background: none;
}

/* ----------------------------------------------------------------- reader */
.reader-pane {
  background: var(--bg);
}
.reader-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  padding: 40px;
  text-align: center;
}
.reader-empty-logo {
  width: 52px;
  height: 52px;
  opacity: 0.9;
  margin-bottom: 4px;
}
.reader-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-2);
}
.reader-empty-hint {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}
.reader-loading {
  padding: 40px;
  color: var(--muted);
}
.reader {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.reader-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(12px + var(--sat)) 16px 10px;
  border-bottom: 1px solid var(--border);
}
.bar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.bar-group + .bar-group {
  padding-left: 8px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}
.bar-spacer {
  flex: 1;
}
.reader-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px clamp(16px, 4vw, 44px) calc(40px + var(--sab));
}
.reader-head,
.thread,
.reply-row {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}
.reader-subject {
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.025em;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.reader-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 540;
  color: var(--muted);
  background: transparent;
}
.tag-btn {
  cursor: pointer;
  color: var(--accent-text);
}
.cat-people {
  color: var(--accent-text);
  border-color: transparent;
  background: var(--accent-soft);
}
.cat-notif {
  color: #b45309;
  border-color: transparent;
  background: color-mix(in srgb, #f59e0b 14%, transparent);
}
.cat-news {
  color: #0f766e;
  border-color: transparent;
  background: color-mix(in srgb, #14b8a6 14%, transparent);
}
[data-theme="dark"] .cat-notif {
  color: #fbbf24;
}
[data-theme="dark"] .cat-news {
  color: #2dd4bf;
}
.thread {
  list-style: none;
  padding: 0;
  margin-top: 22px;
  display: grid;
  gap: 10px;
}
.tmsg {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--raised);
  overflow: hidden;
}
.tmsg:not(.expanded) {
  background: var(--surface);
  border-color: transparent;
}
.tmsg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.tmsg.expanded .tmsg-head {
  padding: 16px 18px 8px;
}
.tmsg-who {
  flex: 1;
  min-width: 0;
  display: grid;
}
.tmsg-name {
  font-weight: 650;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tmsg-email {
  font-weight: 450;
  color: var(--faint);
  font-size: 13px;
}
.tmsg-sub {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tmsg-date {
  font-size: 12.5px;
  color: var(--faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  align-self: flex-start;
  margin-top: 2px;
}
.tmsg-body {
  padding: 4px 18px 18px 66px;
}
.plain {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  max-width: 68ch;
}
.plain.quoted {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border-strong);
}
.quote-toggle {
  margin-top: 10px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}
.quote-toggle .i {
  width: 16px;
  height: 16px;
}
.html-wrap {
  margin-left: -48px;
}
.html-wrap.paper {
  background: #fff;
  border-radius: var(--r);
  padding: 10px;
}
.html-frame {
  display: block;
  width: 100%;
  min-height: 80px;
  border: 0;
  background: transparent;
  color-scheme: normal;
}
.images-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px -48px;
  padding: 8px 10px 8px 12px;
  border-radius: var(--r);
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
}
.images-bar span {
  flex: 1;
  min-width: 160px;
}
.body-error {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13.5px;
}
.atts {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.att {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--raised);
  cursor: pointer;
  max-width: 280px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.att:hover {
  border-color: var(--accent);
  background: var(--accent-softer);
}
.att-ext {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.02em;
  flex: none;
}
.att-meta {
  display: grid;
  min-width: 0;
}
.att-name {
  font-size: 13px;
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-size {
  font-size: 12px;
  color: var(--faint);
}
.att > .i {
  color: var(--faint);
}
.reply-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.skeleton-lines {
  display: grid;
  gap: 10px;
  padding: 6px 0;
}
.skeleton-lines span {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-lines span:nth-child(2) {
  width: 92%;
}
.skeleton-lines span:nth-child(3) {
  width: 84%;
}
.skeleton-lines .short {
  width: 46%;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.mobile-actions {
  display: none;
}

/* ---------------------------------------------------------------- compose */
.compose-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}
.compose {
  pointer-events: auto;
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: min(640px, calc(100vw - 48px));
  height: min(700px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: rise 0.26s var(--ease);
}
@keyframes rise {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
}
.compose-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 18px;
  border-bottom: 1px solid var(--border);
}
.compose-head h2 {
  font-size: 15px;
  flex: 1;
}
.saved {
  font-size: 12px;
  color: var(--faint);
}
.compose-fields {
  flex: none;
}
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.field-row > label {
  font-size: 13px;
  color: var(--faint);
  width: 34px;
  flex: none;
}
.field-row input,
.field-row select {
  border: 0;
  height: 34px;
  padding: 0;
  background: transparent;
  box-shadow: none !important;
  font-size: 14.5px;
}
.from-select {
  flex: 1;
  min-width: 0;
  background-position: right 0 center;
}
.from-dot {
  display: inline-flex;
}
.chips {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.chips input {
  flex: 1;
  min-width: 120px;
}
.addr-chip {
  height: 26px;
  padding: 0 4px 0 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.addr-chip button,
.att-chip button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.addr-chip button:hover,
.att-chip button:hover {
  background: rgba(0, 0, 0, 0.08);
}
.addr-chip .i,
.att-chip .i {
  width: 13px;
  height: 13px;
}
.cc-toggle {
  flex: none;
}
.subject {
  font-weight: 600;
}
.suggest {
  position: absolute;
  left: 52px;
  right: 18px;
  top: calc(100% - 2px);
  z-index: 5;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
}
.suggest li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.suggest li.sel {
  background: var(--accent-soft);
}
.sug-name {
  font-weight: 560;
}
.sug-email {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.6;
  outline: none;
  overflow-wrap: anywhere;
}
.editor blockquote,
.editor .ws-quote blockquote {
  margin: 6px 0;
  padding-left: 12px;
  border-left: 2px solid var(--border-strong);
  color: var(--muted);
}
.editor .ws-quote {
  color: var(--muted);
  font-size: 14px;
}
.editor .ws-sig {
  color: var(--muted);
}
.editor img {
  max-width: 100%;
}
.compose-atts {
  list-style: none;
  margin: 0;
  padding: 8px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border);
}
.att-chip {
  padding-right: 4px;
}
.att-chip .i:first-child {
  width: 14px;
  height: 14px;
}
.compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.fmt {
  display: flex;
  align-items: center;
  gap: 2px;
}
.fmt label {
  cursor: pointer;
}
.send-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.split {
  display: flex;
  position: relative;
}
.split .send-btn {
  border-radius: var(--r) 0 0 var(--r);
  padding: 0 16px;
}
.split-more {
  border-radius: 0 var(--r) var(--r) 0;
  padding: 0 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.22) !important;
}
.menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 10;
  width: 280px;
  padding: 6px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
}
.menu-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--faint);
  padding: 6px 10px 4px;
}
.menu button[role="menuitem"] {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}
.menu button[role="menuitem"]:hover {
  background: var(--accent-soft);
}
.menu-custom {
  display: flex;
  gap: 6px;
  padding: 8px 4px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.menu-custom input {
  height: 32px;
  font-size: 13px;
  padding: 0 8px;
}

/* --------------------------------------------------------------- overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 18, 34, 0.32);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.18s ease-out;
}
.overlay.top {
  align-items: start;
  padding-top: 14vh;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.dialog {
  width: min(520px, 100%);
  max-height: min(680px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--raised);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: pop 0.22s var(--ease);
}
@keyframes pop {
  from {
    transform: scale(0.97) translateY(6px);
    opacity: 0;
  }
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 8px 22px;
}
.dialog-head h2 {
  font-size: 17px;
}
.dialog-body {
  padding: 6px 22px 22px;
  overflow-y: auto;
}
.dialog-form {
  display: grid;
  gap: 14px;
}
.dialog-form .form-error {
  margin: 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.dialog-filter {
  margin-bottom: 10px;
}
.pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.pick-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.pick-list button:hover {
  background: var(--accent-soft);
}
.pick-list .i {
  color: var(--muted);
}
.strength {
  font-size: 12.5px;
  margin-top: -6px;
  min-height: 1em;
}
.strength.weak {
  color: var(--danger);
}
.strength.ok {
  color: var(--warning);
}
.strength.strong {
  color: var(--success);
}
.file-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer;
  font-weight: 560;
  color: var(--text-2);
}
.file-pick:hover {
  border-color: var(--accent);
}
.kbd-list {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 20px;
}
.kbd-list div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.kbd-list dt {
  min-width: 72px;
}
.kbd-list dd {
  margin: 0;
  color: var(--text-2);
}
.palette {
  width: min(600px, 100%);
  background: var(--raised);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop 0.2s var(--ease);
}
.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--faint);
}
.palette-input input {
  border: 0;
  height: 54px;
  padding: 0;
  font-size: 16px;
  box-shadow: none !important;
  background: transparent;
}
.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 360px;
  overflow-y: auto;
}
.palette-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-2);
}
.palette-list li .i {
  color: var(--muted);
}
.palette-list li.sel {
  background: var(--accent-soft);
  color: var(--text);
}
.palette-list li kbd {
  margin-left: auto;
}
.palette-empty {
  color: var(--muted);
}

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--sab));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  max-width: 100%;
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  background: var(--inverse);
  color: var(--on-inverse);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.28s var(--ease);
}
.toast > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.toast > .i {
  color: var(--spark);
}
.toast.success > .i {
  color: #4ade80;
}
.toast.error > .i {
  color: #ff8a8d;
}
[data-theme="dark"] .toast.success > .i {
  color: var(--success);
}
[data-theme="dark"] .toast.error > .i,
[data-theme="dark"] .toast > .i {
  color: var(--accent);
}
.toast .icon-btn {
  color: inherit;
  opacity: 0.6;
}
.toast .icon-btn:hover {
  background: rgba(127, 127, 127, 0.2);
  opacity: 1;
  color: inherit;
}
.toast-btn {
  border: 0;
  background: transparent;
  color: #b9b0ff;
  font-weight: 700;
  padding: 0 10px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
}
[data-theme="dark"] .toast-btn {
  color: var(--accent-hover);
}
.toast-btn:hover {
  background: rgba(127, 127, 127, 0.18);
}
@keyframes toast-in {
  from {
    transform: translateY(12px) scale(0.98);
    opacity: 0;
  }
}

.fab {
  display: none;
}

/* -------------------------------------------------------------------- auth */
.auth {
  min-height: 100dvh;
  overflow-y: auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(32px + var(--sat)) 20px calc(24px + var(--sab));
  background: var(--surface);
  gap: 22px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-md);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}
.auth-logo {
  width: 36px;
  height: 36px;
}
.auth-word {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.025em;
}
.auth-title {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 720;
}
.auth-sub {
  color: var(--muted);
  margin: 10px 0 24px;
  font-size: 15px;
  line-height: 1.5;
}
.auth-form {
  display: grid;
  gap: 14px;
}
.auth .btn.block + .btn.block {
  margin-top: 10px;
}
.google {
  color: var(--text);
}
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--faint);
  font-size: 12.5px;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-switch {
  margin-top: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.auth-foot {
  display: grid;
  justify-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.auth-foot p {
  display: flex;
  align-items: center;
  gap: 6px;
}
.auth-foot .i {
  width: 14px;
  height: 14px;
}
.auth-sent {
  display: grid;
  gap: 12px;
  justify-items: start;
}
.auth-sent h1 {
  font-size: 24px;
}
.auth-sent p {
  color: var(--muted);
  line-height: 1.5;
}
.auth-sent-ic {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.auth-sent-ic .i {
  width: 24px;
  height: 24px;
}
.dev-link {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: var(--r);
  background: var(--warning-soft);
  font-size: 13px;
}

/* --------------------------------------------------------------- onboarding */
.onboard {
  overflow-y: auto;
  background: var(--surface);
}
.onboard-inner {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: calc(16px + var(--sat)) 20px calc(48px + var(--sab));
}
.onboard-top {
  min-height: 40px;
  margin-bottom: 8px;
}
.ob-card {
  max-width: 520px;
  margin: 3vh auto 0;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-sm);
}
.ob-card.wide {
  max-width: 760px;
}
.ob-card h1 {
  font-size: 24px;
  letter-spacing: -0.028em;
}
.ob-logo {
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
}
.ob-lead {
  color: var(--muted);
  margin: 8px 0 22px;
  font-size: 15px;
  line-height: 1.5;
}
.ob-form {
  display: grid;
  gap: 14px;
}
.ob-fine {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--faint);
  margin-top: 18px;
}
.ob-fine .i {
  width: 14px;
  height: 14px;
}
.choice-list {
  display: grid;
  gap: 10px;
}
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--raised);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover {
  border-color: var(--accent);
  background: var(--accent-softer);
}
.choice > .i {
  color: var(--faint);
}
.choice-ic {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  flex: none;
}
.choice-text {
  flex: 1;
  display: grid;
  gap: 4px;
}
.choice-text strong {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.choice-text > span {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}
.badge {
  font-size: 11px;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--spark) 35%, transparent);
  color: #6b4e00;
}
[data-theme="dark"] .badge {
  color: var(--spark);
  background: color-mix(in srgb, var(--spark) 18%, transparent);
}
.guide {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.guide li {
  counter-increment: step;
  position: relative;
  padding: 0 0 26px 48px;
  display: grid;
  gap: 10px;
  justify-items: start;
}
.guide li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.guide li::after {
  content: "";
  position: absolute;
  left: 14.5px;
  top: 34px;
  bottom: 6px;
  width: 1px;
  background: var(--border);
}
.guide li:last-child::after {
  display: none;
}
.guide h3 {
  font-size: 16px;
}
.guide p {
  color: var(--text-2);
  line-height: 1.55;
  max-width: 62ch;
}
.guide .ob-form {
  width: 100%;
  max-width: 460px;
}
.copy-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 600px;
  padding: 6px 6px 6px 12px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
}
.copy-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  white-space: nowrap;
}
.copy-field code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--text);
}
.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--accent-softer);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.guide .callout {
  margin: 0;
}
.callout > .i {
  color: var(--accent-text);
  margin-top: 1px;
}
.callout.warn {
  background: var(--warning-soft);
}
.callout.warn > .i {
  color: var(--warning);
}
.disclosure {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-weight: 560;
  cursor: pointer;
  padding: 0;
}
.disclosure .i {
  color: var(--muted);
}
.disclosure .chev {
  display: inline-grid;
}
.adv {
  display: grid;
  gap: 14px;
}
.server {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px 14px;
  margin: 0;
}
.server legend {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  padding: 0 6px;
}
.server-grid {
  display: grid;
  grid-template-columns: 1fr 88px 130px;
  gap: 10px;
}
.server-grid select {
  width: 100%;
  min-width: 0;
}
.test-result {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.test-result li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r);
  font-size: 13.5px;
  line-height: 1.4;
}
.test-result li.ok {
  background: var(--success-soft);
}
.test-result li.ok .i {
  color: var(--success);
}
.test-result li.bad {
  background: var(--danger-soft);
}
.test-result li.bad .i {
  color: var(--danger);
}
.ob-success {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--success-soft);
  color: var(--success);
  margin-bottom: 18px;
}
.ob-success .i {
  width: 26px;
  height: 26px;
  stroke-width: 2.4;
}
.notify-pitch {
  padding: 14px;
  border-radius: var(--r);
  background: var(--surface);
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}
.notify-pitch div {
  display: flex;
  gap: 10px;
}
.notify-pitch .i {
  color: var(--accent-text);
  margin-top: 2px;
}
.ob-card .btn.block + .btn.block {
  margin-top: 10px;
}
.ok-line {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--success);
  font-weight: 560;
  margin-bottom: 10px;
}
.onboard .form-error {
  max-width: 520px;
  margin: 14px auto 0;
}

/* ---------------------------------------------------------------- settings */
.settings {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  background: var(--bg);
}
.settings-nav {
  border-right: 1px solid var(--border);
  padding: calc(16px + var(--sat)) 10px 16px;
  overflow-y: auto;
}
.settings-nav-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 14px;
}
.settings-nav-head h1 {
  font-size: 21px;
  letter-spacing: -0.025em;
}
.settings-nav .nav-item > .i:last-child {
  display: none;
}
.danger-text,
.danger-text .i {
  color: var(--danger) !important;
}
.settings-back {
  display: none;
}
.settings-body {
  overflow-y: auto;
  padding: calc(28px + var(--sat)) clamp(20px, 4vw, 48px) calc(48px + var(--sab));
}
.set-section {
  max-width: 680px;
}
.set-section h2 {
  font-size: 22px;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}
.set-section h3 {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-2);
  margin: 28px 0 10px;
}
.set-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.set-head-row h2,
.set-head-row h3 {
  margin-bottom: 16px;
}
.set-head-row h3 {
  margin: 28px 0 10px;
}
.set-intro {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 18px;
  max-width: 62ch;
}
.set-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--raised);
}
.set-card + .set-card {
  margin-top: 12px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
}
.set-row + .set-row {
  border-top: 1px solid var(--border);
}
.set-text {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.set-text label,
.set-label {
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.set-text p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.set-foot {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--faint);
}
.empty-card {
  padding: 18px;
  color: var(--muted);
}
.acc-card {
  padding: 14px 12px 14px 16px;
}
.acc-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.acc-card-head .dot {
  width: 12px;
  height: 12px;
}
.acc-id {
  flex: 1;
  min-width: 0;
  display: grid;
}
.acc-id strong,
.acc-id span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acc-id span {
  font-size: 13px;
}
.status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.status.ok {
  color: var(--success);
  background: var(--success-soft);
}
.status.bad {
  color: var(--danger);
  background: var(--danger-soft);
}
.status.warn {
  color: var(--warning);
  background: var(--warning-soft);
}
.reorder {
  display: flex;
}
.acc-msg {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 0 24px;
}
.acc-card > .btn {
  margin: 10px 0 0 24px;
}
.acc-edit {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  padding: 16px 4px 2px 24px;
  border-top: 1px solid var(--border);
}
.swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.swatch.on {
  box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--c);
}
.acc-actions {
  display: flex;
  justify-content: flex-end;
}

/* ============================================================ responsive */
@media (max-width: 1279px) {
  :root {
    --list-w: 360px;
    --side-w: 232px;
  }
}

/* Tablet: sidebar becomes a drawer, list + reader side by side. */
@media (max-width: 1099px) {
  .app {
    grid-template-columns: var(--list-w) minmax(0, 1fr);
  }
  .settings.pane,
  .onboard.pane {
    grid-column: 1 / -1;
  }
  .sidebar {
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 86vw);
    padding-left: var(--sal);
    transform: translateX(-102%);
    transition: transform 0.28s var(--ease), box-shadow 0.28s;
    visibility: hidden;
  }
  .drawer-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
    visibility: visible;
  }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(15, 18, 34, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .drawer-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .compose-btn {
    display: none;
  }
  .fab {
    display: grid;
    place-items: center;
    position: fixed;
    right: calc(20px + var(--sar));
    bottom: calc(20px + var(--sab));
    z-index: 30;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    border: 0;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 24px rgba(91, 75, 240, 0.38), 0 2px 6px rgba(91, 75, 240, 0.3);
    cursor: pointer;
    transition: transform 0.15s var(--ease);
  }
  .fab:active {
    transform: scale(0.94);
  }
  .fab .i {
    width: 24px;
    height: 24px;
  }
  .settings {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}
@media (min-width: 1100px) {
  .only-mobile-tablet {
    display: none !important;
  }
}

/* Phone: single pane stack. */
@media (max-width: 767px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .hide-mobile {
    display: none !important;
  }
  .list-pane,
  .reader-pane {
    grid-column: 1;
    grid-row: 1;
    border-right: 0;
  }
  .reader-pane {
    display: none;
  }
  .has-open .reader-pane {
    display: flex;
    animation: slide-in 0.26s var(--ease);
  }
  .has-open .list-pane {
    visibility: hidden;
  }
  @keyframes slide-in {
    from {
      transform: translateX(24px);
      opacity: 0.4;
    }
  }
  .list-head {
    padding: calc(8px + var(--sat)) 10px 8px 6px;
  }
  .list-title h1 {
    font-size: 20px;
  }
  .search {
    display: none;
    margin: 8px 6px 0 10px;
  }
  .search.open {
    display: flex;
  }
  .row {
    padding-left: 20px;
    padding-right: 14px;
  }
  .reader-bar {
    padding: calc(6px + var(--sat)) 6px 6px;
    gap: 2px;
  }
  .bar-group + .bar-group {
    border-left: 0;
    padding-left: 0;
    margin-left: 0;
  }
  .reader-scroll {
    padding: 18px 16px calc(92px + var(--sab));
  }
  .reader-subject {
    font-size: 21px;
  }
  .tmsg-body {
    padding: 2px 14px 16px;
  }
  .tmsg.expanded .tmsg-head {
    padding: 14px 14px 8px;
  }
  .tmsg-email {
    display: none;
  }
  .html-wrap,
  .images-bar {
    margin-left: 0;
  }
  .reply-row {
    display: none;
  }
  .mobile-actions {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    justify-content: space-around;
    padding: 6px 8px calc(6px + var(--sab));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--border);
  }
  .mobile-actions button {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-width: 56px;
    min-height: 48px;
    padding: 4px 6px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 560;
    border-radius: 12px;
    cursor: pointer;
  }
  .mobile-actions button.primary {
    color: var(--accent-text);
  }
  .mobile-actions .i {
    width: 22px;
    height: 22px;
  }
  .toasts {
    bottom: calc(86px + var(--sab));
  }
  .compose {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
    padding-top: var(--sat);
    padding-bottom: var(--sab);
    animation: sheet 0.3s var(--ease);
  }
  @keyframes sheet {
    from {
      transform: translateY(40px);
      opacity: 0;
    }
  }
  .compose-head {
    padding: 6px 8px;
  }
  .compose-head h2 {
    text-align: center;
  }
  .saved {
    display: none;
  }
  .field-row {
    padding: 4px 14px;
  }
  .editor {
    padding: 14px;
  }
  .settings {
    grid-template-columns: minmax(0, 1fr);
  }
  .settings.has-section .settings-nav {
    display: none;
  }
  .settings:not(.has-section) .settings-body {
    display: none;
  }
  .settings-nav {
    border-right: 0;
  }
  .settings-nav .nav-item {
    height: 50px;
    font-size: 15px;
  }
  .settings-nav .nav-item > .i:last-child {
    display: block;
    color: var(--faint);
  }
  .settings-back {
    display: inline-flex;
    margin: 0 0 8px -8px;
  }
  .settings-body {
    padding: calc(10px + var(--sat)) 16px calc(40px + var(--sab));
  }
  .set-row {
    flex-wrap: wrap;
  }
  .ob-card {
    padding: 24px 20px;
    margin-top: 0;
    border-radius: 16px;
  }
  .onboard-inner {
    padding-left: 12px;
    padding-right: 12px;
  }
  .guide li {
    padding-left: 40px;
  }
  .server-grid {
    grid-template-columns: 1fr 1fr;
  }
  .server-grid .host {
    grid-column: 1 / -1;
  }
  .auth-card {
    padding: 28px 22px 24px;
  }
  .auth {
    justify-content: flex-start;
  }
  .overlay {
    padding: 12px;
  }
  .overlay.top {
    padding-top: calc(12px + var(--sat));
  }
}
@media (min-width: 768px) {
  .only-mobile {
    display: none !important;
  }
}

/* Touch: bigger targets, no iOS zoom on inputs. */
@media (pointer: coarse) {
  .icon-btn {
    width: 44px;
    height: 44px;
  }
  .icon-btn.sm {
    width: 40px;
    height: 40px;
  }
  .nav-item {
    height: 44px;
  }
  .nav-item.folder {
    height: 40px;
  }
  .acc-nav > .chev {
    top: 4px;
    width: 36px;
    height: 36px;
  }
  .btn {
    min-height: 44px;
  }
  .btn.sm {
    min-height: 40px;
  }
  input,
  select,
  textarea,
  .editor,
  .search input,
  .field-row input {
    font-size: 16px !important;
  }
  .sec-toggle,
  .sec-markall {
    min-height: 40px;
  }
  .row:hover {
    background: var(--bg);
  }
  .row.open {
    background: var(--accent-soft);
  }
}

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

@media (forced-colors: active) {
  .row.open,
  .nav-item.active {
    outline: 2px solid CanvasText;
  }
}

.set-row:has(> .switch) {
  flex-wrap: nowrap;
}
.ob-card {
  min-width: 0;
}
.guide li {
  grid-template-columns: minmax(0, 1fr);
  justify-items: stretch;
}
.guide li > .btn {
  justify-self: start;
}
.guide p {
  overflow-wrap: anywhere;
}
.copy-field {
  min-width: 0;
}
.palette-list li > span:not(.dot) {
  flex: 1;
}
.palette-list li > .dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin: 0 4px;
}
.sug-name {
  white-space: nowrap;
}
.suggest li {
  min-width: 0;
}
.set-head-row:has(> h2) {
  margin-bottom: 16px;
}
.set-head-row > h2 {
  margin: 0;
}
@media (max-width: 767px) {
  .split-more {
    border-radius: var(--r) !important;
    border-left: 0 !important;
  }
}
