/* ---------------------------------------------------------------------------
   Tools: calculator, calendar, journal. Same colours and variables as the rest of the workspace, so they follow
   the white / black theme. Everything is prefixed tl- so it cannot touch another page.
   --------------------------------------------------------------------------- */
.tl { padding: 28px var(--pad) 80px; font-family: var(--font); }
.tl > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.tl-head h1 { margin: 0; font-size: clamp(26px, 3vw, 36px); font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; }
.tl-head p { margin: 6px 0 0; font-size: 14.5px; color: var(--ink-soft); }
.tl-card { padding: clamp(16px, 2.2vw, 24px); border: 1px solid var(--sh-line, var(--line)); border-radius: 18px; background: var(--paper); }
.tl-card h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.tl-note { margin: 0 0 14px; font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); }
.tl-gate { padding: 40px 0; text-align: center; color: var(--ink-soft); }
.tl-gate a { color: var(--accent); }

.tl-field { display: grid; gap: 5px; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-soft); }
.tl-field input, .tl-field select, .tl-field textarea { width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--sh-line, var(--line)); border-radius: 12px; background: var(--paper); color: var(--ink); font: inherit; font-size: 15px; transition: border-color 140ms ease, box-shadow 140ms ease; }
.tl-field textarea { height: auto; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.tl-field input:focus, .tl-field select:focus, .tl-field textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--sh-tint, rgba(255, 122, 0, 0.12)); }
.tl-money { position: relative; }
.tl-money::before { content: "R"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--ink-soft); pointer-events: none; }
.tl-money input { padding-left: 30px; }
.tl-btn { display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 18px; border: 1px solid var(--accent); border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-size: 14px; cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease, background 140ms ease; }
.tl-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(255, 122, 0, 0.25); }
.tl-btn--ghost { background: transparent; color: var(--accent); }
.tl-btn--ghost:hover { background: var(--sh-tint, rgba(255, 122, 0, 0.09)); box-shadow: none; }
.tl-btn--danger { background: transparent; border-color: var(--sh-line, var(--line)); color: #b3261e; }
.tl-btn:focus-visible, .tl-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tl-x { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--ink-soft); font-size: 20px; line-height: 1; cursor: pointer; }
.tl-x:hover { background: var(--sh-hover, rgba(0, 0, 0, 0.05)); color: #b3261e; }

/* ---- calculator ---- */
.tl-tabs { display: inline-flex; gap: 4px; padding: 4px; margin: 20px 0 16px; border: 1px solid var(--sh-line, var(--line)); border-radius: 999px; }
.tl-tab { height: 36px; padding: 0 18px; border: 0; border-radius: 999px; background: none; font: inherit; font-size: 14px; color: var(--ink-soft); cursor: pointer; transition: background 140ms ease, color 140ms ease; }
.tl-tab[aria-selected="true"] { background: var(--accent); color: #fff; }
.tl-calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tl-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.tl-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 32px; gap: 8px; align-items: center; }
.tl-row input { height: 42px; padding: 0 12px; border: 1px solid var(--sh-line, var(--line)); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; font-size: 14.5px; }
.tl-row input:focus { outline: 0; border-color: var(--accent); }
.tl-result { position: sticky; top: calc(var(--sh-top, 60px) + 80px); overflow: hidden; }
.tl-big { margin: 6px 0 2px; font-size: clamp(34px, 5vw, 54px); line-height: 1; font-weight: 500; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.tl-big.is-good { color: #1a7f4b; }
.tl-big.is-bad { color: #b3261e; }
.tl-verdict { margin: 8px 0 16px; font-size: 14.5px; line-height: 1.55; }
.tl-lines { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--sh-line, var(--line)); }
.tl-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--sh-line, var(--line)); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.tl-lines li span:first-child { color: var(--ink-soft); }
.tl-lines li.is-total { font-weight: 600; }
.tl-chart { display: block; width: 100%; height: auto; margin-top: 16px; border-radius: 12px; background: var(--sh-tint, rgba(255, 122, 0, 0.06)); }
.tl-chart text { font: 11px var(--font); fill: var(--ink-soft); }
.tl-fine { margin: 14px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }

/* ---- calendar ---- */
.tl-cal { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tl-cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.tl-cal-bar h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.tl-cal-nav { display: flex; gap: 6px; }
.tl-dow, .tl-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.tl-dow span { padding: 6px 0; text-align: center; font-size: 12px; color: var(--ink-soft); }
.tl-day { position: relative; aspect-ratio: 1 / 0.82; padding: 8px; border: 1px solid transparent; border-radius: 12px; background: none; font: inherit; font-size: 14px; text-align: left; color: var(--ink); cursor: pointer; transition: background 120ms ease, border-color 120ms ease; }
.tl-day:hover { background: var(--sh-hover, rgba(0, 0, 0, 0.04)); }
.tl-day.is-out { color: var(--ink-soft); opacity: 0.45; }
.tl-day.is-today { border-color: var(--accent); font-weight: 600; }
.tl-day.is-picked { background: var(--accent); color: #fff; }
.tl-day i { position: absolute; left: 8px; bottom: 7px; display: flex; gap: 3px; }
.tl-day i b { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.tl-day.is-picked i b { background: #fff; }
.tl-evlist { display: grid; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.tl-ev { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--sh-line, var(--line)); border-radius: 12px; }
.tl-ev b { display: block; font-size: 14.5px; font-weight: 600; }
.tl-ev small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ink-soft); }
.tl-empty { margin: 12px 0 0; font-size: 14px; color: var(--ink-soft); }

/* ---- journal ---- */
.tl-jr { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.tl-jr-list { display: grid; gap: 6px; margin-top: 12px; max-height: 62vh; overflow: auto; }
.tl-nt { display: block; width: 100%; padding: 12px 14px; border: 1px solid transparent; border-radius: 12px; background: none; font: inherit; text-align: left; color: var(--ink); cursor: pointer; transition: background 120ms ease; }
.tl-nt:hover { background: var(--sh-hover, rgba(0, 0, 0, 0.04)); }
.tl-nt.is-open { background: var(--sh-active, rgba(255, 122, 0, 0.11)); border-color: var(--accent); }
.tl-nt b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 600; }
.tl-nt small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; font-size: 12.5px; color: var(--ink-soft); }
.tl-title { width: 100%; padding: 6px 0 10px; border: 0; border-bottom: 1px solid var(--sh-line, var(--line)); background: none; color: var(--ink); font: inherit; font-size: 24px; font-weight: 500; letter-spacing: -0.02em; }
.tl-title:focus { outline: 0; border-color: var(--accent); }
.tl-body { width: 100%; min-height: 48vh; margin-top: 14px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 15.5px; line-height: 1.7; resize: vertical; }
.tl-body:focus { outline: 0; }
.tl-saved { font-size: 12.5px; color: var(--ink-soft); }
.tl-ed-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

@media (max-width: 960px) {
  .tl-calc, .tl-cal, .tl-jr { grid-template-columns: 1fr; }
  .tl-result { position: static; }
  .tl-row { grid-template-columns: minmax(0, 1fr) 110px 32px; }
}
@media (prefers-reduced-motion: reduce) { .tl-btn, .tl-day, .tl-tab, .tl-nt { transition: none; } }
.tl-calc[hidden], .tl-cal[hidden], .tl-jr[hidden], .tl-gate[hidden], #jrEditor[hidden], #jrBlank[hidden], .tl-empty[hidden] { display: none; }

/* VAT and percentage calculators */
.tl-tabs { flex-wrap: wrap; border-radius: 22px; }
.tl-pct { position: relative; }
.tl-pct::after { content: "%"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--ink-soft); pointer-events: none; }
.tl-seg { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px; border: 1px solid var(--sh-line, var(--line)); border-radius: 999px; }
.tl-seg-btn { height: 34px; padding: 0 16px; border: 0; border-radius: 999px; background: none; font: inherit; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.tl-seg-btn.is-on { background: var(--accent); color: #fff; }
.tl-mini { padding: 14px 0; border-top: 1px solid var(--sh-line, var(--line)); }
.tl-mini h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.tl-mini h3 em { font-style: normal; color: var(--accent); }
.tl-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tl-pair .tl-field { margin: 0; }
.tl-ans { margin: 10px 0 0; min-height: 1.4em; font-size: 15.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Journal: a quiet writing space. A header with a soft pattern, your notes by day on the left, and a
   generous page to write on.
   --------------------------------------------------------------------------- */
.jr { padding-top: 22px; }
.jr > * { max-width: 1280px; }
.jr-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 18px 28px; padding: clamp(22px, 3.4vw, 40px); border: 1px solid var(--sh-line, var(--line)); border-radius: 26px; overflow: hidden; }
.jr-date { margin: 0 0 6px; font-size: 13.5px; color: var(--accent); letter-spacing: 0.02em; }
.jr-head h1 { margin: 0; font-size: clamp(34px, 4.6vw, 58px); line-height: 1; font-weight: 500; letter-spacing: -0.04em; }
.jr-sub { margin: 10px 0 0; max-width: 520px; font-size: 15px; line-height: 1.55; color: var(--ink-soft); }
.jr-head-actions { display: flex; gap: 10px; }
.jr-head-actions .tl-btn { height: 44px; padding: 0 22px; font-size: 15px; }

.jr-app { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; margin-top: 18px; align-items: start; transition: grid-template-columns 260ms ease; }
.jr-app[hidden] { display: none; }
.jr-app.is-focus { grid-template-columns: 0 minmax(0, 1fr); gap: 0; }
.jr-app.is-focus .jr-side { opacity: 0; pointer-events: none; overflow: hidden; }
.jr-app.is-focus .jr-page { max-width: 820px; margin: 0 auto; width: 100%; }

.jr-side { position: sticky; top: calc(var(--sh-top, 60px) + 20px); display: flex; flex-direction: column; max-height: calc(100vh - var(--sh-top, 60px) - 40px); min-width: 0; transition: opacity 200ms ease; }
.jr-search { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px; border: 1px solid var(--sh-line, var(--line)); border-radius: 999px; background: var(--paper); color: var(--ink-soft); transition: border-color 140ms ease, box-shadow 140ms ease; }
.jr-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--sh-tint, rgba(255, 122, 0, 0.12)); color: var(--accent); }
.jr-search input { flex: 1 1 auto; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font: inherit; font-size: 14.5px; color: var(--ink); }
.jr-count { margin: 14px 4px 6px; font-size: 12.5px; color: var(--ink-soft); }
.jr-list { overflow: auto; padding: 0 2px 12px; scrollbar-width: thin; }
.jr-group { margin: 14px 6px 6px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.jr-item { display: block; width: 100%; margin-bottom: 6px; padding: 13px 15px; border: 1px solid transparent; border-radius: 16px; background: none; font: inherit; text-align: left; color: var(--ink); cursor: pointer; transition: background 140ms ease, border-color 140ms ease, transform 160ms ease; }
.jr-item:hover { background: var(--sh-hover, rgba(0, 0, 0, 0.04)); }
.jr-item.is-open { background: var(--paper); border-color: var(--accent); box-shadow: 0 10px 24px rgba(28, 28, 31, 0.1); }
.jr-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.jr-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.jr-item time { flex: 0 0 auto; font-size: 12px; color: var(--ink-soft); }
.jr-item small { display: block; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.jr-none { margin: 20px 6px; font-size: 14px; color: var(--ink-soft); }
.jr-item:focus-visible, .jr-chip:focus-visible, .jr-focus:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.jr-page { position: relative; min-width: 0; padding: clamp(22px, 3.6vw, 48px); border: 1px solid var(--sh-line, var(--line)); border-radius: 26px; background: var(--paper); box-shadow: 0 18px 44px rgba(28, 28, 31, 0.07); }
.jr-page::before { content: ""; position: absolute; left: clamp(22px, 3.6vw, 48px); top: 0; width: 56px; height: 5px; border-radius: 0 0 6px 6px; background: var(--accent); }
.jr-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-soft); }
.jr-focus { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border: 1px solid var(--sh-line, var(--line)); border-radius: 999px; background: none; font: inherit; font-size: 13px; color: var(--ink-soft); cursor: pointer; transition: border-color 140ms ease, color 140ms ease; }
.jr-focus:hover { border-color: var(--accent); color: var(--accent); }
.jr-title { width: 100%; margin: 14px 0 0; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: clamp(28px, 3.4vw, 42px); font-weight: 500; letter-spacing: -0.035em; line-height: 1.12; }
.jr-title::placeholder { color: color-mix(in srgb, var(--ink) 28%, transparent); }
.jr-title:focus { outline: 0; }
.jr-prompts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 16px 0 6px; font-size: 13px; color: var(--ink-soft); }
.jr-prompts > div { display: flex; flex-wrap: wrap; gap: 8px; }
.jr-chip { height: 32px; padding: 0 14px; border: 1px solid var(--sh-line, var(--line)); border-radius: 999px; background: none; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 160ms ease; }
.jr-chip:hover { border-color: var(--accent); background: var(--sh-tint, rgba(255, 122, 0, 0.09)); color: var(--accent); transform: translateY(-1px); }
.jr-body { display: block; width: 100%; min-height: min(56vh, 560px); margin-top: 10px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 17px; line-height: 1.85; resize: vertical; }
.jr-body::placeholder { color: color-mix(in srgb, var(--ink) 30%, transparent); }
.jr-body:focus { outline: 0; }
.jr-foot { display: flex; align-items: center; gap: 16px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--sh-line, var(--line)); font-size: 13px; color: var(--ink-soft); }
.jr-status { display: inline-flex; align-items: center; gap: 8px; }
.jr-status i { width: 8px; height: 8px; border-radius: 50%; background: #1a7f4b; }
.jr-words { margin-left: auto; font-variant-numeric: tabular-nums; }
.jr-del { border: 0; background: none; font: inherit; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.jr-del:hover { color: #b3261e; text-decoration: underline; }

.jr-blank { display: grid; justify-items: center; text-align: center; padding: clamp(24px, 6vh, 70px) 12px; }
.jr-blank h2 { margin: 18px 0 6px; font-size: clamp(24px, 3vw, 34px); font-weight: 500; letter-spacing: -0.03em; }
.jr-blank p { margin: 0; max-width: 380px; font-size: 15px; line-height: 1.55; color: var(--ink-soft); }
.jr-blank-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }
.jr-blank-art { position: relative; width: 120px; height: 96px; }
.jr-blank-art i { position: absolute; left: 50%; top: 50%; width: 72px; height: 88px; border-radius: 14px; background: #fff; box-shadow: 0 10px 24px rgba(28, 28, 31, 0.16); }
.jr-blank-art i:nth-child(1) { transform: translate(-50%, -50%) rotate(-12deg) translateX(-18px); background: #e4e4e4; }
.jr-blank-art i:nth-child(2) { transform: translate(-50%, -50%) rotate(-3deg) translateX(-4px); background: #efefef; }
.jr-blank-art i:nth-child(3) { transform: translate(-50%, -50%) rotate(7deg) translateX(10px); background: linear-gradient(#fff 0 0) padding-box, #fff; }
.jr-blank-art i:nth-child(3)::after { content: ""; position: absolute; left: 14px; right: 14px; top: 22px; height: 6px; border-radius: 3px; background: #efefef; box-shadow: 0 16px 0 #efefef, 0 32px 0 #efefef; }


@media (max-width: 960px) {
  .jr-app, .jr-app.is-focus { grid-template-columns: 1fr; }
  .jr-side { position: static; max-height: 320px; }
  .jr-app.is-focus .jr-side { display: none; }
  .jr-head-actions { width: 100%; }
  .jr-head-actions .tl-btn { flex: 1 1 0; }
}
@media (prefers-reduced-motion: reduce) { .jr-app, .jr-item, .jr-chip { transition: none; } }
@media (max-width: 760px) { .tl-cal { grid-template-columns: minmax(0, 1fr); } .tl-card { min-width: 0; max-width: 100%; } }
