/* Rules that have to come after every page's own file: each overrides a rule in a later
   section of an earlier file (the dashboard popover, the monthly review's second pass, the
   edit modals), so it can't sit with the rest of its page without losing to it. */

/* ---- Dashboards: a header, readable off toggles, empty clouds, the phone's sheet ---- */
/* What the panel is, over every page's version of it. */
.dash-head {
  display: flex; align-items: center; gap: 7px; flex: none;
  margin: -2px 2px 10px; color: var(--text-2); font-size: var(--fs-12); font-weight: 600;
}
.dash-head i { color: var(--text-3); font-size: var(--fs-11); }
/* A group's label sits close over what it names. */
.dash-section > .dash-label { margin-bottom: 6px; }

/* An off toggle is half of what you choose between: readable, not a ghost of one. */
.dash-filter-pill { color: var(--text-2); border-color: var(--border-strong); }
.dash-filter-pill i { opacity: 1; }

/* A tag cloud with no tags yet: a line saying what goes there (fillGhosts). */
.dash-tag-empty { padding: 2px 8px; color: var(--text-3); font-size: var(--fs-11); line-height: 1.5; text-align: center; }

/* The phone's panel is as tall as what's in it, up to the room between the bars, rather
   than a full-height column with Find More stranded at the bottom. */
@media (max-width: 819px) {
  .dashboard-popover {
    bottom: auto;
    max-height: calc(100dvh - 52px - 56px - env(safe-area-inset-bottom));
    border-width: 0 0 1px 1px;
    border-bottom-left-radius: var(--radius-md);
  }
}

/* Room for a finger: toggles, chips and segments at a comfortable height on touch screens. */
@media (hover: none) {
  .dash-filter-pill, .dash-segmented .sidebar-segmented-tab, .dash-sort-btn { min-height: 36px; }
  .dash-tag-flow .dash-chip:not(.dash-chip--ghost) { min-height: 32px; display: inline-flex; align-items: center; }
}

/* ---- Monthly Review: an empty month's welcome; one footer line; Focus grouped ---- */
.mr-welcome { padding: 28px 28px 24px; text-align: center; }
.mr-welcome-icon {
  display: inline-grid; place-items: center; width: 44px; height: 44px; margin-bottom: 12px;
  border-radius: 12px; background: rgba(34, 197, 94, 0.1); color: #4ade80; font-size: 18px;
}
.mr-welcome-title { margin: 0 0 8px; color: var(--text-1); font-family: Newsreader, Georgia, serif; font-size: 22px; font-weight: 500; }
.mr-welcome-text { max-width: 560px; margin: 0 auto 14px; color: var(--text-2); font-size: var(--fs-13); line-height: 1.6; }
.mr-welcome-links { margin: 0; font-size: var(--fs-13); color: var(--text-3); }
.mr-welcome-links a { color: var(--text-1); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.mr-welcome-links a:hover { text-decoration-color: currentColor; }
/* The footer's links all alike: the inspiration button reads as one more link. */
.mr-empty-sections { margin-top: 18px; line-height: 1.7; }
.mr-empty-sections .mr-inline-link {
  color: var(--text-2); font-size: inherit; text-decoration: underline;
  text-decoration-color: var(--border-strong); text-underline-offset: 3px;
}
.mr-empty-sections .mr-inline-link:hover { color: var(--text-1); }
.mr-empty-links { white-space: normal; }
/* Focus for next month: grouped by kind, with how many are picked. */
.mr-focus-count {
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border-strong);
  color: var(--text-2); font-size: var(--fs-11); font-variant-numeric: tabular-nums;
}
.mr-focus-count.is-full { color: #c4b5fd; border-color: rgba(167, 139, 250, 0.45); }
.mr-focus-picker { display: flex; flex-direction: column; gap: 10px; }
.mr-focus-group { display: flex; flex-direction: column; gap: 6px; }
.mr-focus-group-label { color: var(--text-3); font-size: var(--fs-10); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
/* The reflection's boxes start small and grow as they're written in (jd-autogrow). */
.mr-reflection-form .mr-textarea { min-height: 64px; }
@media (max-width: 720px) {
  .mr-welcome { padding: 22px 16px 18px; }
  .mr-tiles { gap: 8px; }
  .mr-tiles .stat-tile { padding: 10px 12px; }
  .mr-tiles .stat-tile-label { font-size: var(--fs-10); }
  .mr-tiles .stat-tile-value { font-size: 22px; }
  .mr-tiles .mr-tile-of { font-size: 13px; }
  .mr-tiles .stat-tile-sub { font-size: var(--fs-11); }
}

/* ---- Modals: Counts toward's folded select; the done row; Edit Category's header ---- */
.task-form-counts-wrap[hidden] { display: none; }
.task-form-done-row { display: flex; align-items: stretch; gap: 8px; }
.task-form-done-row .mark-completed-btn { flex: 1; }
.task-form-done-delete { display: none; }
.cat-form-header { padding: 12px 16px; }
.cat-form-header > i { font-size: var(--fs-14); }
.cat-form-header-title { font-size: var(--fs-14); letter-spacing: -0.01em; }
.cat-form-modal-close { margin-left: auto; flex-shrink: 0; }
.cat-form-modal-close.has-parent { margin-left: 10px; }
@media (max-width: 640px) {
  /* A phone: Delete beside Mark done, so the footer holds the type toggles and Save. */
  .task-form-done-delete { display: flex; }
  .task-form-done-delete .task-form-danger { height: 100%; padding: 0 12px; }
  .task-form-footer-delete { display: none; }
}

/* Task row parts (tasks/_task_row), once inline styles on every row. Scoped under
   .task-row so they keep the weight the inline styles had over the general rules above. */
.task-row .tr-cell { border: none; }
.task-row .tr-place-lead { padding: 0.4rem 0 0.4rem 0.6rem; vertical-align: middle; }
.task-row .tr-place-icon { color: var(--text-2); border-color: var(--border-strong); }
.task-row .tr-center { text-align: center; vertical-align: middle; }
.task-row .tr-value-title-cell { padding: 0.8rem 0.25rem; position: relative; z-index: 1; overflow: hidden; vertical-align: middle; }
.task-row .tr-journal-cell { padding: 0.5rem 0.75rem; }
.task-row .tr-chip-gap { margin-left: 0.35rem; vertical-align: middle; }
.task-row .tr-journal-tag-chip { border-radius: 0.25rem; padding: 0.1rem 0.35rem; font-size: 0.65rem; margin-left: 0.2rem; background: #0a1a2e; color: #6898b8; border: 1px solid #2a4a6e; }
.task-row .tr-time { color: var(--text-2); cursor: pointer; }
.task-row .tr-reminder-icon { color: var(--text-3); margin-left: 0.4rem; font-size: var(--fs-13); }
.task-row .tr-icon-btn { background: none; border: none; padding: 4px; cursor: pointer; line-height: 1; }
.task-row .tr-small-btn { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 0.25rem; font-size: var(--fs-13); }
.task-row .tr-small-btn.is-paste { color: var(--blue); }
.task-row .tr-value-pencil { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; }
/* A row's notes (benefits) under its title: a bullet and the text. */
.task-row .tr-infos-list { text-align: left; width: 12vw; margin-top: 0.5rem; margin-left: -14px; }
.task-row .tr-info-row { display: flex; align-items: flex-start; }
.task-row .tr-info-row.has-gap { margin-top: 0.4rem; }
.task-row .tr-info-bullet { color: var(--text-3); font-size: 0.9em; margin-right: 0.5rem; flex-shrink: 0; }
.task-row .tr-info-text { margin: 0; color: var(--text-3); font-size: 0.9em; line-height: 1.4; flex: 1; }
.task-row .tr-info-text.is-pre { white-space: pre-wrap; word-break: break-word; }
.task-row .tr-info-text.is-wrapped { white-space: normal; word-wrap: break-word; max-width: 60vw; }
/* A habit's schedule and its next date, quiet beside the title. */
.task-row .task-recurrence-label,
.task-row .iteration-date-picker { color: var(--text-3); opacity: 0.5; font-size: var(--fs-11); }
.task-row .task-recurrence-label { margin-left: 0.5rem; }
.task-row .iteration-date-picker { margin-left: 0.25rem; cursor: pointer; position: relative; }
/* A habit's freebies this week: a filled dot per one used, a ring per one left. */
.task-row .freebie-dots { margin-left: 0.35rem; display: inline-flex; gap: 3px; vertical-align: middle; color: var(--text-3); }
.task-row .freebie-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background-color: transparent; box-shadow: inset 0 0 0 1px currentColor; opacity: 0.4; }
.task-row .freebie-dot.is-used { background-color: currentColor; box-shadow: none; opacity: 0.75; }

/* Inline subtask rows (tasks/_inline_subtask_row), likewise once inline on every row. */
.subtask-inline-row .st-cell { border: none; }
.subtask-inline-row .st-title-cell { padding: 0.25rem 0.5rem; color: #bbb; font-size: var(--fs-14); }
.subtask-inline-row .st-dynamic { color: var(--text-3); opacity: 30%; cursor: pointer; margin-left: 0.5rem; }
.subtask-inline-row .st-date { color: #888; font-size: var(--fs-13); margin-left: 0.5rem; }
.subtask-inline-row .st-date.is-moved { color: #e0a050; }
.subtask-inline-row .st-icons-cell { padding: 0.2rem; }
.subtask-inline-row .st-icons { display: flex; align-items: center; height: 100%; }
.subtask-inline-row .st-icon-col { display: flex; flex-direction: column; margin-left: 0.25rem; }
.subtask-inline-row .st-icon-col.is-first { align-items: center; margin-left: 0; margin-right: 0.25rem; }
.subtask-inline-row .st-icon-pair { display: flex; align-items: center; }
.subtask-inline-row .st-icon-pair.has-gap { margin-bottom: 0.25rem; }
.subtask-inline-row .st-cal { color: #666; cursor: pointer; margin-bottom: 0.25rem; }
.subtask-inline-row .st-caret { cursor: pointer; color: #666; display: flex; align-items: center; }
.subtask-inline-row .st-tag-btn { background: none; border: none; padding: 0; margin-right: 0.45rem; cursor: pointer; }
.subtask-inline-row .st-muted { color: #666; }
.subtask-inline-row .st-muted.is-button { cursor: pointer; }
.subtask-inline-row .st-open-link { margin-left: 0.25rem; text-decoration: none; }
.subtask-inline-row .st-small-btn { background: none; border: none; color: #666; cursor: pointer; padding: 0.25rem; font-size: var(--fs-13); }
.subtask-inline-row .st-small-btn.is-paste { color: var(--blue); }
.subtask-inline-row .st-edge-cell { padding: 0; position: relative; }
.subtask-inline-row .st-fill { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.subtask-inline-row .st-dim { color: #777; }
.subtask-inline-row .st-end-cell { padding: 0; width: 0; }
/* Focus picked: the count turns green once there's one. */
.mr-focus-count.is-some { color: #86efac; border-color: rgba(34, 197, 94, 0.45); }

/* ---- A task's page (tasks/show) ---- */
/* hidden means hidden here: .show-btn and friends set their own display, which beat the
   attribute's, so the paste button and the folded log rows showed anyway. */
.show-page [hidden] { display: none !important; }
.show-history { border-top: 1px solid var(--border-panel); }
.show-subtask-form { margin-top: 1rem; }
.inline-subtask-form { margin: 0.5rem 0; }
.task-form-input.is-resizable { resize: vertical; }
/* Ending a habit is the rare move, so it's a quiet button rather than a green one. Edit
   holds one place whatever sits beside it — Mark done, Retire habit: the right-hand
   corner, and on a phone, where the buttons drop to a row under the title from the
   left, the start of that row. */
@media (max-width: 600px) { .show-actions > .show-btn.is-primary { order: -1; } }
.show-retire-btn { border-color: var(--border); color: var(--text-3); }
.show-retire-btn:hover { border-color: var(--border-strong); color: var(--text-1); }
/* Only one subtask column while no subtask has a day of its own. */
#subtasks-columns:has(> #subtasks-column-date[hidden]) { grid-template-columns: minmax(0, 1fr); }
/* A one-off's folded month: the month and its arrows lead the opened card. */
.show-cal-bar { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-bottom: 12px; }
/* The legend's sample day numbers ("9 To come", "7 Cancelled") upright and big enough to
   read as numbers: 9px italic (they're <i>s) looked like stray marks. */
.show-cal-swatch.is-upcoming, .show-cal-swatch.is-cancelled { width: auto; min-width: 14px; font-size: var(--fs-12); font-style: normal; font-weight: 500; }
/* A habit's kept rate, right after its title: smaller and lighter than the title, so it
   reads as a note on it, and wrapping with it under a long one. */
.show-kept-rate { display: inline-block; margin-left: 0.5em; vertical-align: 0.15em; color: var(--text-3); font-size: var(--fs-14); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0; white-space: nowrap; cursor: default; }
/* Details and Benefits with nothing written: a lone add button, no label (it comes back
   when the editor opens). Here as well as under .show-page, for the Library page's copy. */
.task-details-box .show-label[hidden], .task-info-box .show-label[hidden],
.task-details-add[hidden], .task-details-display[hidden], .task-benefits-toggle[hidden] { display: none; }
/* On a task's own page, an empty Details or Benefits is an icon at the end of the pills
   under the title (tooltip from data-tip), shown while its section is empty and closed;
   the section itself stays out of sight until the icon opens it. Saving, cancelling or
   adding a benefit redraws the section, and these rules follow without any JS state. */
.show-meta-tools { display: inline-flex; align-items: center; gap: 2px; }
.show-meta-add {
  display: none; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-3); font-size: var(--fs-13); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.show-meta-add:hover { background: var(--surface-2); color: var(--text-1); }
.show-meta-add:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; color: var(--text-1); }
.show-page:has(.task-overview .task-details-box.is-empty .task-details-form[hidden]) .show-meta-add[data-opens="details"],
.show-page:has(.task-overview .task-info-box.is-empty .task-info-form[hidden]) .show-meta-add[data-opens="benefits"] { display: inline-flex; }
.task-overview .task-details-box.is-empty:has(.task-details-form[hidden]),
.task-overview .task-info-box.is-empty:has(.task-info-form[hidden]) { display: none; }
/* Share, shared with no one yet: the panel waits behind a button — on a task's own page
   the icon by the due date, elsewhere (a book's page) a "Share with…" button where the
   panel would be. Either goes once the panel is open. */
.show-page:has(#task-share-panel[hidden]) .show-meta-add[data-opens="share"] { display: inline-flex; }
.show-page .task-share-open-row,
#task-share-panel:not([hidden]) + .task-share-open-row { display: none; }
.task-share-open-row { align-self: flex-start; }
/* A task's calendar key (Kept, Missed, To come…) only while the pointer is on the calendar
   or the keyboard is in it. It keeps its room meanwhile, so nothing below jumps as the
   pointer passes. Devices that can't hover keep it showing, or they'd never see it. */
@media (hover: hover) {
  #task-calendar-container .show-cal-legend > span { opacity: 0; transition: opacity var(--dur-fast) ease; }
  #task-calendar-container .show-card-body:has(.show-cal-weekdays:hover, .show-cal-grid:hover, .show-cal-grid:focus-within, .show-cal-legend:hover) .show-cal-legend > span { opacity: 1; }
}
/* "+ Note" leads the key and stays when the key's faded: quiet text, a shade brighter
   than the key. It stands aside once the picked day has a note or its form is open. */
.show-cal-note-add { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0; border: 0; background: none; color: var(--text-2); font: inherit; font-size: var(--fs-12); font-weight: 500; cursor: pointer; }
.show-cal-note-add i { font-size: var(--fs-10); }
.show-cal-note-add:hover { color: var(--text-1); }
.show-cal-note-add:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; color: var(--text-1); }
#task-calendar-container:has(.task-log-day.is-picked .task-log-note-text, .task-occurrence-note:not([hidden])) .show-cal-note-add:not(.show-cal-rating-add) { display: none; }
#task-calendar-container:has(.task-occurrence-rate:not([hidden])) .show-cal-rating-add { display: none; }
/* With written or rated days listed under it, the calendar's body hands straight on to the
   list rather than leaving its full bottom padding as a gap between them. */
#task-calendar-container .show-card-body:has(+ .task-log table) { padding-bottom: 6px; }

/* Keyboard focus, everywhere the same: a blue ring on whatever Tab lands on: links,
   buttons, toggles, disclosures, and checkboxes. :focus-visible, so a mouse click leaves no
   ring. It outranks the many component rules that set outline: none. Text fields keep
   their own focused border instead. */
:where(a, button, summary, select, [role="button"], [role="switch"], [role="tab"],
       input[type="checkbox"], input[type="radio"], input[type="submit"], input[type="button"],
       [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--blue) !important;
  outline-offset: 2px !important;
}

/* The task's calendar card ends close under its "+ Note" row rather than a band below it
   (with a log beneath, the rule above trims it further). */
#task-calendar-container .show-card-body { padding-bottom: 10px; }
#task-calendar-container .show-card-body:has(+ .task-log table) { padding-bottom: 6px; }
/* The day panel's gap rides on the panel, so when it's folded away it leaves none. */
#task-calendar-container .task-occurrence-frame { margin-top: 0; }
#task-calendar-container .task-occurrence-frame > .task-occurrence { margin-top: 16px; }

/* Apex's confirm dialog (confirm_dialog.js), in place of the browser's grey box: a dark
   card with the question, Cancel, and a button named for the action, red when it destroys
   or removes something. */
dialog.apex-confirm {
  width: min(380px, calc(100vw - 32px));
  margin: auto;
  padding: 20px 20px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-pop);
  background-image: var(--sheen);
  color: var(--text-1);
  box-shadow: var(--shadow-card), 0 24px 60px -20px rgba(0, 0, 0, 0.8);
  animation: apex-confirm-in 140ms ease-out;
}
dialog.apex-confirm::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
@keyframes apex-confirm-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.apex-confirm-text { margin: 0 0 18px; font-size: var(--fs-14); line-height: 1.5; white-space: pre-line; }
.apex-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.apex-confirm-btn {
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  font: inherit; font-size: var(--fs-13); font-weight: 600; cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast);
}
.apex-confirm-btn.is-cancel { border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); }
.apex-confirm-btn.is-cancel:hover { background: var(--surface-2); color: var(--text-1); }
.apex-confirm-btn.is-ok { border: 1px solid var(--accent); background: var(--accent); color: #04130a; }
.apex-confirm-btn.is-ok:hover { background: var(--accent-bright); }
.apex-confirm-btn.is-danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.apex-confirm-btn.is-danger:hover { background: var(--danger-bright); border-color: var(--danger-bright); }
.apex-confirm-btn:focus-visible { outline: 2px solid var(--text-1); outline-offset: 2px; }

/* An error toast (apexError) can be clicked away. */
#toast-container .toast.is-dismissable { pointer-events: auto; cursor: pointer; }

/* Skip to content (layouts/application): off-screen until a Tab lands on it. The page it
   jumps to takes focus without drawing a ring round the whole page. */
.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 10001;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: #04130a; font-size: var(--fs-13); font-weight: 600; text-decoration: none;
  transform: translateY(-150%); transition: transform var(--dur-fast);
}
.skip-link:focus { transform: none; outline: 2px solid var(--text-1); outline-offset: 2px; }
#main-content:focus { outline: none; }

/* A row's hover-only buttons show while something in the row has keyboard focus, so a
   Tab never rings an invisible button. (:focus-visible, so a mouse click doesn't.) */
.task-row:has(:focus-visible) .task-row-hover-buttons i.fa-solid,
.task-row:has(:focus-visible) .task-row-hover-buttons i.star-priority,
.subtask-inline-row:has(:focus-visible) .task-row-hover-buttons i.fa-solid,
.subtask-inline-row:has(:focus-visible) .task-row-hover-buttons i.star-priority,
#home-container .task-row:has(:focus-visible) .delete-cancel-cell i,
#home-container .task-row:has(:focus-visible) .add-cell i { opacity: 1; }
.assigned-take-back:focus-visible, .assigned-nudge:focus-visible { opacity: 1; }

/* Phones: list rows don't light up under a thumb that lands on them to scroll. Their
   hover tints are under @media (hover: hover) in their own files; this drops the grey
   tap flash some phones add on top. */
tr, .ledger-row, .ledger-month-item, .thing-row, .thing-task-row, .jd-entry, .an-note-item,
.an-folder-item, .soc-list-row, .soc-item, .search-row, .area-breakdown-row, .show-list-item {
  -webkit-tap-highlight-color: transparent;
}
