/* Telegram theme variables with fallbacks, so the page also renders in a plain browser. */
:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0b0b0b);
  --hint: var(--tg-theme-hint-color, #7b7a76);
  --link: var(--tg-theme-link-color, #2a78d6);
  --accent: var(--tg-theme-button-color, #2a78d6);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --panel: var(--tg-theme-secondary-bg-color, #f1f1ef);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d03b3b);
  --line: rgba(128, 128, 128, 0.25);
  --good: #1a9c1a;
  /* swipe panels carry white labels in both themes, so their fills do not follow the theme */
  --swipe-done: #1a9c1a;
  --swipe-more: #7d7d79;
  --swipe-remind: #c77a12;
  --radius: 12px;
  --gutter: 16px;
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #17181a);
    --text: var(--tg-theme-text-color, #f2f2f0);
    --hint: var(--tg-theme-hint-color, #8f8e89);
    --link: var(--tg-theme-link-color, #5aa2f0);
    --accent: var(--tg-theme-button-color, #3987e5);
    --panel: var(--tg-theme-secondary-bg-color, #0f0f10);
    --card: var(--tg-theme-section-bg-color, #232427);
    --danger: var(--tg-theme-destructive-text-color, #e66767);
    --good: #3cc03c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* The shell is as tall as Telegram's viewport and never scrolls: the title row stands, `main` (or the notes list) scrolls. */
html, body { height: 100vh; margin: 0; overflow: hidden; }
@supports (height: 100dvh) {
  html, body { height: var(--tg-viewport-stable-height, 100dvh); }
}

body {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
}
#back, #topbar { flex: none; }

main {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 8px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px))
    max(var(--gutter), env(safe-area-inset-left, 0px));
  max-width: 720px;
  margin: 0 auto;
  overflow-x: clip;
}
/* The notes list: only the rail and the list column scroll, each by itself; every link of the chain has min-height 0. */
main.fixed { display: flex; flex-direction: column; padding-bottom: 0; overflow-y: hidden; }
main.fixed > .pane, main.fixed > .pane > .screen { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
main.fixed .notes { flex: 1 1 0; min-height: 0; align-items: stretch; }
main.fixed .rail, main.fixed .list-col, main.fixed > .pane > .overlay {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}
main.fixed .rail { scrollbar-width: none; }
main.fixed > .pane > .overlay { flex: 1 1 0; }

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
.hint { color: var(--hint); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.empty, .message { color: var(--hint); text-align: center; padding: 32px 8px; }
.message { font-size: 16px; }

button { font: inherit; color: inherit; cursor: pointer; }

.btn {
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
}
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.wide { display: block; width: 100%; margin-top: 12px; }
.btn.ghost { background: transparent; color: var(--link); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn:active, .chip.filter:active, .icon-btn:active, .rail button:active { opacity: 0.7; }

/* The title row (ADR-021): pinned by the flex shell above `main`, not by `position: sticky` (a sticky bar slid half under Telegram's native header on iOS) */
.bar { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.topbar {
  width: 100%;
  max-width: 720px;
  min-height: 48px;
  margin: 0 auto;
  padding: 8px max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
}
.topbar:not([hidden]) ~ main { padding-top: 0; }
.topbar .input { flex: 1; min-width: 0; }
.back { display: block; align-self: flex-start; margin: 8px max(var(--gutter), env(safe-area-inset-left, 0px)) 0; }
.right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--hint);
  font-size: 15px;
}
.icon-btn.big { font-size: 20px; font-weight: 700; line-height: 1; }
.icon-btn.on, .icon-btn.open {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--card));
  color: var(--link);
}
.place {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin-left: -8px;
  padding: 4px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}
.icon-btn + .place { margin-left: -2px; }
.place .mode { color: var(--hint); font-size: 15px; font-weight: 400; }
.place .caret, .sec-head .caret { color: var(--link); font-size: 12px; }
.place .caret::after, .sec-head .caret::after { content: "▾"; }
.place.open .caret::after, .sec-head.open .caret::after { content: "▴"; }
.place.open, .sec-head.open { background: var(--card); }

/* The popup menu: the places, a row's actions, the Sections. Fixed to the window: the page itself never scrolls. */
.menu-veil { position: fixed; inset: 0; z-index: 19; }
.menu {
  position: fixed;
  z-index: 20;
  min-width: 210px;
  max-width: calc(100% - 16px);
  padding: 6px;
  overflow-y: auto;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  white-space: nowrap;
}
.menu-item .ic { flex: none; min-width: 20px; text-align: center; }
.menu-item .lb { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu-item .n { margin-left: auto; padding-left: 12px; color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.menu-item.on { background: var(--panel); font-weight: 600; box-shadow: inset 3px 0 0 var(--chip, transparent); }
.menu-item.danger { color: var(--danger); }
.menu-item.good { color: var(--good); }
.menu-item.dim .lb, .menu-item.dim .ic { opacity: 0.45; }
.menu-sep { height: 1px; margin: 4px 8px; background: var(--line); }
.place-row { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 6px 0 4px; border-radius: 8px; }
.place-row.on { background: var(--panel); }
.place-row .name { flex: 1; min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.place-row.on .name { font-weight: 600; }
.seg2 { flex: none; display: flex; border: 1px solid var(--accent); border-radius: 8px; }
.seg2 button { position: relative; height: 26px; padding: 0 9px; border: 0; background: transparent; color: var(--link); font-size: 13px; }
.seg2 button:first-child { border-radius: 7px 0 0 7px; }
.seg2 button:last-child { border-radius: 0 7px 7px 0; }
.seg2 button::before { content: ""; position: absolute; inset: -8px 0; } /* a taller target than the drawn 26 px */
.seg2 button.on { background: var(--accent); color: var(--on-accent); }
@media (hover: hover) {
  .menu-item:hover, .place-row .name:hover, .row .more:hover { background: var(--panel); }
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border: 1px solid var(--chip, var(--line));
  border-radius: 999px;
  font-size: 13px;
  background: transparent;
  color: var(--text);
}
.chip.filter { min-height: 36px; padding: 4px 14px; flex: none; }
.chip.filter.locked { cursor: default; }
.chip.filter.locked::after { content: "🔒"; margin-left: 6px; }
.chip.on { background: var(--chip, var(--accent)); border-color: var(--chip, var(--accent)); color: #fff; }
.chip.link { color: var(--link); }

/* Dashboard */
.board { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.headline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
}
.headline-n { font-size: 40px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.headline-label { color: var(--hint); font-size: 15px; }
.headline-overdue {
  margin-left: auto;
  min-height: 32px;
  padding: 2px 12px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  font-size: 14px;
  align-self: center;
}
.box { padding: 12px; background: var(--card); border-radius: var(--radius); }
.box h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--hint); }
.heat { display: block; width: 100%; height: auto; }
.heat-label { fill: var(--hint); font-size: 8px; }
.heat .cell { fill: color-mix(in srgb, var(--hint) 16%, var(--card)); }
.heat.captured .l1 { fill: color-mix(in srgb, var(--accent) 28%, var(--card)); }
.heat.captured .l2 { fill: color-mix(in srgb, var(--accent) 52%, var(--card)); }
.heat.captured .l3 { fill: color-mix(in srgb, var(--accent) 76%, var(--card)); }
.heat.captured .l4 { fill: var(--accent); }
.heat.done .l1 { fill: color-mix(in srgb, var(--good) 28%, var(--card)); }
.heat.done .l2 { fill: color-mix(in srgb, var(--good) 52%, var(--card)); }
.heat.done .l3 { fill: color-mix(in srgb, var(--good) 76%, var(--card)); }
.heat.done .l4 { fill: var(--good); }
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.bar-row:active { opacity: 0.7; }
.bar-label { flex: 0 0 38%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.bar-track { flex: 1; min-width: 0; height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--hint) 16%, var(--card)); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 5px; background: var(--chip, var(--accent)); }
.bar-n { flex: none; min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }

.heat.marks .m-fire { fill: #f0782d; }
.heat.marks .m-meh { fill: color-mix(in srgb, var(--hint) 55%, var(--card)); }
.heat.marks .m-dead { fill: #4a78d0; }
.heat.marks .cell { cursor: pointer; }

/* Дневник: today's Day editor and its week line, the Week, the Month and Year screens, the Dashboard */
.week-line {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--hint);
  font-size: 14px;
  text-align: left;
}
.week-line span { margin-left: auto; color: var(--link); }
.week-line:active { opacity: 0.7; }
.diary-today > .detail { margin-top: 6px; }
.diary-nav { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; }
.diary-nav .btn { flex: none; min-width: 44px; min-height: 40px; font-size: 18px; }
.diary-title { flex: 1; min-width: 0; text-align: center; font-variant-numeric: tabular-nums; }
.diary-months { margin-bottom: 8px; justify-content: center; }
.diary-days { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.day-card { padding: 4px 10px 8px; background: var(--card); border-radius: var(--radius); }
.day-card.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day-card.future { opacity: 0.6; }
.day-head {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.day-name { flex: 1; min-width: 0; font-weight: 600; }
.day-mark { flex: none; width: 28px; font-size: 20px; text-align: center; }
.diary-list { display: flex; flex-direction: column; gap: 2px; }
.entry-row { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.entry-row.pending { opacity: 0.55; }
.entry-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.entry-day { flex: none; width: 52px; color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.level-tag {
  flex: none;
  padding: 1px 8px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  color: var(--link);
  font-size: 12px;
}
.step, .step-spacer { flex: none; width: 36px; height: 36px; }
.step { border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--link); font-size: 18px; line-height: 1; }
.step:active, .mark-btn:active, .day-head:active { opacity: 0.7; }
.step:disabled { opacity: 0.35; }
.mark-row { display: flex; gap: 8px; }
.mark-btn {
  width: 52px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 22px;
  filter: grayscale(1);
  opacity: 0.6;
}
.mark-btn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); filter: none; opacity: 1; }
.add-row { display: flex; gap: 8px; width: 100%; }
.add-row .input { flex: 1; min-width: 0; }
.add-row .btn { flex: none; }
.counter { margin: 0; }
.suggest { width: 100%; }
.suggest .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.diary-editor .diary-list { width: 100%; }
.diary-period { display: flex; flex-direction: column; gap: 10px; }
.diary-period > .chip { align-self: center; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; padding: 10px 12px; background: var(--card); border-radius: var(--radius); }
.stat-n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--hint); font-size: 13px; }
.diary-maps { display: flex; flex-direction: column; gap: 6px; }
.fact { margin: 4px 0; overflow-wrap: anywhere; }


/* Заметки: the Section rail and one Section's rows; Search results by Section; edit mode */
.notes { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; }
.rail { flex: none; display: flex; flex-direction: column; gap: 3px; width: 64px; }
.rail > * { flex: none; } /* a rail taller than its column scrolls (main.fixed) instead of squeezing its buttons */
.rail button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 36px;
  padding: 0 0 0 3px; /* the selection bar's width: a ten-letter caption stays clear of it */
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 600;
  white-space: nowrap;
}
.rail .mark { font-size: 16px; line-height: 18px; }
.rail .cap { max-width: 100%; overflow: hidden; color: var(--hint); font-size: 9.5px; font-weight: 500; line-height: 12px; }
.rail button.abbr .mark { color: var(--chip); font-size: 12px; }
.rail button.on { background: var(--card); box-shadow: inset 3px 0 0 var(--chip, var(--accent)); }
.rail button.on .cap { color: var(--text); }
.rail button.dim .mark { opacity: 0.4; }
.rail button.dim .cap { opacity: 0.7; }
.rail button.done .mark { color: var(--good); }
.rail button.small .mark { font-size: 14px; }
.rail button:disabled { opacity: 0.25; cursor: default; }
.rail-sep { height: 1px; margin: 3px 8px; background: var(--line); }
.list-col { flex: 1; min-width: 0; }
.sec-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  height: 28px;
  margin-left: -4px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
/* In the title row the Section takes the room left and its name is cut first; at 320 px only the count is left. */
.topbar .sec-head { flex: 0 1000 auto; width: auto; min-width: 0; height: 32px; margin: 0 0 0 -10px; padding: 3px 4px 0; overflow: hidden; }
.sec-head .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sec-head .n { color: var(--hint); font-weight: 400; font-variant-numeric: tabular-nums; }
.sec-head .st { color: var(--good); font-weight: 400; }
.sec-head.overdue .name { color: var(--danger); }
.groups { display: flow-root; } /* «Загрузка…»'s margin would collapse through it and shift the list */
.groups:not(.editing) > .group + .group { margin-top: 10px; }
.list-col .empty { padding: 12px 8px; }
.notice { margin: 0 4px 10px; }
.groups.editing { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.group-head {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding-right: 6px;
  border-left: 4px solid var(--chip, var(--line));
  border-radius: var(--radius);
  background: var(--card);
  font-weight: 600;
}
.group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-n { flex: none; padding: 0 6px; color: var(--hint); font-weight: 400; font-variant-numeric: tabular-nums; }
.group.dim .group-name, .group.dim .group-n { opacity: 0.45; }
.group-edit { flex: none; min-width: 40px; padding: 6px 8px; }
.handle {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 48px;
  color: var(--hint);
  font-size: 18px;
  letter-spacing: -3px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.groups.sorting { user-select: none; -webkit-user-select: none; }
.groups.sorting .group { transition: transform 0.15s ease; }
.groups .group.dragging { position: relative; z-index: 2; transition: none; }
.group.dragging .group-head { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); }
.group.dragging .handle { cursor: grabbing; }

/* Item rows: the title flows round «⋮», the Thumbnail sits under it; behind the row, the swipe panels */
.rows { display: flex; flex-direction: column; gap: 1px; overflow: hidden; border-radius: var(--radius); background: var(--line); }
.rows.stale { opacity: 0.55; transition: opacity 0.15s; }
.row-wrap { position: relative; overflow: hidden; }
.row {
  position: relative;
  z-index: 1;
  display: flow-root;
  padding: 7px 12px;
  background: var(--card);
  line-height: 1.3;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.2s;
}
.row.dragging { transition: none; }
.row:active { background: color-mix(in srgb, var(--card) 92%, var(--hint)); }
.row .more {
  position: relative;
  float: right;
  width: 28px;
  height: 24px;
  margin: -3px -6px -4px 6px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--hint);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.row .more::before { content: ""; position: absolute; inset: -8px -6px -10px -8px; } /* a 42 px target round the drawn 28 x 24 */
.row .more.open { background: color-mix(in srgb, var(--accent) 14%, var(--card)); color: var(--link); }
.row .thumb {
  float: right;
  clear: right;
  width: 36px;
  height: 36px;
  margin: 6px 0 0 8px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel);
  -webkit-user-drag: none;
}
.title { font-weight: 600; overflow-wrap: anywhere; }
a.title { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; -webkit-user-drag: none; }
.row .sub {
  display: -webkit-box;
  margin-top: 1px;
  overflow: hidden;
  color: var(--hint);
  font-size: 13px;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.row .meta { margin-top: 2px; color: var(--hint); font-size: 12px; }
.row .meta .late { color: var(--danger); }
.row .meta .ok { color: var(--good); }
.acts { position: absolute; inset: 0; display: flex; visibility: hidden; font-size: 12px; font-weight: 600; }
.acts > * {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  border: 0;
  color: #fff;
}
.acts > * span { font-size: 18px; line-height: 1; }
.acts-r { justify-content: flex-end; background: var(--swipe-done); }
.acts-r .gray { width: 68px; background: var(--swipe-more); }
.acts-r .ok { width: 76px; background: var(--swipe-done); }
.acts-l { justify-content: flex-start; background: var(--swipe-remind); }
.acts-l > * { width: 96px; background: var(--swipe-remind); }
.row-wrap[data-dir="r"] .acts-r, .row-wrap[data-dir="l"] .acts-l { visibility: visible; }
.origin { color: var(--hint); font-size: 13px; }
.gist { overflow-wrap: anywhere; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.badge.ok { color: var(--good); border-color: var(--good); }
.badge.err { color: var(--danger); border-color: var(--danger); }
.badge.run { color: var(--hint); }

.btn:disabled { opacity: 0.45; cursor: default; }

/* Item view */
.busy { pointer-events: none; }
.stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; }
.detail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 14px;
  background: var(--card);
  border-radius: var(--radius);
}
.detail .title { font-size: 18px; margin: 0; }
.detail h3 { margin: 12px 0 0; font-size: 13px; font-weight: 600; color: var(--hint); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; }
.textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.due-row { display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; }
.due-input { flex: 1; min-width: 0; height: 44px; }

/* Section form */
.field-label { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
input.input[type="color"] { padding: 2px 4px; }
details.caption { width: 100%; }
details.caption p { margin: 6px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Usage */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0; }
.toolbar .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.tile { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 12px; background: var(--card); border-radius: var(--radius); border: 2px solid transparent; }
.tile .label { color: var(--hint); font-size: 12px; }
.tile .value { font-size: 24px; font-weight: 600; line-height: 1.15; }
.tile .sub { color: var(--hint); font-size: 12px; }
.tile.clickable { cursor: pointer; }
.tile.on { border-color: var(--accent); }
.tile svg { display: block; align-self: flex-start; width: 100%; max-width: 150px; height: auto; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.spark-dot { fill: var(--accent); }

.block { margin-top: 20px; }

.job { margin-top: 8px; padding: 10px 12px; background: var(--card); border-radius: var(--radius); cursor: pointer; }
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.job-agent { font-weight: 600; }
.job-file { overflow-wrap: anywhere; }
.details { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.details pre { margin: 6px 0 0; padding: 8px; font-size: 11.5px; overflow-x: auto; background: var(--panel); border-radius: 8px; }
.select { font: inherit; font-size: 16px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: max-content;
  max-width: calc(100% - 2 * var(--gutter));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { position: relative; padding: 0; border: 0; background: transparent; color: inherit; font-weight: 600; text-decoration: underline; pointer-events: none; }
.toast button::before { content: ""; position: absolute; inset: -12px -16px -12px -8px; } /* the whole height of the toast */
.toast.show button { pointer-events: auto; }

/* Diary suggestion chip with its «×» (hides the text from the suggestions) */
.chip-group { display: flex; max-width: 100%; min-width: 0; gap: 4px; }
.chip-group .chip { flex: 1 1 auto; min-width: 0; }
.chip-x { flex: none; min-width: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--link); font-size: 18px; line-height: 1; }
.chip-x:active { opacity: 0.7; }
.mark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.mark-pick { min-height: 40px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-size: 22px; line-height: 1; }
.mark-pick.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.mark-pick:disabled { opacity: 0.25; cursor: default; }
