:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #f7f9fc;
  --ink: #1a2430;
  --muted: #5a6a7c;
  --line: #e3e8ee;
  --accent: #0e62ae;
  --on-accent: #ffffff;
  --wash: #dce8f6;
  --danger: #8d2f2f;
  --on-danger: #ffffff;
  --danger-bg: #f8ecec;
  --shadow: 0 16px 40px rgba(16, 40, 72, 0.10);
  --select: #d0e2f4;
  --ring: rgba(14, 98, 174, 0.32);
  --faint: #6d7e90;
  --scroll: #d0d7e0;
  --scroll-hover: #b7c1cd;
  --shade: #f2f5f9;
  --rail: #e6edf4;
}

/* Dark theme snapshot 2026-11-17. Restore by replacing the block below and setting
   the theme-color strings in theme.js and js/render.js back to #1b1e23.
   sanitize.js dark fallbacks: --bg #121417, --line #2d3238.
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --panel: #1b1e23;
  --ink: #ece8e2;
  --muted: #a3a9b2;
  --line: #2d3238;
  --accent: #8eb4dc;
  --on-accent: #121417;
  --wash: #262c34;
  --danger: #f0b4b4;
  --on-danger: #2a1414;
  --danger-bg: #3a2424;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --select: #2c4158;
  --ring: rgba(142, 180, 220, 0.35);
  --faint: #8d959e;
  --scroll: #3c4450;
  --scroll-hover: #5c6674;
  --shade: #16191d;
  --rail: #07080a;
}
*/

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #212327;
  --panel: #2a2e34;
  --ink: #ece8e2;
  --muted: #a3a9b2;
  --line: #42474e;
  --accent: #8eb4dc;
  --on-accent: #121417;
  --wash: #363c46;
  --danger: #f0b4b4;
  --on-danger: #2a1414;
  --danger-bg: #3a2424;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --select: #394d60;
  --ring: rgba(142, 180, 220, 0.35);
  --faint: #8d959e;
  --scroll: #4a5159;
  --scroll-hover: #6a727c;
  --shade: #25282d;
  --rail: #17191d;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-hover);
  background-clip: padding-box;
  border: 2px solid transparent;
}

::-webkit-scrollbar-button,
::-webkit-scrollbar-button:single-button,
::-webkit-scrollbar-button:vertical:start:decrement,
::-webkit-scrollbar-button:vertical:end:increment,
::-webkit-scrollbar-button:horizontal:start:decrement,
::-webkit-scrollbar-button:horizontal:end:increment {
  display: none;
  width: 0;
  height: 0;
}

html, body, #app { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; color: inherit; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 12px;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, filter 120ms ease;
}

button:hover { background: var(--wash); }

button.primary { background: var(--accent); color: var(--on-accent); }
button.primary:hover { filter: brightness(1.06); background: var(--accent); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-bg); }
button.primary.danger { background: var(--danger); color: var(--on-danger); }
button.primary.danger:hover { background: var(--danger); filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: default; }

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

.icon.spin {
  transform-origin: center;
  animation: spin 0.8s linear infinite;
}

.sync-glyph {
  position: relative;
  display: inline-flex;
  flex: none;
}

.bridge-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e23b3b;
  pointer-events: none;
}

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

.icon-btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  color: var(--muted);
  flex: none;
}

input, textarea, select {
  width: 100%;
  min-height: 36px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea { min-height: 220px; resize: vertical; line-height: 1.5; }

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

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

::placeholder { color: var(--muted); opacity: 1; }
::selection { background: var(--select); }

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 480px at 50% -10%, var(--wash), transparent 60%),
    var(--bg);
}

.card, .dialog {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.gate-login { display: flex; flex-direction: column; }
.gate-login .gate-layout { margin-block: auto; }
.gate-copyright { width: 100%; flex-shrink: 0; padding-top: 24px; color: var(--muted); font-size: 0.875rem; text-align: center; }

.gate-layout {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  align-items: center;
  gap: clamp(32px, 6vw, 80px);
}
.gate-info { padding: 24px 0; }
.gate-brand { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.gate-info .brand-mark { display: inline-flex; color: var(--accent); margin: 0; }
.gate-info h1 { margin: 0; font-size: clamp(30px, 4vw, 42px); line-height: 1.15; }
.gate-intro { font-size: clamp(32px, 4vw, 48px); line-height: 1.12; font-weight: 600; margin: 0 0 20px; letter-spacing: -0.03em; }
.gate-info .lead { max-width: 48ch; line-height: 1.65; }
.gate-download { display: inline-flex; align-items: center; gap: 10px; margin-top: 16px; }
.gate-form { width: 100%; min-width: 0; }
.gate-form h2 { margin-top: 0; font-size: 24px; }
.gate-account { overflow-wrap: anywhere; }
.app-loading-content { width: min(480px, 100%); }
.app-loading-brand { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 3vw, 24px); }
.app-loading-brand .app-brand-mark { width: clamp(64px, 10vw, 96px); height: clamp(64px, 10vw, 96px); }
.app-loading-brand h1 { margin: 0; font-size: clamp(26px, 5vw, 48px); line-height: 1.15; letter-spacing: -0.03em; white-space: nowrap; }
.app-loading-pulse { width: min(360px, 100%); margin: 32px auto 0; border-radius: 999px; }
@media (max-width: 799px) {
  .gate-layout { max-width: 480px; grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .gate-info { padding: 8px 0; }
  .gate-brand { margin-bottom: 12px; }
  .gate-intro { margin-bottom: 12px; }
}

.dialog {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
}


.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.dialog-head h2 { margin: 0; }
.dialog-head .icon-btn { width: 32px; height: 32px; min-height: 32px; }

h1 { font-size: 1.4rem; font-weight: 650; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 1rem; font-weight: 650; margin: 0 0 12px; }

.lead, .quiet { color: var(--muted); margin: 0 0 18px; }

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--wash);
  color: var(--accent);
  flex: none;
}

.brand-mark .icon { width: 16px; height: 16px; }

.brand-mark.app-brand-mark { background: transparent; }
.app-brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 25%; }
.gate-info .app-brand-mark { width: 48px; height: 48px; }

.card .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.card .brand-mark .icon { width: 22px; height: 22px; }

label { display: block; font-size: 0.82rem; margin: 12px 0 6px; }

.remember {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.92rem;
}

.remember-choice { position: relative; margin-top: 14px; }
.remember-choice .remember { margin: 0; padding-right: 36px; min-height: 32px; align-items: center; }
.remember-help summary { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; list-style: none; color: var(--muted); }
.remember-help summary::-webkit-details-marker { display: none; }
.remember-help summary:hover { background: var(--wash); }
.remember-help summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.remember-help[open] summary .icon { transform: rotate(180deg); }
.remember-help .quiet { margin: 8px 0 0; }

.remember input {
  width: auto;
  min-height: 0;
  margin-top: 3px;
}

.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.actions button {
  border: 1px solid var(--line);
  background: var(--panel);
}

.actions button.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
}

.banner {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  border-left: 3px solid var(--danger);
  padding: 8px 12px;
  margin: 0 0 12px;
}

.shell { height: 100%; display: flex; flex-direction: column; min-height: 0; }

.topbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 48px 232px var(--list-width, 480px) 10px minmax(0, 1fr);
  align-items: center;
  min-height: 60px;
  padding: 10px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 2px 0 var(--accent);
  container-type: inline-size;
}

:root:not([data-theme="dark"]) .topbar {
  background: var(--accent);
  color: #fff;
  border-bottom-color: #0c5698;
  box-shadow: none;
}

:root:not([data-theme="dark"]) .topbar .brand-sub {
  color: rgba(255, 255, 255, 0.78);
}

:root:not([data-theme="dark"]) .topbar .brand-mark {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

:root:not([data-theme="dark"]) .topbar .menu-btn,
:root:not([data-theme="dark"]) .topbar .bar-title {
  color: #fff;
}

:root:not([data-theme="dark"]) .topbar .tool {
  background: transparent;
  border-color: transparent;
  color: #fff;
}

:root:not([data-theme="dark"]) .topbar .tool:hover,
:root:not([data-theme="dark"]) .topbar .tool.on,
:root:not([data-theme="dark"]) .topbar .menu-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: transparent;
  color: #fff;
}

:root:not([data-theme="dark"]) .topbar .tool.primary,
:root:not([data-theme="dark"]) .topbar .tool.primary:hover {
  background: #fff;
  border-color: transparent;
  color: var(--accent);
  filter: none;
}

:root:not([data-theme="dark"]) .topbar .search-capsule {
  background: #fff;
  border-color: transparent;
  color: var(--ink);
}

:root:not([data-theme="dark"]) .topbar .search-capsule:focus-within {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

:root:not([data-theme="dark"]) .topbar .search-scope-wrap {
  border-left-color: #d5dbe3;
}

.shell:has(.workspace.todo-open) .topbar {
  grid-template-columns: 48px 232px var(--list-width, 480px) 10px minmax(0, 1fr) 280px;
}
.shell.module-calendar .topbar {
  grid-template-columns: 48px 260px minmax(0, 1fr);
}
.shell.module-contacts .topbar {
  grid-template-columns: 48px 220px 320px minmax(0, 1fr);
}
.shell.module-contacts .search {
  grid-column: 3;
  width: auto;
  max-width: none;
  margin: 0 12px;
}
.shell.module-notes .topbar {
  grid-template-columns: 48px 232px minmax(0, 1fr) auto;
}
.shell.module-notes .search {
  grid-column: 3;
  width: auto;
  max-width: 520px;
  margin: 0 0 0 12px;
}
.shell.module-calendar .tools { grid-column: 3; }
.shell.module-contacts .tools { grid-column: 4; }
.shell.module-notes .tools { grid-column: 4; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.01em;
  min-width: 0;
  grid-column: 1 / span 2;
  padding-left: 16px;
}

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

.tools {
  grid-column: 5 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  padding-right: 16px;
  container-type: inline-size;
}

.tool {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.tool:hover { background: var(--wash); }

.tool.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

.tool.primary:hover { background: var(--accent); filter: brightness(1.06); }
.tool.icon-only { width: 36px; padding: 0; }
.tool.on { color: var(--accent); border-color: var(--accent); }

.toasts {
  position: fixed;
  z-index: 8;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  text-align: left;
  white-space: normal;
  justify-content: flex-start;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: 0 10px 24px rgba(16, 20, 28, 0.16);
  padding: 12px 14px;
  min-height: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.35;
  animation: toast-in 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast:hover { background: var(--shade); }

.toast-info { border-left-color: var(--muted); }

.toast-error {
  background: var(--panel);
  color: var(--danger);
  border-color: var(--line);
  border-left-color: var(--danger);
}

.toast-error:hover { background: var(--danger-bg); }

.toast-mail {
  border-color: var(--line);
  border-left-color: var(--accent);
}

:root[data-theme="dark"] .toast {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(12px, 8px); }
  to { opacity: 1; transform: none; }
}

.search {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  min-width: 0;
  width: calc(100% + 96px);
  max-width: none;
  margin: 0 0 0 12px;
}

.search-capsule {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 0 0 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.search-capsule:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.search-icon { display: flex; color: var(--muted); }

.search-capsule input {
  appearance: none;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 32px;
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.search-capsule input:focus,
.search-capsule input:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.search-capsule:not(:has(input:not(:placeholder-shown))) .search-clear {
  visibility: hidden;
  pointer-events: none;
}

.search-mailbox {
  flex: none;
  margin-left: auto;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 24px;
}

.search-mailbox[hidden] { display: none; }

.search-scope-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  align-self: stretch;
  flex: none;
  margin-left: 8px;
  border-left: 1px solid var(--line);
}

.search-scope {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  flex: none;
  gap: 8px;
  width: 8.5rem;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 0 7px 7px 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
}

.search-scope .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.search-scope:hover,
.search-scope[aria-expanded="true"] { background: var(--wash); }

.search-scope:focus,
.search-scope:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.search-scope-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 6;
  min-width: 100%;
  padding: 4px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-scope-menu[hidden] { display: none; }

.search-scope-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 32px;
  margin: 0;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  box-shadow: none;
}

.search-scope-menu button:hover { background: var(--wash); }

.search-scope-menu button[aria-selected="true"] {
  background: var(--wash);
  color: var(--accent);
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button {
  display: none;
  appearance: none;
}

.filter-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
}

.filter-toggle:hover { background: var(--wash); color: var(--ink); }

.filter-toggle.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--wash);
}

.filter-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--panel);
}

.filter-toggle.active .filter-dot { box-shadow: 0 0 0 2px var(--wash); }

.search-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 3;
  width: min(320px, calc(100vw - 32px));
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.search-panel[hidden] { display: none !important; }

.panel-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.search-panel select { width: 100%; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px 232px var(--list-width, 480px) 10px minmax(0, 1fr);
}

.tree, .list, .reader, .todo { min-width: 0; min-height: 0; }

.workspace.todo-open {
  grid-template-columns: 48px 232px var(--list-width, 480px) 10px minmax(0, 1fr) 280px;
}
.workspace.module-calendar { grid-template-columns: 48px 260px minmax(0, 1fr); }
.workspace.module-contacts { grid-template-columns: 48px 220px 320px minmax(0, 1fr); }
@media (min-width: 1320px) {
  .shell.module-contacts .topbar,
  .workspace.module-contacts {
    grid-template-columns: 48px 200px 280px minmax(420px, 1fr) 320px;
  }
  .shell.module-contacts .tools { grid-column: 4 / -1; }
}
.workspace.module-notes { grid-template-columns: 48px minmax(0, 1fr); }

.tree {
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: var(--shade);
  border-right: 1px solid var(--line);
  padding: 10px 10px 24px;
}

.account-block { min-width: 0; }

.account-name {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  text-align: left;
  justify-content: flex-start;
  font-weight: 650;
  padding: 8px;
  border-radius: 8px;
  cursor: default;
}

.account-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.account-title,
.account-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-text small {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.75rem;
}

.folders {
  list-style: none;
  margin: 0 0 14px 18px;
  padding: 2px 0;
  border-left: 1px solid var(--line);
}

.folders li.group-start {
  margin-top: 8px;
}
.folders li.group-end {
  margin-bottom: 8px;
}

.folders li { position: relative; }

.folder-toggle {
  position: absolute;
  left: 1px;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
}
.folder-toggle .icon { width: 14px; height: 14px; }
.folder-toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.folder-toggle:hover { color: var(--accent); background: var(--wash); }

.folder {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-align: left;
  border-radius: 0;
  border-left: 0;
  padding: 0 8px 0 19px;
  min-height: 34px;
  cursor: default;
}

.folder-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.folder-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder .icon { width: 16px; height: 16px; color: var(--muted); }
.folder.nested { padding-left: calc(19px + var(--nest) * 14px); }
.folder.active { background: var(--wash); box-shadow: inset 3px 0 var(--accent); }
.folder.active .icon { color: var(--accent); }
.folder.drop-target,
.account-name.drop-target {
  background: var(--wash);
  box-shadow: inset 2px 0 var(--accent);
}
.folder.drop-target .icon,
.account-name.drop-target .icon { color: var(--accent); }

.drag-chip {
  position: fixed;
  top: -1000px;
  left: 0;
  z-index: 5;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8rem;
  font-weight: 650;
  pointer-events: none;
}

.count {
  color: var(--muted);
  font-size: 0.75rem;
  flex: none;
}

.count.alert {
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 999px;
  min-width: 1.2rem;
  text-align: center;
  padding: 0 6px;
}

.list {
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: none;
}

.list-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.list-head h2 { margin: 0; font-size: 0.95rem; }

.list-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.list-note[hidden] { display: none; }

.list-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  flex: none;
}

.splitter {
  cursor: col-resize;
  touch-action: none;
  border-radius: 0;
  padding: 0;
  background: linear-gradient(to right, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px));
}

.splitter:hover, .splitter:focus-visible {
  background: linear-gradient(to right, transparent calc(50% - 1px), var(--accent) calc(50% - 1px), var(--accent) calc(50% + 1px), transparent calc(50% + 1px));
}

.list-back { display: none; }

.list-scroll { overflow: auto; flex: 1; overflow-anchor: none; }
.list-spacer { position: relative; width: 100%; }
.list-rows { position: absolute; top: 0; left: 0; right: 0; }
.shell.preparing { cursor: progress; }
.shell.preparing .topbar,
.shell.preparing .workspace { pointer-events: none; }

.message {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
  background: transparent;
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  overflow: hidden;
  user-select: none;
  cursor: default;
}

.message:hover, .message.active, .message.current { background: var(--wash); }
.message.active, .message.current { box-shadow: inset 3px 0 var(--accent); }
.message:focus,
.message:focus-visible {
  outline: none;
}
.message.selected,
.message.selected:hover,
.message.selected.active,
.message.selected.current {
  background: var(--select);
}

.message-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.sender, .subject { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender { flex: 1; font-weight: 500; color: var(--muted); }
.sender strong { font-weight: 500; color: inherit; }
.subject { color: var(--faint); font-weight: 400; }
.message.unread .sender,
.message.unread .sender strong { color: var(--ink); font-weight: 700; }
.message.unread .subject { color: var(--ink); font-weight: 650; }

.when {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  color: var(--faint);
  font-size: 0.78rem;
  white-space: nowrap;
}
.message.unread .when,
.message.unread .clip { color: var(--muted); }

.clip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--faint);
}

.clip .icon { width: 14px; height: 14px; }

.avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1;
  color: #fff;
  background: #2f5f93;
  transition: opacity 120ms ease, filter 120ms ease;
}

.message:not(.unread) .avatar {
  filter: grayscale(0.8) brightness(1.12);
  opacity: 0.62;
}

.account-name .avatar,
.mailbox-id .avatar {
  width: 32px;
  height: 32px;
  font-size: 0.68rem;
}

.avatar-0 { background: #2f5f93; }
.avatar-1 { background: #3e6b52; }
.avatar-2 { background: #8d6232; }
.avatar-3 { background: #7a4560; }
.avatar-4 { background: #3e6274; }
.avatar-5 { background: #5d518f; }

.avatar .dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  visibility: visible;
}

.message:hover .avatar .dot,
.message.active .avatar .dot,
.message.current .avatar .dot { border-color: var(--wash); }
.message.selected .avatar .dot,
.message.selected:hover .avatar .dot,
.message.selected.active .avatar .dot,
.message.selected.current .avatar .dot { border-color: var(--select); }

.flag-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-right: -4px;
  border-radius: 6px;
  color: var(--faint);
  cursor: pointer;
}

.flag-mark:hover { color: var(--ink); background: var(--wash); }

.flag-mark.on,
.flag-mark.on:hover {
  color: var(--danger);
  background: transparent;
}

.flag-mark.on .flag-cloth,
.letter-toolbar button.flagged .flag-cloth { fill: currentColor; }

.todo-item .flag-mark {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  cursor: inherit;
}

.reader {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

:root:not([data-theme="dark"]) .reader {
  background: #fff;
}

.reader-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.todo {
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--shade);
  border-left: 1px solid var(--line);
}

.workspace.todo-open .todo { display: flex; }

.todo-back { display: none; }

.todo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: none;
}

.todo-head h2 { margin: 0; font-size: 0.95rem; }

.todo-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.todo-item {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  background: transparent;
  min-height: 0;
  height: auto;
}

.todo-item:hover,
.todo-item.active { background: var(--wash); }

.todo-item.active { box-shadow: inset 3px 0 var(--accent); }

.todo-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.todo-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.todo-top strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.todo-top time {
  flex: none;
  color: var(--faint);
  font-size: 0.75rem;
}

.todo-subject,
.todo-folder {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-subject { color: var(--ink); }

.todo-folder { color: var(--muted); font-size: 0.75rem; }

.todo-foot {
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 68%;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.todo-foot-collapsed { max-height: none; }
.todo-cal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  height: 32px;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.todo-foot:not(.todo-foot-collapsed) .todo-cal-bar { border-bottom: 1px solid var(--line); }
.todo-cal-bar:hover { background: var(--wash); color: var(--ink); }
.todo-cal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.todo-cal-title .icon,
.todo-cal-bar > .icon { width: 14px; height: 14px; }
.todo-agenda { min-height: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.todo-agenda h3 {
  margin: 0;
  padding: 8px 12px 4px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.todo-agenda-list { overflow: auto; max-height: 168px; }
.todo-agenda-empty { margin: 0; padding: 2px 12px 10px; color: var(--muted); font-size: 0.82rem; }
.todo-event {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 0;
  height: auto;
  padding: 7px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.todo-event:hover { background: var(--wash); }
.todo-event .cal-swatch { width: 8px; height: 8px; margin-top: 5px; }
.todo-event-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.todo-event-main strong,
.todo-event-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.todo-event-main strong { font-weight: 650; font-size: 0.84rem; }
.todo-event-main small { color: var(--muted); font-size: 0.72rem; }
.todo-month { flex: none; padding: 8px 8px 10px; }
.todo-month .mini-cal { width: min(100%, 264px); margin: 0 auto 0; }
.todo-month .mini-day { min-height: 28px; }

.compose-pane {
  flex: 1 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--shade);
}

.compose-pane .letter-head {
  background: var(--shade);
  border-bottom: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.compose-pane .letter-title {
  justify-content: flex-start;
  align-items: center;
}

.compose-pane .from {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-sheet {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  grid-template-rows: auto minmax(180px, 1fr);
  column-gap: 16px;
}

.compose-pane.file-drop .compose-sheet {
  position: relative;
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  background: var(--wash);
}

.compose-pane.file-drop .compose-sheet::after {
  content: "Drop to attach";
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 20px;
  pointer-events: none;
}

.compose-write {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 0 0;
}

.compose-write .rich-editor {
  flex: 1;
  min-height: 180px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.compose-write .rich-editor:focus,
.compose-write .rich-editor:focus-visible {
  outline: none;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.rich-editor {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.rich-editor[data-empty="true"]:before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
  float: left;
  height: 0;
}

.rich-editor :is(p, div) { margin: 0; }
.rich-editor ul,
.rich-editor ol { margin: 0.4em 0 0.6em; padding-left: 1.4em; }

.rich-editor blockquote {
  margin: 0.75em 0;
  padding-left: 0.85em;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

.rich-editor a { color: var(--accent); }
.rich-editor img { max-width: 100%; height: auto; vertical-align: bottom; }
.compose-write .rich-editor img,
.signature-editor img { cursor: pointer; }
.compose-write .rich-editor img.is-selected,
.signature-editor img.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#image-frame {
  position: fixed;
  z-index: 9;
  pointer-events: none;
  box-sizing: border-box;
}
#image-frame[hidden] { display: none; }
#image-frame button {
  pointer-events: auto;
  position: absolute;
  width: 22px;
  height: 22px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  gap: 0;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--panel);
  color: var(--accent);
  box-shadow: var(--shadow);
}
#image-frame button:hover { background: var(--panel); filter: none; }
#image-frame .image-remove {
  top: -11px;
  right: -11px;
}
#image-frame .image-remove .icon { width: 14px; height: 14px; }
#image-frame .image-handle {
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  min-width: 0;
  min-height: 0;
  border-radius: 3px;
  cursor: nwse-resize;
  background: var(--accent);
}
#image-frame .image-handle:hover { background: var(--accent); }

.signature-editor {
  min-height: 140px;
  max-height: 240px;
  overflow: auto;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.signature-editor:focus,
.signature-editor:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.settings-mailbox { margin: 0 0 8px; color: var(--muted); }

.settings-dialog {
  width: min(1080px, 100%);
  height: min(720px, calc(100vh - 48px));
  max-height: min(720px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.settings-dialog .dialog-head {
  flex: none;
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.settings-dialog .dialog-head h2 { font-size: 1.15rem; }

.settings-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 188px minmax(0, 1fr);
}

.settings-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--shade);
  border-right: 1px solid var(--line);
}

.settings-pages,
.settings-main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.settings-pages {
  background: var(--bg);
  border-right: 1px solid var(--line);
}

.settings-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin: 10px;
  padding: 0 10px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.92rem;
  color: var(--muted);
}

.settings-search input {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 6px 0;
  color: var(--ink);
}

.settings-search input:focus,
.settings-search input:focus-visible {
  outline: none;
  border: 0;
  box-shadow: none;
}

.settings-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.settings-cats,
.settings-pages,
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 12px;
}

.settings-cats,
.settings-stack {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.settings-stack { display: none; }

.settings-cat,
.settings-page {
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  text-align: left;
}

.settings-cat span,
.settings-page span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-cat .icon { width: 16px; height: 16px; color: var(--muted); }

.settings-cat.active,
.settings-page.active {
  background: var(--wash);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.settings-cat.active .icon { color: var(--accent); }

.settings-group + .settings-group { margin-top: 8px; }

.settings-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px;
  padding-left: 16px;
}

.settings-empty {
  margin: 8px 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.settings-main { padding: 18px 24px 28px; }

.settings-main .settings-empty { margin: 0; }

.settings-back {
  display: none;
  margin: 0 0 12px;
  padding-left: 0;
  color: var(--accent);
}

.settings-form { max-width: 640px; }

.rule-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0 0 8px;
  padding: 4px 6px 4px 12px;
}

.rule-card.open { padding-bottom: 12px; }

.rule-line {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 40px;
}

.rule-enabled {
  margin: 0;
  width: auto;
}

.rule-summary {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-card.off .rule-summary { color: var(--muted); }

.rule-body { margin-top: 4px; }

.rule-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
}

.rule-tools-space { flex: 1; }

.settings-page-head .icon-btn.primary,
.actions .icon-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
}

.settings-page-head .icon-btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.settings-page-head .icon-btn.primary:hover {
  background: var(--accent);
  filter: brightness(1.06);
}

.rule-condition {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.7fr) minmax(0, 1.4fr) auto;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

@media (max-width: 720px) {
  .rule-condition { grid-template-columns: 1fr; }
}

.rule-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 4px;
}

.rule-raw {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 180px;
  padding: 10px;
  border-radius: 8px;
  background: var(--wash);
  font-size: 0.8rem;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 8px 0;
  font-size: 0.92rem;
  cursor: pointer;
}

.checkline input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  flex: none;
  accent-color: var(--accent);
  background: transparent;
  border-radius: 4px;
}

.checkline input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--line);
  box-shadow: none;
}

.settings-form h2 { margin: 22px 0 12px; }

.settings-form .settings-page-title {
  font-size: 1.35rem;
  margin: 0 0 16px;
}

.settings-form .settings-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 16px;
}

.settings-form .settings-page-head .settings-page-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.settings-form .settings-page-head .primary { flex: none; }

.mailbox-dialog { width: min(440px, 100%); }

.mailbox-dialog .lead { margin-top: 0; }

.letter { min-height: 100%; display: flex; flex-direction: column; }

.letter-head {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px 16px;
}

.letter-title {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.letter-title h1 {
  flex: 1 1 18rem;
  min-width: min(100%, 12rem);
  font-size: 1.45rem;
  line-height: 1.25;
  margin: 0;
  overflow-wrap: anywhere;
}

.letter-title .toolbar { flex: none; margin-left: auto; justify-content: flex-end; }

.spam-classification {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--warning, #b66a00) 35%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--warning, #b66a00) 8%, var(--panel));
  color: var(--text);
  font-size: .88rem;
}
.spam-classification strong { font-weight: 700; }
.spam-classification span { overflow-wrap: anywhere; }

.letter .letter-title {
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.letter .letter-title h1 {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.35;
}

.letter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  row-gap: 8px;
}

.letter-bar .avatar { flex: none; }

.letter-person {
  display: flex;
  align-items: center;
  column-gap: 12px;
  flex: 1 1 16rem;
  min-width: 0;
}

.letter-id {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.letter-id time { display: none; }

.letter-who {
  flex: 1 1 16rem;
  min-width: 0;
}

.letter-from {
  margin: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.letter-from strong { font-weight: 650; }
.letter-addr { color: var(--muted); }

.letter-meta {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.letter-actions {
  flex: 1 1 16rem;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: min(100%, 16rem);
  max-width: 100%;
}

.letter-actions time {
  color: var(--faint);
  font-size: 0.78rem;
  white-space: nowrap;
  padding-right: 6px;
}

/* Keep the header/body boundary stable when image loading finishes. */
.letter-image-loading {
  height: 3px;
  flex: 0 0 3px;
  overflow: hidden;
  background: var(--line);
}
.letter-image-loading[hidden] { display: block; visibility: hidden; }
.letter-image-loading::after {
  content: "";
  display: block;
  height: 100%;
  background: var(--accent);
  animation: letter-image-pulse 1.2s ease-in-out infinite;
}
@keyframes letter-image-pulse {
  0%, 100% { opacity: 0.25; transform: scaleX(0.35); }
  50% { opacity: 1; transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .letter-image-loading::after { animation: none; }
}

.letter-body { padding: 18px 24px 64px; }

:root:not([data-theme="dark"]) article.letter,
:root:not([data-theme="dark"]) .letter-body,
:root:not([data-theme="dark"]) .canvas,
:root:not([data-theme="dark"]) .canvas iframe {
  background: #fff;
}
.letter-loading { margin: 0; color: var(--muted); }

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

.toolbar button {
  border: 1px solid var(--line);
  background: var(--bg);
}

.toolbar button:hover { background: var(--wash); }

.toolbar button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

.toolbar button.danger {
  color: var(--danger);
  background: transparent;
  border-color: transparent;
}

.toolbar button.danger:hover { background: var(--danger-bg); }

.letter-toolbar { justify-content: flex-end; gap: 2px; }

.letter .letter-toolbar button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 32px;
  padding: 0 8px;
}

.letter .letter-toolbar button:hover {
  background: var(--wash);
  color: var(--ink);
}

.letter .letter-toolbar button.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.letter .letter-toolbar button.primary:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.letter .letter-toolbar button.flagged,
.letter .letter-toolbar button.flagged:hover {
  color: var(--danger);
}

.letter .letter-toolbar button.flagged:hover { background: var(--danger-bg); }

.letter .letter-toolbar button.original[aria-pressed="true"],
.letter .letter-toolbar button.original[aria-pressed="true"]:hover {
  color: var(--accent);
}

.letter-toolbar .icon-only {
  width: 32px;
  padding: 0;
}

.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.files button, .chips button {
  border: 1px solid var(--line);
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.files button { position: relative; overflow: hidden; border-radius: 999px; padding: 0 12px; }
.files button span {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.files small, .chips small { color: var(--muted); }
.files button .attachment-progress {
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  max-width: none;
  background: var(--wash);
  pointer-events: none;
}
.attachment-progress::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--accent);
  animation: attachment-loading 1.2s ease-in-out infinite;
}
@keyframes attachment-loading {
  from { transform: translateX(-100%); }
  to { transform: translateX(350%); }
}
@media (prefers-reduced-motion: reduce) {
  .attachment-progress::after { animation: none; width: 100%; }
}

.chips { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }

.chips li {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 4px 4px 10px;
  background: var(--bg);
  max-width: 100%;
}

.chip-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chip-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chips button { min-height: 28px; padding: 0 8px; color: var(--muted); }
.chips button:hover { color: var(--danger); background: var(--danger-bg); }
.chips .icon, .files .icon { width: 16px; height: 16px; }

.file-input {
  margin-top: 8px;
  padding: 8px;
  border-style: dashed;
}

.file-input::file-selector-button {
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
}

.compose-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  margin-top: 4px;
  align-content: start;
}

.address-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: start;
  column-gap: 16px;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.address-row > label {
  margin: 0;
  padding: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 20px;
  white-space: nowrap;
}

.address-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 8px;
  min-width: 0;
  min-height: 40px;
}

.recipients {
  position: relative;
  z-index: 3;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: auto;
  min-width: 0;
  min-height: 40px;
  margin: 0;
  padding: 6px 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: text;
}

.recipients:hover,
.recipients:focus-within {
  z-index: 6;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  outline: none;
}

.bcc-toggle {
  align-self: flex-start;
  margin-top: 4px;
  min-height: 28px;
  padding: 0 8px;
  color: var(--accent);
}

.recipients input,
.address-main > input:not([type="hidden"]):not([type="file"]) {
  flex: 1 1 0;
  width: auto;
  min-width: 1ch;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.address-main > input:not([type="hidden"]):not([type="file"]) {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  padding: 10px 0;
  line-height: 20px;
}

.recipients input:focus,
.recipients input:focus-visible,
.address-main > input:focus,
.address-main > input:focus-visible {
  outline: none;
  background: transparent;
  border: 0;
  border-color: transparent;
  box-shadow: none;
}

.attach-field { min-height: 40px; padding: 0; align-items: center; }
.attach-field .chips { margin: 0; flex: 0 1 auto; }

.attach-add {
  margin: 0;
  padding: 10px 0;
  color: var(--accent);
  font-size: 0.92rem;
  line-height: 20px;
  cursor: pointer;
}

.attach-add:hover { text-decoration: underline; }

.attach-field .file-input { display: none; }

.recipient-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 28px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--wash);
}

.recipient-email {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 2;
  display: none;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 450;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.recipient-pill:hover .recipient-email,
.recipient-pill:focus-within .recipient-email { display: block; }

.recipient-text {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 18rem;
  line-height: 1.2;
}

.recipient-text strong { font-weight: 650; }
.recipient-text span { color: var(--muted); }

.pill-x {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  flex: none;
}

.pill-x .icon { width: 10px; height: 10px; }
.pill-x:hover { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }

.recipient-list {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
}

.recipient-list button {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
  min-height: 40px;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: left;
}

.recipient-list button[aria-selected="true"],
.recipient-list button:hover { background: var(--wash); }

.recipient-list .avatar {
  width: 28px;
  height: 28px;
  font-size: 0.62rem;
}

.recipient-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.recipient-option strong,
.recipient-option small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipient-option small { color: var(--muted); font-weight: 400; }

.plain {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 16px/1.55 system-ui, "Segoe UI", sans-serif;
}

.canvas {
  display: block;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.canvas iframe {
  width: 100%;
  height: 0;
  min-height: 0;
  border: 0;
  background: transparent;
  display: block;
  overflow: hidden;
}

.empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  padding: 32px 24px;
  text-align: center;
}

.empty .icon { width: 40px; height: 40px; opacity: 0.55; }
.empty p { margin: 0; max-width: 28rem; }

.back, .folders-back {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg);
}

.filecount {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.72rem;
}

.message:hover .filecount,
.message.active .filecount,
.message.current .filecount,
.message.selected .filecount { background: var(--panel); }

.menu {
  position: fixed;
  z-index: 8;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.menu button {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
  min-height: 32px;
  padding: 0 8px 0 10px;
  border-radius: 6px;
}

.menu button span {
  flex: 1;
  text-align: left;
}

.menu button .icon { width: 16px; height: 16px; color: var(--muted); }
.menu button.danger .icon { color: var(--danger); }

.menu .submenu-arrow { flex: none; font-size: 22px; color: var(--muted); }
.move-submenu {
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.move-submenu[hidden] { display: none; }
.move-submenu button span { overflow-wrap: anywhere; }
.menu [aria-expanded="true"] { background: var(--wash); }

.menu kbd {
  flex: none;
  font: 11px/1.4 system-ui, "Segoe UI", sans-serif;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

.menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--line);
}

.keys-dialog { width: min(720px, 100%); }

.headers-dialog {
  width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.headers-dialog .dialog-head { flex: none; }

.headers-text {
  margin: 0;
  max-height: min(60vh, 560px);
  overflow: auto;
  padding: 12px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12.5px/1.5 ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.keys {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 28px;
  margin: 0;
}

.keys div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.keys dt { margin: 0; font-weight: 650; }
.keys dd { margin: 0; color: var(--muted); text-align: right; }

.alert-bar { padding: 10px 16px 0; background: var(--panel); }
.alert-bar .banner { margin: 0; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.52);
  display: grid;
  place-items: center;
  place-items: safe center;
  padding: 24px;
  overflow: auto;
  z-index: 5;
}

.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
}

.admin-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(10, 12, 16, 0.28);
  cursor: pointer;
}

.admin-scrim:hover { background: rgba(10, 12, 16, 0.28); }

.admin-sheet {
  position: relative;
  z-index: 1;
  width: 75vw;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.admin-panel.opening .admin-sheet {
  animation: admin-slide 180ms ease;
}

@keyframes admin-slide {
  from { transform: translateX(100%); }
  to { transform: none; }
}

.admin-sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.admin-sheet-head h2 { margin: 0; font-size: 1rem; }

.admin-frame-slot,
#admin-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--bg);
}

@media (max-width: 800px) {
  .admin-sheet { width: 100%; }
}

.draft-bar {
  flex: none;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.draft-tabs {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 10px 0;
}

.draft-tab {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  max-width: 240px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.draft-tab.active {
  background: var(--panel);
  box-shadow: inset 0 2px 0 var(--accent);
}

.draft-tab button {
  border-radius: 0;
  background: transparent;
}

.draft-tab button:hover,
.draft-tab button:focus-visible { background: var(--wash); }

.draft-tab button[data-action="draft"] {
  min-width: 0;
  justify-content: flex-start;
  padding: 8px 4px 8px 12px;
}

.draft-tab button[data-action="draft"] span {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-dismiss {
  width: 32px;
  min-height: 36px;
  padding: 0;
  color: var(--muted);
}

.draft-dismiss .icon { width: 14px; height: 14px; }

:root[data-theme="dark"] .overlay { background: rgba(0, 0, 0, 0.72); }

.confirm-overlay { z-index: 12; }
.settings-overlay { z-index: 7; }
.mailbox-overlay { z-index: 10; }
.cal-overlay { z-index: 11; }

.image-overlay {
  z-index: 7;
  padding: 16px;
}

.image-dialog {
  width: min(1100px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px 16px 18px;
  overflow: auto;
}

.image-heading {
  min-width: 0;
  flex: 1;
}

.image-heading h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-count {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.image-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 120px;
  background: var(--shade);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.image-stage img {
  max-width: 100%;
  max-height: min(70vh, calc(100vh - 230px));
  object-fit: contain;
}

.image-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 36px;
  height: 36px;
  min-height: 36px;
  margin-top: -18px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.image-prev { left: 10px; }
.image-next { right: 10px; }
.image-next .icon { transform: rotate(180deg); }

.image-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.image-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 12px 0 0;
}

.image-facts div {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.image-facts dt {
  margin: 0;
  color: var(--muted);
  font-weight: 650;
}

.image-facts dd { margin: 0; }

.image-overlay button[hidden],
.image-facts div[hidden],
.image-count[hidden] { display: none; }

.pdf-overlay {
  z-index: 7;
  padding: 16px;
}

.pdf-dialog {
  width: min(980px, 100%);
  height: min(920px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px;
  overflow: hidden;
}

.pdf-heading {
  min-width: 0;
  flex: 1;
}

.pdf-heading h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-count {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.pdf-stage {
  flex: 1 1 auto;
  min-height: 240px;
  background: var(--shade);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.pdf-stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #525659;
}

.pdf-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pdf-tools [data-action="pdf-next"] .icon { transform: rotate(180deg); }

.pdf-overlay button[hidden] { display: none; }

.confirm-dialog {
  width: min(420px, 100%);
  padding: 22px 22px 18px;
}

.confirm-dialog h2 { margin: 0 0 8px; }

.confirm-dialog p {
  margin: 0;
  line-height: 1.45;
}

.confirm-suppress {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
}

.confirm-suppress input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 1px 0 0;
  padding: 0;
  flex: none;
  accent-color: var(--accent);
}

.confirm-suppress input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--line);
  box-shadow: none;
}

.confirm-dialog .actions { margin-top: 18px; }

.actions button.primary.danger {
  background: var(--danger);
  color: var(--on-danger);
  border-color: transparent;
}

.actions button.primary.danger:hover {
  background: var(--danger);
  filter: brightness(1.08);
}

.mailboxes { list-style: none; padding: 0; margin: 0 0 18px; }

.mailboxes li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.mailbox-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mailbox-id > span:last-child { min-width: 0; }
.mailbox-id strong,
.mailbox-id small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mailboxes small { color: var(--muted); font-weight: 400; }
.mailbox-actions {
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 2px;
  margin-left: auto;
}
.mailboxes button { flex: none; }
.mailbox-actions .icon-btn,
.mailbox-name-actions .icon-btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--muted);
}
.mailboxes button.danger { color: var(--danger); }
.mailboxes button.danger:hover { background: var(--danger-bg); }
.mailboxes li.editing { align-items: stretch; }
.mailbox-edit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  flex: 1;
  gap: 12px;
  width: 100%;
}
.mailbox-edit .mailbox-id { flex: 1; }
.mailbox-name { display: block; flex: 1; min-width: 0; }
.mailbox-name label { margin-top: 0; }
.mailbox-name .banner { margin-top: 8px; }
.mailbox-name-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.mailbox-name-actions .icon-btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}
.mailbox-name-actions .icon-btn.primary:hover {
  background: var(--accent);
  filter: brightness(1.06);
}

.from { margin: 0 0 8px; color: var(--muted); }

@media (max-width: 640px) {
  .keys { grid-template-columns: 1fr; }
}

@container (max-width: 510px) {
  .tool { position: relative; width: 36px; min-width: 36px; padding: 0; }
  .tool .label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.menu-btn,
.bar-title,
.search-toggle,
.drawer-head,
.drawer-scrim { display: none; }

.drawer { display: contents; }
.drawer-main { display: contents; }
.rail-narrow { display: none; }

.shell.drawer-open .overlay,
#app:has(.shell.drawer-open) > .overlay { z-index: 40; }

#app:has(.shell.drawer-open) .menu { z-index: 30; }

@media (max-width: 980px) {
  .topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    min-height: calc(64px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  }
  .shell.search-open .topbar { padding-bottom: 6px; }
  .shell:has(.workspace.todo-open) .topbar { display: flex; }
  .menu-btn {
    display: inline-flex;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    color: var(--ink);
  }
  .bar-title {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand { display: none; }
  .tools { grid-column: auto; flex: none; width: auto; margin-left: auto; padding-right: 0; gap: 2px; container-type: normal; }
  .tools .tool.primary,
  .tools .tool:not(.primary):not(.search-toggle) { display: none; }
  .search-toggle { display: inline-flex; }
  .search { display: none; }
  .shell.search-open .search {
    display: flex;
    flex: 1 1 100%;
    order: 2;
    width: auto;
    max-width: none;
    margin: 0;
  }
  .shell.module-notes.search-open .search,
  .shell.module-contacts.search-open .search { max-width: none; }
  .search-mailbox { max-width: 6.5rem; }
  .search-scope { width: auto; max-width: 6.75rem; gap: 4px; padding: 0 8px; }
  .search-scope-label { overflow: hidden; text-overflow: ellipsis; }
  .search-panel { width: 100%; }
  .tool { position: relative; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; }
  .drawer .rail-create { display: inline-flex; margin-bottom: 6px; }
  .tool .label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .workspace,
  .workspace.todo-open,
  .workspace.module-calendar,
  .workspace.module-contacts,
  .workspace.module-notes {
    position: relative;
    overflow: hidden;
    grid-template-columns: minmax(0, 1fr);
  }
  .drawer {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    position: fixed;
    z-index: 20;
    top: 0;
    bottom: 0;
    left: 0;
    width: 80%;
    overflow: hidden;
    background: var(--shade);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 180ms ease, visibility 0s linear 180ms;
    padding-top: 0;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
  .drawer:not(:has(.tree)) {
    width: calc(48px + env(safe-area-inset-left));
    grid-template-columns: 48px;
    grid-template-rows: minmax(0, 1fr);
    background: var(--rail);
  }
  .drawer:not(:has(.tree)) .drawer-head,
  .drawer:not(:has(.tree)) .drawer-main { display: none; }
  .drawer:not(:has(.tree)) .rail { grid-row: 1; }
  .drawer .rail {
    display: flex;
    grid-column: 1;
    grid-row: 2;
    height: auto;
    min-height: 0;
    align-self: stretch;
    overflow: auto;
  }
  .drawer .rail-divider { margin-top: auto; }
  .rail-narrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  .drawer-main {
    display: flex;
    flex-direction: column;
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    background: var(--shade);
  }
  .shell.drawer-open .drawer {
    transform: none;
    visibility: visible;
    pointer-events: auto;
    transition: transform 180ms ease;
  }
  .drawer-scrim:not([hidden]) {
    display: block;
    position: fixed;
    z-index: 19;
    inset: 0;
    width: auto;
    height: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(16, 20, 28, 0.45);
  }
  .shell.drawer-open .drawer-scrim:not([hidden]),
  .shell.drawer-open .drawer-scrim:not([hidden]):hover { background: rgba(16, 20, 28, 0.45); }
  .drawer-head {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: calc(64px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 4px 0 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: inset 0 2px 0 var(--accent);
  }
  .drawer-head .brand {
    display: flex;
    flex: 1 1 auto;
    grid-column: auto;
    padding-left: 0;
  }
  .drawer-head .icon-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin-left: auto;
  }
  .drawer .tree {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    border-right: 0;
    background: var(--shade);
  }
  .workspace.module-calendar.cal-pane-side .cal-main { display: none; }
  .workspace.module-calendar.cal-pane-grid .cal-side { display: none; }
  .workspace.module-contacts.contact-pane-lists .contact-people,
  .workspace.module-contacts.contact-pane-lists .contact-main { display: none; }
  .workspace.module-contacts.contact-pane-people .contact-lists,
  .workspace.module-contacts.contact-pane-people .contact-main { display: none; }
  .workspace.module-contacts.contact-pane-detail .contact-lists,
  .workspace.module-contacts.contact-pane-detail .contact-people { display: none; }
  .workspace .contact-back { display: flex; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .workspace .cal-back { display: flex; }
  .splitter { display: none; }
  .drawer .tree { display: flex; }
  .workspace > .list,
  .workspace > .reader,
  .workspace > .todo {
    position: absolute;
    inset: 0;
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    transition: transform 280ms ease-out;
  }
  .workspace.pane-list > .list,
  .workspace.pane-tree > .list { transform: none; z-index: 1; }
  .workspace.pane-list > .reader,
  .workspace.pane-tree > .reader,
  .workspace.pane-list > .todo,
  .workspace.pane-tree > .todo { transform: translateX(100%); }
  .workspace.pane-read > .reader { transform: none; z-index: 2; }
  .workspace.pane-read > .list { transform: translateX(-100%); }
  .workspace.pane-read > .todo { transform: translateX(100%); }
  .workspace.pane-todo > .todo { transform: none; z-index: 2; }
  .workspace.pane-todo > .list { transform: translateX(-100%); }
  .workspace.pane-todo > .reader { transform: translateX(100%); }
  .workspace.enter-forward > .list,
  .workspace.enter-forward > .reader,
  .workspace.enter-forward > .todo,
  .workspace.enter-back > .list,
  .workspace.enter-back > .reader,
  .workspace.enter-back > .todo { transition: none; }
  .workspace[data-from="mail:list"].pane-read.enter-forward > .reader,
  .workspace[data-from="mail:todo"].pane-read.enter-forward > .reader,
  .workspace[data-from="mail:list"].pane-todo.enter-forward > .todo,
  .workspace[data-from="mail:read"].pane-todo.enter-forward > .todo { animation: slide-from-right 280ms ease-out; }
  .workspace[data-from="mail:list"].pane-read.enter-forward > .list,
  .workspace[data-from="mail:list"].pane-todo.enter-forward > .list,
  .workspace[data-from="mail:read"].pane-todo.enter-forward > .reader { animation: slide-to-left 280ms ease-out; }
  .workspace[data-from="mail:read"].pane-list.enter-back > .list,
  .workspace[data-from="mail:todo"].pane-list.enter-back > .list,
  .workspace[data-from="mail:compose"].pane-list.enter-back > .list,
  .workspace[data-from="mail:todo"].pane-read.enter-back > .reader { animation: slide-from-left 280ms ease-out; }
  .workspace[data-from="mail:read"].pane-list.enter-back > .reader,
  .workspace[data-from="mail:compose"].pane-list.enter-back > .reader,
  .workspace[data-from="mail:todo"].pane-list.enter-back > .todo,
  .workspace[data-from="mail:read"].pane-todo.enter-back > .todo { animation: slide-to-right 280ms ease-out; }
  .workspace[data-from="mail:read"].enter-forward .compose-pane { animation: slide-from-right 280ms ease-out; }
  .workspace[data-from="mail:compose"].pane-read.enter-back .letter { animation: slide-from-left 280ms ease-out; }
  .workspace.module-calendar.enter-forward.cal-pane-grid > .cal-main { animation: slide-from-right 280ms ease-out; }
  .workspace.module-calendar.enter-back.cal-pane-side > .cal-side { animation: slide-from-left 280ms ease-out; }
  .workspace.module-contacts.enter-forward.contact-pane-people > .contact-people,
  .workspace.module-contacts.enter-forward.contact-pane-detail > .contact-main { animation: slide-from-right 280ms ease-out; }
  .workspace.module-contacts.enter-back.contact-pane-lists > .contact-lists,
  .workspace.module-contacts.enter-back.contact-pane-people > .contact-people { animation: slide-from-left 280ms ease-out; }
  .back, .folders-back {
    display: inline-flex;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
  }
  .settings-back {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0 0 4px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
  }
  .back .icon, .folders-back .icon, .settings-back .icon { width: 24px; height: 24px; }
  .todo-back { display: flex; padding: 4px 6px; border-bottom: 1px solid var(--line); }
  .list-back { display: none; }
  .list-head { display: none; padding: 6px 12px; }
  .list-head.live { display: flex; justify-content: flex-start; }
  .list-head h2 { display: none; }
  .list-head .list-heading:not(:has(.list-note:not([hidden]))) { display: none; }
  .letter-head { padding: 8px 12px; }
  .letter > .letter-head:has(> .letter-title) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "back actions"
      "subject subject"
      "banner banner"
      "person person"
      "files files";
    align-items: center;
    column-gap: 4px;
    row-gap: 2px;
    padding: 4px 8px 10px;
  }
  .letter > .letter-head > .letter-title,
  .letter > .letter-head > .letter-bar,
  .letter .letter-actions { display: contents; }
  .letter .back { grid-area: back; }
  .letter .letter-toolbar {
    grid-area: actions;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .letter .letter-title h1 {
    grid-area: subject;
    margin: 0;
    font-size: 1.15rem;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }
  .letter > .letter-head > .banner { grid-area: banner; margin: 0; }
  .letter .letter-person { grid-area: person; }
  .letter > .letter-head > .files { grid-area: files; }
  .letter-id time {
    display: block;
    flex: none;
    color: var(--faint);
    font-size: 0.78rem;
    white-space: nowrap;
  }
  .letter-id .letter-from { flex: 1 1 auto; min-width: 0; }
  .letter .letter-actions time { display: none; }
  .letter-body, .compose-write { padding-left: 12px; padding-right: 12px; }
  .letter .letter-toolbar button {
    position: relative;
    width: 36px;
    min-width: 36px;
    padding: 0;
  }
  .letter .letter-toolbar button span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .letter-body { padding-top: 12px; padding-bottom: 28px; }
  .draft-tab button[data-action="draft"] span { max-width: 140px; }
}

@keyframes slide-from-right {
  from { transform: translateX(100%); }
  to { transform: none; }
}
@keyframes slide-to-left {
  from { transform: none; }
  to { transform: translateX(-100%); }
}
@keyframes slide-from-left {
  from { transform: translateX(-100%); }
  to { transform: none; }
}
@keyframes slide-to-right {
  from { transform: none; }
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .workspace > .list,
  .workspace > .reader,
  .workspace > .todo,
  .compose-pane,
  .letter,
  .cal-main,
  .cal-side,
  .contact-lists,
  .contact-people,
  .contact-main,
  .settings-main,
  .settings-stack {
    animation: none;
    transition: none;
  }
}

@media (max-width: 800px) {
  .settings-overlay {
    display: block;
    padding: 0;
  }

  .settings-dialog {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .settings-body { grid-template-columns: 1fr; }

  .settings-side { border-right: 0; }

  .settings-cats,
  .settings-pages { display: none; }

  .settings-stack { display: flex; }

  .settings-body:not(.show-page) .settings-main { display: none; }

  .settings-body.show-page .settings-side,
  .settings-body.show-page .settings-pages { display: none; }

  .settings-body.show-page .settings-back { display: inline-flex; }
  .shell.enter-forward .settings-body.show-page > .settings-main { animation: slide-from-right 280ms ease-out; }
  .shell.enter-back .settings-body:not(.show-page) .settings-stack { animation: slide-from-left 280ms ease-out; }

  .settings-main { padding: 16px; }
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  background: var(--rail);
  border-right: 1px solid var(--line);
}
.rail-apps,
.rail-tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.rail-divider {
  width: 24px;
  height: 1px;
  margin: 8px 0;
  background: var(--muted);
  opacity: 0.75;
  flex: none;
}
.rail-btn {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 0;
  color: var(--muted);
}
.rail-create { display: none; }
.rail-btn.active,
.rail-btn.active:hover {
  background: var(--wash);
  color: var(--accent);
  box-shadow: inset 3px 0 var(--accent);
}
.cal-side, .cal-main, .module-placeholder { min-width: 0; min-height: 0; }
.cal-side {
  display: flex;
  flex-direction: column;
  background: var(--shade);
  border-right: 1px solid var(--line);
}
.cal-side-scroll { overflow: auto; padding: 12px 12px 24px; }
.mini-cal { margin-bottom: 8px; }
.mini-bar, .cal-nav, .cal-toolbar, .cal-list-head, .cal-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mini-bar { justify-content: space-between; margin-bottom: 6px; }
.mini-label, .cal-toolbar h2 { font-weight: 650; }
.mini-next .icon, .cal-forward .icon { transform: rotate(180deg); }
.mini-names, .mini-grid, .month-names, .month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.mini-names, .month-names { color: var(--muted); font-size: 0.72rem; text-align: center; }
.mini-names span:nth-child(n + 6),
.month-names span:nth-child(n + 6) { color: var(--faint); }
.mini-day, .month-num {
  position: relative;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.mini-day { min-height: 32px; }
.mini-day.outside, .month-day.outside { color: var(--faint); }
.mini-day.today, .month-num.today, .cal-dayhead.today strong {
  background: var(--accent);
  color: var(--on-accent);
}
.mini-day.selected:not(.today) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.mini-day.busy::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}
.mini-day.today.busy::after { background: var(--on-accent); }
.mini-day.outside.busy::after { opacity: 0.4; }
.cal-today, .cal-jump {
  border: 1px solid var(--line);
  background: var(--panel);
}
.cal-today { width: 100%; margin: 8px 0 14px; }
.cal-jump { min-height: 32px; margin-left: 4px; padding: 0 10px; }
.cal-mailbox, .cal-mailbox-name { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; }
.cal-mailbox select { width: 100%; }
.cal-mailbox-name small { color: var(--muted); font-size: 0.75rem; }
.cal-mailbox-name span { font-weight: 650; }
.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cal-list li { display: flex; align-items: center; gap: 0; border-radius: 8px; }
.cal-list li:hover { background: var(--wash); }
.cal-row { flex: 1; min-width: 0; justify-content: flex-start; gap: 8px; margin: 0; padding: 5px 4px 5px 6px; font-size: 0.9rem; }
.cal-row input { width: 16px; min-height: 16px; padding: 0; flex: none; }
.cal-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-default {
  flex: none;
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
}
.cal-swatch, .cal-choice {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.cal-choice { width: 22px; height: 22px; border: 2px solid transparent; border-radius: 999px; }
.cal-choice.active { border-color: var(--ink); }
.cal-colors { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.cal-list-head { justify-content: space-between; margin-top: 4px; }
.cal-list-head h2 { margin: 0; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.cal-main { display: flex; flex-direction: column; background: var(--panel); --now: #c4493a; isolation: isolate; }
:root[data-theme="dark"] .cal-main { --now: #f3b1a8; }
.cal-back, .contact-back { display: none; }
.contact-lists, .contact-people, .contact-main, .contact-aside { min-width: 0; min-height: 0; }
.contact-lists, .contact-people {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}
.contact-lists { background: var(--shade); }
.contact-people { background: var(--panel); }
.contact-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0;
}
.contact-lists .contact-scroll { padding: 10px 0 24px; }
.contact-lists .cal-mailbox,
.contact-lists .cal-mailbox-name,
.contact-lists .banner { margin-left: 10px; margin-right: 10px; }
.contact-lists .panel-title { margin: 8px 10px 6px; }
.contact-list-row {
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 0 12px 0 16px;
  text-align: left;
  border-radius: 0;
  font-weight: 550;
}
.contact-list-row.active { background: var(--wash); box-shadow: inset 3px 0 var(--accent); }
.contact-list-row .count,
.contact-people-head .count { color: var(--muted); font-size: 0.8rem; font-weight: 550; }
.contact-people-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.contact-people-head h2 { margin: 0; font-size: 0.95rem; }
.contact-people .contact-scroll { padding: 0; }
.contact-row {
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
  min-height: 64px;
  padding: 12px 14px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.contact-row:hover { background: var(--wash); }
.contact-row.active { background: var(--wash); box-shadow: inset 3px 0 var(--accent); }
.contact-row-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.contact-row-copy strong,
.contact-row-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-row-copy small { color: var(--muted); font-weight: 400; }
.contact-empty { margin: 0; padding: 12px 16px; color: var(--muted); font-size: 0.85rem; }
.contact-main {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.contact-detail {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.contact-detail > .empty { flex: 1; padding: 28px 32px; }
.contact-kicker {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.contact-form {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}
.contact-form-head {
  flex: none;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.contact-form-id { min-width: 0; flex: 1 1 12rem; }
.contact-form h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.contact-form-head .banner { flex: 1 1 100%; margin: 0; }
.contact-form-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 24px 48px;
}
.contact-detail:has(.contact-form) { overflow: hidden; }
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 0 auto; }
.contact-actions button { border: 1px solid var(--line); background: var(--bg); }
.contact-actions button.primary { border-color: transparent; background: var(--accent); color: var(--on-accent); }
.contact-actions button.primary:hover { background: var(--accent); filter: brightness(1.06); }
.contact-delete { margin-left: 8px; }
.contact-form textarea { min-height: 96px; margin-top: 0; background: var(--bg); }
.contact-hint { margin: 0 0 16px; color: var(--muted); font-size: 0.86rem; }
.contact-block {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.contact-block h3 {
  margin: 0;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.contact-block-body { padding: 4px 14px 14px; }
.contact-block-empty { margin: 10px 0 0; color: var(--muted); font-size: 0.86rem; }
.contact-form label {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}
.contact-form input,
.contact-form textarea,
.contact-form select { color: var(--ink); font-weight: 450; }
.contact-form label input,
.contact-form label select { margin-top: 4px; }
.contact-block-body > textarea { margin-top: 10px; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.contact-span { grid-column: 1 / -1; }
.contact-repeat {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.contact-repeat select,
.contact-repeat input { margin: 0; }
.contact-address-card {
  margin: 12px 0 0;
  padding: 2px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
.contact-address-card:first-child { margin-top: 2px; border-top: 0; }
.contact-address-card > .contact-repeat {
  grid-template-columns: 160px auto;
  justify-content: space-between;
}
.contact-add {
  margin-top: 10px;
  padding: 0 2px;
  min-height: 32px;
  color: var(--accent);
  font-weight: 650;
}
.contact-add .icon { width: 15px; height: 15px; }
.contact-aside {
  display: none;
  flex-direction: column;
  gap: 0;
  overflow: auto;
  padding: 0;
  background: var(--shade);
  border-left: 1px solid var(--line);
}
@media (min-width: 1320px) {
  .contact-aside { display: flex; }
}
.contact-card {
  --card: #5c6b7a;
  position: relative;
  flex: none;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
  color: var(--ink);
}
.contact-card.avatar-0 { --card: #2f5f93; }
.contact-card.avatar-1 { --card: #3e6b52; }
.contact-card.avatar-2 { --card: #8d6232; }
.contact-card.avatar-3 { --card: #7a4560; }
.contact-card.avatar-4 { --card: #3e6274; }
.contact-card.avatar-5 { --card: #5d518f; }
.contact-card-band {
  position: relative;
  height: 88px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 78%, white), var(--card));
}
.contact-card-avatar {
  position: absolute;
  left: 18px;
  bottom: -30px;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--card);
  box-shadow: 0 0 0 4px var(--panel);
  font-size: 1.28rem;
  font-weight: 650;
  letter-spacing: 0.03em;
}
.contact-card-blank .contact-card-avatar .icon { width: 28px; height: 28px; }
.contact-card-body { padding: 40px 18px 16px; }
.contact-card-kicker {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.contact-card h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.contact-card-role { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }
.contact-card-lines {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}
.contact-card-lines li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font-size: 0.86rem;
}
.contact-card-lines .icon { width: 15px; height: 15px; color: var(--card); }
.contact-card-lines span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-related h3 {
  margin: 0;
  padding: 12px 16px 8px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.contact-related-empty { margin: 0; padding: 0 16px 16px; color: var(--muted); font-size: 0.86rem; }
.contact-mail-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 10px 16px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.contact-mail-row:hover { background: var(--wash); }
.contact-mail-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 600;
}
.contact-mail-row.unread .contact-mail-subject { font-weight: 750; }
.contact-mail-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.75rem;
}
.contact-mail-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-mail-meta time { flex: none; font-variant-numeric: tabular-nums; }
.contact-hero { display: flex; align-items: center; gap: 16px; }
.contact-avatar { width: 64px; height: 64px; font-size: 1.15rem; }
.contact-identity { min-width: 0; }
.contact-identity h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.contact-address, .contact-meta { margin: 4px 0 0; color: var(--muted); }
.contact-note { margin: 18px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.contact-lists .banner { margin-bottom: 14px; }
.cal-toolbar {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.cal-nav { flex: 1; min-width: 0; }
.cal-nav h2 {
  margin: 0 0 0 6px;
  min-width: 0;
  font-size: 1.08rem;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-weather {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 1px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.cal-weather strong { grid-row: span 2; align-self: center; font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-weather span { font-size: 0.86rem; }
.cal-weather small { color: var(--muted); font-size: 0.75rem; }
.cal-weather p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 0.84rem; }
.cal-settings-hours { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cal-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.cal-zoom span { font-size: 0.78rem; color: var(--muted); }
.cal-zoom button { font-size: 1.05rem; line-height: 1; }
.cal-zoom input[type="range"] {
  width: 92px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  accent-color: var(--accent);
}
.cal-zoom input[type="range"]:focus-visible { border: 0; box-shadow: none; }
.cal-zoom output {
  min-width: 3.2em;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.cal-views { display: flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.cal-views button { border-radius: 0; min-height: 32px; padding: 0 11px; font-size: 0.86rem; }
.cal-views button + button { border-left: 1px solid var(--line); }
.cal-views button.active { background: var(--accent); color: var(--on-accent); border-left-color: transparent; }
.cal-views button.active + button { border-left-color: transparent; }
.cal-sheet, .month-sheet { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-sheet { --hour: 64px; --work-start: 8; --work-end: 17; }
.cal-head-row, .cal-allday, .cal-time {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
}
.cal-dayheads, .cal-allday-days, .cal-days {
  display: grid;
  grid-template-columns: repeat(var(--days), minmax(0, 1fr));
}
.cal-gutter {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 4px 8px 0 0;
}
.cal-dayhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-height: 58px;
  padding: 8px 2px 6px;
  border-radius: 0;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.cal-dayhead span {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-dayhead.weekend { background: color-mix(in srgb, var(--shade) 72%, var(--panel)); }
.cal-dayhead strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 650;
}
.cal-dayhead.selected:not(.today) strong { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-wx { display: block; font-size: 0.72rem; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.2; }
.cal-scroll { flex: 1; min-height: 0; overflow: auto; }
.cal-sticky {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--panel);
}
.cal-times { position: relative; height: calc(24 * var(--hour)); }
.cal-times span {
  position: absolute;
  right: 8px;
  transform: translateY(2px);
  line-height: 1;
}
.cal-times span.is-first { transform: none; }
.cal-col {
  position: relative;
  height: calc(24 * var(--hour));
  border-left: 1px solid var(--line);
  --off: color-mix(in srgb, var(--shade) 86%, var(--panel));
  --hair: color-mix(in srgb, var(--line) 65%, transparent);
  background: linear-gradient(
    to bottom,
    var(--off) 0 calc(var(--work-start) * var(--hour)),
    transparent calc(var(--work-start) * var(--hour)) calc(var(--work-end) * var(--hour)),
    var(--off) calc(var(--work-end) * var(--hour)) 100%
  );
}
.cal-hour {
  position: relative;
  display: block;
  width: 100%;
  height: var(--hour);
  min-height: var(--hour);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: inset 0 -1px 0 var(--line);
}
.cal-hour::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--hour) / 2);
  height: 1px;
  background: var(--hair);
  pointer-events: none;
}
.cal-hour:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cal-event, .cal-chip {
  --cal: var(--accent);
  position: absolute;
  z-index: 1;
  overflow: hidden;
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  border: 0;
  border-radius: 5px;
  border-left: 3px solid var(--cal);
  background: color-mix(in srgb, var(--cal) 24%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cal) 30%, transparent);
  color: var(--ink);
  padding: 3px 6px 3px 5px;
  min-height: 0;
  line-height: 1.25;
  cursor: pointer;
}
.cal-event:hover, .cal-chip:hover {
  background: color-mix(in srgb, var(--cal) 36%, var(--panel));
  z-index: 5;
}
.cal-event { container-type: inline-size; }
.cal-event-title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 650;
}
.cal-event-time, .cal-event-place { display: block; color: var(--muted); font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 88px) {
  .cal-event-time, .cal-event-place { display: none; }
}
.cal-event.compact { padding-top: 1px; padding-bottom: 1px; }
.cal-event.compact .cal-resize { display: none; }
.cal-event.compact .cal-event-time,
.cal-event.compact .cal-event-place,
.cal-event:not(.roomy) .cal-event-place { display: none; }
.cal-event.cancelled .cal-event-title, .cal-chip.cancelled span { text-decoration: line-through; }
.cal-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--now);
  z-index: 4;
  pointer-events: none;
}
.cal-now::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--now);
}
.cal-allday { border-bottom: 1px solid var(--line); }
.cal-allday .cal-gutter {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 8px;
  font-size: 0.68rem;
  white-space: nowrap;
}
.cal-allday-wrap { position: relative; min-height: 34px; }
.cal-allday-days { position: absolute; inset: 0; }
.cal-allday-col { border-left: 1px solid var(--line); }
.cal-allday-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--days), minmax(0, 1fr));
  grid-auto-rows: 22px;
  gap: 2px 4px;
  min-height: 34px;
  padding: 4px 3px;
}
.cal-allday-board .cal-event {
  position: relative;
  align-items: center;
  width: auto;
  height: auto;
  margin: 0;
  padding: 1px 6px;
}
.cal-allday-board .cal-event-time,
.cal-allday-board .cal-event-place { display: none; }
.month-sheet { padding: 0; }
.month-names {
  padding: 8px 0 6px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.month-grid {
  flex: 1;
  grid-template-rows: repeat(6, minmax(0, 1fr));
  min-height: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.month-day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  padding: 4px;
  background: var(--panel);
}
.month-day.weekend { background: color-mix(in srgb, var(--shade) 70%, var(--panel)); }
.month-day.selected:not(.today) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.month-day .cal-wx { align-self: flex-start; margin: 0 0 2px 4px; }
.month-num { align-self: flex-start; width: 26px; height: 26px; min-height: 26px; margin-bottom: 1px; font-weight: 650; }
.cal-chip {
  position: static;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 20px;
  padding: 1px 5px 1px 4px;
  white-space: nowrap;
}
.cal-chip time { flex: none; color: var(--muted); font-size: 0.68rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-chip span { overflow: hidden; text-overflow: ellipsis; font-size: 0.75rem; font-weight: 650; }
.cal-more {
  width: 100%;
  justify-content: flex-start;
  min-height: 20px;
  padding: 0 4px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}
.module-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 32px;
}
.module-placeholder h1 { margin: 0; }
.module-placeholder p { margin: 0; color: var(--muted); }
.cal-dialog { width: min(460px, 100%); }
.event-dialog {
  --cal: var(--accent);
  --event-icon: 32px;
  --event-gutter: 12px;
  width: min(960px, calc(100vw - 80px));
  max-height: min(960px, calc(100vh - 64px));
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-top: 3px solid var(--cal);
  box-shadow: 0 24px 70px rgba(10, 14, 20, 0.28);
}
.event-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  flex: none;
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--line);
}
.event-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}
.event-swatch {
  width: 12px;
  height: 12px;
  flex: none;
  margin: 0;
  border-radius: 3px;
  background: var(--cal);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 18%, transparent);
}
.event-head .icon-btn { margin: 0; }
.event-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}
.event-kicker [data-event-kicker] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.event-head #event-summary {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 4px 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  box-shadow: inset 0 -1px 0 transparent;
}
.event-head #event-summary:hover { box-shadow: inset 0 -1px 0 var(--line); }
.event-head #event-summary:focus-visible {
  outline: none;
  border: 0;
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--accent);
}
:root[data-theme="dark"] .event-dialog {
  background: #2a3038;
  border-color: #3d4652;
  border-top-color: color-mix(in srgb, var(--cal) 72%, #fff);
}
:root[data-theme="dark"] .event-head,
:root[data-theme="dark"] .event-foot {
  border-color: #3d4652;
}
:root[data-theme="dark"] .event-card {
  background: #323842;
  border-color: #454e5b;
}
:root[data-theme="dark"] .event-foot { background: #262c34; }
:root[data-theme="dark"] .event-dialog input:not([type="checkbox"]):not(#event-summary),
:root[data-theme="dark"] .event-dialog select,
:root[data-theme="dark"] .event-dialog textarea,
:root[data-theme="dark"] .event-presets button,
:root[data-theme="dark"] .event-foot button:not(.primary) {
  background: #22272e;
  border-color: #454e5b;
}
:root[data-theme="dark"] .event-swatch { background: color-mix(in srgb, var(--cal) 68%, #fff); }
:root[data-theme="dark"] .event-when-copy .event-glyph,
:root[data-theme="dark"] .event-glyph-cal { color: color-mix(in srgb, var(--cal) 62%, #fff); }
:root[data-theme="dark"] .event-presets button.active {
  border-color: color-mix(in srgb, var(--cal) 48%, #fff);
  background: color-mix(in srgb, var(--cal) 34%, var(--panel));
}
.event-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px 32px 20px;
}
.event-body > .banner { margin: 0; }
.event-dialog label { margin: 0; }
.event-dialog input:not([type="checkbox"]):not(#event-summary),
.event-dialog select {
  min-height: 40px;
}
.event-card {
  margin: 0;
  padding: 18px 18px 18px calc(var(--event-icon) + var(--event-gutter));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--shade);
}
.event-card.is-bad {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  background: var(--danger-bg);
}
.event-card.is-bad [data-event-when] { color: var(--danger); }
.event-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.event-when-copy {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.event-when-copy p { margin: 0; }
.event-when-copy [data-event-when] { font-weight: 650; line-height: 1.3; }
.event-span { margin-top: 2px; color: var(--muted); font-size: 0.82rem; }
.event-glyph {
  display: grid;
  place-items: center;
  width: var(--event-icon);
  height: 40px;
  flex: none;
  color: var(--muted);
}
.event-glyph .icon { width: 16px; height: 16px; }
.event-when-copy .event-glyph,
.event-glyph-cal { color: var(--cal); }
.event-when-copy .event-glyph {
  position: absolute;
  left: calc(-1 * (var(--event-icon) + var(--event-gutter)));
  top: 50%;
  width: var(--event-icon);
  height: auto;
  transform: translateY(-50%);
}
.event-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 650;
  white-space: nowrap;
}
.event-switch input {
  appearance: none;
  width: 40px;
  height: 24px;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--ink) 24%, var(--bg));
  background-image: radial-gradient(circle at 12px 50%, #fff 7px, transparent 8px);
  background-repeat: no-repeat;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.event-switch input:checked {
  background-color: var(--accent);
  background-image: radial-gradient(circle at 28px 50%, #fff 7px, transparent 8px);
}
.event-switch input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border: 0;
  box-shadow: none;
}
.event-when { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.event-when label,
.event-when input { min-width: 0; }
.event-when label span,
.event-field-name {
  display: block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.event-card input:not([type="checkbox"]) { background: var(--panel); }
.event-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.is-all-day .event-presets { display: none; }
.event-presets button {
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
}
.event-presets button:hover { color: var(--ink); }
.event-presets button.active {
  background: color-mix(in srgb, var(--cal) 16%, var(--panel));
  border-color: var(--cal);
  color: var(--ink);
  font-weight: 650;
}
.event-reminders { display: flex; flex-wrap: wrap; gap: 8px; }
.event-remind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
}
.event-remind button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.event-remind button:hover { color: var(--ink); }
.event-remind-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.event-remind-presets button,
.event-remind-custom button {
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
}
.event-remind-presets button:hover,
.event-remind-custom button:hover { color: var(--ink); }
.event-remind-custom {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.event-remind-custom input { max-width: 180px; }
.event-field {
  display: grid;
  grid-template-columns: var(--event-icon) minmax(0, 1fr);
  column-gap: var(--event-gutter);
  row-gap: 0;
  align-items: center;
  margin: 0;
}
.event-field-body { display: contents; }
.event-field-name { grid-column: 2; grid-row: 1; }
.event-field .event-glyph {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
}
.event-field input,
.event-field select,
.event-field textarea {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  min-width: 0;
}
.event-field:has(textarea) .event-glyph { align-self: start; }
.event-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 24px;
  margin: 0;
}
.event-pair .event-field { margin-top: 0; }
.event-repeat { min-width: 0; }
.event-every {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  margin-left: calc(var(--event-icon) + var(--event-gutter));
  padding-left: 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.event-every[hidden] { display: none; }
.event-every input {
  width: 4.75rem;
  flex: none;
  min-height: 40px;
  padding: 4px 8px;
  text-align: center;
}
.event-hint { margin: 0; color: var(--muted); font-size: 0.82rem; }
.event-dialog textarea { min-height: 140px; max-height: 240px; }
.event-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex: none;
  flex-wrap: wrap;
  padding: 16px 32px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--shade) 65%, var(--panel));
}
.event-foot-tools,
.event-foot-save { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.event-foot button { min-height: 40px; }
.event-foot-save { margin-left: auto; }
.event-foot button {
  border: 1px solid var(--line);
  background: var(--panel);
}
.event-foot button:hover { background: var(--wash); }
.event-foot button.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0 16px;
}
.event-foot button.primary:hover { background: var(--accent); filter: brightness(1.06); }
.event-tool { color: var(--muted); }
.event-tool.danger { color: var(--danger); }
.event-tool.danger:hover { background: var(--danger-bg); }
.event-tool .icon { width: 16px; height: 16px; }
@media (max-width: 980px) {
  .cal-back, .contact-back { display: flex; }
  .cal-back { padding: 8px 10px 0; }
  .contact-form-head { padding: 12px 16px; }
  .contact-form-body { padding: 12px 16px 32px; }
  .contact-detail > .empty { padding: 20px 16px 32px; }
  .cal-toolbar { padding: 8px 10px; }
  .cal-nav h2 { font-size: 0.98rem; }
  .cal-views button { padding: 0 8px; }
}
@media (max-width: 720px) {
  .cal-views button { font-size: 0.78rem; padding: 0 7px; }
  .contact-grid { grid-template-columns: 1fr; }
  .contact-repeat { grid-template-columns: minmax(0, 1fr) auto; }
  .contact-repeat select { grid-column: 1 / -1; }
  .event-when, .event-pair, .cal-settings-hours { grid-template-columns: 1fr; }
  .event-overlay { padding: 0; align-items: end; }
  .event-dialog {
    width: 100%;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }
  .event-head,
  .event-body,
  .event-foot {
    padding-left: 20px;
    padding-right: 20px;
  }
  .event-head { padding-top: 20px; padding-bottom: 16px; }
  .event-body { gap: 20px; padding-top: 20px; padding-bottom: 24px; }
  .event-foot { padding-top: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .event-dialog textarea { min-height: 96px; }
}
.compose-overlay { align-items: stretch; justify-content: center; padding: 24px; }
.compose-pop {
  width: min(960px, 100%);
  background: var(--panel);
  border-radius: 12px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.compose-pop .compose-pane { min-height: 70vh; }

.ics-dialog {
  --cal: var(--accent);
  width: min(880px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.ics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex: none;
  padding: 20px 24px 12px;
}
.ics-head-copy { min-width: 0; }
.ics-head h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
  line-height: 1.25;
}
.ics-meta, .ics-clash, .ics-loading {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.ics-clash.is-clash { color: var(--danger); }
.ics-dialog .banner { margin: 0 24px 8px; }
.ics-switch {
  display: flex;
  flex: none;
  gap: 6px;
  overflow-x: auto;
  padding: 0 24px 12px;
}
.ics-switch button {
  flex: none;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--bg);
}
.ics-switch button.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}
.ics-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.ics-grid .ics-loading { padding: 24px; }
.ics-sheet { flex: 1; min-height: 0; }
.ics-sheet .cal-hour { pointer-events: none; }
.ics-sheet .cal-hour:hover { background: transparent; }
.ics-sheet .cal-dayhead { cursor: default; }
.ics-sheet .cal-event { cursor: default; }
.ics-sheet .cal-event.incoming {
  outline: 2px solid var(--cal);
  outline-offset: 1px;
  z-index: 4;
}
.ics-sheet .cal-event.clash {
  outline: 2px solid var(--danger);
  outline-offset: 1px;
  z-index: 3;
}
@media (max-width: 720px) {
  .ics-overlay { padding: 0; align-items: end; }
  .ics-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }
  .ics-head, .ics-switch { padding-left: 16px; padding-right: 16px; }
}

.notes { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.note-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px 0;
}
.note-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
}
.note-account span { font-weight: 650; }
.note-account span,
.note-account small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-account small { color: var(--muted); }
.note-account select { width: auto; max-width: min(320px, 42vw); flex: none; }
.notes-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 28px 64px; }
.notes-locked { max-width: 640px; margin: 12px auto 0; }
.note-views {
  display: flex;
  flex: none;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.note-views button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
}
.note-views button[aria-selected="true"],
.note-views button[aria-selected="true"]:hover {
  background: var(--accent);
  color: var(--on-accent);
}
.note-take,
.note-compose {
  width: min(560px, 100%);
  margin: 0 auto 22px;
}
.note-take,
.note-compose,
.note-card,
.note-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(20, 28, 40, 0.05), 0 8px 24px rgba(20, 28, 40, 0.04);
}
.note-take { display: flex; align-items: center; }
.note-take-main {
  flex: 1;
  justify-content: flex-start;
  min-height: 48px;
  padding: 0 16px;
  color: var(--muted);
  font-weight: 500;
}
.note-take-main:hover,
.note-take-list:hover { background: transparent; color: var(--ink); }
.note-take-list { width: 40px; min-height: 40px; margin-right: 6px; padding: 0; color: var(--muted); }
.note-compose,
.note-editor { padding: 14px 16px 10px; }
.note-title,
.note-body,
.note-item-text {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding: 2px 0;
}
.note-title { min-height: 36px; font-size: 1.05rem; font-weight: 650; }
.note-body {
  min-height: 120px;
  margin-top: 4px;
  overflow: hidden;
  resize: none;
  field-sizing: content;
}
.note-title:focus,
.note-title:focus-visible,
.note-body:focus,
.note-body:focus-visible,
.note-item-text:focus,
.note-item-text:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}
.note-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.note-row { display: flex; align-items: center; gap: 8px; }
.note-row input[type="checkbox"] { width: 16px; min-width: 16px; min-height: 16px; flex: none; accent-color: var(--accent); }
.note-item-text { min-height: 32px; }
.note-row.done .note-item-text { color: var(--muted); text-decoration: line-through; }
.note-tick {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line);
  border-radius: 3px;
  flex: none;
}
.note-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.note-colors { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.note-swatch {
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
}
.note-swatch[data-color="sand"] { background: #f3ead6; }
.note-swatch[data-color="sage"] { background: #e3efe4; }
.note-swatch[data-color="sky"] { background: #e3eef6; }
.note-swatch[data-color="rose"] { background: #f6e4e4; }
.note-swatch[data-color="lilac"] { background: #ece6f6; }
.note-swatch[data-color="stone"] { background: #e7eaee; }
.note-swatch.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.note-tool { width: 32px; min-height: 32px; padding: 0; color: var(--muted); }
.note-tool.on,
.note-tool.on:hover { color: var(--accent); }
.note-tool.danger:hover { color: var(--danger); background: var(--danger-bg); }
.note-done { min-height: 32px; padding: 0 12px; margin-left: 4px; font-weight: 650; }
.note-group { margin-top: 8px; }
.note-group h2 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.note-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  align-items: start;
}
.note-card { position: relative; box-shadow: 0 1px 2px rgba(20, 28, 40, 0.04); }
.note-open {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  min-height: 84px;
  padding: 14px 32px 14px 14px;
  border-radius: 12px;
  text-align: left;
  background: transparent;
}
.note-open:hover { background: transparent; }
.note-open strong { font-weight: 650; }
.note-open p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 12;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-pinned { position: absolute; top: 10px; right: 10px; color: var(--muted); }
.note-pinned .icon { width: 14px; height: 14px; }
.note-preview { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.note-preview li { display: flex; align-items: flex-start; gap: 8px; }
.note-preview li span {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  flex: none;
  opacity: 0.55;
}
.note-preview li.done { color: var(--muted); text-decoration: line-through; }
.note-preview li.done span { background: currentColor; }
.note-preview li.more { color: var(--muted); }
.note-card[data-color="sand"],
.note-compose[data-color="sand"],
.note-editor[data-color="sand"] { background: #f3ead6; }
.note-card[data-color="sage"],
.note-compose[data-color="sage"],
.note-editor[data-color="sage"] { background: #e3efe4; }
.note-card[data-color="sky"],
.note-compose[data-color="sky"],
.note-editor[data-color="sky"] { background: #e3eef6; }
.note-card[data-color="rose"],
.note-compose[data-color="rose"],
.note-editor[data-color="rose"] { background: #f6e4e4; }
.note-card[data-color="lilac"],
.note-compose[data-color="lilac"],
.note-editor[data-color="lilac"] { background: #ece6f6; }
.note-card[data-color="stone"],
.note-compose[data-color="stone"],
.note-editor[data-color="stone"] { background: #e7eaee; }
.note-editor { position: relative; width: min(560px, 100%); padding: 22px 44px 14px 20px; }
.note-dismiss { position: absolute; top: 8px; right: 8px; }
@media (max-width: 720px) {
  .note-head { padding: 12px 14px 0; gap: 8px; }
  .notes-scroll { padding: 12px 14px 40px; }
  .note-overlay { padding: 0; align-items: end; }
  .note-editor {
    width: 100%;
    overflow: visible;
    border-radius: 16px 16px 0 0;
  }
}
:root[data-theme="dark"] .note-card[data-color="sand"],
:root[data-theme="dark"] .note-compose[data-color="sand"],
:root[data-theme="dark"] .note-editor[data-color="sand"] { background: #3d3628; }
:root[data-theme="dark"] .note-card[data-color="sage"],
:root[data-theme="dark"] .note-compose[data-color="sage"],
:root[data-theme="dark"] .note-editor[data-color="sage"] { background: #243128; }
:root[data-theme="dark"] .note-card[data-color="sky"],
:root[data-theme="dark"] .note-compose[data-color="sky"],
:root[data-theme="dark"] .note-editor[data-color="sky"] { background: #243140; }
:root[data-theme="dark"] .note-card[data-color="rose"],
:root[data-theme="dark"] .note-compose[data-color="rose"],
:root[data-theme="dark"] .note-editor[data-color="rose"] { background: #3a2828; }
:root[data-theme="dark"] .note-card[data-color="lilac"],
:root[data-theme="dark"] .note-compose[data-color="lilac"],
:root[data-theme="dark"] .note-editor[data-color="lilac"] { background: #322a3d; }
:root[data-theme="dark"] .note-card[data-color="stone"],
:root[data-theme="dark"] .note-compose[data-color="stone"],
:root[data-theme="dark"] .note-editor[data-color="stone"] { background: #2a2e33; }
:root[data-theme="dark"] .note-swatch[data-color="sand"] { background: #3d3628; }
:root[data-theme="dark"] .note-swatch[data-color="sage"] { background: #243128; }
:root[data-theme="dark"] .note-swatch[data-color="sky"] { background: #243140; }
:root[data-theme="dark"] .note-swatch[data-color="rose"] { background: #3a2828; }
:root[data-theme="dark"] .note-swatch[data-color="lilac"] { background: #322a3d; }
:root[data-theme="dark"] .note-swatch[data-color="stone"] { background: #2a2e33; }

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