/* Tempus app shell. Components come from vendor/ui.css (alex-ui tailscale-2). */
:where(svg[aria-hidden]) { width: 16px; height: 16px; }

body { background: var(--bg-page); }

/* The logo is FreeSerif's hourglass (GNU FreeFont), as a path, on an accent tile. */
.app-logo-tile { display: grid; place-content: center; width: 25px; height: 25px; flex: none; border-radius: 6px; color: var(--accent-fg); background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 80%, white), var(--accent)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), inset 0 1px 0 rgb(255 255 255 / 0.25); }
.app-logo { width: 12px; height: 16px; }
.app-brand .app-logo-tile { width: 21px; height: 21px; border-radius: 5px; }
.app-brand .app-logo { width: 10px; height: 14px; }

.app { display: flex; min-height: 100vh; }
.app-nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100vh;
  width: 232px;
  flex-shrink: 0;
  padding: var(--space-4) var(--space-3);
  background: var(--bg-page);
  border-right: 1px solid var(--border);
}
.app-brand { display: flex; align-items: center; gap: var(--space-2); color: var(--fg); text-decoration: none; height: 30px; padding: 0 var(--space-2); font-weight: 600; letter-spacing: -0.012em; }
.app-nav__footer { display: flex; flex-direction: column; gap: var(--space-3); margin-top: auto; padding: var(--space-3) var(--space-2) 0; border-top: 1px solid var(--border); }
.app-account { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-width: 0; }
.app-account__who { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.app-account__who > .ui-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The user's initial, as in Manicule. */
.app-avatar { background: var(--accent-subtle); color: var(--accent-text); font-size: var(--text-sm); box-shadow: none; }
.app-account__button { width: auto; height: auto; padding: 2px; border-radius: 50%; }

.app-main {
  flex: 1;
  min-width: 0;
  max-width: 880px;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Login and signup take the whole page. */
body[data-page="auth"] :is(.app-nav, .app-topbar) { display: none; }
body[data-page="auth"] { background: var(--bg-subtle); }
body[data-page="auth"] .app-main { max-width: none; align-items: center; justify-content: center; }
.app-auth { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: var(--space-5); }
.app-auth__brand { display: flex; align-items: center; justify-content: center; gap: var(--space-2); color: var(--fg); text-decoration: none; font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.015em; }
.app-auth__card { display: flex; flex-direction: column; gap: var(--space-4); padding: 28px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.app-auth__title { margin: 0 0 var(--space-1); font-size: var(--text-2xl); font-weight: 650; letter-spacing: -0.02em; }
.app-auth__input { height: var(--control-lg); font-size: var(--text-md); }
.app-auth__submit { width: 100%; justify-content: center; }
.app-auth__foot { margin: 0; text-align: center; font-size: var(--text-sm); color: var(--fg-muted); }
.app-auth .ui-hint:empty { display: none; }
.app-password { position: relative; }
.app-password .ui-input { width: 100%; padding-right: 40px; }
.app-password__toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: grid; place-content: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-md); background: none; color: var(--fg-muted); cursor: pointer; }
.app-password__toggle:hover { background: var(--bg-muted); color: var(--fg); }
.app-password__toggle:focus-visible { outline: none; box-shadow: var(--focus); }

/* Four more Category colours alongside the theme's eight. */
:root {
  --hue-lime: #6c9f1d;
  --hue-sky: #2389d6;
  --hue-brown: #9a6a3c;
  --hue-grey: #7a7672;
}
:root[data-theme="dark"] {
  --hue-lime: #98c94c;
  --hue-sky: #58aef0;
  --hue-brown: #c49668;
  --hue-grey: #a39f9b;
}

/* Categories: coloured dots, the sidebar list, the phone list and the dialogs. */
.app-dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: var(--c); }
.app-dot--lg { width: 12px; height: 12px; }
.ui-nav__item .app-dot { margin: 0 3px; }
.app-categories__add { width: 20px; height: 20px; }
/* Dragging to reorder (see sortable in app.js). */
#category-nav .ui-nav__item,
#view .ui-task { user-select: none; -webkit-touch-callout: none; }
.is-sorting :is(.ui-nav__item, .ui-task) { transition: transform 150ms var(--ease); cursor: grabbing; }
.is-sorting :is(.ui-nav__item, .ui-task).is-dragging { position: relative; z-index: 1; transition: none; background: var(--bg); box-shadow: var(--shadow-lg); }
.app-nav__categories { display: none; }
.app-catlist { margin: 0; padding: 0; list-style: none; }
.app-catlist a,
.app-catlist__new {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 13px var(--space-2);
  font: inherit;
  color: var(--fg);
  text-align: left;
  text-decoration: none;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.app-catlist a:hover { background: var(--bg-subtle); }
.app-catlist__count { margin-left: auto; font-size: var(--text-sm); color: var(--fg-muted); }
.app-catlist a > svg:last-child { color: var(--fg-faint); }
.app-catlist__new { font-weight: 500; color: var(--accent-text); border-bottom: 0; }
.app-swatches { margin: 0; padding: 0; border: 0; }
/* A legend sits outside the field's flex gap, so space it by hand, leaving
   room for the selected swatch's ring. */
.app-swatches legend { margin-bottom: var(--space-3); padding: 0; }
.app-swatches__row { display: flex; flex-wrap: wrap; gap: 10px; padding-left: 4px; }
.app-swatch { display: grid; width: 22px; height: 22px; border-radius: 50%; background: var(--c); cursor: pointer; }
.app-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.app-swatch:has(input:checked) { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--c); }
.app-swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Cards: the task detail and capture dialogs share one layout. A title row,
   then a bar with When and Category on the left and controls on the right. */
.ui-dialog.app-card { width: min(480px, calc(100vw - 32px)); padding: var(--space-4) var(--space-3) var(--space-2) var(--space-4); overflow: visible; }
.ui-dialog.app-detail { display: none; }
.ui-dialog.app-detail[open] { display: flex; flex-direction: column; gap: var(--space-3); }
.app-card__title { display: flex; align-items: flex-start; gap: 10px; }
.app-card__title .ui-checkcircle { margin-top: 3px; }
.app-detail textarea { width: 100%; padding: 0; font: inherit; color: var(--fg); background: none; border: 0; outline: 0; resize: none; field-sizing: content; }
.app-detail textarea:focus-visible { box-shadow: none; }
#detail-title { font-size: var(--text-lg); font-weight: 600; line-height: 1.35; }
/* One line always: When and Category shorten with "…" before anything wraps. */
.app-card__bar { display: flex; align-items: center; gap: 2px; margin-left: 20px; }
.app-card__bar > * { flex-shrink: 0; }
.app-card__bar > .ui-menu:has(> .app-prop) { flex-shrink: 1; min-width: 0; }
.app-card__spacer { flex: 1; }
.app-prop { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 30px; padding: 0 8px; font: inherit; font-size: var(--text-sm); color: var(--fg); white-space: nowrap; background: none; border: 0; border-radius: var(--radius-md); cursor: pointer; }
.app-prop:hover { background: var(--bg-muted); }
.app-prop.is-today { color: var(--success-text); }
.app-prop.is-empty { color: var(--fg-muted); }
.app-prop__chevron { width: 13px; height: 13px; opacity: 0.6; }
.app-prop > svg, .app-prop > .app-dot { flex-shrink: 0; }
.app-prop__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.app-card .ui-menu__list, .app-capture .ui-menu__list { min-width: 200px; }
.app-card .ui-menu__item[aria-current="true"], .app-capture .ui-menu__item[aria-current="true"] { background: var(--bg-muted); }

/* Today: Overdue and done fold into one row each; the first open Task is "Next". */
.app-today { display: flex; flex-direction: column; gap: var(--space-4); }
.app-fold__summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 10px var(--space-3);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  text-align: left;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
}
.app-fold__chevron { margin-left: auto; color: var(--fg-faint); }
.app-fold--overdue .app-fold__summary { color: var(--danger-text); background: var(--danger-subtle); border-color: transparent; }
.app-fold--done .app-fold__summary { border-color: transparent; }
.app-fold__extra { display: flex; justify-content: flex-end; padding-top: var(--space-2); }
.app-next { background: var(--accent-subtle); border-bottom-color: transparent; border-radius: var(--radius-md); }
.app-next .ui-task__title { font-weight: 600; }
.app-next__tag { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-text); }

/* All's View menu: switches for what the page shows. */
.app-view__menu { min-width: 220px; }
.app-view__option { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 var(--space-2); font-size: var(--text-sm); border-radius: var(--radius-sm); cursor: pointer; }
.app-view__option:hover { background: var(--bg-muted); }
.app-view__option > svg { width: 15px; height: 15px; color: var(--fg-muted); }
.app-view__option .ui-switch { margin-left: auto; }
.app-view__scrim { display: none; }

/* Capture: one quiet line at rest; focused (or holding text), it opens up to
   show where the Task will go. */
.app-capture__box {
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.app-capture__line { display: flex; align-items: center; gap: 10px; height: 40px; }
.app-capture__plus { width: 16px; height: 16px; flex-shrink: 0; color: var(--fg-muted); }
.app-capture__key { font: inherit; font-size: 11px; line-height: 1; padding: 3px 6px; color: var(--fg-muted); border: 1px solid var(--border); border-radius: 5px; }
.app-capture__bar { display: none; margin: -2px -8px 0; padding-bottom: var(--space-1); }
.app-capture.is-open .app-capture__box { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.app-capture.is-open .app-capture__bar { display: flex; }
.app-capture.is-open :is(.app-capture__plus, .app-capture__key) { display: none; }
/* The input's own text is transparent; the mirror behind it draws the same
   text with recognised words marked, so both need identical type. */
.app-capture__field { position: relative; flex: 1; min-width: 0; }
.app-capture__input,
.app-capture__mirror { font: inherit; font-size: var(--text-lg); font-weight: 600; line-height: 1.35; letter-spacing: inherit; }
.app-capture__input { position: relative; width: 100%; padding: 0; color: transparent; caret-color: var(--fg); background: none; border: 0; outline: 0; }
.app-capture__mirror { position: absolute; inset: 0; overflow: hidden; white-space: pre; color: var(--fg); pointer-events: none; }
.app-parsed { color: var(--accent-text); background: var(--accent-subtle); border-radius: 3px; box-shadow: 0 0 0 2px var(--accent-subtle); }
.app-capture__input::placeholder { color: var(--fg-muted); font-weight: 400; }
.app-capture__input:focus-visible { outline: none; box-shadow: none; }
.app-capture__added { display: inline-flex; align-items: center; gap: 4px; margin-right: var(--space-2); font-size: var(--text-sm); font-weight: 500; color: var(--success); opacity: 0; }
.app-capture__added svg { width: 14px; height: 14px; }
.app-capture__added.is-shown { animation: app-added 1500ms var(--ease) forwards; }
.app-capture__added.is-shown svg { animation: app-tick-pop 360ms var(--ease); }
/* A Task just captured flashes in its list. */
.app-new { animation: app-new 1600ms var(--ease); scroll-margin: var(--space-6) 0 180px; }
@keyframes app-new {
  0%, 40% { background: var(--success-subtle); }
}
@keyframes app-added {
  0% { opacity: 0; transform: translateY(6px); }
  15%, 75% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}

[hidden] { display: none !important; }
.ui-stack { gap: var(--space-3); }
a.ui-button { text-decoration: none; }

/* Triage needs its buttons visible without hovering. */
.app-triage .ui-task__actions { opacity: 1; }
.ui-task__body[data-action="edit"] { cursor: pointer; }

.app-day { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-5); align-items: start; }
.app-day__calendar { width: 264px; padding: var(--space-3); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.app-day__lists { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }

.app-date-dialog { width: 296px; }
.app-dialog-delete { margin-right: auto; color: var(--danger); }

.app-topbar { display: none; }

/* Phones: a top bar with the account menu, the nav as a bottom tab bar. */
@media (max-width: 760px) {
  .app-auth__card { padding: var(--space-5) 20px; }
  .app { flex-direction: column; }
  .app-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--space-2) + env(safe-area-inset-top)) var(--space-3) var(--space-2) var(--space-4);
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
  }
  .app-topbar .app-brand { padding: 0; }
  .app-nav {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    height: auto;
    width: auto;
    padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .app-nav > .app-brand,
  .app-nav__footer,
  .app-categories { display: none; }
  .app-nav__categories { display: flex; }
  .app-nav .ui-nav { flex-direction: row; }
  .app-nav .ui-nav__item {
    position: relative;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    height: 52px;
    padding: 0;
    font-size: var(--text-xs);
    text-align: center;
  }
  .app-nav .ui-nav__item[aria-current="page"] { background: none; }
  .app-nav .ui-nav__item svg { width: 22px; height: 22px; }
  .app-nav .ui-nav__count:not(:empty) {
    position: absolute;
    top: 4px;
    left: calc(50% + 6px);
    min-width: 16px;
    height: 16px;
    margin: 0;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    color: var(--accent-fg);
    background: var(--accent);
    border-radius: 8px;
  }
  .app-main { padding: var(--space-4) var(--space-4) calc(140px + env(safe-area-inset-bottom)); }
  /* Capture docks at the bottom, above the tab bar, like a chat app's message
     box. While typing, the tab bar goes and it sits on the keyboard. */
  .app-capture {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(61px + env(safe-area-inset-bottom));
    z-index: 11;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-page);
    border-top: 1px solid var(--border);
  }
  .app-capture__key { display: none; }
  .app-capture:focus-within { bottom: var(--keyboard, 0px); padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom)); }
  .app-capture.is-open .app-capture__box { box-shadow: none; }
  body:has(.app-capture:focus-within) .app-nav { display: none; }
  .app-detail .app-card__bar { margin-left: 0; }
  .app-card__bar .ui-button--icon { width: 28px; }
  /* All's View menu becomes a bottom sheet. */
  .app-view:has(.app-view__menu:not([hidden])) .app-view__scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 0.35); }
  .app-view__menu {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 31;
    padding: var(--space-3) var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    animation: app-slide-up 220ms var(--ease);
  }
  .app-view__option { height: 44px; font-size: var(--text-md); }
  /* The keyboard is below the bar, so menus open upwards. */
  .app-capture .ui-menu__list { top: auto; bottom: calc(100% + 4px); }
  .app-day { grid-template-columns: minmax(0, 1fr); }
  .app-day__calendar { order: -1; justify-self: start; }
  .app-triage .ui-task { flex-wrap: wrap; }
  .app-triage .ui-task__actions { flex-basis: 100%; margin: 0; padding-left: 28px; }
}

@keyframes app-slide-up {
  from { transform: translateY(100%); }
}
