/* App shell: top bar, sidebar, outliner pages, dialogs, menus, toasts. */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body,
#app {
  height: 100%;
  margin: 0;
}
body {
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ico {
  display: inline-grid;
  place-items: center;
  flex: none;
  line-height: 0;
}
code {
  font: 0.88em var(--mono);
  background: var(--line);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
kbd {
  font: 11px var(--font);
  color: var(--muted);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  background: var(--surface);
}
.muted {
  color: var(--muted);
}
/* `hidden` must win over any display rule below */
[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ layout */
.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}
.stage {
  flex: 1;
  min-width: 0;
  position: relative;
}
.view {
  position: absolute;
  inset: 0;
  display: none;
}
.app[data-view='outliner'] .view-outliner,
.app[data-view='canvas'] .view-canvas {
  display: block;
}
.side-host {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: margin-left 0.22s var(--ease);
  z-index: 20;
}
.app[data-sidebar='closed'] .side-host {
  margin-left: calc(-1 * var(--sidebar-w));
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.spacer {
  flex: 1;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 16px;
  margin-right: 4px;
}
.logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  position: relative;
  display: inline-block;
}
.logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M6 6.5l5 10 5-10' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 0.12s;
}
.icon-btn:hover:not(:disabled) {
  background: var(--line);
  color: var(--ink);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.icon-btn.sm {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}
.nav-btns {
  display: flex;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--line);
  border-radius: 10px;
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 13px 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 550;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg-btn:hover {
  color: var(--ink);
}
.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.seg-btn.active .ico {
  color: var(--accent);
}

.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  min-width: 230px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  border-radius: 9px;
  color: var(--muted);
  text-align: left;
}
.search-btn:hover {
  border-color: var(--muted);
}
.search-btn .sb-label {
  flex: 1;
  font-size: 13.5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-weight: 550;
  font-size: 13.5px;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover {
  background: var(--line);
}
.btn.full {
  width: 100%;
}
.btn.danger {
  color: var(--red);
}
.btn.danger:hover {
  background: var(--red-soft);
  border-color: var(--red);
}
.btn.big {
  height: 46px;
  padding: 0 20px;
  font-size: 15px;
  border-radius: 11px;
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}
a.btn {
  text-decoration: none;
  color: inherit;
}
a.btn.primary {
  color: #fff;
}
/* a button that reads as a link inside a sentence */
.linklike {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn.center {
  display: flex;
  margin: 18px auto;
}
.today-btn .ico {
  color: var(--amber);
}

.sync {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  white-space: nowrap;
  max-width: 230px;
}
.sync:hover {
  background: var(--line);
}
.sync.warn .dot {
  background: var(--amber);
}
.sync.warn {
  color: var(--ink-2);
}
.sync span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.sync .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
}
.sync.busy .dot {
  background: var(--amber);
  animation: blink 1s infinite;
}
.sync.err .dot {
  background: var(--red);
}
.sync.err {
  color: var(--red);
}
.sync.demo .dot {
  background: var(--muted);
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: var(--amber-soft);
  color: var(--ink);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.banner .banner-text {
  flex: 1;
  min-width: 0;
}
.banner .ico {
  color: var(--amber);
}
.banner .btn.sm {
  flex: none;
}
/* states that stop changes from being saved: sign in again (warn), the notes folder is missing (err) */
.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: none;
}
.banner.state.err {
  background: var(--red-soft);
}
.banner.state.err .ico {
  color: var(--red);
}

/* the dimmed page behind the sidebar drawer on a phone (see the responsive rules) */
.scrim {
  display: none;
}

/* ----------------------------------------------------------------- sidebar */
.sidebar {
  width: var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
}
.sb-tabs {
  display: flex;
  padding: 10px 10px 0;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}
.sb-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.sb-tab:hover {
  color: var(--ink);
}
.sb-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.sb-panel {
  flex: 1;
  min-height: 0;
}
.sb-body {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.sb-top {
  padding: 12px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sb-scroll {
  flex: 1;
  overflow: auto;
  padding: 0 6px 24px;
}
.sb-filter {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13.5px;
}
.sb-filter:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}
.sb-today {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
}
.sb-today .ico {
  color: var(--amber);
}
.sb-today b {
  display: block;
  line-height: 1.2;
}
.sb-today small {
  color: var(--muted);
  font-size: 12px;
}
.sb-today.active,
.sb-today:hover {
  border-color: var(--amber);
}
.sb-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 14px 8px 4px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sb-head.toggle:hover {
  color: var(--ink);
}
.sb-head .count {
  margin-left: auto;
  font-weight: 500;
  letter-spacing: 0;
}
.sb-head .push {
  margin-left: auto;
}
.sb-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  color: var(--ink-2);
}
.sb-row:hover {
  background: var(--line);
}
.sb-row.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.sb-row .ico {
  color: var(--muted);
}
.sb-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.sb-title small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.2;
}
.sb-sub {
  font-size: 11.5px;
  color: var(--muted);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-off {
  color: var(--muted);
  opacity: 0.7;
}
.sb-empty,
.sb-hint {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 10px;
  margin: 0;
}
.sb-hint code {
  font-size: 11.5px;
  word-break: break-all;
}
.sb-empty.warn {
  color: var(--red);
}
.sb-warn {
  display: flex;
  gap: 8px;
  margin: 14px 6px;
  padding: 10px;
  border-radius: 10px;
  background: var(--amber-soft);
  font-size: 12.5px;
}
.sb-warn .ico {
  color: var(--amber);
  margin-top: 2px;
}
.sb-warn p {
  margin: 4px 0;
}
.inbox-row .btn {
  flex: none;
}
.dropzone {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 16px 10px;
  border: 1.5px dashed var(--line-2);
  border-radius: 12px;
  text-align: center;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.dropzone span {
  font-size: 12px;
  color: var(--muted);
}
.dropzone .ico {
  color: var(--accent);
  margin-bottom: 4px;
}
.dropzone:hover,
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.avatar {
  --h: 220;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: hsl(var(--h) 45% 28%);
  background: hsl(var(--h) 60% 88%);
}
.avatar.sm {
  width: 24px;
  height: 24px;
  font-size: 10px;
}
.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 20px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .avatar {
    color: hsl(var(--h) 70% 85%);
    background: hsl(var(--h) 35% 24%);
  }
}

/* ---------------------------------------------------------- outliner pages */
.outliner,
.ol-scroll {
  height: 100%;
}
.ol-scroll {
  overflow: auto;
}
.page-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 34px 32px 160px;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.eyebrow .ico {
  color: var(--amber);
}
.divider-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 44px 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.page {
  margin-bottom: 8px;
}
.page.compact {
  margin-bottom: 26px;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.page-head.daily {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.head-main {
  flex: 1;
  min-width: 0;
}
.kicker {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--violet);
}
.page-title {
  display: block;
  width: 100%;
  margin: 0;
  padding: 2px 6px;
  margin-left: -6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 720;
  letter-spacing: -0.022em;
  color: var(--ink);
}
input.page-title:hover {
  background: var(--line);
}
input.page-title:focus {
  outline: 2px solid var(--accent);
  background: var(--surface);
}
.page.big .page-title.static {
  font-size: 34px;
}
.page.compact .page-title {
  font-size: 19px;
  font-weight: 650;
  color: var(--ink-2);
}
.page-title.static {
  width: auto;
  cursor: default;
}
.daily-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
}
.pill.today {
  background: var(--amber-soft);
  color: var(--amber);
}
.iso,
.chip-link {
  font: 12.5px var(--mono);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 2px 4px;
  border-radius: 5px;
}
.chip-link:hover {
  background: var(--line);
  color: var(--ink);
}
.day-nav {
  display: flex;
  gap: 6px;
  margin: 2px 0 6px -8px;
}
.page-body {
  margin-left: -4px;
}

.contact-panel {
  margin: 4px 0 18px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 16px;
}
.field {
  display: block;
}
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}
.field-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--surface-2);
}
.field-input:hover {
  border-color: var(--line-2);
}
.field-input:focus {
  outline: 2px solid var(--accent);
  background: var(--surface);
}

.refs {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.refs-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.refs-title .count {
  background: var(--line);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 0 7px;
  letter-spacing: 0;
  font-size: 11.5px;
}
.refs.empty p {
  margin: 0;
  font-size: 13.5px;
}
.ref-group {
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.ref-source {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  border: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-weight: 650;
  font-size: 13.5px;
  color: var(--accent-ink);
}
.ref-source:hover {
  background: var(--accent-soft);
}
.ref-source .ico {
  color: var(--muted);
}
.ref-block {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14.5px;
}
.ref-block + .ref-block {
  border-top: 1px dashed var(--line);
}
.ref-block:hover {
  background: var(--surface-2);
}
.ref-trail {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.static-blk {
  display: flex;
  gap: 4px;
}
.static-blk .bullet {
  width: 16px;
  height: 22px;
}
.static-text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.static-kids {
  margin-left: 20px;
}

/* ------------------------------------------------- palette / dialogs / menus */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  background: rgba(20, 19, 16, 0.36);
  backdrop-filter: blur(2px);
  animation: fade 0.12s ease-out;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.palette {
  width: min(620px, calc(100vw - 24px));
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: pop 0.16s var(--ease);
}
@keyframes pop {
  from {
    transform: translateY(-6px) scale(0.985);
    opacity: 0;
  }
}
.palette-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.palette-input {
  flex: 1;
  height: 54px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
}
.palette-list {
  max-height: min(52vh, 420px);
  overflow: auto;
  padding: 6px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.palette-item .ico {
  color: var(--muted);
}
.palette-item.sel {
  background: var(--accent-soft);
}
.palette-item.sel .ico {
  color: var(--accent);
}
.pi-title {
  font-weight: 550;
  white-space: nowrap;
}
.pi-sub {
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.palette-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: var(--surface-2);
}

.dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  animation: pop 0.18s var(--ease);
}
.dialog.wide {
  width: min(960px, calc(100vw - 24px));
}
.modal-backdrop:has(.dialog) {
  padding-top: 6vh;
}
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px 20px;
}
.dlg-head h2 {
  margin: 0;
  font-size: 17px;
}
.dlg-body {
  padding: 4px 20px 16px;
  overflow: auto;
}
.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}
.dlg-input,
.dlg-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface-2);
}
.dlg-textarea {
  resize: vertical;
  line-height: 1.5;
}
.dlg-textarea.mono {
  font: 13px/1.55 var(--mono);
}
.dlg-input:focus,
.dlg-textarea:focus {
  outline: 2px solid var(--accent);
  background: var(--surface);
}
.lbl {
  display: block;
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-2);
}
.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 20px;
}
.sum-side .lbl:first-child {
  margin-top: 12px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border: 1px dashed var(--line-2);
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink-2);
}
.chip.exists {
  border-style: solid;
}
.chip:hover {
  border-color: var(--accent);
}
.chip.on {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent-ink);
}
.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 8px 0;
  font-size: 13px;
}
.check input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.kw {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
}
/* who wrote the draft (Claude or Veda itself) */
.sum-note {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 12.5px;
}
.sum-note .ico {
  color: var(--accent);
  margin-top: 2px;
}
.sum-note p {
  margin: 0;
}
/* "Claude is reading …" */
.working {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 4px 6px;
  text-align: center;
}
.working p {
  margin: 0;
}
.working-text {
  font-weight: 550;
}
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.confirm-body p {
  margin: 4px 0 10px;
}

/* ---------------------------------------------------------------- settings */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.set-section {
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}
.set-section:last-child {
  border-bottom: 0;
}
.set-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.set-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 4px 14px;
  margin: 10px 0;
}
.set-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  padding-top: 2px;
}
.set-value {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.set-detail {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.set-detail.warn {
  color: var(--red);
}
.set-detail:empty {
  display: none;
}
.set-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.set-inline .dlg-input {
  flex: 1;
  min-width: 0;
}
.set-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.set-warn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--amber-soft);
  font-size: 13px;
}
.set-warn p {
  flex: 1;
  margin: 0;
}
.set-warn .ico {
  color: var(--amber);
}
select.dlg-input {
  height: 38px;
}

/* ------------------------------------------- connect, loading and message screens */
.boot-screen {
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(8vh + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.boot-card {
  width: min(460px, 100%);
  padding: 28px 28px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
}
.boot-card.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.boot-card h1,
.connect-panel h1 {
  margin: 14px 0 6px;
  font-size: 22px;
  letter-spacing: -0.015em;
}
.connect-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
}
.connect-lead {
  margin: 0 0 14px;
  color: var(--ink-2);
}
.connect-error {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13.5px;
}
.connect-note {
  display: flex;
  gap: 9px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--amber-soft);
  font-size: 13.5px;
}
.connect-note p {
  margin: 0;
}
.connect-note .ico {
  color: var(--amber);
  margin-top: 2px;
}
.connect-part {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.connect-part > .linklike {
  font-size: 13px;
}
.connect-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-2);
  font-size: 14px;
}
.connect-steps li + li {
  margin-top: 4px;
}
.code-row {
  display: flex;
  gap: 8px;
}
.code-row .dlg-input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
}
.connect-small {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.connect-alt {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.boot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* in the Reconnect dialog the dialog's own title says it */
.connect-dialog .connect-panel h1 {
  display: none;
}

.pop-menu {
  position: fixed;
  z-index: 200;
  min-width: 210px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  box-shadow: var(--shadow-2);
  animation: pop 0.12s var(--ease);
}
.pop-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  text-align: left;
  font-size: 13.5px;
  white-space: nowrap;
}
.pop-item:hover:not(:disabled) {
  background: var(--accent-soft);
}
.pop-item .ico {
  color: var(--muted);
  width: 15px;
}
.pop-item.danger {
  color: var(--red);
}
.pop-item.danger .ico {
  color: var(--red);
}
.pop-item.danger:hover {
  background: var(--red-soft);
}
.pop-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--line);
}

.ac {
  position: fixed;
  z-index: 150;
  min-width: 220px;
  max-width: 340px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  font: 14px var(--font);
}
.ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
}
.ac-item.sel {
  background: var(--accent-soft);
}
.ac-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-kind {
  font-size: 11px;
  color: var(--muted);
}
.ac-plus {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  line-height: 1;
}
.ta-mirror {
  font: inherit;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 8px 10px 16px;
  background: #24231f;
  color: #f4f3ee;
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  animation: toast-in 0.2s var(--ease);
}
.toast.warn {
  background: #5b3a0e;
}
@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}
.toast-msg {
  flex: 1;
}
.toast-action {
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 650;
  padding: 4px 11px;
  border-radius: 7px;
}
.toast-action:hover {
  background: rgba(255, 255, 255, 0.24);
}
.toast-x {
  border: 0;
  background: none;
  color: #bdbab0;
  padding: 4px;
}

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

/* Safe areas: index.html uses viewport-fit=cover, so the home indicator and (in landscape) the notch
   sit over the page. Keep content and controls out from under them. */
.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
}
.toasts {
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.page-wrap {
  padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px));
}
.sb-scroll {
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 860px) {
  /* the sidebar becomes a drawer over the page, with the page dimmed behind it */
  .side-host {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(var(--sidebar-w), 86vw);
    padding-left: env(safe-area-inset-left, 0px);
    box-shadow: var(--shadow-3);
  }
  .sidebar {
    width: 100%;
  }
  .app[data-sidebar='closed'] .side-host {
    margin-left: calc(-1 * min(var(--sidebar-w), 86vw) - env(safe-area-inset-left, 0px) - 24px);
  }
  .app[data-sidebar='open'] .scrim {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 15;
    background: rgba(20, 19, 16, 0.32);
    animation: fade 0.15s ease-out;
  }
  .search-btn {
    min-width: 0;
    width: 36px;
    padding: 0;
    justify-content: center;
  }
  .search-btn .sb-label,
  .search-btn kbd,
  .brand,
  .sync span,
  .today-btn span:not(.ico) {
    display: none;
  }
  .today-btn {
    width: 34px;
    padding: 0;
  }
  .page-wrap {
    padding: 22px max(18px, env(safe-area-inset-right, 0px)) calc(120px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  }
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .dlg-foot {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  /* compact top bar: icons only */
  .topbar {
    gap: 4px;
  }
  .seg-btn span:not(.ico) {
    display: none;
  }
  .seg-btn {
    padding: 0 10px;
  }
  /* an installed iPhone app has no browser Back button: keep ours, drop Forward */
  .nav-btns .fwd {
    display: none;
  }
  /* the status pill makes room: a dot on the Settings button shows offline, sign-in and save problems */
  .topbar .sync {
    display: none;
  }
  .settings-btn {
    position: relative;
  }
  .app[data-sync='warn'] .settings-btn::after,
  .app[data-sync='err'] .settings-btn::after {
    content: '';
    position: absolute;
    top: 7px;
    right: 7px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    background: var(--amber);
  }
  .app[data-sync='err'] .settings-btn::after {
    background: var(--red);
  }
  .page-title {
    font-size: 26px;
  }
  .page.big .page-title.static {
    font-size: 28px;
  }
  /* dialogs become sheets from the bottom of the screen */
  .modal-backdrop,
  .modal-backdrop:has(.dialog) {
    align-items: flex-end;
    padding: env(safe-area-inset-top, 0px) 0 0;
  }
  .dialog,
  .dialog.wide {
    width: 100%;
    max-height: calc(100% - 12px);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: sheet 0.2s var(--ease);
  }
  .dialog.wide,
  .dialog.settings {
    height: calc(100% - 12px);
  }
  .dlg-body {
    flex: 1;
    padding: 4px 16px 14px;
  }
  .dlg-head {
    padding: 10px 10px 6px 16px;
  }
  .dlg-foot {
    padding: 10px 16px 12px;
  }
  .dlg-foot .btn {
    flex: 1 1 auto;
  }
  .palette {
    width: calc(100vw - 16px);
  }
  .modal-backdrop:has(.palette) {
    align-items: flex-start;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }
  .set-row {
    grid-template-columns: 1fr;
  }
  .boot-screen {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  .boot-card {
    padding: 22px 18px 20px;
  }
  .toasts {
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    align-items: stretch;
  }
  .toast {
    max-width: none;
  }
  /* the state banner's choices go on a line of their own, below its text (and its close button) */
  .banner.state {
    flex-wrap: wrap;
  }
  .banner.state .icon-btn {
    order: 1;
  }
  .banner.state .banner-actions {
    order: 2;
    width: 100%;
  }
}
@media (max-width: 370px) {
  /* the smallest phones: Today is in the sidebar too */
  .today-btn {
    display: none;
  }
}
@keyframes sheet {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

/* Touch screens: every control at least 44 px (Apple's minimum), and text fields at 16 px or more,
   below which iOS zooms the whole page in when one is focused. (The editor's own: css/editor.css.) */
@media (pointer: coarse) {
  .topbar .icon-btn,
  .dlg-head .icon-btn,
  .banner .icon-btn {
    width: 44px;
    height: 44px;
  }
  .topbar .btn,
  .topbar .search-btn,
  .seg-btn {
    height: 40px;
    min-width: 44px;
  }
  .sync {
    height: 44px;
    min-width: 44px;
    justify-content: center;
  }
  .sidebar .btn,
  .dialog .btn,
  .boot-card .btn,
  .banner .btn,
  .page-head .btn,
  .day-nav .btn,
  .toast-action {
    min-height: 44px;
  }
  .toast-x {
    width: 44px;
    height: 44px;
  }
  .sb-tab,
  .sb-row,
  .sb-today,
  .pop-item,
  .palette-item,
  .ref-source {
    min-height: 44px;
  }
  .chip {
    height: 36px;
    padding: 0 12px;
  }
  .check {
    min-height: 32px;
    align-items: center;
  }
  .check input {
    width: 20px;
    height: 20px;
    margin-top: 0;
  }
  .linklike {
    padding: 6px 0;
  }
  .dlg-input,
  .dlg-textarea,
  .dlg-textarea.mono,
  .sb-filter,
  .field-input,
  .palette-input,
  select.dlg-input {
    font-size: 16px;
  }
  .dlg-input,
  .sb-filter,
  .field-input,
  select.dlg-input {
    min-height: 44px;
  }
  .dropzone {
    padding: 20px 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
