/* css/style.css — the whole design, used by every page.

   "Sheet" style: LifeThreads looks like a spreadsheet (Excel, Google Sheets)
   or a classic business system. White surfaces, thin grey grid lines, the
   system font, plain words, no emoji, no shadows, no gradients, no rounded
   cards. Colour is used only for meaning: the four thread states (as cell
   fills, like conditional formatting) and one blue for selection and the
   main action. Calm and predictable on purpose: nothing moves or competes
   for attention, which helps analytical and ADHD brains alike.

   Contents: 1 tokens · 2 base · 3 controls · 4 sheets (tables) · 5 app frame
   · 6 pages · 7 small screens */

/* ---------- 1. Tokens ---------- */

:root {
  --bg: #ffffff;
  --head: #f8f9fa;        /* column / row headers, toolbars */
  --head-2: #eef0f2;      /* group rows, hover on headers */
  --canvas: #eceef1;      /* the grey work area behind the panels */
  --panel-head: #e3e6ea;  /* title bars of panels */
  --group-band: #e8ebee;  /* group rows inside sheets */
  --grid: #e2e3e5;        /* cell lines */
  --border: #c4c7c5;      /* control borders, panel edges */
  --text: #1f1f1f;
  --text-2: #444746;
  --muted: #6b6f73;
  --accent: #1a73e8;      /* selection and the main action */
  --accent-dark: #1557b0;
  --accent-tint: #e8f0fe;
  --danger: #c5221f;
  --danger-tint: #fce8e6;
  --success: #188038;
  --success-tint: #e6f4ea;

  /* Thread states, as Google Sheets' light fills with matching dark text */
  --open-fill: #d9ead3;    --open-ink: #274e13;
  --closed-fill: #fce5cd;  --closed-ink: #7f3f00;
  --notnow-fill: #d9d2e9;  --notnow-ink: #351c75;
  --forever-fill: #d9d9d9; --forever-ink: #3a3a3a;

  --font: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: Consolas, 'Courier New', monospace;
  --bar: 44px;            /* top bar height */
  --sidebar: 340px;
  --gutter: 20px;

  color-scheme: light;
}

/* ---------- 2. Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: 400 14px/1.45 var(--font);
}
img { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; color: var(--text-2); }
h1, h2, h3 { margin: 0; color: var(--text); font-weight: 600; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
::selection { background: var(--accent-tint); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }
.wrap { width: 100%; max-width: 1100px; margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 520px; }
.narrow-wide { max-width: 760px; }
.kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--border); border-radius: 3px; background: #fff; font: 600 11px/16px var(--font); color: var(--text-2); text-align: center; }

/* ---------- 3. Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border: 1px solid var(--border); border-radius: 3px;
  background: #fff; color: var(--text); font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--head); text-decoration: none; color: var(--text); }
.btn:active { background: var(--head-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--head-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); color: var(--danger); }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--muted); border-right-color: transparent; animation: spin .8s linear infinite;
}
.btn-primary.is-busy::after { border-color: #fff; border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn { padding: 2px 4px; border: 0; background: none; color: var(--accent); font-size: 13px; cursor: pointer; border-radius: 2px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* Inputs: thin box, blue edge when focused (like an active cell) */
.input, .field input[type='text'], .field input[type='email'], .field input[type='password'],
.field input[type='date'], .field select, .field textarea, select.input {
  width: 100%; height: 32px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 2px; background: #fff; color: var(--text); font-size: 14px;
}
textarea.input, .field textarea { height: auto; min-height: 72px; line-height: 1.45; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, select.input:focus {
  outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent);
}
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: #9aa0a6; }
[aria-invalid='true'] { border-color: var(--danger) !important; }

.form { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 560px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 4px; }
.field > label:not(.check), .field > .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-error { font-size: 13px; color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.form-message { padding: 8px 10px; border: 1px solid transparent; font-size: 13px; }
.form-message:empty { display: none; }
.form-message.error { background: var(--danger-tint); border-color: #f4c7c3; color: var(--danger); }
.form-message.success { background: var(--success-tint); border-color: #ceead6; color: var(--success); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.note { font-size: 13px; color: var(--muted); }

/* Segmented choice (Today / Tomorrow / Someday): joined buttons like a toolbar group */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.segmented button { height: 30px; padding: 0 12px; border: 0; border-left: 1px solid var(--border); background: #fff; color: var(--text-2); cursor: pointer; }
.segmented button:first-child { border-left: 0; }
.segmented button:hover { background: var(--head); }
.segmented button[aria-pressed='true'], .segmented button[aria-selected='true'] { background: var(--accent-tint); color: var(--accent-dark); font-weight: 600; }

.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; margin-bottom: -1px; border: 1px solid transparent; color: var(--text-2); }
.tabs a:hover { text-decoration: none; background: var(--head); }
.tabs a[aria-current='page'] { border-color: var(--border); border-bottom-color: #fff; background: #fff; color: var(--text); font-weight: 600; }

/* Pop-up menus */
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 200px; padding: 4px 0;
  background: #fff; border: 1px solid var(--border); box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.menu p { padding: 6px 12px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--grid); margin-bottom: 4px; }
.menu p strong { display: block; color: var(--text); }
.menu a, .menu button {
  display: block; width: 100%; padding: 6px 12px; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; font-size: 14px;
}
.menu a:hover, .menu button:hover { background: var(--accent-tint); text-decoration: none; color: var(--text); }
.menu .danger { color: var(--danger); }

/* Dialog windows */
dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  border: 1px solid #8e9194; border-radius: 4px; background: #fff; color: var(--text); box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
dialog::backdrop { background: rgba(32, 33, 36, .35); }
.dialog-body { display: grid; gap: 14px; padding: 16px; }
.dialog-body > header { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--grid); }
.dialog-body h2 { font-size: 16px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--grid); }

/* Status bar at the bottom (messages and "Undo"), like a spreadsheet's */
.toast {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px; min-height: 30px; padding: 4px var(--gutter) calc(4px + env(safe-area-inset-bottom));
  background: var(--head-2); border-top: 1px solid var(--border); color: var(--text); font-size: 13px;
  transform: translateY(100%); visibility: hidden; transition: transform .15s, visibility .15s;
}
.toast.show { transform: none; visibility: visible; }
.toast button { height: 22px; padding: 0 10px; border: 1px solid var(--border); border-radius: 3px; background: #fff; font-size: 12px; cursor: pointer; }
.toast button:hover { background: var(--head); }

.loading { display: grid; place-items: center; padding: 40px 0; color: var(--muted); }
.loading::before { content: 'Loading…'; font-size: 13px; }

.empty { padding: 16px; border: 1px dashed var(--border); color: var(--muted); }
.empty h3 { margin-bottom: 4px; }

/* ---------- 4. Sheets: tables with grid lines ---------- */

.sheet { width: 100%; border-collapse: collapse; background: #fff; table-layout: auto; }
.sheet th, .sheet td { border: 1px solid var(--grid); padding: 5px 8px; text-align: left; vertical-align: top; }
.sheet thead th { position: sticky; top: 0; z-index: 1; background: var(--head); color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.sheet .rn { width: 36px; background: var(--head); color: var(--muted); text-align: center; font-size: 12px; }
.sheet tbody tr:hover > td:not(.rn) { background-color: #f8f9fa; }
.sheet .num-col { width: 1%; white-space: nowrap; text-align: right; }
.sheet .fit { width: 1%; white-space: nowrap; }
.sheet .group td { background: var(--head-2); font-weight: 600; color: var(--text-2); }
.sheet .group td .count { font-weight: 400; color: var(--muted); margin-left: 6px; }
.sheet .group .link-btn { float: right; }
.sheet .empty-row td { color: var(--muted); font-style: italic; }
.sheet a { color: var(--text); }
.sheet a:hover { color: var(--accent); }
.sheet-wrap { overflow-x: auto; border: 1px solid var(--border); }
.sheet-wrap > .sheet { border-style: hidden; }   /* the wrapper draws the outer edge */

/* Thread states as cell fills (text label always shown too) */
.st-active { --fill: var(--open-fill);    --ink: var(--open-ink); }
.st-paused { --fill: var(--closed-fill);  --ink: var(--closed-ink); }
.st-idle   { --fill: var(--notnow-fill);  --ink: var(--notnow-ink); }
.st-done   { --fill: var(--forever-fill); --ink: var(--forever-ink); }
select.status-select {
  width: 100%; height: 26px; padding: 0 22px 0 6px; border: 1px solid transparent; border-radius: 2px;
  background: var(--fill) linear-gradient(45deg, transparent 50%, var(--ink) 50%) no-repeat calc(100% - 9px) 50% / 5px 5px;
  color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; -webkit-appearance: none; appearance: none;
}
select.status-select:hover { border-color: var(--border); }
select.status-select:focus { outline: none; border-color: var(--accent); }
.status-field { display: flex; align-items: center; gap: 8px; }
.status-field select.status-select { width: 160px; height: 30px; }
.dot { display: none; }

/* ---------- 5. App frame: top bar, threads column, main area ---------- */

.topbar { position: sticky; top: 0; z-index: 30; height: var(--bar); background: var(--head); border-bottom: 1px solid var(--border); }
.topbar .inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-inline: 12px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 15px; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand img { width: 20px; height: 20px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid transparent; border-radius: 3px;
  background: none; color: var(--text); font-size: 14px; cursor: pointer; list-style: none; white-space: nowrap;
}
.tb-btn:hover { background: var(--head-2); border-color: var(--border); text-decoration: none; }
.tb-btn::-webkit-details-marker { display: none; }
.user-menu { position: relative; }
.user-menu > summary { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* Public pages header (landing, sign in) */
.site-header { border-bottom: 1px solid var(--border); background: var(--head); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--bar); }
.site-header nav { display: flex; gap: 6px; align-items: center; }
.site-footer { padding: 24px var(--gutter) 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--grid); margin-top: 32px; }

.shell { display: grid; align-items: start; min-height: calc(100dvh - var(--bar)); }
.main { min-width: 0; padding: 16px var(--gutter) 64px; container: main / inline-size; }
.main-inner { max-width: 1400px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(92vw, var(--sidebar));
  display: flex; flex-direction: column; gap: 12px; padding: 12px; background: #fff; border-right: 1px solid var(--border);
  overflow-y: auto; transform: translateX(-102%); visibility: hidden; transition: transform .15s, visibility .15s;
}
.sidebar.open { transform: none; visibility: visible; }
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(32, 33, 36, .3); }
.sidebar-hide { display: none; }
@media (min-width: 1000px) {
  .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: var(--bar); z-index: 1; width: auto; height: calc(100dvh - var(--bar));
    transform: none; visibility: visible; background: var(--head);
  }
  .scrim, .threads-toggle, .sidebar-close { display: none !important; }
  .sidebar-hide { display: inline-flex; }
  .sidebar-hidden .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar-hidden .sidebar { display: none; }
  .sidebar-hidden .threads-toggle { display: inline-flex !important; }
}

.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-top h2 { font-size: 14px; }
.side-links { display: grid; border: 1px solid var(--border); background: #fff; }
.side-links a { padding: 6px 10px; color: var(--text); }
.side-links a:hover { background: var(--accent-tint); text-decoration: none; }
.side-links a[aria-current='page'] { background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
/* "Interests": a switch, not a page; pressed = the column lists interests */
.side-links button { padding: 6px 10px; border: 0; border-top: 1px solid var(--grid); background: transparent; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.side-links button:hover { background: var(--accent-tint); }
.side-links button[aria-pressed='true'] { background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.side-links button + a { border-top: 1px solid var(--grid); }

/* The threads list: a sheet with row numbers, the whole row in its state's fill */
.thread-sheet td { padding: 0; vertical-align: middle; }
.thread-sheet td.rn { padding: 4px 0; }
.thread-sheet tbody tr:hover > td:not(.rn) { background-color: transparent; }
.thread-sheet tr[class*='st-'] > td:not(.rn) { background: var(--fill); color: var(--ink); }
.thread-sheet tr.current > td.rn { background: var(--accent); color: #fff; font-weight: 600; }
.thread-sheet tr.current > td:not(.rn) { box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
.thread-sheet .name a { display: block; padding: 5px 8px 0; color: var(--ink); overflow-wrap: break-word; }
.thread-sheet .name a:hover { text-decoration: underline; }
.thread-sheet .type { display: block; padding: 0 8px 5px; font-size: 11px; color: var(--ink); opacity: .75; }
.thread-sheet .state { width: 128px; padding: 2px; }
.thread-sheet select.status-select { background-color: transparent; }
.thread-sheet select.status-select:hover, .thread-sheet select.status-select:focus { background-color: #fff; }

/* Grouping the threads by category */
.side-tools { display: flex; justify-content: flex-end; }
.side-tools .btn[aria-pressed='true'] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-dark); }
.thread-sheet .group td { padding: 0; }
.group-toggle {
  display: block; width: 100%; padding: 4px 8px; border: 0; background: transparent;
  font: inherit; font-weight: 700; color: inherit; text-align: left; cursor: pointer;
}
.group-toggle:hover { background: rgba(0, 0, 0, .04); }
.props .category-select { width: auto; min-width: 180px; }

/* New thread form (in the column) */
.new-thread { display: grid; gap: 10px; padding: 10px; border: 1px solid var(--border); background: #fff; }
.new-thread textarea.input { min-height: 80px; }

/* ---------- 6. Pages ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.page-head .title { min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head .sub { font-size: 13px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.crumb { display: inline-block; margin-bottom: 8px; font-size: 13px; }

/* Property rows under a title (Status, Description…) */
.props { display: grid; grid-template-columns: 120px minmax(0, 1fr); border: 1px solid var(--grid); margin-bottom: 18px; max-width: 900px; }
.props > .k, .props > .v { padding: 6px 8px; border-bottom: 1px solid var(--grid); }
.props > .k { background: var(--head); color: var(--text-2); font-size: 13px; font-weight: 600; border-right: 1px solid var(--grid); }
.props > .k:nth-last-child(2), .props > .v:last-child { border-bottom: 0; }
.props textarea.cell, .props input.cell { width: 100%; }
/* A long project description folds to a few lines; a dashed bottom edge says "there is more" */
.props textarea.cell.folded { overflow: hidden; border-bottom: 1px dashed var(--border); }
.desc-foot { display: flex; align-items: center; gap: 8px; }
.desc-foot .link-btn { padding-left: 0; }

/* Cells you can type in directly */
.cell {
  display: block; width: 100%; min-height: 26px; padding: 3px 4px; border: 1px solid transparent; border-radius: 0;
  background: transparent; color: inherit; font: inherit; resize: none; overflow: hidden;
}
.cell:hover { border-color: var(--grid); }
.cell:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #fff; }
textarea.cell { line-height: 1.45; }
.cell::placeholder { color: #9aa0a6; }
.saved { font-size: 12px; color: var(--success); opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }

/* Today */
.today-grid { display: grid; gap: 20px; align-items: start; }
.today-grid > * { min-width: 0; }
@container main (min-width: 860px) {
  .today-grid { grid-template-columns: minmax(0, 1fr) 280px; }
  .today-side { position: sticky; top: calc(var(--bar) + 16px); }
}
.today-side { display: grid; gap: 16px; }
.summary { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--grid); margin-bottom: 12px; width: fit-content; max-width: 100%; }
.summary > div { padding: 4px 12px; border-right: 1px solid var(--grid); font-size: 13px; }
.summary > div:last-child { border-right: 0; }
.summary b { font-size: 15px; margin-right: 4px; }
.add-bar { display: flex; gap: 6px; margin-bottom: 6px; }
.add-bar .input { flex: 1; min-width: 0; }
.add-bar .input[type='date'] { flex: 0 0 150px; }
.add-more { display: grid; gap: 10px; padding: 10px; margin-bottom: 10px; border: 1px solid var(--grid); background: var(--head); }
@media (min-width: 560px) { .add-more .two { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } }
.add-more .two { display: grid; gap: 10px; }
.add-tools { display: flex; gap: 12px; margin-bottom: 12px; }

/* Calendar: a 7-column grid */
.cal { border: 1px solid var(--border); background: #fff; }
.cal-top { display: flex; align-items: center; justify-content: space-between; padding: 4px; background: var(--head); border-bottom: 1px solid var(--grid); }
.cal-title { font-weight: 600; font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { padding: 3px 0; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--head); border-bottom: 1px solid var(--grid); }
.cal-day {
  position: relative; height: 34px; padding: 2px 4px; border: 0; border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid);
  background: #fff; text-align: left; cursor: pointer; display: block;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: var(--accent-tint); }
.cal-day .d { font-size: 12px; }
.cal-day .n { position: absolute; right: 3px; bottom: 2px; font-size: 10px; font-weight: 700; color: var(--accent-dark); }
.cal-day.out .d { color: #b0b3b8; }
.cal-day.today .d { font-weight: 700; color: var(--accent); }
.cal-day.selected { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-tint); }
.cal-foot { padding: 4px; border-top: 1px solid var(--grid); display: flex; justify-content: center; }
.round-btn { width: 26px; height: 26px; border: 1px solid transparent; border-radius: 3px; background: none; cursor: pointer; font-size: 14px; color: var(--text-2); }
.round-btn:hover { background: var(--head-2); border-color: var(--border); }

/* Tasks (rows of a sheet) */
.task-sheet td { vertical-align: middle; }
.task-sheet .ck { width: 34px; text-align: center; }
.task-sheet .ck input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.task-sheet .title-cell { min-width: 180px; }
.task-sheet .title-btn { padding: 0; border: 0; background: none; text-align: left; color: var(--text); cursor: pointer; overflow-wrap: anywhere; }
.task-sheet .title-btn:hover { color: var(--accent); text-decoration: underline; }
.task-sheet tr.is-done .title-btn { color: var(--muted); text-decoration: line-through; }
.task-sheet .has-notes { margin-left: 6px; font-size: 11px; color: var(--muted); }
.task-sheet .late { color: var(--closed-ink); }
.task-sheet .open-btn { width: 24px; height: 24px; border: 1px solid transparent; border-radius: 2px; background: none; cursor: pointer; color: var(--text-2); font-size: 11px; }
.task-sheet .open-btn:hover { border-color: var(--border); background: #fff; }
.task-sheet tr.open > td:not(.rn) { background: var(--accent-tint); }
.task-sheet tr.detail > td { background: #fbfbfc; padding: 10px 12px; }
.task-sheet tr[draggable='true'] { cursor: grab; }
.task-sheet tr.dragging { opacity: .4; }
/* On the board an unfolded task can be grabbed by its empty space too (not by its fields). */
.board .task-detail { cursor: grab; }
.board .task-detail :is(input, textarea, select) { cursor: auto; }
.board .task-detail :is(button, a) { cursor: pointer; }
.task-detail { display: grid; gap: 8px; max-width: 760px; }
/* Date, Deadline, State, Project: labels in one column, equal-width fields lined up in the next */
.task-detail .detail-props { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; align-items: baseline; }  /* the label sits on its field's line, also when links wrap below it */
.task-detail .detail-props .dv { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.task-detail .detail-props .input { width: 12rem; max-width: 100%; }
.task-detail .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Thread page: the chain as a row of cells, read left to right */
.chain-wrap { border: 1px solid var(--border); overflow-x: auto; background: #fff; }
.chain { display: flex; align-items: stretch; min-width: min-content; }
.chain > * { flex: none; }
.node { width: 260px; display: flex; flex-direction: column; border-right: 1px solid var(--grid); background: #fff; }
.node .head { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 28px; padding: 0 8px; background: var(--head); border-bottom: 1px solid var(--grid); font-size: 12px; font-weight: 600; color: var(--text-2); }
.node .text { flex: 1; min-height: 120px; padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); cursor: text; }
.node .text:hover { box-shadow: inset 0 0 0 1px var(--grid); }
.node .text:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.node.latest .head { background: var(--accent-tint); color: var(--accent-dark); }
.node.root { position: sticky; left: 0; z-index: 2; width: 240px; border-right: 1px solid var(--border); }
.node.root .text { font-weight: 600; cursor: default; }
.node.root .text:hover { box-shadow: none; }
/* Interest page: several chains, one row each, a line between rows */
.chain-rows { display: flex; flex-direction: column; gap: 10px; background: var(--canvas); }
.panel .chain-rows > .chain-wrap { border-bottom: 1px solid var(--border); }
.panel .chain-rows > .chain-wrap + .chain-wrap { border-top: 1px solid var(--border); }
.node.root .text.line-name { cursor: pointer; }
.node.root .text.line-name:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.node.root .line-name-input { margin: 8px; width: calc(100% - 16px); }
.chain-new { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--head); }
.chain-new .input { flex: 1 1 220px; max-width: 360px; }
.chain-new label { font-size: 13px; font-weight: 600; }
.node .actions { display: flex; gap: 2px; }
.node .actions button { height: 22px; padding: 0 6px; border: 1px solid transparent; border-radius: 2px; background: none; font-size: 12px; color: var(--text-2); cursor: pointer; }
.node .actions button:hover { border-color: var(--border); background: #fff; }
.node .actions button.danger { color: var(--danger); }
.node .actions button:disabled { opacity: .35; cursor: default; }
.node.editor .text-edit { flex: 1; display: flex; flex-direction: column; }
.node.editor textarea { flex: 1; min-height: 120px; padding: 8px; border: 0; box-shadow: inset 0 0 0 2px var(--accent); resize: none; line-height: 1.45; }
.node.editor textarea:focus { outline: none; }
.node.editor .row { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-top: 1px solid var(--grid); }
.node.editor .hint { padding: 0 8px 6px; font-size: 12px; }
.node.add { align-items: center; justify-content: center; gap: 4px; min-height: 148px; border: 0; background: #fff; color: var(--accent); cursor: pointer; font-size: 14px; }
.node.add:hover { background: var(--accent-tint); }
.node.add small { color: var(--muted); font-size: 12px; }
.arrow { position: relative; width: 34px; display: grid; place-items: center; border-right: 1px solid var(--grid); background: var(--head); color: var(--muted); font-size: 16px; }
.arrow .glyph::before { content: '\2192'; }   /* → */
.arrow .insert { position: absolute; bottom: 6px; width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 2px; background: #fff; color: var(--accent); font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; }
.arrow:hover .insert, .arrow .insert:focus-visible { opacity: 1; }
@media (hover: none) { .arrow .insert { opacity: 1; } }
.chain-help { margin-top: 6px; font-size: 12px; color: var(--muted); }

@container main (max-width: 640px) {
  .chain-wrap { overflow: visible; }
  .chain { flex-direction: column; min-width: 0; }
  .node, .node.root { width: 100%; position: static; border-right: 0; border-bottom: 1px solid var(--grid); }
  .arrow { width: 100%; height: 26px; border-right: 0; border-bottom: 1px solid var(--grid); }
  .arrow .glyph::before { content: '\2193'; }   /* ↓ */
  .arrow .insert { bottom: auto; right: 8px; }
  .node .text { min-height: 60px; }
}

/* Project page */
.project-grid { display: grid; gap: 20px; align-items: start; grid-template-areas: 'know' 'tools' 'board' 'cal'; }
.project-grid > * { min-width: 0; }
.area-cal { grid-area: cal; }
.area-know { grid-area: know; }
.area-tools { grid-area: tools; }
.area-board { grid-area: board; }
@container main (min-width: 700px) {
  .project-grid { grid-template-columns: 260px minmax(0, 1fr); grid-template-areas: 'cal know' 'cal tools' 'board board'; }
}
@container main (min-width: 1000px) {
  .project-grid { grid-template-columns: 260px minmax(0, 1fr) 260px; grid-template-areas: 'cal know tools' 'board board board'; }
}
.add-line { display: flex; gap: 6px; margin-top: 6px; }
.add-line .input { flex: 1; min-width: 0; }
.filter-note { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.board { display: grid; gap: 12px; align-items: start; }
@container main (min-width: 760px) { .board { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.board .col.drop-over .sheet-wrap { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wip-note { padding: 4px 8px; margin-bottom: 6px; font-size: 12px; background: var(--closed-fill); color: var(--closed-ink); }

/* Marketing: characters */
.char-sheet .avatar-cell { width: 44px; padding: 3px; }
.char-sheet .avatar-cell img, .char-sheet .avatar-cell span { width: 36px; height: 36px; object-fit: cover; display: grid; place-items: center; background: var(--head-2); color: var(--muted); font-weight: 600; }
.char-sheet tr.open > td:not(.rn) { background: var(--accent-tint); }
.char-sheet tr.detail > td { background: #fbfbfc; padding: 12px; }
.char-detail { display: grid; gap: 12px; max-width: 980px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-row .label, .label-row label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; padding: 6px; border: 1px solid var(--grid); background: #fff; }
.photos.drop-over { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.photo { position: relative; aspect-ratio: 1; border: 1px solid var(--grid); background: var(--head); overflow: hidden; }
.photo .thumb { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.photo .thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo .remove { position: absolute; top: 2px; right: 2px; height: 20px; padding: 0 6px; border: 1px solid var(--border); background: #fff; font-size: 11px; color: var(--danger); cursor: pointer; }
.photo.uploading { display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.photo.add { display: grid; place-content: center; text-align: center; gap: 2px; border-style: dashed; border-color: var(--border); background: #fff; color: var(--accent); cursor: pointer; font-size: 13px; }
.photo.add:hover, .photo.add:focus-within { background: var(--accent-tint); }
textarea.input.prompt { min-height: 240px; font-family: var(--mono); font-size: 13px; }
dialog.viewer { width: auto; max-width: calc(100vw - 24px); padding: 0; background: #fff; }
dialog.viewer img { max-width: calc(100vw - 26px); max-height: calc(100dvh - 26px); }
dialog.viewer .dialog-close { position: fixed; top: 10px; right: 10px; height: 28px; padding: 0 10px; border: 1px solid var(--border); background: #fff; cursor: pointer; }

/* Offers: a real sheet, one row per offer */
.offer-sheet { min-width: 900px; }
.offer-sheet td { padding: 0; }
.offer-sheet td.rn, .offer-sheet td.act { padding: 5px 6px; }
.offer-sheet .c-name { width: 18%; }
.offer-sheet .c-price { width: 12%; }
.offer-sheet .c-benefits { width: 32%; }
.offer-sheet .c-details { width: 32%; }
.offer-sheet .cell { min-height: 32px; padding: 6px 8px; }
.offer-sheet .c-name .cell { font-weight: 600; }
.offer-sheet .c-price .cell { font-weight: 600; }
.offer-sheet tbody tr:hover > td:not(.rn) { background-color: #fff; }

/* Birthdays: the calendar on the left, the sheet of people on the right */
.birthday-grid { display: grid; gap: 20px; align-items: start; }
.birthday-grid > * { min-width: 0; }
@media (min-width: 900px) {
  .birthday-grid { grid-template-columns: 300px minmax(0, 1fr); }
  .birthday-side { position: sticky; top: calc(var(--bar) + 16px); }
}
.bd-add { display: grid; gap: 6px; margin-bottom: 12px; }
.bd-fields { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.bd-filter { margin: 0 0 8px; font-size: 13px; }
.bd-filter .link-btn { padding-left: 0; }
.birthday-sheet { min-width: 560px; }
.birthday-sheet td { padding: 0; }
.birthday-sheet td.rn, .birthday-sheet td.act, .birthday-sheet td.c-text { padding: 5px 8px; }
.birthday-sheet td.c-text { white-space: nowrap; }
.birthday-sheet .cell { min-height: 32px; padding: 6px 8px; }
.birthday-sheet .c-born { width: 160px; }
.birthday-sheet tbody tr:hover > td:not(.rn) { background-color: #fff; }
/* Someone's birthday is today: a soft fill, and the row also says "Today" */
.birthday-sheet tr.bd-today > td:not(.rn) { background-color: var(--accent-tint); }

/* Account */
.account { padding-block: 20px 64px; display: grid; gap: 22px; }
.account > header { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.group-title { font-size: 15px; font-weight: 600; padding-bottom: 6px; border-bottom: 1px solid var(--grid); margin-bottom: 4px; }
.account .panel { display: grid; gap: 12px; padding: 14px 16px; }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: '+ '; color: var(--muted); }
details.panel[open] > summary::before { content: '− '; }

/* Sign in / sign up / first login */
.auth-page { padding-block: 32px 64px; }
.auth-box { display: grid; gap: 16px; padding: 20px; border: 1px solid var(--border); background: #fff; }
.auth-box header { display: grid; gap: 4px; }
.google-btn img { width: 18px; height: 18px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--grid); }

/* Landing */
.landing { padding-block: 32px 24px; display: grid; gap: 28px; }
.landing .intro { display: grid; gap: 10px; max-width: 680px; }
.landing .intro h1 { font-size: 26px; }
.landing .intro p { font-size: 15px; }
.landing h2 { font-size: 16px; margin-bottom: 8px; }
.faq details { border: 1px solid var(--grid); border-top: 0; }
.faq details:first-child { border-top: 1px solid var(--grid); }
.faq summary { padding: 8px 10px; cursor: pointer; font-weight: 600; background: var(--head); }
.faq details p { padding: 8px 10px; }

/* ---------- Dropdowns inside cells: priority, task state, colours ---------- */

select.cell-select {
  height: 26px; padding: 0 20px 0 6px; border: 1px solid transparent; border-radius: 2px;
  background: transparent linear-gradient(45deg, transparent 50%, currentColor 50%) no-repeat calc(100% - 8px) 50% / 5px 5px;
  color: var(--text); font-size: 13px; cursor: pointer; -webkit-appearance: none; appearance: none;
}
select.cell-select:hover { border-color: var(--border); }
select.cell-select:focus { outline: none; border-color: var(--accent); }

/* Priority (Eisenhower matrix) as conditional formatting: P1 red, P2 yellow, P3 blue, P4 plain */
select.prio-1 { background-color: #f4cccc; color: #660000; font-weight: 600; }
select.prio-2 { background-color: #fff2cc; color: #7f6000; }
select.prio-3 { background-color: #cfe2f3; color: #073763; }
select.prio-4 { color: var(--muted); }

/* Task state, same fills as thread statuses: Backlog grey, In progress orange, Done green */
select.state-backlog, .state-tag.state-backlog { background-color: var(--forever-fill); color: var(--forever-ink); }
select.state-doing,   .state-tag.state-doing   { background-color: var(--closed-fill);  color: var(--closed-ink); }
select.state-done,    .state-tag.state-done    { background-color: var(--open-fill);    color: var(--open-ink); }
.state-tag { display: inline-block; padding: 1px 6px; border-radius: 2px; font-size: 12px; }

/* ---------- My Calendar ---------- */

/* Category colours (time blocks, legend, colour picker) */
.cat-blue   { --c-fill: #cfe2f3; --c-ink: #073763; --c-edge: #6fa8dc; }
.cat-green  { --c-fill: #d9ead3; --c-ink: #274e13; --c-edge: #93c47d; }
.cat-orange { --c-fill: #fce5cd; --c-ink: #783f04; --c-edge: #f6b26b; }
.cat-purple { --c-fill: #d9d2e9; --c-ink: #20124d; --c-edge: #8e7cc3; }
.cat-red    { --c-fill: #f4cccc; --c-ink: #660000; --c-edge: #e06666; }
.cat-yellow { --c-fill: #fff2cc; --c-ink: #7f6000; --c-edge: #ffd966; }
.cat-teal   { --c-fill: #d0e0e3; --c-ink: #0c343d; --c-edge: #76a5af; }
.cat-grey   { --c-fill: #efefef; --c-ink: #3a3a3a; --c-edge: #b7b7b7; }
select.cat-select { background-color: var(--c-fill); color: var(--c-ink); font-weight: 600; min-width: 96px; }

.cal-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.cal-toolbar .range-label { margin-left: 6px; font-weight: 600; }
.cal-toolbar .grow { flex: 1; }
.cat-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; font-size: 13px; color: var(--text-2); }
.cat-legend .sw { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px; border: 1px solid var(--c-edge); background: var(--c-fill); }

/* The grid: a sticky row of days on top, a sticky column of hours on the left */
.tg-scroll { position: relative; overflow: auto; max-height: calc(100dvh - var(--bar) - 210px); min-height: 380px; border: 1px solid var(--border); background: #fff; }
.tg { display: grid; grid-template-rows: auto auto; }
.tg-corner, .tg-dayhead { position: sticky; top: 0; z-index: 4; height: 54px; background: var(--head); border-bottom: 1px solid var(--border); }
.tg-corner { left: 0; z-index: 5; border-right: 1px solid var(--border); }
.tg-dayhead {
  display: grid; align-content: center; gap: 0; padding: 2px 8px; border: 0; border-left: 1px solid var(--grid); border-bottom: 1px solid var(--border);
  text-align: left; cursor: pointer; line-height: 1.2;
}
.tg-dayhead:hover { background: var(--head-2); }
.tg-dayhead .dn { font-size: 11px; color: var(--muted); }
.tg-dayhead .dd { font-size: 15px; font-weight: 600; }
.tg-dayhead .tc { font-size: 11px; color: var(--muted); min-height: 13px; }
.tg-dayhead.today { box-shadow: inset 0 -2px 0 var(--accent); }
.tg-dayhead.today .dd { color: var(--accent); }
.tg-gutter { position: sticky; left: 0; z-index: 3; background: var(--head); border-right: 1px solid var(--border); }
.tg-gutter span { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; color: var(--muted); }
.tg-col {
  position: relative; border-left: 1px solid var(--grid); cursor: cell; touch-action: pan-x pan-y;
  /* hour lines (solid) and half-hour lines (light) */
  background-image: linear-gradient(to bottom, var(--grid) 1px, transparent 1px), linear-gradient(to bottom, #f3f4f5 1px, transparent 1px);
  background-size: 100% 48px, 100% 48px;
  background-position: 0 0, 0 24px;
}
.tg-col.today { background-color: #fbfcff; }
.now-line { position: absolute; left: 0; right: 0; z-index: 3; height: 2px; background: var(--danger); pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* Time blocks */
.blk {
  position: absolute; z-index: 1; overflow: hidden; padding: 2px 5px;
  border: 1px solid var(--c-edge); border-left-width: 4px; border-radius: 2px;
  background: var(--c-fill); color: var(--c-ink); font-size: 12px; line-height: 1.3;
  cursor: grab; user-select: none; touch-action: none;
}
.blk:hover { z-index: 2; }
.blk:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; z-index: 2; }
.blk.dragging { z-index: 6; opacity: .9; cursor: grabbing; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.blk .blk-time { display: block; font-size: 11px; opacity: .85; }
.blk .blk-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.blk.short .blk-time, .blk.short .blk-title { display: inline; }
.blk.short .blk-time { margin-right: 4px; }
.blk-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.blk.preview { pointer-events: none; border-style: dashed; opacity: .85; }

/* Day view: the calendar and the day's tasks side by side */
.day-split { display: grid; gap: 16px; align-items: start; }
.day-split > * { min-width: 0; }
@container main (min-width: 900px) { .day-split { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.2fr); } }
.day-split .add-bar select.input { width: auto; flex: 0 0 auto; }

/* Tasks Reporter: the calendar on the left, the day's finished tasks on the right */
.report-grid { display: grid; gap: 16px; align-items: start; }
.report-grid > * { min-width: 0; }
@container main (min-width: 760px) { .report-grid { grid-template-columns: 320px minmax(0, 1fr); } }

.form-grid.three { display: grid; gap: 10px; }
@media (min-width: 480px) { .form-grid.three { grid-template-columns: 1.4fr 1fr 1fr; } }
.dialog-actions .grow { flex: 1; }

/* ---------- Panels: the sections of the right-hand side ----------
   The work area is a light grey canvas; every section is a white panel with
   a grey title bar, so sections stand apart like separate tables on a page.
   The page's main working section has a blue edge on its title bar. */

.main { background: var(--canvas); }
.panel { background: #fff; border: 1px solid var(--border); min-width: 0; }
.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 40px; padding: 6px 12px;
  background: var(--panel-head); border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 15px; font-weight: 700; }
.panel-sub { font-size: 12px; color: var(--muted); }
.panel-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.panel.primary .panel-head { box-shadow: inset 4px 0 0 var(--accent); padding-left: 16px; }
.panel-body { padding: 12px; display: grid; gap: 10px; }
.panel-body > * { min-width: 0; }
.panel.flush .panel-body { padding: 0; gap: 0; }
.panel.flush .sheet-wrap, .panel.flush .chain-wrap, .panel.flush .cal, .panel.flush .tg-scroll { border: 0; }
.panel-foot { padding: 6px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--grid); }
.panel .add-bar, .panel .add-tools, .panel .add-more { margin-bottom: 0; }
.panel .cat-legend { margin: 0; padding: 8px 12px; border-bottom: 1px solid var(--grid); }
.panel .cal-toolbar { margin: 0; }
.panel .summary { margin: 0; background: #fff; }
.panel .summary > div { padding: 2px 10px; }

/* Stronger bands for groups inside sheets (Today, Done, No date…) */
.sheet .group td { background: var(--group-band); color: var(--text); font-weight: 700; border-top: 1px solid var(--border); }
.sheet thead th { background: var(--head-2); color: var(--text); }

/* Board columns: a small header band on top of each column's sheet */
.board .col { display: grid; gap: 0; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: var(--group-band); border: 1px solid var(--border); border-bottom: 0; }
.col-head h3 { font-size: 13px; font-weight: 700; }
.col-head .count { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 10px; background: #fff; border: 1px solid var(--border); font-size: 12px; text-align: center; }
.board .col .wip-note { margin: 0; border: 1px solid var(--border); border-bottom: 0; }

/* The property block under a title stays a white sheet on the canvas */
.props { background: #fff; border-color: var(--border); }
.page-head { border-bottom: 0; margin-bottom: 12px; padding-bottom: 0; }
.page-head h1 { font-size: 22px; }

/* ---------- Focus (projects): only the chosen tasks ---------- */

.focus-mode .topbar, .focus-mode .sidebar, .focus-mode .scrim { display: none !important; }
.focus-mode .shell { grid-template-columns: minmax(0, 1fr) !important; min-height: 100dvh; }
.focus-wrap { max-width: 920px; margin: 24px auto 48px; display: grid; gap: 16px; }
.focus-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 14px 18px; background: #fff; border: 1px solid var(--border); box-shadow: inset 4px 0 0 var(--accent);
}
.focus-bar h1 { font-size: 22px; overflow-wrap: anywhere; }
.focus-bar .sub { font-size: 13px; color: var(--muted); }
.focus-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; border-top: 1px solid var(--grid); }
.focus-actions .grow { flex: 1; }
.focus-add-wrap { padding: 8px 12px 10px; border-top: 1px solid var(--grid); }
.focus-add-wrap .add-line { margin-top: 0; }
.focus-add { flex-wrap: wrap; }
.focus-add input.input { flex: 1 1 180px; }
.focus-add select.input { flex: 0 1 200px; width: auto; }
.focus-done { display: grid; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--success-tint); }
.focus-done p { color: var(--success); font-weight: 600; }
/* Day focus (My Calendar): the time block now / next, in its category colour */
.focus-now {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 14px;
  background: #fff; border: 1px solid var(--border); box-shadow: inset 4px 0 0 var(--c-edge, var(--border));
}
.focus-now-label { padding: 1px 6px; font-size: 12px; font-weight: 600; background: var(--c-fill, var(--head)); color: var(--c-ink, var(--text)); }
.focus-now-title { font-weight: 600; overflow-wrap: anywhere; }
.focus-now .grow { flex: 1; }
.prio-tag { display: inline-block; padding: 1px 6px; border-radius: 2px; font-size: 12px; }
.prio-tag.prio-1 { background: #f4cccc; color: #660000; font-weight: 600; }
.prio-tag.prio-2 { background: #fff2cc; color: #7f6000; }
.prio-tag.prio-3 { background: #cfe2f3; color: #073763; }
.prio-tag.prio-4 { color: var(--muted); }
.task-sheet label { cursor: pointer; }

/* ---------- 7. Small screens and motion ---------- */

@media (max-width: 640px) {
  :root { --gutter: 12px; }
  .input, .field input, .field select, .field textarea, select.input, .cell { font-size: 16px; }  /* no zoom on iOS */
  .add-bar { flex-wrap: wrap; }
  .add-bar .input { flex: 1 1 100%; }
  .add-bar .input[type='date'] { flex: 1 1 auto; }
  .task-sheet .col-project, .task-sheet .col-due { display: none; }
  .props { grid-template-columns: 96px minmax(0, 1fr); }
  .capture-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* "One thing at a time" dialog */
.focus-notes { white-space: pre-wrap; padding: 8px 10px; border: 1px solid var(--grid); background: var(--head); }

/* The grey canvas fills the whole work area, however short the content is */
.shell { align-items: stretch; }
.main { min-height: calc(100dvh - var(--bar)); }
.focus-mode .main { min-height: 100dvh; }
@media (min-width: 1000px) { .shell { background: var(--head); } }

/* Project names in task rows stay on one line (full name on hover) */
.task-sheet td.col-project a { display: block; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-sheet select.project-select { width: 100%; min-width: 120px; max-width: 180px; text-overflow: ellipsis; }
/* Web addresses in cells (linkify in common.js): blue and underlined, a click opens them */
a.text-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; overflow-wrap: anywhere; }
a.text-link:hover { color: var(--accent-dark); }
.task-sheet .due-extra { display: block; }
.task-sheet .due-extra .link-btn { padding: 0; }

/* ---------- All-day events ---------- */

/* The "All day" row of the calendar grid: sticky under the day headers */
.tg-allday-label, .tg-allday { position: sticky; top: 54px; z-index: 4; min-height: 30px; background: #fff; border-bottom: 2px solid var(--border); }
.tg-allday-label { left: 0; z-index: 5; display: grid; place-items: center; padding: 2px; background: var(--head); border-right: 1px solid var(--border); font-size: 10px; font-weight: 600; color: var(--muted); text-align: center; line-height: 1.1; }
.tg-allday { display: grid; align-content: start; gap: 2px; padding: 3px; border-left: 1px solid var(--grid); cursor: copy; }
.tg-allday:hover { background: var(--accent-tint); }
.tg-allday.drop-over { background: var(--accent-tint); box-shadow: inset 0 0 0 2px var(--accent); }
.evt {
  padding: 1px 6px; border: 1px solid var(--c-edge); border-left-width: 4px; border-radius: 2px;
  background: var(--c-fill); color: var(--c-ink); font-size: 12px; font-weight: 600; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: grab; user-select: none; touch-action: none;
}
.evt.cont-left { border-left-width: 1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.evt.cont-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.evt.cont-left::before { content: '\2026 '; opacity: .6; }
.evt:focus-visible { outline: 2px solid var(--accent); }
.evt.dragging { opacity: .6; cursor: grabbing; }

/* Small calendar: a bar on days that have an event */
.cal-day.marked::after { content: ''; position: absolute; left: 3px; right: 3px; top: 2px; height: 3px; background: var(--accent); }   /* top edge, so it never covers the task count */
.cal-day.selected.marked::after { background: var(--accent-dark); }

/* Events panel on Today */
#events { margin-bottom: 16px; }
.events-sheet td { vertical-align: middle; }
.events-sheet .evt-name a { font-weight: 600; }

/* ---------- Work/break timer ----------
   A small window in the bottom-right corner, on every app page (also in
   Focus). Work = blue edge, break = green edge, finished = grey. */

.timer {
  position: fixed; right: 16px; bottom: calc(40px + env(safe-area-inset-bottom)); z-index: 58;
  width: 300px; display: grid; gap: 6px; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(0, 0, 0, .18), inset 4px 0 0 var(--accent);
}
.timer.phase-break { box-shadow: 0 4px 16px rgba(0, 0, 0, .18), inset 4px 0 0 var(--success); }
.timer.phase-done { box-shadow: 0 4px 16px rgba(0, 0, 0, .18), inset 4px 0 0 var(--muted); }
.timer.flash { background: var(--accent-tint); }
.timer.phase-break.flash { background: var(--success-tint); }
.timer-top { display: flex; align-items: center; gap: 6px; }
.timer-top .grow { flex: 1; }
.timer-phase { font-size: 13px; font-weight: 700; }
.timer-time { font-size: 40px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.timer.paused .timer-time { color: var(--muted); }
.timer-bar { height: 6px; background: var(--head-2); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s linear; }
.timer.phase-break .timer-bar i { background: var(--success); }
.timer-what { font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.timer-next { font-size: 13px; padding: 4px 8px; background: var(--head); border: 1px solid var(--grid); color: var(--text); }
.timer .input { height: 30px; font-size: 13px; }
.timer .form-actions { gap: 6px; }
.timer-sound { margin-left: auto; font-size: 12px; }
.timer.min { width: auto; padding: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.timer-pill { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; background: #fff; cursor: pointer; font-size: 14px; }
.timer-pill .timer-time { font-size: 16px; }
.timer.min.phase-work .timer-pill { box-shadow: inset 4px 0 0 var(--accent); }
.timer.min.phase-break .timer-pill { box-shadow: inset 4px 0 0 var(--success); }
@media (max-width: 640px) { .timer { left: 8px; right: 8px; width: auto; } .timer.min { left: auto; } }

/* Break video (Focus mode): covers the whole page until it ends. Above everything, the timer too. */
.break-video { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: #000; }
.break-video .break-video-player { width: 100%; height: 100%; object-fit: contain; background: #000; }
.break-video-note { padding: 8px 16px 12px; color: #bbb; font-size: 13px; text-align: center; }
.break-sound { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* The floating "keep on top" window (Document Picture-in-Picture): the same white
   timer as on the page; during the break video, the video fills it. */
.pip-body { margin: 0; min-height: 100vh; background: #fff; }
.timer.in-pip { position: static; width: auto; min-height: 100vh; border: 0; box-shadow: inset 4px 0 0 var(--accent); }
.timer.in-pip.phase-break { box-shadow: inset 4px 0 0 var(--success); }
.timer.in-pip.min { min-height: 0; }
.pip-stage { display: none; }
/* Video in the window (tab not in view): a thin timer bar stays above it */
.pip-body.playing { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; background: #000; }
.pip-body.playing .timer.in-pip { min-height: 0; display: flex; align-items: center; gap: 8px; padding: 3px 10px; background: #fff; }
.pip-body.playing .timer.in-pip > :not(.timer-top):not(.timer-time) { display: none; }
.pip-body.playing .timer.in-pip .timer-top button { display: none; }
.pip-body.playing .timer.in-pip .timer-time { margin-left: auto; font-size: 18px; }
.pip-body.playing .pip-stage { position: relative; display: grid; min-height: 0; }
.pip-stage .break-video-player { width: 100%; height: 100%; object-fit: contain; }
.pip-tools { position: fixed; right: 8px; bottom: 8px; display: flex; gap: 6px; }

/* On a time block: a small start button, and a highlight while it is timed */
.blk-play {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 20px; padding: 0; border: 1px solid var(--c-edge); border-radius: 2px;
  background: #fff; color: var(--c-ink); font-size: 10px; line-height: 1; cursor: pointer; opacity: 0;
}
.blk:hover .blk-play, .blk:focus-within .blk-play, .blk.timing .blk-play, .blk-play:focus-visible { opacity: 1; }
@media (hover: none) { .blk-play { opacity: 1; } }
.blk.timing { box-shadow: 0 0 0 2px var(--accent); z-index: 3; }

/* Timer section in the block dialog */
.timer-field { border: 1px solid var(--grid); padding: 8px 10px 10px; margin: 0; display: grid; gap: 6px; }
.timer-field legend { padding: 0 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.timer-field .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.timer-field select.input { width: auto; }
.timer-field input[type='number'] { width: 70px; }

/* Focus: "Start now", a time block from now with the timer, in one line */
.start-now select.input { width: auto; max-width: 100%; }
.start-now #now-what { flex: 0 1 260px; min-width: 0; }

/* ---------- Deadlines and the Timeline ----------
   A task's deadline is shown in words in its row; on /timeline each task is a
   bar from the day it was created to its deadline. */

.task-sheet .deadline-tag { display: inline-block; margin-left: 6px; font-size: 11px; color: var(--text-2); }
.task-sheet .deadline-tag.late { color: var(--closed-ink); }
/* Board columns: date and deadline on a line under the name; the name takes the room that is left */
.task-sheet .task-meta { display: block; margin-top: 1px; font-size: 11px; color: var(--muted); }
.task-sheet .task-meta .deadline-tag { margin-left: 0; font-size: inherit; }
.task-sheet .task-meta .late { color: var(--closed-ink); }
.board .task-sheet .title-cell { min-width: 0; }

.tl-add select.input { flex: 0 1 200px; width: auto; }
.tl-add .input[type='date'] { flex: 0 0 150px; }
.panel .tl-add { padding: 8px 12px; border-bottom: 1px solid var(--grid); }
.tl-scroll { overflow-x: auto; container-type: inline-size; background: #fff; }
.tl { --tl-name: 260px; min-width: calc(var(--tl-name) + var(--tl-n) * var(--tl-w)); }
.tl-head, .tl-row { display: grid; grid-template-columns: var(--tl-name) repeat(var(--tl-n), minmax(var(--tl-w), 1fr)); }
.tl-head { background: var(--head-2); border-bottom: 1px solid var(--border); }
.tl-row { min-height: 40px; border-bottom: 1px solid var(--grid); }
.tl-corner, .tl-name { grid-column: 1; grid-row: 1; position: sticky; left: 0; z-index: 3; min-width: 0; padding: 5px 8px; border-right: 1px solid var(--border); background: #fff; }
.tl-corner { display: flex; align-items: flex-end; background: var(--head-2); font-size: 13px; font-weight: 600; }
.tl-name { display: grid; align-content: center; gap: 1px; }
.tl-name .title-btn { padding: 0; border: 0; background: none; text-align: left; color: var(--text); cursor: pointer; font-size: 13px; overflow-wrap: anywhere; }
.tl-name .title-btn:hover { color: var(--accent); text-decoration: underline; }
.tl-meta { font-size: 11px; color: var(--muted); }
.tl-meta .prio-tag { padding: 0 4px; font-size: 11px; }
.tl-row.is-done .title-btn { color: var(--muted); text-decoration: line-through; }
.tl-row.open .tl-name { background: var(--accent-tint); }
.tl-dh { padding: 3px 2px; border-left: 1px solid var(--grid); text-align: center; font-size: 11px; color: var(--muted); line-height: 1.2; }
.tl-dh b { display: block; font-size: 13px; color: var(--text); }
.tl-dh.today { box-shadow: inset 0 -2px 0 var(--accent); }
.tl-dh.today b { color: var(--accent); }
.tl-day { grid-row: 1; border-left: 1px solid var(--grid); }
.tl-dh.weekend, .tl-day.weekend { background-color: #f7f8f9; }
.tl-day.today { background-color: #f1f6fe; }
.tl-bar {
  grid-row: 1; position: relative; z-index: 1; align-self: center; height: 22px; margin: 0 2px; padding: 0 16px 0 6px;
  border: 1px solid var(--accent); border-radius: 2px; background: #d2e3fc; color: var(--accent-dark);
  font-size: 12px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-bar.cont-left { margin-left: 0; border-left-style: dashed; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.tl-bar.cont-right { margin-right: 0; border-right-style: dashed; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tl-bar.done { border-color: var(--border); background: var(--head-2); color: var(--muted); }
.tl-bar.dragging { box-shadow: 0 0 0 2px var(--accent); }
.tl-end { position: absolute; top: 0; right: 0; bottom: 0; width: 12px; padding: 0; border: 0; background: var(--accent); cursor: ew-resize; touch-action: none; }
.tl-end:focus-visible { outline: 2px solid var(--text); outline-offset: 0; }
.tl-tail { grid-row: 1; z-index: 1; align-self: center; height: 0; margin: 0 4px 0 0; border-top: 2px dotted var(--closed-ink); }
.tl-due { grid-row: 1; z-index: 2; align-self: start; justify-self: center; width: 6px; height: 6px; margin-top: 2px; border-radius: 50%; background: var(--text-2); }   /* above the bar, never over its text */
.tl-group { padding: 4px 8px; background: var(--group-band); border-top: 1px solid var(--border); border-bottom: 1px solid var(--grid); font-size: 13px; font-weight: 700; }
.tl-group > span { position: sticky; left: 8px; }
.tl-group .count { font-weight: 400; color: var(--muted); }
.tl-detail { position: sticky; left: 0; width: 100cqw; padding: 10px 12px; border-bottom: 1px solid var(--grid); background: #fbfbfc; }
.tl-empty { position: sticky; left: 0; width: 100cqw; padding: 14px 12px; color: var(--muted); }
@media (max-width: 640px) { .tl { --tl-name: 150px; } }

/* ---------- Documents (project tool): cards in a row, the editor, print ---------- */

/* The list: page-like cards side by side; the row scrolls sideways on purpose */
.doc-row { display: flex; gap: 14px; padding: 14px; overflow-x: auto; background: var(--canvas); }
.doc-card {
  flex: 0 0 190px; height: 268px; display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 10px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
}
a.doc-card:hover { border-color: var(--accent); text-decoration: none; }
a.doc-card:focus-visible { outline-offset: 2px; }
.doc-card-title { font-weight: 600; overflow-wrap: anywhere; }
.doc-card-text {
  flex: 1; overflow: hidden; font-size: 11px; line-height: 1.45; color: var(--text-2); white-space: pre-line;
  -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent);
}
.doc-card-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--grid); padding-top: 6px; }
.doc-card-new { border-style: dashed; padding: 0; background: transparent; }
.doc-new-btn { flex: 1; border: 0; background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; }
.doc-new-btn:hover { background: var(--accent-tint); }
.doc-new-form { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: #fff; height: 100%; }
.doc-new-form label { font-size: 13px; font-weight: 600; }

/* The editor: the name, a toolbar like a word processor's, an A4 page on grey */
.doc-head .title { flex: 1; min-width: 0; }
.doc-title {
  width: 100%; padding: 2px 4px; border: 1px solid transparent; background: transparent;
  font-size: 20px; font-weight: 600; color: var(--text);
}
.doc-title:hover { border-color: var(--grid); }
.doc-title:focus { border-color: var(--accent); background: #fff; outline: none; }
.doc-toolbar {
  position: sticky; top: var(--bar); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 6px 8px; border: 1px solid var(--border); background: var(--head);
}
.doc-toolbar select.input { width: auto; flex: 0 0 auto; height: 30px; padding: 0 6px; font-size: 13px; }
#doc-style { min-width: 128px; }
#doc-font { min-width: 132px; }
.tool-btn {
  min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid transparent; background: transparent;
  color: var(--text); font-size: 13px; cursor: pointer; list-style: none;
}
.tool-btn::-webkit-details-marker { display: none; }
.tool-btn:hover { background: var(--head-2); border-color: var(--border); }
.tool-btn[aria-pressed='true'] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-dark); }
.tool-btn b, .tool-btn i, .tool-btn u, .tool-btn s { font-size: 14px; }
.tool-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }
.doc-colors { position: relative; }
.doc-colors > summary { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; font-weight: 600; }
.doc-swatch { display: block; width: 16px; height: 3px; margin-top: 2px; background: #1f1f1f; }
.doc-colors .menu { left: 0; right: auto; min-width: 170px; }
.doc-color { display: flex !important; align-items: center; gap: 8px; }
.doc-chip { display: inline-block; width: 14px; height: 14px; border: 1px solid rgba(0, 0, 0, .25); }

.doc-desk { padding: 24px 12px; background: var(--canvas); border: 1px solid var(--border); border-top: 0; overflow-x: auto; }
.doc-page {
  width: 794px; max-width: 100%; min-height: 1123px; margin: 0 auto; padding: 72px 76px;  /* A4 at 96 dpi, 2 cm margins */
  background: #fff; border: 1px solid var(--border); outline: none;
  font-family: Calibri, Carlito, 'Segoe UI', sans-serif; font-size: 11pt; line-height: 1.4; color: #1f1f1f;
  white-space: pre-wrap; overflow-wrap: break-word; cursor: text;
}
.doc-page:focus-visible { outline: none; border-color: var(--accent); }
/* The same look as the Word styles in docx.js */
.doc-page p { margin: 0 0 8pt; color: inherit; }
.doc-page h1 { margin: 0 0 12pt; font-size: 26pt; font-weight: 700; line-height: 1.15; color: #1f1f1f; }
.doc-page h2 { margin: 18pt 0 4pt; font-size: 16pt; font-weight: 700; color: #2e74b5; }
.doc-page h3 { margin: 12pt 0 4pt; font-size: 13pt; font-weight: 700; color: #2e74b5; }
.doc-page h4 { margin: 12pt 0 4pt; font-size: 12pt; font-weight: 700; color: #1f4d78; }
.doc-page blockquote { margin: 0 0 8pt 24pt; padding-left: 10pt; border-left: 3px solid #c4c7c5; font-style: italic; color: #404040; }
.doc-page ul, .doc-page ol { margin: 0 0 8pt; padding-left: 24pt; }
.doc-page li { margin: 0 0 2pt; }
.doc-page > :first-child { margin-top: 0; }

@media (max-width: 640px) {
  .doc-desk { padding: 0; border: 0; }
  .doc-page { min-height: 70vh; padding: 20px 16px; border: 0; }
  .doc-title { font-size: 18px; }
  .doc-head { flex-wrap: wrap; }
  .doc-head .title { flex-basis: 100%; }
  .doc-toolbar select.input { font-size: 16px; }
}

/* PDF: the print dialog shows only the page, on A4 */
@page { size: A4; margin: 2cm; }
@media print {
  body.print-doc .topbar, body.print-doc .sidebar, body.print-doc .scrim, body.print-doc .crumb,
  body.print-doc .page-head, body.print-doc .doc-toolbar, body.print-doc .chain-help, body.print-doc .toast,
  body.print-doc .timer, body.print-doc dialog { display: none !important; }
  body.print-doc, body.print-doc .shell, body.print-doc .main, body.print-doc .main-inner { display: block; margin: 0; padding: 0; background: #fff; }
  body.print-doc .doc-desk { padding: 0; border: 0; background: #fff; overflow: visible; }
  body.print-doc .doc-page { width: auto; min-height: 0; padding: 0; border: 0; }
  body.print-doc .doc-page h1, body.print-doc .doc-page h2, body.print-doc .doc-page h3, body.print-doc .doc-page h4 { break-after: avoid; }
}
