/* Layout and components. Colours come from /theme.css tokens.
   Type, shapes and chrome follow the suite look shared with fintracker. */

/* Bricolage Grotesque, SIL Open Font License 1.1 (latin subset). */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url("bricolage-grotesque.woff2") format("woff2");
}

:root {
  --radius: 18px;
  --sans: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --serif: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
}

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

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 8% -10%, var(--glow, transparent), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--selection, var(--accent-soft)); }

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

button, .button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--wash, var(--surface-alt)); }
button:disabled { opacity: 0.6; cursor: default; }
button.primary, .button.primary {
  background: var(--accent-fill, var(--accent));
  border-color: transparent;
  color: var(--on-accent);
}
button.primary:hover, .button.primary:hover { background: var(--accent-fill, var(--accent)); filter: brightness(1.06); }
button.danger { background: transparent; border-color: var(--danger-line, var(--negative)); color: var(--negative); }
button.danger:hover { background: var(--negative-soft, var(--surface-alt)); }
button.link {
  border: 0;
  background: none;
  padding: 0;
  min-height: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.wide { width: 100%; }

.icon { display: inline-flex; line-height: 0; }
.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-color: transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: var(--wash, var(--surface-alt)); border-color: transparent; }
/* "add" buttons: outlined circle, as in myve Cards */
.icon-btn.accent { width: 40px; height: 40px; flex: none; border-color: var(--border); color: var(--text); }
.icon-btn.accent:hover { border-color: var(--border); }

input[type="text"], input[type="password"], input[type="url"], select, textarea {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input, var(--surface));
  width: 100%;
  min-width: 0;
}
input::placeholder { color: var(--muted); opacity: 0.8; }
input.invalid { border-color: var(--negative) !important; color: var(--negative); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 0.78rem; color: var(--muted); }
.hint { color: var(--muted); margin: 0; font-size: 0.9rem; }
.form-error { color: var(--negative); margin: 0; min-height: 1.2em; font-size: 0.9rem; }
.form-actions { display: flex; justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 1; }
.inline-form select { width: auto; }

/* ---------- top: see the shell at the end ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--brand);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}
/* app logo beside the site title */
.mark { width: 28px; height: 28px; flex: none; display: block; }
.login-card .mark { width: 26px; height: 26px; }

/* page heading: title left, page actions (add / return / ⋮) right */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 18px; }
.kicker { margin: 0 0 6px; color: var(--accent); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
.title { font-size: clamp(2.1rem, 4vw, 3.2rem); line-height: 1.1; overflow-wrap: anywhere; }
.head-links { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: 8px; }
.head-links .icon-btn { width: 40px; height: 40px; flex: none; border-color: var(--border); color: var(--muted); }
.head-links .icon-btn:hover, .head-links .icon-btn[aria-expanded="true"] { color: var(--text); background: var(--wash, var(--surface-alt)); }
.head-links .icon-btn.accent { color: var(--text); font-size: 1.45rem; }

.save-btn[data-state="saved"] { color: var(--muted); }
.save-btn[data-state="pending"] { color: var(--accent); }
.save-btn[data-state="done"] { color: var(--positive); }
.save-btn[data-state="saving"] { color: var(--accent); }
.save-btn[data-state="saving"] svg { animation: spin 0.9s linear infinite; }
.save-btn[data-state="error"], .save-btn[data-state="conflict"] { color: var(--negative); }
.save-btn[data-state="offline"] { color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- popup menus ---------- */

.popup {
  position: absolute;
  z-index: 50;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.menu-item {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  border: 0;
  background: none;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text);
}
.menu-item:hover { background: var(--wash, var(--surface-alt)); color: var(--accent-hover); }
.menu-item .icon { color: var(--muted); }
.menu-label { flex: 1; text-align: left; }
.menu-row { display: flex; align-items: center; }
.menu-row .menu-item { flex: 1; }
.menu-side { width: 32px; height: 32px; }
.menu-side svg { width: 17px; height: 17px; }
.menu-sub .menu-item { padding-left: 40px; min-height: 32px; }
.menu-item.pending { background: var(--accent-soft); font-weight: 600; }
.menu-note { max-width: 240px; padding: 4px 10px 6px 40px; font-size: 0.78rem; color: var(--muted); }
.menu-heading { padding: 6px 12px 4px; font-size: 0.78rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.14em; }

/* ---------- views ---------- */

.view { max-width: calc(var(--page-w) + 2 * var(--page-side)); margin: 0 auto; padding: 28px var(--page-side) 72px; }
.loading, .empty { text-align: center; color: var(--muted); margin-top: 48px; }
.empty .icon { vertical-align: middle; }

/* checkboxes */
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

/* tables: every cell centred, rows striped */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 13px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}
td { padding: 6px 8px; vertical-align: middle; text-align: center; }
/* faint column separators on every table */
th + th, td + td { border-left: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
tbody tr.even { background: var(--surface); }
tbody tr.odd { background: var(--surface-alt); }
tbody tr:hover { background: color-mix(in srgb, var(--text) 7%, var(--surface)); }
.col-act { width: 1%; white-space: nowrap; text-align: center; }
.del-btn:hover { color: var(--negative); }
.archive-btn:hover { color: var(--accent); }

.choice { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.choice input { margin-top: 3px; flex: none; }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); }
code { font: 0.85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-alt); padding: 1px 5px; border-radius: 5px; }
.key-reveal { display: flex; flex-direction: column; gap: 6px; }
.key-reveal input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.scope-picker { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.access-form { gap: 10px; }
.list-picker { padding-left: 12px; border-left: 2px solid var(--border); }
.sheet .col-act { white-space: nowrap; }
pre.diff {
  margin: 0;
  max-height: 50vh;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-sunk);
  font: 0.8rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
pre.diff span { display: block; white-space: pre; }
pre.diff .diff-head { color: var(--muted); }
pre.diff .del { color: var(--negative); background: color-mix(in srgb, var(--negative) 10%, transparent); }
pre.diff .add { color: var(--positive); background: color-mix(in srgb, var(--positive) 10%, transparent); }

button.danger-outline { color: var(--negative); }
button.danger-outline:hover { border-color: var(--negative); }

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

.settings-view { display: flex; flex-direction: column; gap: 18px; }
.card { padding: 16px 18px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.card > h2 { font-size: 1.45rem; }
.narrow-form { max-width: 360px; }
.narrow-form .form-actions { justify-content: flex-start; }
input[type="password"] { width: 100%; }

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

.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.modal.wide { width: min(860px, calc(100vw - 32px)); }
.modal::backdrop { background: var(--backdrop, rgb(20 12 5 / 45%)); }
.modal-head h2 { font-size: 1.45rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 4px 18px; }
.modal-body { padding: 8px 18px 18px; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }
.skipped { max-height: 240px; overflow: auto; margin: 0; padding-left: 18px; font-size: 0.85rem; color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 100;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.has-undo #toast { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 56px); }

#undo-bar {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 100;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
  white-space: nowrap;
}
#undo-bar .icon-btn { color: var(--bg); }
.undo-btn {
  position: relative;
  overflow: hidden;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 0;
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}
.undo-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--accent, currentColor);
  transform-origin: left;
  animation: undo-run linear forwards;
}
@keyframes undo-run { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .undo-timer { animation-timing-function: steps(30); } }
#toast.error { background: var(--surface); color: var(--negative); box-shadow: inset 0 0 0 1px var(--danger-line, var(--negative)), var(--shadow); }

/* ---------- login ---------- */

.login { min-height: 100vh; min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)); display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%);
  padding: 28px 24px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-card .brand h1 { font-size: 1.6rem; font-weight: 600; }
.login-card input { padding: 0 12px; min-height: 44px; }
.login-card .button, .login-card button.wide { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; }
.or { text-align: center; color: var(--muted); font-size: 0.85rem; }
.login-foot { display: flex; justify-content: center; }
.boot-error { text-align: center; margin-top: 30vh; color: var(--negative); }

/* User settings: a titled part of a card (Export/import, Home region, Add region). */
.sub-section { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.sub-section h3 { margin: 0; font-size: 0.95rem; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-actions { flex-wrap: wrap; gap: 8px; }
.settings-view .form-actions { justify-content: flex-start; }
.settings-view .form-actions .button { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }

/* ---------- lists ---------- */

textarea { padding: 8px 12px; resize: vertical; min-height: 72px; line-height: 1.4; }
.invisible { visibility: hidden; }
.sheet .col-num { width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.sheet .col-act .icon-btn { width: 34px; height: 34px; }
/* Lists overview: the Title column reads left to right. */
.overview th:first-child, .overview td.col-title { text-align: left; padding-left: 16px; }
.list-link { font-weight: 600; color: var(--text); text-decoration: none; }
.list-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.cell-text { display: inline-block; min-height: 34px; line-height: 34px; }
.tag { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; font-size: 0.72rem; color: var(--muted); background: var(--wash, var(--surface-alt)); vertical-align: middle; }

/* items */
.items .col-check { width: 1%; }
.items td.col-check { height: 1px; padding: 0; }
.items .check-cell { display: grid; place-items: center; min-width: 40px; min-height: 40px; height: 100%; cursor: pointer; }
.items .col-image { width: 1%; }
.items th .icon-cell { display: inline-flex; vertical-align: middle; }
.items th .icon-cell svg { width: 16px; height: 16px; }
.items .item-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.items a.item-name:hover { color: var(--accent); }
.items a.item-name svg { width: 15px; height: 15px; color: var(--muted); }
.item-desc { margin-top: 2px; font-size: 0.85rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.items tr.checked .item-name { text-decoration: line-through; color: var(--muted); }
.items tr.checked .thumb { opacity: 0.55; }
.thumb-btn { padding: 0; min-height: 0; border: 0; border-radius: 10px; background: none; }
.thumb { display: block; width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: var(--surface-sunk); }
.list-foot { display: flex; justify-content: center; margin-top: 16px; }
.full-image { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 12px; }

/* item form */
.image-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.thumb-wrap { position: relative; }
.form-thumb { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-sunk); }
.thumb-remove { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; background: var(--surface); border-color: var(--border); color: var(--negative); }
.thumb-remove svg { width: 15px; height: 15px; }
.thumb-remove:hover { background: var(--negative-soft); }
#item-form .hint:empty { display: none; }

/* search */
.head-links .filter-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.search-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 0 6px 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--input, var(--surface)); }
.search-bar .icon { color: var(--muted); }
.search-bar svg { width: 16px; height: 16px; }
.search-input { flex: 1; min-width: 0; min-height: 40px; border: 0; background: none; outline: none; }
.search-bar:focus-within { border-color: var(--accent); }
.match-hint { margin-top: 2px; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.match-link { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 2px; }
.match-link:hover { color: var(--accent); }
/* The item a search result linked to. */
.items tr.flash td { animation: flash 2.4s ease-out; }
@keyframes flash { from, 40% { background: var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { .items tr.flash td { animation-timing-function: steps(1, end); } }

/* tags */
.tag-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; vertical-align: middle; }
.tag-chip { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border: 0; border-radius: 999px; font-size: 0.75rem; color: var(--accent); background: var(--accent-soft); }
button.tag-chip:hover { background: var(--accent-soft); filter: brightness(1.15); text-decoration: underline; }
.list-tags { margin: -8px 0 14px; }
.list-tags .tag-chips { margin-left: 0; }
/* Item tags sit under the item. */
.item-tags { margin-top: 4px; }
.item-tags .tag-chips { margin-left: 0; justify-content: center; }
.items tr.checked .tag-chip { opacity: 0.6; }
/* Lists page: tags sit quietly on their own line under the title. */
.overview td.col-title { padding-top: 8px; padding-bottom: 8px; line-height: 1.3; }
.overview .tag-chips { display: flex; gap: 2px 10px; margin: 3px 0 0; }
.overview .tag-chip { min-height: 0; padding: 0; border-radius: 0; background: none; font-size: 0.72rem; letter-spacing: 0.01em; color: var(--muted); }
.overview button.tag-chip:hover { background: none; filter: none; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.overview .match-hint { margin-top: 3px; }
.list-name { font-weight: 600; }

/* Drag to reorder, the same in every myve app (reorder.ts): the dots at the left of a row. */
.grip {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 34px;
  border-radius: 8px;
  color: var(--faint);
  cursor: grab;
  touch-action: none;
}
.grip:hover { color: var(--text); background: var(--wash, var(--surface-alt)); }
.grip svg { width: 18px; height: 18px; }
/* In a table they sit in the first cell, whose text starts after them. */
.movable th:first-child, .movable td.col-title { padding-left: 38px; }
.movable td.col-title { position: relative; }
.movable .grip { position: absolute; top: 50%; left: 6px; transform: translateY(-50%); }
/* Where it lands. On the cells: not every browser positions a line in a row. */
tr[data-drop='before'] > td { box-shadow: inset 0 3px var(--accent); }
tr[data-drop='after'] > td { box-shadow: inset 0 -3px var(--accent); }
.drag-source { opacity: 0.45; }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.drag-ghost {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  max-width: 240px;
  padding: 8px 12px;
  overflow: hidden;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.drag-ghost.invalid { border-color: var(--negative); opacity: 0.7; }

/* palette */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 34px; height: 34px; min-height: 0; padding: 0; border: 2px solid var(--border); border-radius: 50%; }
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.swatch-default { background: linear-gradient(135deg, #e4b56a 50%, #171a20 50%); }

/* palette dock: bottom left of every page */
.palette-dock { position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 90; }
.palette-btn { width: 42px; height: 42px; border: 1px solid var(--border); background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.palette-btn:hover, .palette-btn[aria-expanded="true"] { background: var(--surface); color: var(--accent-hover); border-color: var(--accent); }
.palette-panel { position: absolute; left: 0; bottom: calc(100% + 10px); width: min(300px, calc(100vw - 32px)); padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }

/* API keys */
.key-reveal { display: flex; flex-direction: column; gap: 6px; }
.key-reveal input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.settings-view code { overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .view { padding: 18px var(--page-side) 64px; }
  td { padding: 4px; }
  th { padding: 10px 4px; font-size: 0.68rem; letter-spacing: 0.02em; }
  .sheet .col-act .icon-btn { width: 30px; height: 34px; }
  .thumb { width: 44px; height: 44px; }
  /* Icons that do not fit beside the title go below it. */
  .page-head { flex-wrap: wrap; align-items: flex-start; gap: 8px 16px; }
  .page-head > div:first-child { flex: 1 1 13.5rem; min-width: 0; }
  .page-head > .head-links { margin-left: auto; }
}
/* Touch screens: larger targets. */
@media (pointer: coarse) {
  .items .check-cell { min-width: 44px; min-height: 44px; }
  .items .check-cell input { width: 22px; height: 22px; }
  .items a.item-name { padding-block: 8px; }
  .tag-chip { min-height: 28px; padding: 0 10px; }
  .overview .tag-chip { min-height: 26px; padding: 0 4px; margin-left: -4px; }
  .sheet .col-act .icon-btn { width: 36px; height: 40px; }
  .check { min-height: 36px; }
  .menu-item { min-height: 40px; }
}

/* ---------------------------------------------------------------------------
   Shell, the same in every myve app: the menu button (top left) opens the side
   menu; status icons sit at the top right. On phones the side menu is a bar at
   the bottom, with a gear for the theme, settings, and signing out.
   Each app maps the --shell-* colours to its own tokens.
   --------------------------------------------------------------------------- */
:root {
  --shell-nav-w: 264px;
  --shell-bar-h: 62px;
  --shell-tap: 44px;
  --shell-top: 64px;
  /* The page column (TEMPLATE.md, Page widths): its width, and the room beside it. */
  --page-w: 1120px;
  --page-side: 16px;
  /* Where page titles start: the page column, centred. */
  --shell-page-left: max(var(--page-side), calc((100% - var(--page-w)) / 2));
  /* Room that fixed buttons at the bottom keep free (the phone bar). */
  --shell-under: 0px;
}
@media (max-width: 800px) {
  :root {
    --page-side: 10px;
  }
}
/* As wide, and in the same place, with and without a scrollbar. */
html:has(body.has-shell):not(.editor-fullscreen) {
  scrollbar-gutter: stable;
}
body.has-shell {
  padding-top: calc(var(--shell-top) + env(safe-area-inset-top));
}
.shell-menu,
.shell-status {
  position: fixed;
  z-index: 40;
  top: calc(10px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  min-height: var(--shell-tap);
  border: 1px solid var(--shell-line);
  border-radius: 14px;
  background: var(--shell-float);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shell-pill-shadow, 0 6px 20px rgba(0, 0, 0, 0.16));
}
.shell-menu {
  z-index: 47;
  left: calc(10px + env(safe-area-inset-left));
  justify-content: center;
  width: var(--shell-tap);
  padding: 0;
  color: var(--shell-text);
  cursor: pointer;
}
.shell-menu:hover {
  background: var(--shell-panel);
}
.shell-status {
  right: calc(10px + env(safe-area-inset-right));
  gap: 2px;
  padding: 0 4px;
}
.shell-status:empty {
  display: none;
}
.shell-scrim {
  position: fixed;
  z-index: 44;
  inset: 0;
  background: var(--shell-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.shell-nav {
  position: fixed;
  z-index: 45;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(86vw, var(--shell-nav-w));
  display: flex;
  flex-direction: column;
  padding: calc(var(--shell-top) + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  background: var(--shell-panel);
  border-right: 1px solid var(--shell-line);
  box-shadow: var(--shell-shadow);
  transform: translateX(-102%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0s linear 0.2s;
}
.shell-open .shell-nav {
  transform: none;
  visibility: visible;
  transition: transform 0.2s ease;
}
.shell-open .shell-scrim {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease;
}
/* The site's name: plain text that leads home, in line with the page titles
   (right of the menu button when the page starts further left), top left on
   phones. It scrolls away with the page. */
.shell-title {
  position: absolute;
  z-index: 40;
  top: calc(10px + env(safe-area-inset-top));
  left: max(calc(10px + var(--shell-tap) + 12px + env(safe-area-inset-left)), var(--shell-page-left));
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--shell-tap);
  max-width: calc(50% - 90px);
  color: var(--shell-text);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.shell-title:hover {
  color: var(--shell-accent);
}
.shell-title img,
.shell-title .mark {
  flex: none;
  width: 24px;
  height: 24px;
}
.shell-title span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shell-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.shell-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--shell-text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.2;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
  justify-content: flex-start;
  box-shadow: none;
  cursor: pointer;
}
.shell-item svg {
  flex: none;
  color: var(--shell-muted);
}
.shell-item > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-item:hover {
  background: var(--shell-wash);
}
.shell-item.on {
  background: var(--shell-accent-dim);
  color: var(--shell-accent);
}
.shell-item.on svg {
  color: inherit;
}
.shell-item:focus-visible,
.shell-bar-item:focus-visible,
.shell-title:focus-visible,
.shell-menu:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: -2px;
}
.shell-sub {
  min-height: 36px;
  padding-left: 40px;
  font-size: 0.92rem;
}
.shell-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 2px;
  color: var(--shell-muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.shell-label svg {
  flex: none;
}
.shell-sep {
  flex: none;
  height: 1px;
  margin: 8px 10px;
  background: var(--shell-line);
}
.shell-foot {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--shell-line);
}
.shell-foot form,
.shell-pop form {
  margin: 0;
}
.shell-pop {
  position: absolute;
  z-index: 46;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--shell-line);
  border-radius: 14px;
  background: var(--shell-panel);
  box-shadow: var(--shell-shadow);
}
.shell-pop[hidden] {
  display: none;
}
/* Theme labels: the toggle names the theme it switches to. */
.shell-when-light {
  display: none;
}
.shell-bar {
  display: none;
}

@media (max-width: 700px) {
  :root {
    --shell-under: calc(var(--shell-bar-h) + env(safe-area-inset-bottom));
  }
  body.has-shell {
    padding-top: calc(60px + env(safe-area-inset-top));
    padding-bottom: calc(var(--shell-bar-h) + env(safe-area-inset-bottom));
  }
  /* The bar holds the menu; only the wiki keeps the menu button, for its drawers. */
  .shell-menu:not(.shell-keep),
  .shell-nav:not(.shell-keep),
  .shell-scrim:not(.shell-keep) {
    display: none;
  }
  .shell-title {
    left: calc(10px + env(safe-area-inset-left));
    max-width: calc(100vw - 170px);
  }
  .shell-bar {
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-around;
    height: calc(var(--shell-bar-h) + env(safe-area-inset-bottom));
    padding: 4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--shell-panel);
    border-top: 1px solid var(--shell-line);
  }
  .shell-bar-item {
    flex: 1 1 0;
    min-width: 0;
    height: 54px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    margin: 0;
    padding: 0 2px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--shell-muted);
    font: inherit;
    font-size: 0.68rem;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    -webkit-touch-callout: none;
    user-select: none;
  }
  .shell-bar-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .shell-bar-item.on,
  .shell-bar-item[aria-expanded='true'] {
    color: var(--shell-accent);
  }
  .shell-bar .shell-pop {
    left: auto;
    right: 8px;
    bottom: calc(100% + 8px);
    width: min(240px, calc(100vw - 16px));
  }
  .shell-bar-gear {
    position: static;
  }
}

@keyframes shell-fade {
  from {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .shell-nav,
  .shell-scrim {
    transition: none;
  }
}

/* Shell colours, from the theme's tokens. */
:root {
  --shell-panel: var(--surface);
  --shell-float: var(--top, color-mix(in srgb, var(--bg) 88%, transparent));
  --shell-line: var(--border);
  --shell-text: var(--text);
  --shell-muted: var(--muted);
  --shell-accent: var(--accent);
  --shell-accent-dim: var(--accent-soft);
  --shell-wash: var(--wash, var(--surface-alt));
  --shell-shadow: var(--shadow);
  --shell-backdrop: var(--backdrop, rgba(0, 0, 0, 0.45));
  --shell-pill-shadow: 0 6px 20px rgba(72, 48, 12, 0.08);
}
:root[data-mode="dark"] { --shell-pill-shadow: 0 6px 20px rgba(0, 0, 0, 0.16); }
/* Above the palette button; dialogs and toasts stay above it. */
.shell-title, .shell-status, .shell-bar { z-index: 92; }
.shell-menu { z-index: 97; }
.shell-scrim { z-index: 94; }
.shell-nav { z-index: 95; }
.shell-pop { z-index: 96; }
.shell-status .icon-btn { width: 36px; height: 36px; border: 0; }
.shell-title .mark { width: 24px; height: 24px; }
/* What is scrolled to, or focused, stays clear of the phone bar. */
html { scroll-padding-bottom: calc(var(--shell-under) + 12px); }
/* Buttons fixed at the bottom stay above the phone bar. */
.palette-dock { bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--shell-under)); }
#toast,
#undo-bar { bottom: calc(max(20px, env(safe-area-inset-bottom)) + var(--shell-under)); }
body.has-undo #toast { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 56px + var(--shell-under)); }
@media (max-width: 700px) {
  .palette-dock { bottom: calc(var(--shell-under) + 12px); }
  #toast,
  #undo-bar { bottom: calc(var(--shell-under) + 12px); }
  body.has-undo #toast { bottom: calc(var(--shell-under) + 64px); }
}

/* ---------------------------------------------------------------------------
   Touch screens, the same in every myve app but journal and myvemail (tiles
   has its own): no zoom, no sideways scrolling, smaller text on phones. The
   viewport tag (maximum-scale=1) keeps a phone from zooming in on a field,
   shell.ts cancels pinching, touch-action ends double-tap zoom.
   --------------------------------------------------------------------------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: pan-x pan-y;
}
html,
body {
  overflow-x: clip;
}
@media (max-width: 700px) {
  html {
    font-size: 15px;
  }
  body {
    font-size: 1rem;
  }
}
