:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #667085; --line: #e3e6eb;
  --accent: #2459d6; --accent-text: #fff; --danger: #c62828; --tag: #e8eefc;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --card: #1b2029; --text: #e7eaf0; --muted: #98a2b3; --line: #2b323e;
    --accent: #5b8cff; --accent-text: #0b1020; --danger: #ef5350; --tag: #24304a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
/* the page itself never moves sideways; only a table wider than the screen scrolls, inside its frame */
html { overflow-x: hidden; overscroll-behavior-y: none; } /* the site's own pull-to-refresh, not the browser's (which would ask for the password again) */
body { overflow-x: clip; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  max-width: none; margin: 0 auto; padding: 0 16px 48px; /* every page spans the screen */
}
body.busy { cursor: progress; }
body.busy button { opacity: .6; pointer-events: none; }
[hidden] { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.top-actions { display: flex; gap: 6px; }
.status { min-height: 1.5em; margin: 4px 0 10px; color: var(--muted); font-size: .95rem; }
.status.error { color: var(--danger); }
.status:empty { min-height: 0; margin: 0 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.hint { color: var(--muted); font-size: .92rem; }
form, .form { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: .92rem; color: var(--muted); }
input, textarea {
  font: inherit; color: var(--text); background: var(--bg); width: 100%;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; }
/* 16px minimum: smaller text makes iPhone zoom in when a field is tapped */
input, textarea, select { font-size: 16px; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row.buttons { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
button {
  font: inherit; border: 0; border-radius: 8px; padding: 10px 16px; min-height: 44px;
  background: var(--accent); color: var(--accent-text); cursor: pointer;
}
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); padding: 8px 12px; }
button.danger { background: var(--danger); color: #fff; }
.toolbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.summary { color: var(--muted); font-size: .9rem; margin: 10px 0; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item-btn {
  display: block; width: 100%; text-align: start; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.item-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.item-title { overflow-wrap: anywhere; }
.item-amount { white-space: nowrap; direction: ltr; }
.item-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; margin-top: 2px; }
.tag { background: var(--tag); border-radius: 999px; padding: 0 8px; }
.item-notes { color: var(--muted); font-size: .9rem; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } .top-actions button { padding: 6px 8px; font-size: .85rem; } }
h3 { font-size: 1rem; margin: 0 0 10px; }
#viewAnalysis, #viewSettings, .analysis { display: grid; gap: 12px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-head h2 { margin: 0; }
.stats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stat-top { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; }
.stat-top span:first-child { overflow-wrap: anywhere; }
.stat-val { white-space: nowrap; direction: ltr; color: var(--muted); }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; min-height: 0; }
.ai-output { margin-top: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6;
  border-top: 1px solid var(--line); padding-top: 12px; }
/* Privacy cover: shown while the page is in the background */
.privacy-cover { display: none; }
body.covered .privacy-cover {
  display: flex; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted); font-size: 1.4rem; font-weight: 600;
}
body.covered main, body.covered .status { visibility: hidden; }
.save-btn { margin-top: 12px; }
.saved-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.saved-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.saved-meta { color: var(--muted); font-size: .85rem; }
.saved-q { font-weight: 600; overflow-wrap: anywhere; }
.saved-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; line-height: 1.6; }
.saved-actions { display: flex; gap: 6px; margin-top: 8px; }
.saved-actions button { padding: 6px 10px; min-height: 36px; font-size: .88rem; }
#viewJournal { display: grid; gap: 12px; }
textarea.grow { resize: none; overflow: hidden; min-height: 6.5em; line-height: 1.6; }
textarea.grow.j3 { min-height: calc(3 * 1.6em + 22px); }
textarea.grow.j1 { min-height: 44px; }
.journal-window label.cell { color: var(--text); font-weight: 600; font-size: 1rem; }
.journal-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; }
.journal-item h4 { margin: 0; font-size: .85rem; color: var(--muted); font-weight: 600; }
.journal-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.journal-date { font-weight: 600; }
.top-actions { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 480px) {
  .top { flex-wrap: wrap; }
  .top-actions { width: 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
  .top-actions:not([hidden]) { display: grid; }
  .top-actions button { padding: 6px 1px; font-size: .8rem; }
}
.save-state { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.save-state.error { color: var(--danger); white-space: normal; }
.journal-window .row-head { justify-content: flex-end; min-height: 1.2em; }
/* Journal date: compact, as small as a label (16px kept so iPhone does not zoom) */
input.j-date { width: auto; min-height: 0; padding: 2px 6px; border: 0; background: transparent;
  color: var(--muted); justify-self: start; line-height: 1.3; }
.top-actions button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.ai-chat { display: grid; gap: 10px; margin-bottom: 12px; }
.ai-chat:empty { display: none; }
.ai-q { justify-self: start; max-width: 90%; background: var(--tag); border-radius: 12px; padding: 8px 12px;
  white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.ai-a { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
#viewSheets { display: grid; gap: 10px; }
.sheet-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 2px; } /* all the sheet buttons in view, on a second line if needed */
.sheet-tabs[hidden] { display: none; }
.sheet-tabs button { white-space: nowrap; padding: 6px 12px; min-height: 36px; }
.sheet-tabs button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.sheet-wrap { overflow: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; width: fit-content; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.sheet-wrap:has(.sheet-grid:empty) { display: none; }
.sheet-grid { border-collapse: collapse; font-size: 16px; }
.sheet-grid td { border: 1px solid var(--line); padding: 4px 8px; min-width: 4em; max-width: 22em; vertical-align: top;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.sheet-grid td:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--bg); }
#viewBeck { display: grid; gap: 14px; }
#viewBeck .row-head { align-items: flex-start; }
.beck-intro { margin: 0; font-weight: 600; line-height: 1.6; }
.beck-items { display: grid; gap: 12px; }
.beck-item { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 0; }
.beck-item legend { font-weight: 700; padding: 0 4px; }
.beck-opt { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; color: var(--text); font-size: 1rem; cursor: pointer; }
.beck-opt input { width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.beck-help { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--tag); color: var(--text); line-height: 1.6; }
.beck-score { margin: 0; font-size: 1.1rem; font-weight: 700; }
.j-event-head { display: flex; align-items: center; gap: 8px; }
.j-event-head label.cell { display: inline; }
.j-event-head span { color: var(--muted); font-weight: 700; }
.j-pairs { display: grid; gap: 12px; }
.j-pair { display: grid; gap: 8px; }
.j-pair label.cell { color: var(--text); font-weight: 600; font-size: 1rem; }
.j-meta { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.j-meta label.cell { color: var(--text); font-weight: 600; font-size: 1rem; }
select { font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; min-height: 44px; padding: 6px 10px; min-width: 4.5em; }
/* plus shape */
.j-add { justify-self: start; position: relative; width: 40px; height: 40px; min-height: 0; padding: 0;
  border-radius: 50%; border: 2px solid var(--accent); background: transparent; }
.j-add::before, .j-add::after { content: ''; position: absolute; left: 50%; top: 50%; background: var(--accent); border-radius: 2px; }
.j-add::before { width: 18px; height: 3px; transform: translate(-50%, -50%); }
.j-add::after { width: 3px; height: 18px; transform: translate(-50%, -50%); }
/* journal: each text box starts on the same line as its heading, one line high, and grows */
.j-row { display: grid; grid-template-columns: 4.2em 1fr; gap: 8px; align-items: start; }
.j-lbl { color: var(--text); font-weight: 600; font-size: 1rem; padding-top: 10px; }
.j-meta { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.j-meta .j-value { grid-template-columns: auto auto; }
.j-event { grid-template-columns: 4.2em 1fr auto auto; }
.j-dot { color: var(--muted); font-weight: 700; padding-top: 10px; }
.j-event .j-date { padding-top: 10px; }
.j-pair { display: grid; gap: 8px; }
.j-event { grid-template-columns: 4.2em minmax(0, 1fr) auto auto; gap: 6px; }
/* short date on the event line; the real date input lies over it (invisible) and opens the picker */
.j-date-wrap { position: relative; padding-top: 10px; color: var(--muted); white-space: nowrap; }
.j-date-text { display: inline-block; min-width: 4.6em; border-bottom: 1px dashed var(--line); }
.j-date-overlay { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.j-row { grid-template-columns: 3.8em 1fr; }
.j-event { grid-template-columns: 3.8em minmax(0, 1fr) auto auto; }
/* first sheet: row numbers, sorting, topics, long-press red rows */
.sheet-grid th { background: var(--tag); border: 1px solid var(--line); padding: 6px 8px; text-align: start;
  font-weight: 700; cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; }
.sheet-grid th.num, .sheet-grid td.num { text-align: center; min-width: 2.6em; color: var(--muted); user-select: none; }
#sheetGrid.first td.num { cursor: pointer; }
.sheet-grid tr.selected td.num { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.sheet-grid tr.selected td { box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
.move-bar { position: fixed; left: 50%; transform: translateX(-50%); width: calc(100vw - 32px); z-index: 65; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 12px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / .15); }
.move-bar[hidden] { display: none; }
.sheet-wrap.moved { margin-top: 16px; }
.sheet-grid.first td { -webkit-touch-callout: none; }
.sheet-grid td.dist { padding: 2px 4px; }
.sheet-grid td.dist select { min-height: 36px; width: 100%; min-width: 7em; padding: 4px 6px; background: transparent; }
.sheet-grid td.topic { white-space: nowrap; min-width: 6em; }
/* header: three page buttons + menu */
@media (max-width: 480px) {
  .top-actions { grid-template-columns: repeat(3, 1fr) 48px; }
}
.top-actions { position: relative; }
.menu-btn { position: relative; min-width: 44px; }
.menu-btn { padding: 0; display: grid; place-items: center; }
.menu-btn[hidden] { display: none; }
.menu-btn img { display: block; width: 28px; height: 28px; border-radius: 6px; }
.menu-btn.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.nav-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 50; display: grid; gap: 4px; min-width: 9em;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.nav-menu button { text-align: start; width: 100%; font-size: 1rem !important; padding: 10px 12px !important; }
.nav-menu button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
/* boxes ("squares") in אפרת / תובנות */
.cards { display: grid; gap: 12px; overflow-anchor: none; } /* the box being written is kept in place by the app itself */
.e-card { display: grid; gap: 10px; }
.e-card .save-state { justify-self: end; min-height: 1.1em; }
.e-card .j-date-text { min-width: 4.6em; }
/* the header starts below the phone's status bar */
.top { padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
body { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
/* header: page buttons and menu on one row, sheet buttons below */
.top { flex-direction: column; align-items: stretch; gap: 8px; }
.top > * { min-width: 0; max-width: 100%; } /* a long row of sheet buttons scrolls inside its row instead of widening the page */
.title-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.top-actions { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.top-actions[hidden] { display: none !important; }
@media (max-width: 480px) { .top-actions { grid-template-columns: repeat(3, 1fr); } }
.title-row .nav-menu { top: calc(100% + 6px); inset-inline-start: 0; inset-inline-end: auto; }

/* first sheet: smaller text; on a phone the thoughts column fills the screen and the rest scroll */
.sheet-grid.first { font-size: 14px; }
.sheet-grid.first td.dist select { font-size: 14px; }
/* computer: the sheet page spans the screen; the thoughts column gets most of the room */
@media (min-width: 721px) {
  body.wide { max-width: none; }
  .sheet-wrap:has(.sheet-grid.first) { width: 100%; }
  .sheet-grid.first { width: 100%; }
  .sheet-grid.first th.thought, .sheet-grid.first td.thought { width: 60%; max-width: none; }
  .sheet-grid.first th.num { width: 3em; }
}
/* first sheet: each table in a box with a title; the arrow hides the table */
.sheet-boxes { display: grid; gap: 12px; }
#groupBoxes:empty { display: none; }
#sheetBoxes:not(.boxed):not(.types) .box-head { display: none; }
:is(#sheetBoxes, #sortBoxes).boxed .sheet-box, #sheetBoxes.types .sheet-box { display: grid; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
/* type tables sit close together */
#sheetBoxes.types, #sheetBoxes.types #groupBoxes, #sheetBoxes.types .grp-body { gap: 4px; }
#sheetBoxes.types .grp { margin-bottom: 4px; }
#sheetBoxes.types .box-head { padding: 2px 8px; }
#sheetBoxes.types .box-title { background: transparent; border-color: transparent; }
#sheetBoxes.types .sheet-box[hidden] { display: none; }
/* a wide table never widens its box or the page (Safari): it scrolls inside its own frame, and the title row stays on screen */
#viewSheets, .sheet-boxes, :is(#sheetBoxes, #sortBoxes).boxed .sheet-box, #sheetBoxes.types .sheet-box { grid-template-columns: minmax(0, 1fr); }
/* the table fills its box edge to edge: one frame, no inner margin taking room from the text */
:is(#sheetBoxes, #sortBoxes).boxed .sheet-box, #sheetBoxes.types .sheet-box { padding: 0; gap: 0; overflow: hidden; }
:is(#sheetBoxes, #sortBoxes).boxed .box-head { padding: 6px 8px; }
:is(#sheetBoxes, #sortBoxes).boxed .sheet-wrap, #sheetBoxes.types .sheet-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0; width: 100%; max-width: 100%; }
.sheet-box, .sheet-boxes, .box-head { min-width: 0; max-width: 100%; }
.box-head { display: flex; align-items: center; gap: 6px; }
.box-title { flex: 1; min-width: 0; font-weight: 600; }
.box-toggle { position: relative; min-width: 44px; padding: 0; }
.box-toggle::before { content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: translate(-50%, -70%) rotate(45deg); }
.sheet-box.collapsed .box-toggle::before { transform: translate(-30%, -50%) rotate(135deg); }
.sheet-box.collapsed .sheet-wrap { display: none; }
.move-bar { grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 6px; }
.move-bar button { padding-inline: 6px; }
.move-bar select { min-width: 0; }
@media (max-width: 720px) {
  :is(#sheetBoxes, #sortBoxes).boxed .sheet-grid.first th.thought, :is(#sheetBoxes, #sortBoxes).boxed .sheet-grid.first td.thought { width: calc(100vw - 34px); min-width: calc(100vw - 34px); max-width: calc(100vw - 34px); }
  /* type tables: the thoughts fill the box; # and the rest are reached by scrolling the table */
  #sheetBoxes.types .sheet-grid.first th.thought, #sheetBoxes.types .sheet-grid.first td.thought { width: calc(100vw - 34px); min-width: calc(100vw - 34px); max-width: calc(100vw - 34px); }
}
@media (max-width: 720px) {
  .sheet-grid.first th.thought, .sheet-grid.first td.thought { width: calc(100vw - 34px); min-width: calc(100vw - 34px); max-width: calc(100vw - 34px); }
  /* # stays on screen next to the thoughts, so rows can be picked without scrolling */
  .sheet-grid.first th.num, .sheet-grid.first td.num { width: 40px; min-width: 40px; max-width: 40px; padding-inline: 2px; }
}

/* pull down to refresh */
.pull-hint { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 4px); left: 50%; z-index: 60; width: 34px; height: 34px;
  border-radius: 50%; background: var(--card); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.15); pointer-events: none; }
.pull-hint[hidden] { display: none; }
.pull-hint::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); }
.pull-hint.ready::before { border-color: var(--accent); border-top-color: transparent; }
.pull-hint.spinning::before { animation: pull-spin .8s linear infinite; border-color: var(--line); border-top-color: var(--accent); }
@keyframes pull-spin { to { transform: rotate(360deg); } }

/* one text size for all the text on the site; buttons keep their own sizes.
   (fields below 16px would make iPhone zoom in on tap; the viewport's maximum-scale=1 prevents that) */
body, body *:not(button):not(button *) { font-size: 14px !important; }
button { font-size: 1rem; }

/* save messages: at the bottom of the screen (above the bar of picked rows when it is open) */
.save-state { display: none !important; }
.save-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 70;
  background: var(--card); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15); white-space: nowrap; pointer-events: none; }
.save-toast[hidden] { display: none; }
.save-toast.error { color: var(--danger); white-space: normal; max-width: calc(100vw - 32px); }
body:has(#moveBar:not([hidden])) .save-toast { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }

/* the distortion type list on the last line of the thoughts cell */
.sheet-grid td.thought .cell-text { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.4em; outline: none; }
.sheet-grid td.thought:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.dist-inline { margin-top: 6px; }
.dist-inline select { width: 100%; min-height: 32px; padding: 2px 6px; background: transparent; }

/* תובנות: a calm, minimal box */
.i-card { display: grid; gap: 14px; padding: 14px 16px; border-radius: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.i-block { position: relative; }
/* the title sits at the start of the text's first line (bigger and bold); the text keeps the full width */
.i-card .i-lbl { position: absolute; inset-inline-start: 0; top: 3px; font-size: 17px !important; line-height: 22px; font-weight: 700; color: var(--text); }
.i-card textarea { text-indent: 3.8em; }
.i-card textarea { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 4px 0 6px; resize: none; }
.i-card textarea:focus { outline: none; border-bottom-color: var(--accent); }
.i-foot { display: flex; align-items: center; gap: 8px; padding-top: 2px; }
.i-foot .i-pick { min-height: 34px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; width: auto; }
.i-foot .e-topic { flex: 1; min-width: 0; }
.i-foot .i-pick.empty { color: var(--muted); }
.i-foot .j-date-wrap { margin-inline-start: auto; color: var(--muted); white-space: nowrap; padding-top: 0; display: flex; align-items: center; } /* level with the lists */

/* type tables: only the thoughts, one under the other, with a fine line between them */
#sheetBoxes.types .sheet-grid td { border: 0; border-bottom: 1px solid var(--line); padding: 8px 10px; }
#sheetBoxes.types .sheet-grid tr:last-child td { border-bottom: 0; }
#sheetBoxes.types .box-title { cursor: text; }

/* type tables: the title row looks like the old "מחשבות" header row of the table */
#sheetBoxes.types .box-head { background: var(--tag); padding: 0 8px; min-height: 0; gap: 4px; }
#sheetBoxes.types .box-title { font-weight: 700; color: var(--text); padding: 6px 2px; min-height: 0; border: 0; border-radius: 0; background: transparent; }
#sheetBoxes.types .box-title:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent); }
#sheetBoxes.types .box-toggle { min-height: 0; min-width: 32px; height: 32px; border: 0; background: transparent; }
#sheetBoxes.types .sheet-box.collapsed .sheet-wrap { display: none; }

/* text aligned to both sides everywhere */
body, textarea, td, .cell-text, [contenteditable] { text-align: justify; }

/* time on the site */

/* אפרת in the תובנות style */
.i-card .j-pairs { display: grid; gap: 14px; }
.i-card .j-pair { display: grid; gap: 14px; }
.i-card .j-pair + .j-pair { padding-top: 14px; border-top: 1px dashed var(--line); }
.i-card .j-add { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: transparent; }
.i-card .j-add::before { width: 14px; height: 2px; }
.i-card .j-add::after { width: 2px; height: 14px; }
.i-foot .i-text { flex: 1; min-width: 0; min-height: 34px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; }
.i-foot .i-text::placeholder { color: var(--muted); }
/* a box never gets wider than the screen */
.cards, .i-card, .i-card .j-pairs, .i-card .j-pair { grid-template-columns: minmax(0, 1fr); }
.e-card, .i-foot > * { min-width: 0; }

/* room under the last rows for the bar of picked rows */
body:has(#moveBar:not([hidden])) main { padding-bottom: 90px; }
.move-bar select[hidden], .move-bar button[hidden] { display: none; }
.move-bar { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 1fr; }
/* the site's icon fills the menu button */
#btnMenu { padding: 0; border: 0; overflow: hidden; background: transparent; min-width: 44px; width: 44px; height: 44px; min-height: 44px; border-radius: 12px; }
#btnMenu img { width: 44px; height: 44px; border-radius: 0; }
#btnMenu.active { box-shadow: 0 0 0 2px var(--accent); }

/* text fields with bold / red words (look like the text lines they replace) */
.rich { white-space: pre-wrap; overflow-wrap: anywhere; outline: none; cursor: text; min-height: 1.5em; }
.i-card .rich { line-height: 22px; width: 100%; border-bottom: 1px solid var(--line); padding: 4px 0 6px; min-height: 30px; text-align: justify; }
.i-card .rich:focus { border-bottom-color: var(--accent); }
.i-card .i-lbl { cursor: text; }
/* the bar under selected text */
.fmt-bar { position: fixed; z-index: 80; top: max(8px, env(safe-area-inset-top, 0px)); left: max(8px, env(safe-area-inset-left, 0px)); display: flex; gap: 6px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.fmt-bar[hidden] { display: none; }
.fmt-bar button { min-width: 44px; min-height: 40px; padding: 0; font-size: 1.1rem; }
#fmtBold { font-weight: 800; }
#fmtRed { color: #FF0000; font-weight: 800; }

/* the distortion list and the row number at the end of the thought */
.dist-inline { display: flex; align-items: center; gap: 8px; }
.dist-inline select { flex: 1; min-width: 0; }
.dist-inline .num { min-width: 2.2em; padding: 6px 4px; text-align: center; color: var(--muted); border-radius: 6px; cursor: pointer; user-select: none; }
.sheet-grid tr.selected .dist-inline .num { background: var(--accent); color: var(--accent-text); font-weight: 700; }

/* מיון: the title row of each table looks like the one on the עיוותי חשיבה page */
:is(#sheetBoxes, #sortBoxes).boxed .box-head { background: var(--tag); padding: 0 8px; gap: 4px; min-height: 0; }
:is(#sheetBoxes, #sortBoxes).boxed .box-title { font-weight: 700; color: var(--text); padding: 6px 2px; min-height: 0; border: 0; border-radius: 0; background: transparent; }
:is(#sheetBoxes, #sortBoxes).boxed .box-title:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent); }
:is(#sheetBoxes, #sortBoxes).boxed .box-toggle { min-height: 0; min-width: 32px; height: 32px; border: 0; background: transparent; }
.box-sort { display: none; }
:is(#sheetBoxes, #sortBoxes).boxed .box-sort { display: block; width: auto; min-height: 0; padding: 2px 6px; border: 0; background: transparent; color: var(--muted); }
:is(#sheetBoxes, #sortBoxes).boxed .sheet-box.collapsed .box-sort { display: none; }
/* other pages from Excel: the text across the whole width, like the other pages */
#sheetBoxes:not(.boxed):not(.types) .sheet-wrap { width: 100%; }
#sheetBoxes:not(.boxed):not(.types) .sheet-grid:not(.first) { width: 100%; }
#sheetBoxes:not(.boxed):not(.types) .sheet-grid:not(.first) td { max-width: none; }

/* the tables on אפרת / תובנות: in a box like on מיון, and they never move sideways */
.moved-box { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.moved-box:has(.sheet-grid:empty) { display: none; }
.moved-box .box-head { display: flex; align-items: center; background: var(--tag); padding: 0 8px; gap: 4px; }
.moved-box .box-title { flex: 1; font-weight: 700; padding: 6px 2px; }
.moved-box .box-toggle { position: relative; min-height: 0; min-width: 32px; height: 32px; padding: 0; border: 0; background: transparent; }
.moved-box .box-sort { display: block; width: auto; min-height: 0; padding: 2px 6px; border: 0; background: transparent; color: var(--muted); }
.moved-box.collapsed .box-sort, .moved-box.collapsed .sheet-wrap { display: none; }
.moved-box .sheet-wrap.moved { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; width: 100%; max-width: 100%; overflow-x: hidden; touch-action: pan-y; }
.moved-box .sheet-grid.first { width: 100%; table-layout: fixed; }
.moved-box .sheet-grid.first th.thought, .moved-box .sheet-grid.first td.thought { width: auto !important; min-width: 0 !important; max-width: none !important; }
.moved-box .sheet-grid.first td:not(.thought) { width: 22%; }

/* the עיוותי חשיבה page: menus that open to their thoughts (not a table) */
.type-list { display: grid; }
.type-item { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; outline: none; text-align: justify; }
.type-item:last-child { border-bottom: 0; }
.type-item:focus { background: var(--bg); }
.type-item.red-row { background: #FF0000; color: #000; }
#sheetBoxes.types .sheet-wrap { overflow: visible; }
/* the box that picks a row, next to its number */
.row-check { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
/* the page buttons share the row, however many there are */
.top-actions:not([hidden]) { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
.top-actions button[hidden] { display: none; }

/* the way in: ruled lines down the page, the last one for the password */
.lined-page { --line-h: 34px; display: grid; }
.lined-page textarea.lined, .lined-page .lined-last {
  width: 100%; border: 0; border-radius: 0; padding: 0 4px; margin: 0; background-color: transparent; outline: none; box-shadow: none;
  line-height: var(--line-h); resize: none; color: var(--text);
  background-image: linear-gradient(to bottom, transparent calc(var(--line-h) - 1px), var(--line) calc(var(--line-h) - 1px));
  background-size: 100% var(--line-h); background-attachment: local;
}
.lined-page textarea.lined { height: calc(100dvh - 190px); min-height: calc(6 * var(--line-h)); }
@supports (height: round(down, 100px, 34px)) {
  .lined-page textarea.lined { height: round(down, calc(100dvh - 190px), var(--line-h)); } /* whole lines, so the last one follows on */
}
.lined-page .lined-last { height: var(--line-h); min-height: 0; letter-spacing: .15em; }
.lined-page .lined-last:focus { background-image: linear-gradient(to bottom, transparent calc(var(--line-h) - 2px), var(--accent) calc(var(--line-h) - 2px)); }
.lined-page .form { display: block; }
#btnLogin[hidden] { display: none; }

/* the keyboard cursor: on the right in every place text is written, also in an empty line */
[contenteditable], .rich, textarea, input[type="text"], input[type="password"] { text-align-last: start; }
[contenteditable]:empty, .rich:empty { text-align: start; }

/* 3 טורים: the distortion list, a line of its own between the thought and the answer */
.j-dist-row { display: flex; }
.j-dist-row .i-pick { flex: 1; min-width: 0; min-height: 34px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; }
.j-dist-row .i-pick.empty { color: var(--muted); }

/* 3 טורים */
.i-card .j-date-inline { display: inline-block; position: relative; padding: 0; margin-inline-start: 8px; font-size: 14px !important; font-weight: 400; color: var(--muted); vertical-align: baseline; }
.i-card .j-date-inline .j-date-text { font-size: 14px !important; }
.i-card .j-interp { border-bottom: 0; padding-bottom: 2px; } /* the distortion list follows on without a line */
.i-card .j-pair { gap: 8px; }
.i-card .j-pair .i-block:has(.j-alt) { margin-top: 6px; }
.i-card .j-foot .e-value { width: auto; }
.i-card > .j-add { justify-self: center; }

/* תובנות: a box with a line that grows with the text, and a + below */
.note-card { padding: 10px 16px; }
.i-card .note-line { min-height: 34px; padding: 6px 0; }

.i-card .j-value-inline { display: inline-block; width: auto; margin-inline-start: 8px; min-height: 0; padding: 0 6px; font-size: 14px !important; font-weight: 400; vertical-align: baseline; border: 1px solid var(--line); border-radius: 999px; background: transparent; }

/* 3 טורים: the lists on the lines of their titles; ערך and + at the end of the last line of the answer */
.i-card .j-inline-pick, .ibox .j-inline-pick { display: inline-block; width: auto; max-width: 60vw; margin-inline-start: 8px; min-height: 0; height: 26px; padding: 0 6px; font-size: 14px !important; font-weight: 400; vertical-align: baseline; border: 1px solid var(--line); border-radius: 999px; background: transparent; }
.i-card .j-inline-pick.empty, .ibox .j-inline-pick.empty { color: var(--muted); }
.i-card .i-block.has-tail::after { content: ''; display: block; clear: both; }
.i-card .j-tail-spacer { float: left; width: 0; }
.i-card .j-tail { float: left; clear: left; display: inline-flex; align-items: stretch; gap: 4px; padding: 1px 0; margin-inline-start: 8px; position: relative; z-index: 1; }
.i-card .j-tail .j-add { width: auto; height: auto; aspect-ratio: 1; flex: none; }
.i-card .j-tail .j-add::before { width: 18px; }
.i-card .j-tail .j-add::after { height: 18px; }
.i-card .j-tail .j-inline-pick { height: auto; }
.i-card .i-lbl.has-pick { inset-inline-end: 0; display: flex; align-items: center; }
.i-card .i-lbl.has-pick .j-dist { flex: 1; min-width: 0; max-width: none; }
.i-card .j-tail .j-inline-pick { margin: 0; padding: 0 4px; min-width: 0; width: 56px; }
/* closer together */
.i-card.e-card:has(.j-pairs) { gap: 8px; }
.i-card .j-pairs { gap: 8px; }
.i-card .j-pair { gap: 2px; }
.i-card .j-pair .i-block:has(.j-alt) { margin-top: 0; }
.i-card .j-pair + .j-pair { padding-top: 8px; }

/* 3 טורים: picked boxes, duplicate lists */
.i-card.dup-picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.i-card.dup-member { margin-inline-start: 18px; border-inline-start: 3px solid var(--accent); }
.i-card .dup-toggle { display: inline-flex; align-items: center; gap: 2px; margin-inline-start: 6px; padding: 0 7px; height: 20px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 12px !important; font-weight: 600; vertical-align: 2px; }
.i-card .dup-toggle::after { content: '▾'; font-size: 11px; }
.i-card.dup-open .dup-toggle::after { content: '▴'; }
.i-card.dup-main .e-event + *, .i-card.dup-main .i-lbl:has(.dup-toggle) { cursor: pointer; }
.i-card .dup-main-btn { min-height: 0; height: 22px; padding: 0 9px; margin-inline-start: 8px; border: 1px solid var(--accent); border-radius: 999px; background: transparent; color: var(--accent); font-size: 12px; font-weight: 600; vertical-align: 2px; }
.i-card .dup-main-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.i-card .dup-main-btn[hidden] { display: none; }
body:has(#dupBar:not([hidden])) main { padding-bottom: 90px; }
body:has(#dupBar:not([hidden])) .save-toast { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }

/* תובנות, at the top: boxes with a title (as on the עיוותי חשיבה page), all together under "תובנות" */
#insightBoxes { margin-bottom: 12px; }
.ins-group-head { display: flex; align-items: center; gap: 4px; padding: 0 4px; cursor: pointer; }
.ins-group-title { flex: 1; font-size: 17px !important; font-weight: 700; padding: 6px 0; }
.ins-group .box-toggle, .ibox .box-toggle { min-height: 0; min-width: 32px; height: 32px; border: 0; background: transparent; }
.ins-group.collapsed .box-toggle::before, .ibox.collapsed .box-toggle::before { transform: translate(-30%, -50%) rotate(135deg); }
.ins-group.collapsed .ins-list { display: none; }
.ins-list { display: grid; gap: 8px; }
.e-card.ibox { display: grid; gap: 0; padding: 0; overflow: hidden; border-radius: 12px; }
.ibox .box-head { background: var(--tag); padding: 0 8px; gap: 4px; }
.ibox .box-title { font-weight: 700; color: var(--text); padding: 6px 2px; min-height: 0; border: 0; border-radius: 0; background: transparent; }
.ibox .box-title:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent); }
.ibox .ibox-body { border-top: 1px solid var(--line); padding: 8px 10px; }
.ibox.collapsed .ibox-body { display: none; }
.ibox .e-ibox { text-align: justify; min-height: 1.5em; }
/* 3 טורים: a box folded to its אירוע line */
.i-card .j-fold { position: relative; display: inline-block; width: 26px; height: 16px; min-height: 0; padding: 0; margin-inline-start: 4px; border: 0; background: transparent; vertical-align: -1px; top: -5px; }
.i-card .j-fold::before { content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -5px 0 0 -5px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: translateY(-3px) rotate(45deg); transform-origin: 50% 50%; }
.i-card.j-closed .j-fold::before { transform: translateX(3px) rotate(135deg); } /* (the drawn corner, not the square, in the middle) */
.i-card.j-closed { overflow: hidden; } /* (its first 3 lines: by clipClosed) */

/* 3 טורים: after "מחשבה הגיונית", lists of the תובנות titles and a + for another list */
.i-card .i-lbl.has-ins { align-items: flex-start; }
.i-card .i-lbl.has-ins > .j-ins-picks { flex: 1; min-width: 0; display: grid; gap: 4px; margin-inline-start: 8px; }
.i-card .j-ins-picks .j-ins { width: 100%; max-width: none; margin: 0; }
.i-card .j-ins-add, .ibox .j-ins-add { position: relative; flex: none; width: 26px; height: 26px; min-height: 0; padding: 0; margin-inline-start: 4px; border: 1px solid var(--line); border-radius: 50%; background: transparent; }
.i-card .j-ins-add::before, .i-card .j-ins-add::after, .ibox .j-ins-add::before, .ibox .j-ins-add::after { content: ''; position: absolute; left: 50%; top: 50%; background: var(--accent); border-radius: 2px; transform: translate(-50%, -50%); }
.i-card .j-ins-add::before, .ibox .j-ins-add::before { width: 12px; height: 2px; }
.i-card .j-ins-add::after, .ibox .j-ins-add::after { width: 2px; height: 12px; }

/* menus that open / close a whole part of a page */
.grp { display: grid; gap: 8px; margin-bottom: 12px; }
.grp-head { display: flex; align-items: center; gap: 4px; padding: 0 4px; cursor: pointer; }
.grp-title { flex: 1; font-size: 17px !important; font-weight: 700; padding: 6px 0; }
.grp .grp-head .grp-toggle { position: relative; min-height: 0; min-width: 32px; height: 32px; padding: 0; border: 0; background: transparent; }
.grp-toggle::before { content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: translate(-50%, -70%) rotate(45deg); }
.grp.collapsed .grp-toggle::before { transform: translate(-30%, -50%) rotate(135deg); }
.grp.collapsed > .grp-body { display: none; }
.grp-body { display: grid; gap: 12px; min-width: 0; }

.i-card .dup-check { flex: none; align-self: center; width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); }

/* CBT page: a text box at the top of a menu */
.grp-note { padding: 8px 10px; }
.grp-note .grp-note-text { text-align: justify; min-height: 1.5em; }
/* a date opens only by tapping the date itself */
.j-date-wrap { overflow: hidden; }
.j-date-overlay { max-width: 100%; }
.i-card .j-ins-picks .j-dist { width: 100%; max-width: none; margin: 0; }
/* while writing: no justify, so the cursor at the end of a paragraph stands right after its last word (iPhone) */
.rich:focus, [contenteditable]:focus { text-align: start; }

/* the + of מחשבה אוטומטית: which list to add */
.i-card .i-lbl.has-ins { position: absolute; }
.i-card .j-add-menu { position: absolute; top: 30px; left: 0; z-index: 30; display: grid; gap: 4px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.18); font-size: 14px !important; font-weight: 400; }
.i-card .j-add-menu[hidden] { display: none; }
.i-card .j-add-menu button { min-height: 36px; padding: 4px 12px; white-space: nowrap; font-size: 14px; }
/* אירוע, its arrow, its date and the text: on one line (nothing in the title makes its line taller) */
.i-card .j-date-inline, .i-card .j-date-inline .j-date-text { line-height: 1; }
.i-card .j-date-inline { vertical-align: -3px; }

/* סיכום: the round + before the first part, and its menu under it */
.i-card .s-start { display: flex; justify-content: flex-end; }
.i-card .s-start .j-tail { float: none; height: 44px; }
.i-card .j-tail .j-add-menu { top: 100%; margin-top: 4px; }

.ins-split { border: 0; border-top: 1px dashed var(--line); margin: 2px 8px; }

/* מחשבה הגיונית: "הוכחה לזה:" lines under the text, and their + */
.i-card .j-proofs { display: grid; gap: 4px; justify-items: start; margin-top: 4px; clear: none; }
/* while writing in any text field: from the right (the cursor on the right, also in an empty field) */
textarea:focus, .rich:focus, [contenteditable]:focus, [contenteditable]:empty, .rich:empty { text-align: right; text-align-last: right; }
.i-card .j-proof { display: flex; width: 100%; }
.i-card .j-proof .j-ins { flex: 1; min-width: 0; max-width: none; margin: 0; }
/* the password line: a text line whose letters show as dots (so it writes from the right like any line) */
.secret { -webkit-text-security: disc; text-security: disc; }
.secret.shown { -webkit-text-security: none; text-security: none; }
/* תגיות, תובנות: inside a box, under its text, the + for עיוותי חשיבה lists */
.ibox .ibox-dists { display: grid; gap: 4px; }
.ibox .ibox-dists:not(:empty) { margin-bottom: 6px; }
.ibox .ibox-dists .j-dist { flex: 1 1 100%; max-width: none; margin: 0; }
.ibox .box-head .j-ins-add { margin: 0; }

/* the way in: the password line writes from the right; its message on the same line */
.lined-page .form { position: relative; }
.lined-page .lined-last { text-align: right; }
.login-err { position: absolute; top: 0; right: 4px; line-height: var(--line-h); color: var(--danger); font-size: 14px; pointer-events: none; }
.login-err.at-left { right: auto; left: 4px; }
.login-err[hidden] { display: none; }
/* מחשבות, at the top: only a round + in the middle (a new box) */
.new-box.i-card { position: relative; display: flex; justify-content: center; padding: 4px 0; background: none; border: 0; box-shadow: none; }
.new-box.i-card .j-add-menu { left: 50%; transform: translateX(-50%); top: 100%; margin-top: 4px; }
/* מחשבה הגיונית: the + right after its title; its menu of תובנות titles */
.i-card .j-proof-pick { display: inline-block; vertical-align: top; margin-inline-start: 6px; }
.i-card .j-proof-pick .j-proof-add { width: 22px; height: 22px; margin: 0; }
/* its menu: from the title's start (right), toward the page, never past it; long titles wrap */
.i-card .j-proof-pick .j-add-menu { top: 100%; left: auto; inset-inline-start: 0; margin-top: 4px; width: max-content; max-width: calc(100vw - 48px); max-height: 50vh; overflow-y: auto; }
.i-card .j-proof-pick .j-add-menu button { white-space: normal; text-align: start; }
/* "כפול" when the picked boxes are in duplicate lists already: pressed (again: out of the list) */
#btnDup[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
/* תובנות page: after the תגיות menus, מיון, then ארכיון and the 3 טורים table */
.journal-part { display: grid; gap: 12px; }
#sortPart[hidden], #journalPart[hidden], #sheetBoxes[hidden] { display: none; }
#sortGroups:empty { display: none; }
/* CBT page: the part buttons (one part shown at a time); מיון small, right under them */
.part-btns { display: flex; gap: 6px; }
.part-btns[hidden] { display: none; }
.part-btns > button, .part-pick > button { flex: 1; min-width: 0; font-weight: 600; padding: 6px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px !important; }
.part-btns button[hidden] { display: none; }
.part-btns button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.part-pick { position: relative; flex: 1.4; display: flex; min-width: 0; }
.part-menu { position: absolute; top: calc(100% + 4px); inset-inline-end: 0; z-index: 40; display: grid; gap: 4px; padding: 6px; min-width: 9em; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.part-menu[hidden] { display: none; }
.part-menu button { text-align: start; }
.sort-btns { margin-top: -4px; justify-content: center; }
.sort-btns > button { flex: none; min-height: 28px; padding: 2px 14px; font-size: 13px !important; }
#sortPart > .grp-head { display: none; }
#sortPart[hidden], #winsPart[hidden], #cbtExtra[hidden] { display: none; }
.wins-part { display: grid; gap: 12px; }
#journalPart .cards:empty { display: none; }
/* הצלחות: small buttons side by side; today's table under them */
#viewWins { display: grid; gap: 12px; }
.win-btn { min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: 14px; }
.win-btn.done { animation: win-done .6s ease; }
@keyframes win-done { 0% { background: var(--accent); color: var(--accent-text); } 100% { background: transparent; } }
.win-name { width: 8em; min-height: 34px; padding: 4px 10px; border-radius: 999px; font-size: 14px; }
.win-tool { position: relative; min-width: 34px; min-height: 34px; padding: 0; border-radius: 50%; background: transparent; color: var(--accent); }
.win-tool[hidden] { display: none; }
.win-name.win-new { width: 5em; border-style: dashed; }
.win-day h3 { margin: 0 0 6px; font-size: 15px; }
.win-table { width: 100%; border-collapse: collapse; }
.win-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.win-table tr:last-child td { border-bottom: 0; }
.win-time { width: 3.5em; color: var(--muted); direction: ltr; text-align: start; white-space: nowrap; }
.win-x { width: 32px; text-align: end; }
.win-del { min-height: 28px; min-width: 28px; padding: 0; border: 0; color: var(--muted); }
.win-btn { display: inline-flex; align-items: center; gap: 6px; }
.win-count { min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--accent-text); color: var(--accent); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.win-count[hidden] { display: none; }
/* הצלחות, today: the date, then the achievements as tags, each with its × */
.win-day { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; }
.win-date { font-weight: 700; margin-inline-end: 4px; }
.win-tag { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--tag); font-size: 14px; }
.win-tag .win-del { min-height: 22px; min-width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; }
/* תכונות: boxes with a title and a table */
.tbox-area { display: grid; gap: 12px; }
.tbox-area[hidden] { display: none; }
.tbox { display: grid; gap: 8px; padding: 10px; }
.tbox-top { display: flex; align-items: center; gap: 8px; }
.tbox-title { flex: 1; min-width: 0; font-weight: 700; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 4px 2px; }
.tbox-title:focus { outline: none; border-bottom-color: var(--accent); }
.tbox-cols { width: auto; min-height: 30px; padding: 2px 6px; font-size: 14px; }
.tbox-wrap { overflow-x: auto; }
.tbox-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tbox-grid td { border: 1px solid var(--line); padding: 6px 8px; min-width: 3em; vertical-align: top; overflow-wrap: anywhere; text-align: right; }
.tbox-grid .tbox-head { font-weight: 700; background: var(--tag); }
.tbox-grid td:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbox-add { justify-self: center; position: relative; width: 40px; height: 40px; min-height: 0; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; }
.tbox-add::before, .tbox-add::after { content: ''; position: absolute; left: 50%; top: 50%; background: var(--accent); border-radius: 2px; transform: translate(-50%, -50%); }
.tbox-add::before { width: 16px; height: 2px; }
.tbox-add::after { width: 2px; height: 16px; }
/* the handles: a row's number at its start, a mark above each column; a picked one is blue */
.tbox-grid td.tbox-rh, .tbox-grid td.tbox-corner { width: 2.2em; min-width: 0; padding: 4px 2px; text-align: center; color: var(--muted); font-size: 12px; border-color: transparent; background: transparent; }
.tbox-grid td.tbox-rh { cursor: pointer; }
.tbox-grid td.tbox-rh::before { content: '•'; }
.tbox-grid td.tbox-ch { height: 14px; padding: 0; border-color: transparent; cursor: pointer; position: relative; }
.tbox-grid td.tbox-ch::before { content: ''; position: absolute; left: 30%; right: 30%; top: 5px; height: 4px; border-radius: 2px; background: var(--line); }
.tbox-grid td.picked { background: rgba(37, 99, 235, .14); }
.tbox-grid td.tbox-rh.picked, .tbox-grid td.tbox-ch.picked::before { color: var(--accent); background: var(--accent); }
.tbox-grid td.tbox-rh.picked { color: var(--accent-text); border-radius: 6px; }
.tbox-bar { grid-template-columns: 1fr 1fr 1fr; }
/* הצלחות: the date (tap: another day), and a text inside a tag */
.win-date { position: relative; display: inline-block; cursor: pointer; }
.win-date-text { border-bottom: 1px dashed var(--line); }
.win-date-pick { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; min-height: 0; padding: 0; border: 0; cursor: pointer; }
.win-tag .win-what { cursor: text; }
.win-note { color: var(--muted); cursor: text; margin-inline-start: 4px; }
.win-note[hidden] { display: none; }
.win-note-input { width: 8em; min-height: 24px; padding: 0 6px; font-size: 14px; border-radius: 999px; }
/* תכונות: picking cells of a column (סימון טווח) */
.range-tools { display: flex; justify-content: flex-start; }
.range-tools[hidden] { display: none; }
#btnRange { min-height: 32px; padding: 4px 12px; font-size: 14px; }
#btnRange[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
body.range-mode #sheetGrid td[data-c], body.range-mode #tboxArea .tbox-cell { cursor: pointer; user-select: none; -webkit-user-select: none; }
td.range-picked { background: rgba(37, 99, 235, .18) !important; outline: 2px solid var(--accent); outline-offset: -2px; }
/* a part's title: a tap changes its kind */
.kind-pick { position: relative; display: inline-block; }
.i-card .kind-name { min-height: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: inherit !important; cursor: pointer; }
.i-card .kind-pick > .j-add-menu { top: 100%; margin-top: 4px; left: auto; inset-inline-start: 0; width: max-content; }
/* a הצלחות part: its tags (whole words inside the rounded tag), a + for them, × to delete it; its text right after */
.i-card .win-lbl { white-space: normal; }
.win-pills { display: inline; }
.win-pill, .win-pill-like { display: inline-block; margin-inline-start: 6px; padding: 1px 10px; border-radius: 999px; background: var(--tag); font-size: 14px !important; font-weight: 800; line-height: 20px; white-space: nowrap; }
.i-card .win-more { width: 22px; height: 22px; margin-inline-start: 6px; vertical-align: top; }
.i-card .win-del-part { min-height: 0; width: 22px; height: 22px; padding: 0; margin-inline-start: 4px; border: 0; background: transparent; color: var(--muted); font-size: 16px !important; font-weight: 400; vertical-align: top; }
.i-card .s-item[data-kind="win"] .e-text { font-weight: 400; }
/* how many times a tag was marked */
.tag-count { display: inline-block; min-width: 20px; height: 20px; margin-inline-start: 6px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 12px !important; font-weight: 700; line-height: 20px; text-align: center; vertical-align: 1px; }
.tag-count[hidden] { display: none; }
.win-btn .tag-count { background: var(--accent-text); color: var(--accent); margin-inline-start: 0; }
/* CBT: a tag's count - a tap shows the boxes with it */
.box-head .tag-count { flex: none; }
.tag-boxes { display: grid; gap: 12px; margin-top: 8px; }
.tag-boxes:empty { display: none; }
.tag-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 14px; }
.tag-select { max-width: 100%; min-height: 34px; font-size: 14px; }
/* הצלחות: its tags in two groups; one dragged onto the other group moves there */
.win-btns { display: grid; gap: 8px; }
.win-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 38px; padding: 4px; border-radius: 12px; }
.win-group + .win-group { border-top: 1px dashed var(--line); border-radius: 0 0 12px 12px; }
.win-group.drop { background: rgba(37, 99, 235, .1); }
.win-btn { touch-action: none; user-select: none; -webkit-user-select: none; }
.win-btn.dragging { opacity: .4; }
.win-ghost { position: fixed; z-index: 90; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
/* תכונות: a column's edge to drag (its width); a box's × */
.tbox-grid col.tbox-col-h { width: 2.2em; }
.tbox-grid td.tbox-ch { overflow: visible; }
.tbox-resize { position: absolute; top: -4px; bottom: -4px; left: -7px; width: 14px; z-index: 2; cursor: col-resize; touch-action: none; }
.tbox-resize::after { content: ''; position: absolute; left: 6px; top: 2px; bottom: 2px; width: 2px; border-radius: 1px; background: var(--muted); opacity: .5; }
.tbox-del { flex: none; min-height: 30px; min-width: 30px; padding: 0; border: 0; color: var(--muted); font-size: 18px !important; }
.danger-text { color: var(--danger); }
.range-tools { gap: 8px; }
.range-tools [hidden] { display: none; }
/* a box of הצלחות only: one line - "הצלחות", the date, a + for a tag; its tags one after another, no lines, no titles */
.wins-head { display: flex; align-items: center; gap: 8px; }
.wins-head[hidden] { display: none; }
.wins-title { font-weight: 700; }
.wins-head .j-date-wrap { margin: 0; }
.wins-box .s-item .i-lbl > .kind-pick:first-child { display: none; }
.wins-box .s-item .rich { border-bottom: 0; padding-bottom: 2px; min-height: 0; }
.wins-box .j-pairs { gap: 2px; }
.wins-box .j-tail .j-add { display: none; }
.wins-head .j-add-menu { top: 100%; margin-top: 4px; left: auto; inset-inline-start: 0; width: max-content; }
.wins-box .s-item .i-lbl .win-more { display: none; } /* (its tags: by the + on the box's line) */

/* Hebrew: every field starts on the right, also a password or a key written in English letters */
input:not([type="checkbox"]):not([type="radio"]):not([type="date"]):not([type="time"]), textarea, select, [contenteditable] { direction: rtl; text-align: right; }
/* מחשבה אוטומטית / תובנה with no list chosen yet: the + right after the title, the text on the same line */
.i-card .i-lbl.has-pick:not(:has(.j-inline-pick)) { inset-inline-end: auto; }
.i-card .i-lbl.has-pick:not(:has(.j-inline-pick)) > .j-ins-picks { display: none; }
/* הצלחות: its tags and texts one after another (no new line for each), starting at the title's edge */
.wins-box .j-pairs { display: block; }
.wins-box .s-item { display: inline; }
.wins-box .s-item .i-lbl { position: static; display: inline; }
.wins-box .s-item .rich { display: inline; width: auto; padding: 0 .4em 0 .6em; text-indent: 0; }
.wins-box .s-item:first-child .win-pill:first-child { margin-inline-start: 0; }
.fmt-move { position: relative; display: inline-flex; }
.fmt-bar #fmtMove { padding: 0 10px; font-size: 15px; }
.fmt-bar #fmtMove[hidden] { display: none; }
.fmt-move-menu { position: absolute; top: 100%; inset-inline-end: 0; margin-top: 4px; display: grid; gap: 4px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.fmt-move-menu[hidden] { display: none; }
.fmt-move-menu button { min-height: 36px; padding: 4px 12px; white-space: nowrap; font-size: 14px; }
/* אירוע: its topics, each in a rounded tag (a tap removes it), after its + */
.topic-pills { display: inline; }
.i-card .topic-pill { display: inline-block; width: auto; min-height: 0; margin-inline-start: 6px; padding: 1px 10px; border: 0; border-radius: 999px; background: var(--tag); color: var(--text); font-size: 14px !important; font-weight: 800; line-height: 20px; white-space: nowrap; vertical-align: baseline; }
.i-card .j-add-menu .topic-new { min-height: 36px; padding: 4px 10px; font-size: 14px; width: 12em; }
/* every box: its title and arrow as on אירוע */
.i-card .wins-title { line-height: 22px; font-weight: 700; color: var(--text); }
/* the + of a title line: as tall as the line (the line keeps its height) */
.i-card .i-lbl .topic-more { width: 22px; height: 22px; vertical-align: top; }
/* a closed box: its lines only (the + and ✓ at its end: when open) */
.i-card.j-closed .j-tail { display: none; }
.i-card.j-closed { position: relative; }
.i-card.j-closed::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 12px; background: var(--card); border-radius: 0 0 14px 14px; z-index: 2; }
.wins-head .j-fold { top: 0; }
/* CBT: four part buttons in one row, each as wide as its name */
.part-btns:not(.sort-btns) { gap: 4px; }
.part-btns:not(.sort-btns) > button, .part-btns .part-pick { flex: 1 1 auto; }
.part-btns:not(.sort-btns) > button, .part-pick > button { padding: 6px 6px; }
/* the CBT parts: in the top row, next to the menu button */
.title-row #partBtns { flex: 1; min-width: 0; }
/* אירועים: the boxes of another topic than the one picked */
.e-card.topic-out { display: none !important; }
#topicFilter:empty { display: none; }
#sortCards:not(:empty) { margin-bottom: 12px; }
#careCards { display: grid; gap: 10px; }
.top > .title-row { flex: 1 1 100%; width: 100%; }
/* a + of tags from several pages: each page's name, then its tags */
.i-card .tag-pages-menu .menu-sec { padding: 4px 8px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.i-card .tag-pages-menu .menu-none { padding: 0 12px; color: var(--muted); }
/* every kind: its + the same size, and the arrow level with the line of the title */
.i-card .i-lbl .j-ins-add, .i-card .i-lbl .j-proof-add, .i-card .wins-head .j-ins-add { width: 22px; height: 22px; vertical-align: top; }
.i-card .i-lbl .j-fold, .i-card .wins-head .j-fold { top: 0; height: 22px; vertical-align: top; }
.i-card .i-lbl .j-fold::before, .i-card .wins-head .j-fold::before { margin: -4px 0 0 -4px; transform: translateY(-2px) rotate(45deg); }
.i-card.j-closed .i-lbl .j-fold::before, .i-card.j-closed .wins-head .j-fold::before { transform: translateX(2px) rotate(135deg); }
/* the tags: small, one after another (not the whole width); dragged to a new place */
.ins-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ins-list > .e-card.ibox { width: auto; max-width: 100%; }
.ins-list .ibox .box-title { width: auto; min-width: 0; }
.ins-list .ibox .box-head { display: flex; align-items: center; }
#groupBoxes .grp[data-key="types"] > .grp-body { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
#sheetBoxes.types #groupBoxes .sheet-box[data-type] { flex: 0 0 auto; max-width: 100%; }
#sheetBoxes.types #groupBoxes .sheet-box[data-type]:not(.collapsed) { flex-basis: 100%; }
#sheetBoxes.types #groupBoxes .sheet-box[data-type] .box-title { width: auto; min-width: 0; flex: 0 1 auto; }
.e-card.ibox, .sheet-box[data-type] > .box-head { -webkit-touch-callout: none; }
.dragging { opacity: .4; }
.drop-before { box-shadow: 4px 0 0 -1px var(--accent); }
.drop-after { box-shadow: -4px 0 0 -1px var(--accent); }
/* העברה: its menu as wide as its names */
.fmt-move-menu { width: max-content; }
/* a title line with lists: a list as wide as its name (no room left on the line: on the next one) */
.i-card .i-lbl.has-pick { flex-wrap: wrap; row-gap: 4px; }
.i-card .i-lbl.has-pick > .j-ins-picks { flex: 1 0 auto; max-width: 100%; }
/* a tag in a title line: a tap - change it, or remove it */
.i-card .i-lbl [data-type] { cursor: pointer; }
.i-card .pill-menu { top: 100%; margin-top: 4px; left: auto; inset-inline-start: 0; width: max-content; max-width: 80vw; }
.i-card .pill-menu .danger-text { color: var(--danger, #c0392b); }
/* the lists of a title line (עיוותי חשיבה, תובנות, טעויות, הצלחות): each as wide as its name, one after another */
.i-card .i-lbl.has-ins > .j-ins-picks { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.i-card .i-lbl .j-ins-picks > select { width: auto; max-width: 100%; margin: 0; flex: 0 1 auto; }
.wins-box .s-item .i-lbl > .j-ins-picks { display: inline-flex; vertical-align: middle; }
.i-card .i-lbl.has-ins > .j-ins-picks { flex: 1 1 0; min-width: 8em; }
.i-card .i-lbl.has-pick .j-ins-picks > select.j-inline-pick { flex: 0 1 auto; width: auto; }
.login-status { color: var(--muted); padding: 2px 4px; min-height: 1.4em; }
.login-status:empty { display: none; }
/* every part of מידע alike: its title, its + and lists as wide as they are (more: on the next line); its text after
   them on the line when there is room */
.i-card :is(.s-item, .ev-block) > .i-lbl.has-pick { inset-inline-end: auto; flex-wrap: wrap; }
.i-card :is(.s-item, .ev-block) > .i-lbl.has-ins > .j-ins-picks { display: contents; } /* (its lists: one after another on the title line, the next ones below) */
.i-card :is(.s-item, .ev-block) > .i-lbl.has-pick { column-gap: 4px; row-gap: 4px; }
/* every page of tags: its strip - ✎, then its tags, each as wide as its name and number, as many on a line as fit */
.tag-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 10px; }
.tag-strip:empty, .tag-strip[hidden] { display: none; }
.tag-strip .tag-edit { order: 0; min-width: 34px; min-height: 34px; padding: 0 8px; border-radius: 999px; font-size: 15px; }
.tag-strip .tag-edit[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tag-strip .tag-chip { display: inline-flex; align-items: center; gap: 6px; width: auto; min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: 14px; white-space: nowrap; touch-action: manipulation; }
.tag-strip button.tag-chip { border: 1px solid var(--line); background: var(--tag); color: var(--text); font-weight: 600; }
.tag-strip button.tag-chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tag-strip button.tag-chip.on .tag-count { background: var(--accent-text); color: var(--accent); }
.tag-strip input.tag-chip { width: 8em; }
.ins-store[hidden] { display: none; }

/* a text box at the top of a page: its first 3 lines (all of it while written in) */
.grp-note:not(:focus-within) .grp-note-text, #noteCards .e-card:not(:focus-within) .e-care { max-height: calc(3 * 1.6em); overflow: hidden; }
#noteCards .e-card:not(:focus-within) .e-care { max-height: calc(3 * 22px + 10px); }
/* a box of הצלחות: its tags right after its title line (not on the line below) */
.wins-box .wins-head:not([hidden]) { display: inline-flex; vertical-align: middle; margin-inline-end: 6px; }
.wins-box .j-pairs { display: inline; }
