/* anton x — shared design system
   Default tokens = DARK mode. Light mode overrides live in `html.light` below.
   Theme is controlled by an `html.light` class set by the inline init script
   in partials/header.php and login.php (FOUC-safe, runs before paint). */
:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #161616;
  --surface-hover: #1a1a1a;
  --border: #1f1f1f;
  --border-strong: #2a2a2a;
  --text: #f5f5f5;
  --text-muted: #8a8a8a;
  --text-dim: #5a5a5a;
  --accent: #FACC15;
  --accent-hover: #fbd84a;
  --accent-on: #1a1400;            /* foreground color when sitting ON top of --accent */
  --accent-soft: rgba(250, 204, 21, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --info-soft: rgba(120, 120, 120, 0.14);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.25);

  /* ===== Fluid type scale (mobile-first, capped on desktop) =====
     Used by .t-body / .t-small / h1..h3 helpers and selectively across the
     design. Per-page styles can still hard-code sizes; these are the
     defaults a sensible component reaches for. */
  --fs-small: clamp(12px, 2vw, 13px);
  --fs-body:  clamp(14px, 2.4vw, 15px);
  --fs-lead:  clamp(15px, 2.6vw, 16px);
  --fs-h3:    clamp(17px, 3.4vw, 20px);
  --fs-h2:    clamp(20px, 4.6vw, 26px);
  --fs-h1:    clamp(26px, 6.4vw, 36px);

  /* ===== Safe-area tokens =====
     Computed once so individual components don't have to repeat env(...).
     `0px` fallback so non-mobile browsers behave identically. */
  --sai-top:    env(safe-area-inset-top,    0px);
  --sai-right:  env(safe-area-inset-right,  0px);
  --sai-bottom: env(safe-area-inset-bottom, 0px);
  --sai-left:   env(safe-area-inset-left,   0px);

  /* ===== Bottom-nav height =====
     A real CSS var so any page can reserve space (`padding-bottom`) under
     fixed content. Set to 0 on desktop; flipped to 56px in the mobile
     breakpoint where the bottom tab bar actually shows. */
  --bottom-nav-h: 0px;

  /* ===== Keyboard inset =====
     Updated by partials/footer.php (visualViewport listener) to the height
     of the on-screen keyboard. Components that need to sit above the
     keyboard read this (the chat composer does). 0 when no keyboard. */
  --keyboard-inset: 0px;

  color-scheme: dark;
}

/* ===== LIGHT MODE TOKENS =====
   Same variable names, different values. Anything in the design system that
   references these variables flips automatically. */
html.light {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --surface-hover: #ececef;
  --border: #e5e5e8;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-muted: #5a5a63;
  --text-dim: #8e8e95;
  /* Per user feedback the accent stays yellow in both modes — buttons are
     yellow with black text everywhere, not the orange/amber-700 I tried
     earlier. Soft tint is bumped slightly so it remains visible on white. */
  --accent: #FACC15;
  --accent-hover: #fbd84a;
  --accent-on: #1a1400;
  --accent-soft: rgba(250, 204, 21, 0.20);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.10);
  --info-soft: rgba(24, 24, 27, 0.06);
  --shadow-card: 0 2px 8px rgba(24,24,27,0.06);
  color-scheme: light;
}

/* Light-mode targeted overrides for elements that hardcoded dark colors in
   per-page <style> blocks (can't reach them from a theme variable). */
/* Topbar (task_view.php and any sticky header in the design) — was
   rgba(10,10,10,0.85). In light mode use a translucent white instead. */
html.light .topbar { background: rgba(255, 255, 255, 0.85); }
/* Dashboard calendar: out-of-month cells were #060606 which renders as a
   black square against a white page. Flip to a soft gray. */
html.light .cal-cell.dim { background: #eaecf0; }
/* The dashboard's "today" tint and its border were rgba yellow with very
   low alpha — readable on dark, almost invisible on white. Bump the alpha. */
html.light .cal-cell.today { background: rgba(250,204,21,0.10); }
html.light .cal-cell.today::before { border-color: rgba(250,204,21,0.55); }

/* =====================================================================
   LIGHT MODE: yellow-as-text is unreadable on white. Per user feedback,
   every place that uses var(--accent) as a text color flips to a dark
   neutral (#3f3f46, zinc-700). Backgrounds / borders / dots / button
   surfaces stay yellow — only text changes. */
html.light .brand .x,
html.light .pill.status,
html.light .micro-pill.progress,
html.light .sp-progress,
html.light .tsp.progress,
html.light .cal-cell.today .cal-day,
html.light .cal-task.review .t-state,
html.light .chip-yellow,
html.light .h-pill.role .v,
html.light .stat-row .v.accent,
html.light .scope-tabs .tab.active .count,
html.light .section-nav a.active .count,
html.light .tabs-row .tab.active .count,
html.light .pwd-hint .strength.strong,
html.light .stat-tile .ico.amber,
html.light .task-icon.amber,
html.light .folder .ico,
html.light .auth-eyebrow,
html.light .search-eyebrow,
html.light .stat-card .ico.amber,
html.light .item-title:hover,
html.light .client-name:hover,
html.light .projects-link:hover,
html.light .doc-name:hover,
html.light .task-title a:hover,
html.light .r-title a:hover,
html.light .ready-title a:hover,
html.light .project-link:hover,
html.light .forgot-link:hover,
html.light .auth-foot a:hover,
html.light .open-link,
html.light .save-hint.dirty,
html.light .role-row.active .role-name,
html.light .role-edit,
html.light .section-action:hover,
html.light .results-head .see-all:hover,
html.light .recent-row .body .title mark,
html.light .result-row .body .title mark,
html.light .role-pill,
html.light .page-stat-card .num,
html.light .panel-title .ico,
html.light .perm-key,
html.light .input-shell:focus-within svg.leading,
html.light .auth-card .auth-eyebrow::before,
html.light .scope-meta b,
html.light .results-shell .results-head .see-all:hover,
html.light .a-pill.amber,
html.light .summary-meta .row .v.accent,
html.light .preview-strip .preview-label,
html.light .preview-label,
html.light .s-card .a,
html.light .ready-banner .role-pill .dot,
html.light .submit-state .label,
html.light .seg-btn.approve.active,
html.light .seg-btn.send-back.active,
html.light .tab.active .count,
html.light .auth-shell .auth-title,
html.light .save-hint,
html.light .ready-banner .lbl,
html.light .selected-role-banner .role-pill {
  color: #3f3f46;     /* zinc-700, dark neutral, fully readable on white */
}

/* Per the user's explicit instruction: "no text colour should be yellow,
   find appropriate dark colour". A single dark neutral is used for every
   former yellow-text usage including the brand X. The yellow stays in
   button backgrounds, the active sidebar indicator bar, status dots,
   etc. (those are not text). */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 22px 24px 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: inherit;
}
.brand .x {
  color: var(--accent);
  margin-left: 4px;
}
/* Inline SVG logo. "anton" text uses currentColor; "X" stays #F2CC2F via
   its hardcoded fill in the SVG, so the accent stays the same yellow in
   both themes — no filter tricks needed. */
.brand-logo {
  display: block;
  width: 100%;
  max-width: 130px;
  line-height: 0;
  color: #E8E8E8;
}
.brand-logo svg {
  display: block;
  width: 100%;
  height: auto;
}
html.light .brand-logo {
  color: #1a1a1a;
}

.nav {
  /* Forced column flex so Bootstrap's .nav (display: flex; flex-wrap: wrap) cannot lay out the sidebar items horizontally regardless of CSS load order or browser cache. */
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  list-style: none;
  padding: 4px 12px;
  margin: 0;
  flex: 1 1 auto;
  overflow-y: auto;
}
.nav::-webkit-scrollbar { width: 0; }

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 18px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: -3px;
  margin-left: -12px;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

.user-card {
  margin: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-card .name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-card .role { font-size: 11px; color: var(--text-dim); }

/* ===== Main / topbar ===== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); transition: color 0.15s; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--text-dim); }
.breadcrumb .current { color: var(--text); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  transition: all 0.15s ease; white-space: nowrap;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn svg { width: 14px; height: 14px; }
.btn-ghost { color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: #1a1400; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); color: #1a1400; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-danger { background: var(--danger-soft); color: #fca5a5; border-color: rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); color: #fca5a5; }
.btn-block { width: 100%; }
.btn-lg { padding: 11px 16px; font-size: 13.5px; }

/* Back button — added to every page per requirement */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.15s ease;
  text-decoration: none;
}
.back-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); transform: translateX(-1px); }
.back-btn svg { width: 13px; height: 13px; }

/* ===== Pills ===== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted);
}
.pill.priority { background: var(--danger-soft); color: #fca5a5; border-color: rgba(239,68,68,0.25); }
.pill.priority .dot { background: #ef4444; }
.pill.status { background: var(--accent-soft); color: var(--accent); border-color: rgba(250,204,21,0.25); }
.pill.status .dot { background: var(--accent); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== Inputs ===== */
.input, .select, textarea.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: all 0.15s;
  font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); background: var(--bg); }
.input::placeholder, textarea.input::placeholder { color: var(--text-dim); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.select option { background: #1a1a1a; color: var(--text); }
textarea.input { resize: vertical; min-height: 64px; }

/* ===== Card chrome ===== */
.rail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.rail-card-head {
  padding: 14px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.rail-card-title {
  font-size: 11px; font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.rail-card-body { padding: 4px 16px 16px; }

.section-title {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  text-transform: uppercase; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 8px;
}
.section-title .count {
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.section-action {
  font-size: 12px; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px;
  transition: all 0.15s;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
}
.section-action:hover { color: var(--text); background: var(--surface-2); }
.section-action svg { width: 12px; height: 12px; }

.helper-text { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; line-height: 1.4; }

/* ===== Save flash ===== */
.save-flash { transition: transform 0.1s; }
.save-flash:active { transform: scale(0.97); }

/* ===== Theme toggle (fixed top-right on every page) =====
   Rendered by partials/header.php for designed pages and inlined in
   login.php so it's present even on the unauthenticated screen.
   `!important` on positioning so it can't be clobbered by any page-level
   $pageHeadExtra `button { ... }` selectors or Bootstrap's reboot. */
.theme-toggle,
button.theme-toggle {
  position: fixed !important;
  /* Safe-area-aware so the button sits below the iPhone notch / island and
     clear of the right rounded corner on landscape. */
  top: calc(var(--sai-top) + 16px) !important;
  right: calc(var(--sai-right) + 18px) !important;
  left: auto !important;
  bottom: auto !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px;
  min-height: 44px;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 999px !important;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999 !important;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.04) inset;
  font: inherit;
  line-height: 1;
  pointer-events: auto;
}
html.light .theme-toggle,
html.light button.theme-toggle {
  box-shadow: 0 4px 14px rgba(24,24,27,0.10), 0 0 0 1px rgba(0,0,0,0.02) inset;
  background: #ffffff;
  border-color: var(--border-strong);
  color: var(--text);
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
  background: var(--surface-2);
}
html.light .theme-toggle:hover {
  background: var(--surface-2);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;     /* clicks always hit the button, never the inner svg */
}
/* Show sun in dark mode (click → light); show moon in light mode (click → dark). */
.theme-toggle .ico-moon { display: none; }
html.light .theme-toggle .ico-sun { display: none; }
html.light .theme-toggle .ico-moon { display: block; }
@media (prefers-reduced-motion: reduce) {
  .theme-toggle, .theme-toggle:hover { transition: none; transform: none; }
}
@media (max-width: 560px) {
  .theme-toggle, button.theme-toggle {
    width: 40px !important; height: 40px !important;
    top: calc(var(--sai-top) + 12px) !important;
    right: calc(var(--sai-right) + 12px) !important;
  }
  .theme-toggle svg { width: 18px; height: 18px; }
}

/* ===== Global page-header back-button stacking =====
   Force the back button to render ABOVE the page title on every page.
   Per-page inline <style> blocks define `.page-header-left` (and variants)
   with `display: flex; align-items: center;` which stacks them horizontally.
   Scoping under `.app` raises specificity from (0,1,0) to (0,2,0) so this
   rule wins regardless of where the inline block is in the cascade. */
.app .page-header-left,
.app .ph-left,
.app .ch-left,
.app .breadcrumb-left {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* ===== Flash messages ===== */
.flash {
  margin: 16px 32px 0;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid;
  display: flex; align-items: center; gap: 10px;
}
.flash svg { width: 16px; height: 16px; flex-shrink: 0; }
.flash-success { background: var(--success-soft); color: #86efac; border-color: rgba(34,197,94,0.25); }
.flash-error { background: var(--danger-soft); color: #fca5a5; border-color: rgba(239,68,68,0.25); }

/* ===== Tables shared ===== */
table { font-family: inherit; }

/* ===== Form helpers ===== */
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label, .field-label {
  font-size: 11.5px; color: var(--text-muted);
  font-weight: 500;
}
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 768px) { .form-grid.cols-2 { grid-template-columns: 1fr; } }

/* ===================================================================
   MOBILE & RESPONSIVE — Global foundations
   =================================================================== */

/* Responsive images: never overflow their container */
img { max-width: 100%; height: auto; display: block; }

/* Suppress the blue/grey tap flash on iOS & Android */
a, button, [role="button"], .nav-item, label, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
}

/* Table scroll wrapper — injected by JS in footer.php around every table
   inside .main so tables never cause horizontal page scroll on mobile. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* ===== Mobile nav overlay ===== */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
body.nav-open .nav-overlay { display: block; }
body.nav-open { overflow: hidden; }

/* ===== Hamburger button — shown on mobile, hidden on desktop ===== */
.nav-hamburger {
  display: none;
  position: fixed;
  top: calc(var(--sai-top) + 16px);
  left: calc(var(--sai-left) + 16px);
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
html.light .nav-hamburger {
  box-shadow: 0 4px 14px rgba(24, 24, 27, 0.10);
  background: #ffffff;
}
.nav-hamburger:hover { background: var(--surface-2); color: var(--accent); border-color: var(--accent); }
.nav-hamburger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.15s ease;
  pointer-events: none;
}
/* Animate to X when nav is open */
body.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
body.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===================================================================
   BREAKPOINTS — mobile-upward refinements
   =================================================================== */

/* ── 1024px  iPad landscape / small desktop ─────────────────────── */
@media (max-width: 1024px) {
  .topbar { padding: 0 20px; }
  .flash  { margin-left: 20px; margin-right: 20px; }
}

/* ── 768px  Tablet portrait + all phones — the main layout pivot ── */
@media (max-width: 768px) {

  /* ===== Mobile nav: bottom bar IS the nav. =====
     Per user feedback, the floating top-left hamburger, top-right bell,
     and top-right theme toggle are all hidden on mobile. Every action
     they exposed is reachable from the bottom-nav (theme toggle and
     notifications surface inside the "More" sheet; all drawer
     destinations are listed in the same sheet). This keeps the top of
     the screen clean for content. */
  .nav-hamburger,
  .anton-bell,
  .theme-toggle,
  button.theme-toggle {
    display: none !important;
  }

  /* Off-canvas sidebar: collapse the two-column grid to one column
     and move the sidebar to a fixed drawer that slides in from the left. */
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: min(280px, 85vw);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    /* Respect the iPhone notch / island when the drawer is open. */
    padding-top: var(--sai-top);
    padding-bottom: var(--sai-bottom);
  }
  body.nav-open .sidebar { transform: translateX(0); }

  /* The hamburger sits at top:16 left:16, so when the drawer is open the
     X icon overlaps the first ~44px of the .brand row. Push the brand
     logo right when the drawer is open so the X doesn't crop "anton". */
  body.nav-open .brand {
    padding-left: 60px;
  }

  /* Reveal the hamburger button */
  .nav-hamburger { display: inline-flex; }

  /* Topbar: slightly shorter; leave clearance for hamburger (left) and
     fixed bell + theme-toggle (right). */
  .topbar {
    height: 56px;
    padding: 0 130px 0 72px;
  }
  html.light .topbar { background: rgba(255, 255, 255, 0.9); }

  /* Nav items — generous touch targets */
  .nav-item {
    padding: 12px 14px;
    min-height: 48px;
    font-size: 14px;
  }
  .nav-section { padding: 16px 14px 6px; }
  .user-card   { margin: 8px 12px 12px; }

  /* Buttons — 44px minimum tap target */
  .btn        { min-height: 44px; padding: 10px 16px; }
  .btn-lg     { min-height: 48px; padding: 12px 18px; }
  .back-btn   { min-height: 44px; padding: 10px 14px; }
  .section-action { min-height: 40px; padding: 8px 10px; }

  /* Inputs — 16px is the iOS minimum to prevent viewport auto-zoom.
     Below 16px the browser zooms in on focus, breaking the layout. */
  .input, .select, textarea.input {
    font-size: 16px;
    padding: 11px 14px;
    min-height: 48px;
  }
  .select { padding-right: 38px; }
  textarea.input { min-height: 88px; }

  /* Bootstrap legacy form controls (pages not yet on the design system) */
  .form-control, .form-select { font-size: 16px !important; min-height: 48px; }

  /* Flash messages */
  .flash { margin: 10px 16px 0; font-size: 12.5px; }
}

/* ── 560px  phones — matches theme-toggle/bell 560px breakpoint ─── */
@media (max-width: 560px) {
  .topbar { padding: 0 112px 0 64px; }
  .nav-hamburger {
    top: calc(var(--sai-top) + 12px);
    left: calc(var(--sai-left) + 12px);
  }
  .flash { margin: 8px 12px 0; }
}

/* ── 430px  large phones (iPhone 14 Pro Max, Pixel 8) ───────────── */
@media (max-width: 430px) {
  .topbar { height: 52px; padding: 0 108px 0 64px; }
  .breadcrumb { font-size: 12px; gap: 6px; }
}

/* ── 375px  small phones (iPhone SE, older iPhones) ─────────────── */
@media (max-width: 375px) {
  .topbar { padding: 0 104px 0 60px; }
  .btn   { font-size: 12.5px; }
  .flash { margin: 6px 10px 0; }
}

/* Disable drawer & hamburger animations for users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar            { transition: none; }
  .nav-hamburger span { transition: none; }
  .nav-overlay        { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ===================================================================
   GLOBAL CONTENT AREA OVERRIDES — higher specificity beats per-page
   inline <style> blocks that define .content and .page-header.
   Per-page styles appear after anton.css in <head>, so an equal-
   specificity rule here would lose the cascade. Using .app .main .content
   (specificity 0,3,0) safely beats a plain .content (0,1,0) rule.
   =================================================================== */

@media (max-width: 1024px) {
  .app .main .content    { padding-left: 24px; padding-right: 24px; }
  .app .main .page-header { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 768px) {
  /* Prevent any per-page content (table, calendar grid, hero card) from
     pushing the whole .main wide. Per-page horizontal scroll containers
     (.table-scroll, calendars) still work — they scroll inside their own
     bounding box.
     padding-bottom reserves space for the fixed bottom-nav: because the
     anton.css base rule sets `body { height: 100% }`, putting padding on
     body itself doesn't extend the scrollable document — content
     overflows body's capped box and the last few rows hide behind the
     bottom-nav. Adding the padding to .main (which IS in-flow and grows
     with content) is what actually pushes the last row above the
     bottom-nav. 28px breathing room over the nav itself. */
  .app .main {
    overflow-x: hidden;
    min-width: 0;
    padding-bottom: calc(var(--bottom-nav-h) + var(--sai-bottom) + 28px);
  }

  /* Hamburger / bell / theme-toggle are hidden on mobile (above), so the
     .page-header can use normal symmetric padding again. Top inset is
     just a safe-area cushion so the breadcrumb / Back row sits below
     the iPhone notch / status bar. */
  .app .main .content     { padding: 16px 8px 28px; gap: 20px; min-width: 0; }
  .app .main .page-header {
    padding: calc(var(--sai-top) + 12px) 8px 4px 8px;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
  }
  .app .main .page-title  { font-size: clamp(18px, 5vw, 26px); min-width: 0; word-break: break-word; }
  .app .main .page-sub    { font-size: 12px; min-width: 0; }

  /* Modal overlays launched from any page */
  .app .main .modal-overlay { padding: 16px 12px; }
  .app .main .modal-card    { max-width: 100%; }

  /* Quick-action button rows on dashboards / list pages — wrap by default
     and use the full width if there's a primary CTA. */
  .quick-actions,
  .page-header-right,
  .ph-right,
  .filter-row,
  .filter-bar,
  .toolbar-row,
  .actions-row {
    flex-wrap: wrap !important;
    width: 100%;
    gap: 8px !important;
    min-width: 0;
  }
  .quick-actions .quick-btn,
  .page-header-right .btn,
  .ph-right .btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Long-running side-effect: horizontally scrolling stat-card strips on
     dashboards / my_tasks / clients. Force them to wrap into a 2×N grid
     so users can see all stats at once. */
  .stat-row,
  .stat-cards,
  .stats-strip,
  .at-status-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    overflow: visible !important;
    min-width: 0;
  }

  /* ===== .page-stats — page-header stats row =====
     Used by Clients, Projects, and Website Logins as the right-side
     block of the page-header (4 numbered stats: Total / Active /
     Paused / Projects). The desktop layout floats these in the
     top-right corner; on mobile that produces a 2×2 grid hovering next
     to the title block and visually colliding with the toolbar / CTA
     button below it.
     Re-present as a single horizontal chip-pill row beneath the title.
     Each stat becomes [num · LABEL] in a pill with subtle border, so
     they read as quick at-a-glance facts (and can scroll sideways
     if a page ever adds a 5th+ stat). Title block above stays clean,
     toolbar below has its own row. */
  .app .main > .page-header .page-stats,
  .app .main > .page-header > .page-stats {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    grid-template-columns: none !important;
    width: 100%;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-top: 4px;
    padding: 2px 0;
    align-items: stretch;
  }
  .app .main > .page-header .page-stats::-webkit-scrollbar,
  .app .main > .page-header > .page-stats::-webkit-scrollbar { display: none; }
  .app .main > .page-header .page-stats .stat,
  .app .main > .page-header > .page-stats .stat {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    text-align: left;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .app .main > .page-header .page-stats .stat-num,
  .app .main > .page-header > .page-stats .stat-num {
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  .app .main > .page-header .page-stats .stat-label,
  .app .main > .page-header > .page-stats .stat-label {
    font-size: 10.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
  }

  /* Any block that overflows horizontally inside a content card on mobile
     should scroll inside that card, NOT push the whole page wide. */
  .app .main .content > * { min-width: 0; max-width: 100%; }

  /* Tab strips at the top of pages: scroll horizontally inside their
     container instead of cropping behind the hamburger. */
  .scope-tabs,
  .section-nav,
  .tabs-row,
  .ph-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap !important;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .scope-tabs::-webkit-scrollbar,
  .section-nav::-webkit-scrollbar,
  .tabs-row::-webkit-scrollbar,
  .ph-tabs::-webkit-scrollbar { display: none; }

  /* ===== Page-panel horizontal padding normalization =====
     Many pages render their top-level sections (page-header, toolbar,
     stat strips, table wraps, panels) with the desktop pattern
     `max-width: 1640px; margin: 0 auto; width: 100%; padding: Y 32px`.
     The 32px horizontal padding looks right on a wide desktop but on
     a phone it puts the inner content ~32px from the screen edge,
     while sibling sections that happen to use 16px end up ~16px from
     the edge — producing the visible misalignment seen on My Tasks
     (task card sits ~16px further inset than the toolbar / stat
     tiles above it).
     Normalize every common top-level panel selector to 16px on
     mobile so the whole page stays on the same column. !important
     because per-page styles often use the `padding: Ypx 32px` shorthand
     at the same specificity, so a non-important rule would lose. */
  .app .main > .page-header,
  .app .main > .toolbar,
  .app .main > .stat-tiles,
  .app .main > .stat-row,
  .app .main > .stats-strip,
  .app .main > .page-stats,
  .app .main > .table-wrap,
  .app .main > .filter-row,
  .app .main > .toolbar-row,
  .app .main > .actions-row,
  .app .main > .panel,
  .app .main > .section,
  .app .main > .content,
  .app .main > .client-head,
  .app .main > .project-head,
  .app .main > .task-head,
  .app .main > .section-nav,
  .app .main > .body-wrap,
  .app .main > .body-stack,
  .app .main > .body-grid,
  .app .main > .cards,
  .app .main > .tabs-row,
  .app .main > .search-wrap,
  .app .main > .top-search-wrap,
  .app .main > .folders,
  .app .main > .settings-tabs {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

@media (max-width: 430px) {
  .app .main .content     { padding: 12px 8px 20px; gap: 14px; }
  .app .main .page-header { padding: calc(var(--sai-top) + 8px) 8px 4px 8px; }
  /* Keep the same slim 8px gutter on very narrow phones. */
  .app .main > .page-header,
  .app .main > .toolbar,
  .app .main > .stat-tiles,
  .app .main > .stat-row,
  .app .main > .stats-strip,
  .app .main > .page-stats,
  .app .main > .table-wrap,
  .app .main > .filter-row,
  .app .main > .toolbar-row,
  .app .main > .actions-row,
  .app .main > .panel,
  .app .main > .section,
  .app .main > .content,
  .app .main > .client-head,
  .app .main > .project-head,
  .app .main > .task-head,
  .app .main > .section-nav,
  .app .main > .body-wrap,
  .app .main > .body-stack,
  .app .main > .body-grid,
  .app .main > .cards,
  .app .main > .tabs-row,
  .app .main > .search-wrap,
  .app .main > .top-search-wrap,
  .app .main > .folders,
  .app .main > .settings-tabs {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

@media (max-width: 375px) {
  .app .main .content     { padding: 10px 8px 16px; }
  .app .main .page-header { padding: calc(var(--sai-top) + 6px) 8px 4px 8px; }
}

/* ===================================================================
   MOBILE BOTTOM TAB BAR
   ===================================================================
   This is a multi-section app — Dashboard, Search, Chat, Tasks, plus
   secondary modules behind a "More" drawer. A bottom tab bar (the
   Slack / Instagram / Linear pattern for multi-section mobile UIs) is
   the primary mobile nav. The drawer is still available via "More"
   for the long tail (Clients, Projects, Docs, Admin, …) but the five
   most-used destinations live one thumb-tap away.

   Markup is rendered by partials/nav.php inside the .app container so
   the active state can be picked from $activeKey server-side. Hidden
   on desktop via the `display: none` default below; revealed at the
   same 768px breakpoint as the off-canvas sidebar. */

.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  :root { --bottom-nav-h: 56px; }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 990;
    /* Sit ABOVE the iPhone home indicator. Inner row keeps its 56px
       height; the env() padding adds the indicator gap below. */
    padding-bottom: var(--sai-bottom);
    padding-left:   var(--sai-left);
    padding-right:  var(--sai-right);
    background: rgba(10, 10, 10, 0.92);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
    /* Hide when the on-screen keyboard is open. The visualViewport
       listener in partials/footer.php toggles body.kb-open. */
  }
  html.light .bottom-nav { background: rgba(255, 255, 255, 0.92); }
  body.kb-open .bottom-nav { transform: translateY(150%); }
  .bottom-nav {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .bottom-nav-row {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 56px;
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    text-decoration: none;
    color: var(--text-muted);
    background: none;
    border: 0;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.01em;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: color 0.12s ease;
  }
  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    pointer-events: none;
  }
  .bottom-nav-item .label {
    font-size: 10.5px;
    letter-spacing: -0.005em;
  }
  .bottom-nav-item:active { transform: scale(0.94); }
  .bottom-nav-item.active { color: var(--accent); }
  /* Light mode: a yellow icon on white is washed out. Use the same dark
     neutral the rest of the file flips to for ex-yellow text. */
  html.light .bottom-nav-item.active { color: #3f3f46; }
  .bottom-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--accent);
  }

  .bottom-nav-item .bn-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: oklch(0.70 0.20 25);
    color: #fff;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border-radius: 999px;
    box-shadow: 0 0 0 2px var(--bg);
  }
  html.light .bottom-nav-item .bn-badge { box-shadow: 0 0 0 2px #fff; }

  /* Reserve space at the bottom of every scrollable page so the last
     row of content isn't trapped under the tab bar. */
  body { padding-bottom: calc(var(--bottom-nav-h) + var(--sai-bottom)); }
  /* Pages that lock the body (chat, modals) opt-out by setting their
     own padding. */
  body.no-bottom-pad { padding-bottom: 0; }
}

/* ===================================================================
   ACTION SHEETS / BOTTOM SHEETS — global JS utility
   Built by partials/footer.php (window.AntonSheet / window.AntonConfirm)
   This is the mobile-native replacement for browser confirm/alert and
   the surface where long-press context menus, the "More" tab overflow
   menu, and any chat message action menu live.
   =================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.sheet-backdrop.open { opacity: 1; }
html.light .sheet-backdrop { background: rgba(24, 24, 27, 0.35); }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2001;
  background: var(--surface);
  color: var(--text);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  /* Cushion below the last button row above the home indicator. */
  padding: 8px 16px calc(16px + var(--sai-bottom));
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.35);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sheet.open { transform: translateY(0); }
.sheet-grabber {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 6px auto 12px;
}
.sheet-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.sheet-msg {
  font-size: var(--fs-body);
  color: var(--text);
  padding: 4px 4px 14px;
  line-height: 1.45;
}
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  min-height: 48px;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.12s ease, transform 0.05s ease;
  text-decoration: none;
}
.sheet-action svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.9; }
.sheet-action-badge {
  margin-left: auto;
  background: oklch(0.70 0.20 25);
  color: #fff;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  min-width: 20px;
  padding: 3px 7px;
  border-radius: 999px;
  text-align: center;
  flex-shrink: 0;
}
.sheet-action:hover { background: var(--surface-2); }
.sheet-action:active { background: var(--surface-hover); transform: scale(0.985); }
.sheet-action.danger { color: #fca5a5; }
html.light .sheet-action.danger { color: #b91c1c; }
.sheet-action.danger:hover { background: var(--danger-soft); }
.sheet-action.primary { color: var(--accent-on); background: var(--accent); }
html.light .sheet-action.primary { color: var(--accent-on); }
.sheet-action.primary:hover { background: var(--accent-hover); }
.sheet-cancel-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* When a sheet is open, lock body scroll without the iOS-bounce shift. */
body.sheet-open { overflow: hidden; touch-action: none; }

/* ===================================================================
   TOASTS — minimal, replaces ad-hoc alert() for non-blocking errors
   =================================================================== */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sai-bottom) + var(--bottom-nav-h) + 16px);
  transform: translateX(-50%);
  z-index: 2500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100vw - 24px));
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: var(--fs-small);
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  transform: translateY(10px);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; background: var(--danger-soft); }
.toast.success { border-color: rgba(34, 197, 94, 0.35); color: #86efac; background: var(--success-soft); }
html.light .toast.error { color: #b91c1c; }
html.light .toast.success { color: #166534; }

/* ===================================================================
   GLOBAL MOBILE INTERACTION POLISH
   =================================================================== */
@media (max-width: 768px) {
  /* No 300ms tap delay on every interactive primitive. */
  a, button, [role="button"], .nav-item, label, input, select, textarea,
  .bottom-nav-item, .sheet-action, .pill, .chip {
    touch-action: manipulation;
  }
  /* Prevent iOS rubber-band bounce on the body — only intentional scroll
     containers should scroll. (Chat opts out and locks body itself.) */
  html, body {
    overscroll-behavior-y: none;
  }
  /* Modal overlays cover the safe-area corners on notched devices. */
  .app .main .modal-overlay {
    padding-top: max(16px, var(--sai-top));
    padding-bottom: max(16px, calc(var(--sai-bottom) + var(--bottom-nav-h)));
  }
}

/* Subtle floating-action button — used by chat's jump-to-latest and any
   page that wants a thumb-zone primary action. */
.fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.fab:hover { background: var(--accent-hover); }
.fab:active { transform: scale(0.93); }

/* ===================================================================
   Accessibility + feedback utilities (items #5, #7, #8)
   =================================================================== */

/* Skip-to-main link: visually hidden until focused, then pinned top-left. */
.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 10000;
  padding: 10px 16px;
  background: var(--accent);
  color: #1a1400;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.main:focus { outline: none; }

/* Global keyboard focus ring — only shows for keyboard users, not on click. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Inline validation error (item #7). Empty by default; populated by JS. */
.field-error {
  display: block;
  color: #fca5a5;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
  min-height: 0;
}
.field-error:empty { display: none; }
[aria-invalid="true"] {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15) !important;
}

/* Button loading state (item #5): swap label for a spinner, block input. */
@keyframes anton-spin { to { transform: rotate(360deg); } }
.btn.is-loading,
button.is-loading,
.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--accent);
  animation: anton-spin 0.6s linear infinite;
}
/* On primary/yellow buttons the spinner should read against dark text. */
.btn-primary.is-loading::after,
.btn-yellow.is-loading::after { color: #1a1400; }

/* Reduced-motion: kill the spin + transitions for users who opt out. */
@media (prefers-reduced-motion: reduce) {
  .is-loading::after { animation-duration: 1.5s; }
  .skip-link { transition: none; }
}

/* ===== Attach-on-create uploader (New-task popups) =====================
   Used by partials/task_attachments_field.php + styles/task_attachments.js.
   Visual language mirrors the Anton chat composer's pending-file pills so the
   upload experience feels identical across the app. */
.ta-uploader .ta-hint {
  margin-left: auto;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-dim);
}
.ta-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.ta-dropzone:hover,
.ta-dropzone:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  outline: none;
}
.ta-dropzone.ta-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.ta-dropzone-icon { width: 22px; height: 22px; opacity: 0.85; }
.ta-dropzone-text { font-size: 13px; }
.ta-dropzone-text strong { color: var(--accent); font-weight: 600; }

.ta-pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
/* Pending-file pills — same structure/classes as the chat composer. */
.ta-pending .pending-file {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 6px 5px 8px;
  font-size: 12px;
  max-width: 260px;
}
.ta-pending .pending-file-thumb {
  width: 30px; height: 30px;
  border-radius: 5px;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--text-dim);
}
.ta-pending .pending-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ta-pending .pending-file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ta-pending .pending-file-name {
  font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 170px;
}
.ta-pending .pending-file-meta { color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.ta-pending .pending-file-bar {
  display: block;
  height: 3px;
  background: var(--bg);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.ta-pending .pending-file-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear;
}
.ta-pending .pending-file-remove {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 4px;
  font-size: 16px;
  line-height: 1;
}
.ta-pending .pending-file-remove:hover { color: var(--danger); }
.ta-pending .pending-file-uploading { opacity: 0.8; }
.ta-pending .pending-file-error { border-color: var(--danger); }
.ta-pending .pending-file-error .pending-file-meta { color: var(--danger); }
