/*
 * Shared page shell for the Task Master Check-In app.
 * Theme tokens, tab bar, clock, page frame, and common controls live here so
 * every page renders the same chrome from one source.
 */

/* The hidden attribute must win over any layout rule that sets `display`. */
[hidden] { display: none !important; }

/* Keep the page out of the first paint while profile.js builds the signed-in
   shell. Otherwise navigation briefly shows the un-sidebarred layout before
   the sidebar, theme, and page heading snap into place. */
body.profile-booting .page { visibility: hidden; }

:root {
  --shell: var(--tm-chrome-bg);
  --ink: var(--tm-text-primary);
  --muted: var(--tm-text-secondary);
  --line: var(--tm-lines-border);
  --paper: var(--tm-canvas-surface);
  --green: var(--tm-accent-base);
  --sage: var(--tm-categories-area-accent);
  --wash: var(--tm-canvas-bg);
  --danger: var(--tm-status-danger-base);
  --danger-soft: var(--tm-status-danger-text);
  --warn: var(--tm-status-warning-base);
  --sans: Arial, sans-serif;
  --control-height: 38px;
  --control-radius: 3px;
  --control-pad-x: 12px;
  --control-bg: var(--tm-canvas-surface-sunken);
  --control-line: var(--tm-lines-border);
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  background-color: var(--tm-canvas-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--wash);
  font-family: var(--sans);
}

.page {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 32px;
  animation: arrive 420ms ease-out both;
}

.clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  padding: 8px 14px;
  border: 1px solid var(--tm-lines-border-strong);
  border-radius: 3px;
  color: var(--green);
  background: var(--tm-canvas-surface);
  font: 600 0.8125rem var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.clock-date {
  color: var(--muted);
  font: 600 0.75rem var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.clock-zone {
  color: var(--muted);
  font: 600 0.6875rem var(--sans);
  letter-spacing: 0.04em;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 2px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.tab {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: var(--tm-canvas-surface-sunken);
  font: 600 0.8125rem var(--sans);
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.tab:hover { border-color: var(--tm-lines-border-strong); color: var(--ink); background: var(--tm-lines-border); }
.tab[aria-current="page"] { border-color: var(--green); color: var(--tm-accent-on-accent); background: var(--green); }

header { padding: 0 2px 22px; }

h1 {
  margin: 0;
  font-family: var(--sans);
  font-size: 2.375rem;
  font-weight: 600;
  line-height: 1.05;
}

main {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--tm-shadow-lg), var(--tm-shadow-sm);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.6875rem;
}

.saved { display: inline-flex; align-items: center; gap: 7px; }
.saved::before { width: 6px; height: 6px; border-radius: 50%; background: var(--sage); content: ""; }
.shortcut { color: var(--tm-text-muted); }

/* -------------------------------------------------------------------
 * Shared form controls
 * Text inputs, native selects, textareas, placeholders, and field text
 * roles all live here so every page renders the same control surface.
 * ----------------------------------------------------------------- */

.text-input,
.select-input,
.textarea-input {
  flex: 1 1 140px;
  min-width: 0;
  min-height: var(--control-height);
  padding: 0 var(--control-pad-x);
  border: 1px solid var(--control-line);
  border-radius: var(--control-radius);
  color: var(--ink);
  background: var(--control-bg);
  font: 0.875rem var(--sans);
}

.select-input {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23BCAB8F' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.textarea-input {
  padding: 10px var(--control-pad-x);
  line-height: 1.6;
  resize: vertical;
}

.text-input::placeholder,
.select-input::placeholder,
.textarea-input::placeholder {
  color: var(--muted);
  font-style: italic;
  opacity: 1;
}

.text-input[type="date"],
.text-input[type="time"] {
  font-variant-numeric: tabular-nums;
}

.text-input[type="date"]::-webkit-calendar-picker-indicator,
.text-input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.8;
}

.text-input[type="date"]:hover::-webkit-calendar-picker-indicator,
.text-input[type="time"]:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
}

.text-input[type="date"]::-webkit-datetime-edit,
.text-input[type="time"]::-webkit-datetime-edit,
.text-input[type="date"]::-webkit-datetime-edit-fields-wrapper,
.text-input[type="time"]::-webkit-datetime-edit-fields-wrapper,
.text-input[type="date"]::-webkit-datetime-edit-text,
.text-input[type="time"]::-webkit-datetime-edit-text,
.text-input[type="date"]::-webkit-datetime-edit-day-field,
.text-input[type="date"]::-webkit-datetime-edit-month-field,
.text-input[type="date"]::-webkit-datetime-edit-year-field,
.text-input[type="time"]::-webkit-datetime-edit-hour-field,
.text-input[type="time"]::-webkit-datetime-edit-minute-field,
.text-input[type="time"]::-webkit-datetime-edit-ampm-field {
  color: var(--ink);
  background: transparent;
}

.text-input[type="date"]::-webkit-datetime-edit-text,
.text-input[type="time"]::-webkit-datetime-edit-text {
  color: var(--muted);
  padding: 0 1px;
}

.text-input[type="date"]::-webkit-datetime-edit-day-field:focus,
.text-input[type="date"]::-webkit-datetime-edit-month-field:focus,
.text-input[type="date"]::-webkit-datetime-edit-year-field:focus,
.text-input[type="time"]::-webkit-datetime-edit-hour-field:focus,
.text-input[type="time"]::-webkit-datetime-edit-minute-field:focus,
.text-input[type="time"]::-webkit-datetime-edit-ampm-field:focus {
  color: var(--ink);
  background: var(--tm-lines-border);
  border-radius: 2px;
  outline: none;
}

.text-input[type="date"]::-webkit-inner-spin-button,
.text-input[type="time"]::-webkit-inner-spin-button,
.text-input[type="date"]::-webkit-clear-button,
.text-input[type="time"]::-webkit-clear-button {
  display: none;
}

.text-input:focus-visible,
.select-input:focus-visible,
.textarea-input:focus-visible {
  outline: 2px solid var(--tm-focus-ring);
  outline-offset: 2px;
}

.text-input:disabled,
.select-input:disabled,
.textarea-input:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.text-input.is-valid,
.select-input.is-valid,
.textarea-input.is-valid {
  border-color: var(--sage);
}

.text-input.is-invalid,
.select-input.is-invalid,
.textarea-input.is-invalid {
  border-color: var(--danger-soft);
}

.field-error {
  margin: -2px 0 0;
  padding: 0;
  color: var(--danger-soft);
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: left;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font: italic 0.75rem/1.45 var(--sans);
  letter-spacing: 0;
  text-transform: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--tm-accent-base);
  border-radius: 3px;
  color: var(--tm-accent-on-accent);
  background: var(--tm-accent-base);
  font: 600 0.8125rem var(--sans);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}
.button:hover { border-color: var(--tm-accent-hover); background: var(--tm-accent-hover); }
.button:focus-visible { outline: 2px solid var(--tm-focus-ring); outline-offset: 3px; }

.button-outline {
  border-color: var(--tm-neutral-border);
  color: var(--tm-accent-base);
  background: var(--tm-neutral-bg);
}
.button-outline:hover {
  border-color: var(--tm-accent-base);
  color: var(--tm-text-primary);
  background: var(--tm-neutral-hover-bg);
}
.button-outline:focus-visible { outline: 2px solid var(--tm-focus-ring); outline-offset: 3px; }

.button-quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--tm-neutral-border);
  border-radius: 3px;
  color: var(--tm-neutral-text);
  background: var(--tm-neutral-bg);
  font: 600 0.8125rem var(--sans);
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.button-quiet:hover { border-color: var(--tm-neutral-hover-border); color: var(--tm-text-primary); background: var(--tm-neutral-hover-bg); }
.button-quiet:focus-visible { outline: 2px solid var(--tm-focus-ring); outline-offset: 3px; }

.button:disabled,
.button-quiet:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.entry-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.entry-list:empty { display: none; }

.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--tm-status-warning-border);
  border-radius: 3px;
  background: var(--tm-status-warning-soft-bg);
  color: var(--tm-status-warning-text);
  font-size: 0.875rem;
  word-break: break-word;
}

.entry-actions { display: flex; gap: 12px; }
.entry-action {
  position: relative;
  border: 0;
  padding: 0;
  color: var(--muted);
  background: none;
  font: 600 0.75rem var(--sans);
  cursor: pointer;
}
.entry-action:hover { color: var(--ink); }
/* Keep the visual icon small but give it a 32px hit area. */
.entry-action::before {
  content: "";
  position: absolute;
  inset: -7px;
}
.entry-action.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.entry-action.icon-action svg { width: 14px; height: 14px; display: block; }
.entry-action.icon-edit { color: var(--tm-table-icon-edit); }
.entry-action.icon-remove { color: var(--tm-table-icon-remove); }
.entry-action.icon-edit:hover { color: var(--tm-table-icon-edit); }
.entry-action.icon-remove:hover { color: var(--tm-table-icon-remove); }

.entry-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.entry-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.entry-check span.done { color: var(--muted); text-decoration: line-through; }

.settings-note { margin: 0 0 16px; color: var(--muted); font-size: 0.875rem; line-height: 1.5; }

.form-error { margin: -6px 0 10px; color: var(--danger-soft); font-size: 0.8125rem; line-height: 1.4; }
.form-error[hidden] { display: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
  .page { width: calc(100% - 24px); padding-top: 30px; }
  header { padding-bottom: 17px; }
  h1 { font-size: 2.125rem; }
  .footer { align-items: flex-start; flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
 * Server-backed login gate (profile.js)
 * ----------------------------------------------------------------------- */

.profile-locked { overflow: hidden; }
.profile-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--tm-overlay);
}
.profile-gate[hidden] { display: none; }
.profile-gate-card {
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid var(--tm-lines-border-strong);
  border-radius: 4px;
  background: var(--tm-canvas-surface);
  box-shadow: var(--tm-shadow-lg);
}
.profile-gate-card h2 { margin: 0 0 8px; font-size: 1.25rem; }
.profile-gate-note { margin: 0 0 18px; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.profile-form { display: grid; gap: 12px; }
.profile-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.profile-message { min-height: 18px; margin: 0; color: var(--muted); font-size: 0.75rem; line-height: 1.4; }
.profile-message.error { color: var(--danger-soft); }
.profile-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.impersonation-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 6px 20px;
  border: 0;
  border-radius: 0;
  color: #FFFFFF;
  background: #C8102E;
  /* Bleed the red band across the animated sidebar rail so closing the
     sidebar never exposes a light strip beside it. */
  box-shadow: 0 0 0 100vmax #C8102E;
  clip-path: inset(0 -100vmax);
  font: 600 0.75rem/1.35 var(--sans);
}
.impersonation-bar .button-quiet {
  min-height: 0;
  padding: 3px 10px;
  border: 1px solid #FFFFFF;
  border-radius: 2px;
  color: #FFFFFF;
  background: transparent;
}
.impersonation-bar .button-quiet:hover {
  color: #FFFFFF;
  background: rgba(0, 0, 0, 0.22);
}
.impersonation-bar .button-quiet:focus-visible {
  outline: 2px solid #FFFFFF;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
 * Full-height collapsible primary sidebar for signed-in profiles.
 * ----------------------------------------------------------------------- */
body.app-sidebar-mode {
  padding-left: 240px;
}
/* Animate padding for deliberate toggles only. Applying app-sidebar-mode on
   first load must not animate the page in from the left. */
body.app-sidebar-mode.sidebar-animating { transition: padding-left 160ms ease; }
body.app-sidebar-mode.sidebar-collapsed { padding-left: 0; }

body.app-sidebar-mode .page {
  padding-top: 0;
  /* The page is revealed together with the shell, so skip the entrance
     animation that would leave a strip above the header band. */
  animation: none;
}
body.app-sidebar-mode .page > header { display: none; }
/* Solid header band, bled to the viewport edges and matched by the sidebar. */
body.app-sidebar-mode .tabs {
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 12px;
  height: 80px;
  margin-bottom: 18px;
  padding: 0 2px;
  background: var(--tm-chrome-bg);
  box-shadow: 0 0 0 100vmax var(--tm-chrome-bg);
  clip-path: inset(0 -100vmax);
  border-bottom: 0;
}
body.app-sidebar-mode .tabs > .tab { display: none; }
body.app-sidebar-mode .tabs #sidebar-toggle { order: 0; }
body.app-sidebar-mode .tabs > .page-heading {
  order: 1;
  min-width: 0;
  margin: 0;
  color: var(--tm-chrome-text);
  font-size: 2.375rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.app-sidebar-mode .tabs .header-identity {
  order: 2;
  flex: 0 0 auto;
  margin-left: auto;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--tm-chrome-border);
  border-radius: 3px;
  color: var(--tm-chrome-muted);
  background: var(--tm-chrome-hover-bg);
  cursor: pointer;
}
.sidebar-toggle:hover { color: var(--tm-chrome-text); border-color: var(--tm-accent-base); background: var(--tm-chrome-active-bg); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--tm-chrome-text); outline-offset: 2px; }
.sidebar-toggle svg { width: 16px; height: 16px; }

body.app-sidebar-mode .app-sidebar,
body.app-sidebar-mode .settings-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 200;
  width: 240px;
  height: 100vh;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  margin: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  overflow-y: auto;
  border: 0;
  border-right: 1px solid var(--tm-chrome-border);
  border-radius: 0;
  background: var(--tm-chrome-bg);
}
body.app-sidebar-mode.sidebar-collapsed .app-sidebar,
body.app-sidebar-mode.sidebar-collapsed .settings-sidebar { display: none; }

/* While the cached shell placeholder is up, keep the in-page Settings nav out
   of the layout. It is moved into the real sidebar as soon as boot finishes. */
body.shell-placeholder .settings-sidebar { display: none !important; }

.app-sidebar-mode .settings-shell { grid-template-columns: minmax(0, 1fr); }
.app-sidebar-mode.orders-view.sidebar-open .settings-sidebar,
.app-sidebar-mode.assignments-view.sidebar-open .settings-sidebar,
.app-sidebar-mode.reports-view.sidebar-open .settings-sidebar { display: flex; }
.app-sidebar-mode.orders-view .settings-section-nav,
.app-sidebar-mode.assignments-view .settings-section-nav,
.app-sidebar-mode.reports-view .settings-section-nav,
.app-sidebar-mode.orders-view .app-sidebar-separator,
.app-sidebar-mode.assignments-view .app-sidebar-separator,
.app-sidebar-mode.reports-view .app-sidebar-separator,
.app-sidebar-mode.orders-view .settings-sidebar-title,
.app-sidebar-mode.assignments-view .settings-sidebar-title,
.app-sidebar-mode.reports-view .settings-sidebar-title { display: none; }

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 80px;
  margin: -18px -14px 8px;
  padding: 0 14px;
  border-bottom: 0;
}
.app-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 7px;
  color: var(--tm-chrome-accent);
  background: var(--tm-chrome-hover-bg);
}
.app-brand-mark svg { width: 18px; height: 18px; }
.app-brand-name { color: var(--tm-chrome-text); font: 600 1.0625rem var(--sans); }
.app-sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--tm-chrome-border);
  border-radius: 3px;
  color: var(--tm-chrome-muted);
  background: transparent;
  cursor: pointer;
}
.app-sidebar-close:hover {
  color: var(--tm-chrome-text);
  border-color: var(--tm-chrome-border);
  background: var(--tm-chrome-hover-bg);
}
.app-sidebar-close:focus-visible { outline: 2px solid var(--tm-chrome-text); outline-offset: 2px; }
.app-sidebar-close svg { width: 14px; height: 14px; }

.app-sidebar-nav { display: grid; gap: 3px; }
.app-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--tm-chrome-text);
  background: transparent;
  font: 600 0.8125rem var(--sans);
  text-decoration: none;
  white-space: nowrap;
}
.app-sidebar-nav a:hover { border-color: var(--tm-chrome-border); color: var(--tm-chrome-text); background: var(--tm-chrome-hover-bg); }
.app-sidebar-nav a:focus-visible { outline: 2px solid var(--tm-chrome-text); outline-offset: 2px; }
.app-sidebar-nav a[aria-current="page"] {
  border-color: transparent;
  color: var(--tm-chrome-active-text);
  background: transparent;
  box-shadow: inset 3px 0 0 var(--tm-chrome-accent);
}
.app-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.app-nav-icon svg { width: 18px; height: 18px; }
.app-sidebar-nav a[aria-current="page"] .app-nav-icon { color: var(--tm-chrome-accent); }
.app-sidebar-separator { height: 1px; margin: 10px 0; background: var(--tm-chrome-border); }

.app-sidebar-account {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--tm-chrome-border);
}
.app-sidebar-sessions { display: grid; gap: 2px; }
.app-sidebar-sessions[hidden] { display: none; }
.app-sidebar-session {
  padding: 7px 10px;
  border: 0;
  border-radius: 3px;
  color: var(--tm-chrome-muted);
  background: transparent;
  font: 400 0.75rem var(--sans);
  text-align: left;
  cursor: pointer;
}
.app-sidebar-session:hover { color: var(--tm-chrome-text); background: var(--tm-chrome-hover-bg); }
.app-sidebar-session:focus-visible { outline: 2px solid var(--tm-chrome-text); outline-offset: 2px; }
.app-sidebar-clock {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--tm-chrome-muted);
  background: transparent;
  font: 600 0.75rem var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.app-sidebar-clock .clock-date { order: 0; }
.app-sidebar-clock time {
  order: 1;
  color: var(--tm-chrome-text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.app-sidebar-clock .clock-zone { order: 2; }
.app-sidebar-clock .clock-date,
.app-sidebar-clock .clock-zone { color: var(--tm-chrome-muted); }

.header-identity { display: flex; align-items: center; gap: 6px; }
.header-identity-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 6px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: inherit;
  text-decoration: none;
}
.header-identity-link:focus-visible { outline: 2px solid var(--tm-chrome-text); outline-offset: 2px; }
.header-identity-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  color: var(--tm-chrome-accent);
  background: var(--tm-chrome-hover-bg);
}
.header-identity-avatar svg { width: 28px; height: 28px; }
.header-identity-text { display: grid; gap: 2px; min-width: 0; text-align: right; }
.header-identity-name {
  color: var(--tm-chrome-text);
  font: 600 0.9375rem var(--sans);
  overflow-wrap: anywhere;
}
.header-identity-role-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.header-identity-role {
  color: var(--tm-chrome-muted);
  font: 400 0.75rem var(--sans);
}
.app-sidebar-swap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: var(--tm-chrome-accent);
  background: transparent;
  cursor: pointer;
}
.app-sidebar-swap:hover { color: var(--tm-chrome-text); background: transparent; }
.app-sidebar-swap:focus-visible { outline: 2px solid var(--tm-chrome-text); outline-offset: 2px; }
.app-sidebar-swap svg { width: 16px; height: 16px; }

.header-identity-menu {
  position: fixed;
  z-index: 260;
  display: grid;
  gap: 12px;
  width: min(280px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid var(--tm-lines-border-strong);
  border-radius: 12px;
  color: var(--tm-text-primary);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tm-accent-base) 7%, transparent), transparent 42%),
    var(--tm-canvas-surface);
  box-shadow: var(--tm-shadow-lg);
}
.header-identity-menu[hidden] { display: none; }
.header-identity-menu:focus { outline: none; }
.header-identity-menu-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--tm-lines-border);
}
.header-identity-menu-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border: 1px solid var(--tm-lines-border-strong);
  border-radius: 50%;
  color: var(--tm-chrome-accent);
  background:
    linear-gradient(145deg, var(--tm-chrome-hover-bg), var(--tm-canvas-surface-sunken));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tm-accent-base) 12%, transparent);
}
.header-identity-menu-avatar svg { width: 28px; height: 28px; }
.header-identity-menu-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.header-identity-menu-name {
  font: 600 0.9375rem var(--sans);
  overflow-wrap: anywhere;
}
.header-identity-menu-role {
  color: var(--tm-text-secondary);
  font: 400 0.8125rem var(--sans);
}
.header-identity-menu-swap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--tm-lines-border);
  border-radius: 8px;
  color: var(--tm-text-primary);
  background: var(--tm-canvas-surface-sunken);
  font: 600 0.8125rem var(--sans);
  cursor: pointer;
}
.header-identity-menu-swap:hover {
  border-color: var(--tm-accent-base);
  background: var(--tm-canvas-hover);
}
.header-identity-menu-swap:focus-visible {
  outline: 2px solid var(--tm-focus-ring);
  outline-offset: 2px;
}
.header-identity-menu-swap svg {
  width: 14px;
  height: 14px;
  color: var(--tm-accent-base);
}

@media (min-width: 721px) {
  .header-identity-menu { display: none !important; }

  /* With the app sidebar open, anchor the page to the sidebar instead of
     letting the whole shell float into the middle on very wide screens. */
  body.app-sidebar-mode .page {
    width: auto;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: 20px;
    padding-right: 20px;
  }

  /* With the sidebar closed there is no rail to anchor to, so keep the
     content at its natural reading width and centre it in the viewport. */
  body.app-sidebar-mode.sidebar-collapsed .page {
    width: min(1200px, calc(100% - 40px));
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
  }
}
.app-sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--tm-status-danger-border);
  border-radius: 3px;
  color: var(--danger-soft);
  background: var(--tm-status-danger-soft-bg);
  font: 600 0.75rem var(--sans);
  text-align: center;
  cursor: pointer;
}
.app-sidebar-logout:hover { color: var(--tm-status-danger-text); border-color: var(--tm-status-danger-border); background: var(--tm-status-danger-soft-bg); }
.app-sidebar-logout:focus-visible { outline: 2px solid var(--danger-soft); outline-offset: 2px; }
.app-sidebar-logout svg { width: 15px; height: 15px; }

@media (max-width: 720px) {
  body.app-sidebar-mode { padding-left: 0; }
  body.app-sidebar-mode .app-sidebar,
  body.app-sidebar-mode .settings-sidebar {
    height: calc(100vh - 32px);
    display: none;
  }
  body.app-sidebar-mode.sidebar-open .app-sidebar,
  body.app-sidebar-mode.sidebar-open .settings-sidebar { display: flex; }
  body.app-sidebar-mode.sidebar-open .app-sidebar-close { display: inline-flex; }
  body.app-sidebar-mode.sidebar-open::before {
    content: "";
    position: fixed;
    /* Dim the whole page, not just the area below the header: the sidebar is
       the only thing that should stay in focus while the drawer is open. */
    inset: 0;
    z-index: 190;
    background: var(--tm-overlay);
  }
  body.app-sidebar-mode .header-identity-text,
  body.app-sidebar-mode .header-identity > .app-sidebar-swap { display: none; }
  /* Keep the desktop header band at 80px when the profile collapses, so the
     vertically centred page heading does not move. Phones shorten it below. */
  body.app-sidebar-mode .tabs { padding: 0 2px; }
}

/* Larger type and tap targets are for touch screens only. A mouse-driven
   desktop keeps the same text sizes when the window is narrowed. */
@media (max-width: 720px) and (pointer: coarse) {
  html { font-size: 17px; }

  .text-input,
  .select-input,
  .textarea-input {
    min-height: 44px;
    padding-left: 14px;
    padding-right: 14px;
    font-size: 16px;
  }
  .textarea-input { padding-top: 12px; padding-bottom: 12px; }

  .button,
  .button-quiet {
    min-height: 44px;
    padding-left: 18px;
    padding-right: 18px;
    font-size: 0.875rem;
  }

  .tab {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.875rem;
  }
  .sidebar-toggle {
    width: 42px;
    height: 42px;
  }

  .entry-item { padding: 12px; }
  .entry-item .entry-check {
    font-size: 0.9375rem;
    line-height: 1.5;
  }
  .entry-check input {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
  }
  .entry-item .entry-action {
    min-width: 44px;
    min-height: 44px;
    font-size: 0.875rem;
  }
  .entry-actions { gap: 24px; }
  .entry-action::before { inset: -12px; }
  .entry-action.icon-action { width: 20px; height: 20px; }
  .entry-action.icon-action svg { width: 16px; height: 16px; }

  .app-sidebar-close {
    width: 40px;
    height: 40px;
  }
  .app-sidebar-nav a {
    min-height: 44px;
    font-size: 0.875rem;
  }
  .app-sidebar-session,
  .app-sidebar-logout {
    min-height: 40px;
    font-size: 0.8125rem;
  }
  .app-sidebar-clock { font-size: 0.8125rem; }
  .header-identity-menu-swap { min-height: 40px; font-size: 0.8125rem; }
  .profile-gate-note { font-size: 0.875rem; }
  body.app-sidebar-mode .tabs { height: 68px; }
  body.app-sidebar-mode .tabs > .page-heading { font-size: 1.625rem; }
}
