/* Design tokens. Light and dark are two complete, separate palettes (no inversion).
   Dark = pure AMOLED black. Light = pure white. Components consume tokens only. */

:root {
  --bg: #FFFFFF;
  --bg-elevated: #FAFAFA;
  --bg-overlay: #F5F5F5;
  --surface: #FFFFFF;
  --surface-elevated: #FAFAFA;
  --border-subtle: #F0F0F0;
  --border-default: #E5E5E5;
  --border-strong: #D4D4D4;
  --border-focus: #000000;
  --text-primary: #000000;
  --text-secondary: #525252;
  --text-tertiary: #737373;
  --text-disabled: #A3A3A3;
  --text-placeholder: #6B6B6B;
  --primary: #0B5FFF;
  --primary-hover: #0A4FD6;
  --primary-active: #0841B0;
  --primary-text: #FFFFFF;
  --primary-subtle: rgba(11, 95, 255, 0.10);
  --success: #16A34A;
  --success-subtle: rgba(22, 163, 74, 0.10);
  --warning: #D97706;
  --warning-subtle: rgba(217, 119, 6, 0.10);
  --error: #DC2626;
  --error-subtle: rgba(220, 38, 38, 0.10);
  --info: #2563EB;
  --info-subtle: rgba(37, 99, 235, 0.10);
  --input-bg: #FFFFFF;
  --input-disabled: #FAFAFA;
  --hover-bg: #F5F5F5;
  --shadow-none: none;
  --shadow-menu: 0 1px 2px rgba(0, 0, 0, 0.06);
  --color-scheme: light;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --container: 1120px;
  --touch-target: 44px;
  --z-base: 0;
  --z-sticky: 100;
  --z-nav: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration: 150ms;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #0A0A0A;
    --bg-overlay: #111111;
    --surface: #0D0D0D;
    --surface-elevated: #141414;
    --border-subtle: #1A1A1A;
    --border-default: #262626;
    --border-strong: #333333;
    --border-focus: #FFFFFF;
    --text-primary: #FFFFFF;
    --text-secondary: #B3B3B3;
    --text-tertiary: #808080;
    --text-disabled: #4D4D4D;
    --text-placeholder: #8F8F8F;
    --primary: #4C8DFF;
    --primary-hover: #74A6FF;
    --primary-active: #2F74F5;
    --primary-text: #000000;
    --primary-subtle: rgba(76, 141, 255, 0.10);
    --success: #22C55E;
    --success-subtle: rgba(34, 197, 94, 0.10);
    --warning: #F59E0B;
    --warning-subtle: rgba(245, 158, 11, 0.10);
    --error: #EF4444;
    --error-subtle: rgba(239, 68, 68, 0.10);
    --info: #3B82F6;
    --info-subtle: rgba(59, 130, 246, 0.10);
    --input-bg: #000000;
    --input-disabled: #0A0A0A;
    --hover-bg: #1A1A1A;
    --color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #0A0A0A;
  --bg-overlay: #111111;
  --surface: #0D0D0D;
  --surface-elevated: #141414;
  --border-subtle: #1A1A1A;
  --border-default: #262626;
  --border-strong: #333333;
  --border-focus: #FFFFFF;
  --text-primary: #FFFFFF;
  --text-secondary: #B3B3B3;
  --text-tertiary: #808080;
  --text-disabled: #4D4D4D;
  --text-placeholder: #8F8F8F;
  --primary: #4C8DFF;
  --primary-hover: #74A6FF;
  --primary-active: #2F74F5;
  --primary-text: #000000;
  --primary-subtle: rgba(76, 141, 255, 0.10);
  --success: #22C55E;
  --success-subtle: rgba(34, 197, 94, 0.10);
  --warning: #F59E0B;
  --warning-subtle: rgba(245, 158, 11, 0.10);
  --error: #EF4444;
  --error-subtle: rgba(239, 68, 68, 0.10);
  --info: #3B82F6;
  --info-subtle: rgba(59, 130, 246, 0.10);
  --input-bg: #000000;
  --input-disabled: #0A0A0A;
  --hover-bg: #1A1A1A;
  --color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-elevated: #FAFAFA;
  --bg-overlay: #F5F5F5;
  --surface: #FFFFFF;
  --surface-elevated: #FAFAFA;
  --border-subtle: #F0F0F0;
  --border-default: #E5E5E5;
  --border-strong: #D4D4D4;
  --border-focus: #000000;
  --text-primary: #000000;
  --text-secondary: #525252;
  --text-tertiary: #737373;
  --text-disabled: #A3A3A3;
  --text-placeholder: #6B6B6B;
  --primary: #0B5FFF;
  --primary-hover: #0A4FD6;
  --primary-active: #0841B0;
  --primary-text: #FFFFFF;
  --primary-subtle: rgba(11, 95, 255, 0.10);
  --success: #16A34A;
  --success-subtle: rgba(22, 163, 74, 0.10);
  --warning: #D97706;
  --warning-subtle: rgba(217, 119, 6, 0.10);
  --error: #DC2626;
  --error-subtle: rgba(220, 38, 38, 0.10);
  --info: #2563EB;
  --info-subtle: rgba(37, 99, 235, 0.10);
  --input-bg: #FFFFFF;
  --input-disabled: #FAFAFA;
  --hover-bg: #F5F5F5;
  --color-scheme: light;
}

html { color-scheme: var(--color-scheme); }
body { background: var(--bg); color: var(--text-primary); font-family: var(--font-sans); }

:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

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

.skip-link { position: absolute; left: -9999px; top: 0; z-index: var(--z-toast); background: var(--bg); color: var(--text-primary); padding: var(--space-2) var(--space-4); border: 1px solid var(--border-focus); }
.skip-link:focus { left: var(--space-4); top: var(--space-4); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--touch-target); padding: 0 var(--space-4); border-radius: var(--radius-md); font-weight: 600; border: 1px solid transparent; cursor: pointer; transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease); }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--hover-bg); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--hover-bg); }
.btn-danger { background: #B91C1C; color: #FFFFFF; }
.btn-danger:hover { background: #991B1B; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { width: 100%; min-height: var(--touch-target); padding: var(--space-2) var(--space-3); background: var(--input-bg); color: var(--text-primary); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.field::placeholder { color: var(--text-placeholder); }
.field:focus { border-color: var(--border-focus); outline: none; }
.field:disabled { background: var(--input-disabled); }
.field[aria-invalid="true"] { border-color: var(--error); }

.card { background: var(--surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }

.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border-radius: var(--radius-sm); font-size: 0.8125rem; font-weight: 600; border: 1px solid currentColor; }
.badge-success { color: var(--success); background: var(--success-subtle); }
.badge-warning { color: var(--warning); background: var(--warning-subtle); }
.badge-error { color: var(--error); background: var(--error-subtle); }
.badge-info { color: var(--info); background: var(--info-subtle); }
.badge-neutral { color: var(--text-secondary); background: transparent; }

.progress { height: 8px; background: var(--border-default); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width 400ms var(--ease); }

.skeleton { background: linear-gradient(90deg, var(--border-subtle) 25%, var(--border-default) 50%, var(--border-subtle) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--border-default); vertical-align: top; }
.table th { color: var(--text-secondary); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; }

.toast-region { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-4); pointer-events: none; }
.toast { pointer-events: auto; width: min(100%, 420px); background: var(--surface-elevated); color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); }
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--error); }
.toast-info { border-left: 4px solid var(--info); }
.toast-warning { border-left: 4px solid var(--warning); }

dialog.modal { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: var(--space-6); max-width: min(92vw, 520px); }
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.6); }

.theme-toggle { min-width: var(--touch-target); min-height: var(--touch-target); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: transparent; color: var(--text-primary); border: 1px solid var(--border-default); cursor: pointer; }
.theme-toggle:hover { background: var(--hover-bg); }

/* ===== App shell (signed-in pages) ===== */
.app-shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
@media (min-width: 960px) { .app-shell { grid-template-columns: 264px minmax(0, 1fr); } }
.app-sidebar { display: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: var(--space-4) var(--space-3); background: var(--surface); border-right: 1px solid var(--border-default); }
@media (min-width: 960px) { .app-sidebar { display: block; } }
.app-brand { display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch-target); padding: 0 var(--space-2); font-weight: 700; color: var(--text-primary); text-decoration: none; }
.app-role { margin: 0 0 var(--space-2); padding: 0 var(--space-2); font-size: 0.8125rem; color: var(--text-secondary); }
.app-group { margin-top: var(--space-4); }
.app-group-title { margin: 0 0 var(--space-1); padding: 0 var(--space-2); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); }
.app-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.app-link { display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch-target); padding: 0 var(--space-2); border-radius: var(--radius-md); color: var(--text-secondary); text-decoration: none; font-size: 0.9375rem; }
.app-link:hover { background: var(--hover-bg); color: var(--text-primary); }
.app-link:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.app-link.is-active { background: var(--primary-subtle); color: var(--text-primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.app-link i, .app-link svg { width: 18px; height: 18px; flex: none; }
.app-body { min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: var(--z-nav); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 60px; padding: var(--space-2) var(--space-4); background: var(--bg); border-bottom: 1px solid var(--border-default); }
.app-topbar-start { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.app-topbar-title { margin: 0; font-size: 0.875rem; font-weight: 600; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.app-mobile-menu { position: relative; }
.app-mobile-menu > summary { list-style: none; cursor: pointer; }
.app-mobile-menu > summary::-webkit-details-marker { display: none; }
@media (min-width: 960px) { .app-mobile-menu { display: none; } }
.app-mobile-panel { position: absolute; left: 0; top: calc(100% + 8px); width: min(320px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto; padding: var(--space-3); background: var(--surface-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-menu); z-index: var(--z-overlay); }
.app-main { width: 100%; max-width: 1200px; margin: 0 auto; box-sizing: border-box; padding: var(--space-6) var(--space-4) var(--space-8); }
@media (min-width: 640px) { .app-main { padding-left: var(--space-6); padding-right: var(--space-6); } }
.page-head h1 { margin: 0; }

/* ===== Progress: circles and bars ===== */
.ui-circle { margin: 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); }
.ui-circle-ring { position: relative; width: 120px; height: 120px; }
.ui-circle-ring svg { width: 100%; height: 100%; display: block; }
.ui-circle-track { fill: none; stroke: var(--border-default); stroke-width: 10; }
.ui-circle-value { fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 60px 60px; transition: stroke-dashoffset 0.9s var(--ease); }
.ui-circle-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.25rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.ui-circle-title { font-weight: 600; color: var(--text-primary); }
.ui-circle-caption { margin: 0; font-size: 0.8125rem; color: var(--text-secondary); }
.ui-progress-grid { display: grid; gap: var(--space-6); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: center; }
.ui-bars { display: grid; gap: var(--space-4); min-width: 0; }
.ui-bar-wrap { display: grid; gap: var(--space-1); }
.ui-bar-head { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 0.875rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ui-bar { height: 10px; border-radius: 999px; background: var(--border-default); overflow: hidden; }
.ui-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.9s var(--ease); }
.ui-bar-caption { margin: 0; font-size: 0.8125rem; color: var(--text-tertiary); }
@media (prefers-reduced-motion: reduce) { .ui-circle-value, .ui-bar-fill { transition: none; } }

/* ===== Shell refinements: collapse, badges, mobile bottom bar, toasts, AI ===== */
.app-toggle { min-height: var(--touch-target); min-width: var(--touch-target); padding: 0; display: inline-grid; place-items: center; }
.app-toggle i, .app-toggle svg { width: 20px; height: 20px; }
.app-shell { transition: grid-template-columns 0.2s var(--ease); }
@media (min-width: 960px) {
  .app-shell.is-collapsed, html.sidebar-collapsed .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .app-shell.is-collapsed .app-brand span, html.sidebar-collapsed .app-shell .app-brand span,
  .app-shell.is-collapsed .app-role, html.sidebar-collapsed .app-shell .app-role,
  .app-shell.is-collapsed .app-group-title, html.sidebar-collapsed .app-shell .app-group-title,
  .app-shell.is-collapsed .app-link-label, html.sidebar-collapsed .app-shell .app-link-label { display: none; }
  .app-shell.is-collapsed .app-link, html.sidebar-collapsed .app-shell .app-link { justify-content: center; padding: 0; position: relative; }
  .app-shell.is-collapsed .app-badge, html.sidebar-collapsed .app-shell .app-badge { position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; font-size: 0.6875rem; padding: 0 4px; }
  .app-shell.is-collapsed .app-sidebar, html.sidebar-collapsed .app-shell .app-sidebar { padding-left: var(--space-2); padding-right: var(--space-2); }
  .app-shell.is-collapsed .app-brand, html.sidebar-collapsed .app-shell .app-brand { justify-content: center; padding: 0; }
  .app-shell.is-collapsed .app-group, html.sidebar-collapsed .app-shell .app-group { border-top: 1px solid var(--border-subtle); margin-top: var(--space-3); padding-top: var(--space-3); }
  .app-shell.is-collapsed .app-group:first-of-type, html.sidebar-collapsed .app-shell .app-group:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
}
.app-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--primary-text); font-size: 0.75rem; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.app-avatar-link { display: inline-grid; place-items: center; border-radius: 50%; min-height: var(--touch-target); min-width: var(--touch-target); }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; }
.avatar-initial { background: var(--primary-subtle); color: var(--text-primary); font-weight: 700; font-size: 1.25rem; }
.app-bottom-nav { display: none; }
.app-dot { position: absolute; top: 6px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
@media (max-width: 959px) {
  .app-bottom-nav { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav); background: var(--surface-elevated); border-top: 1px solid var(--border-default); padding-bottom: env(safe-area-inset-bottom); }
  .app-bottom-nav ul { list-style: none; margin: 0; padding: 0 var(--space-2); display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .app-bottom-nav ul::-webkit-scrollbar { display: none; }
  .app-bottom-link { position: relative; display: grid; place-items: center; min-width: 56px; height: 56px; color: var(--text-secondary); border-radius: var(--radius-md); }
  .app-bottom-link i, .app-bottom-link svg { width: 22px; height: 22px; }
  .app-bottom-link.is-active { color: var(--primary); background: var(--primary-subtle); }
  .app-bottom-link:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
  .app-main { padding-bottom: 104px; }
  .toast-region { bottom: calc(68px + env(safe-area-inset-bottom)); left: 0; right: 0; padding: 0 var(--space-3); align-items: stretch; }
  .toast { width: 100%; max-width: none; }
  .app-topbar-title { display: none; }
}
.ai-fab { position: fixed; right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; z-index: var(--z-nav); box-shadow: var(--shadow-menu); cursor: pointer; }
.ai-fab:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 3px; }
/* Mobile: sit above the bottom navigation. Declared after the base rule so it wins. */
@media (max-width: 959px) { .ai-fab { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); } }
.ai-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 48px); border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--surface-elevated); color: var(--text-primary); padding: var(--space-4); }
.ai-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.ai-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.ai-log { max-height: 320px; min-height: 120px; overflow-y: auto; display: grid; gap: var(--space-2); align-content: start; }
.ai-msg { max-width: 88%; padding: 8px 12px; border-radius: var(--radius-md); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); }
.ai-msg-user { justify-self: end; background: var(--primary-subtle); }
.ai-msg-error { background: var(--error-subtle); }
.ai-chat .field { flex: 1; min-width: 0; }
.alert-warning { padding: var(--space-3) var(--space-4); border-left: 4px solid var(--warning); background: var(--warning-subtle); border-radius: var(--radius-md); color: var(--text-primary); }
.app-main .card, .ai-chat { min-width: 0; }
.whitespace-pre-line { white-space: pre-line; }
.break-all { word-break: break-all; }
.min-w-0 { min-width: 0; }
.leading-relaxed { line-height: 1.7; }


/* ===== Readable text in every theme ===== */
select.field option, select.field optgroup { background: var(--input-bg); color: var(--text-primary); }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--bg-overlay); color: var(--text-primary); padding: 1px 5px; border-radius: var(--radius-sm); }
a { text-underline-offset: 3px; }
:root:not([data-theme="dark"]) .badge-success { color: #15803D; }
:root:not([data-theme="dark"]) .badge-warning { color: #92400E; }
:root:not([data-theme="dark"]) .badge-error { color: #B91C1C; }
:root:not([data-theme="dark"]) .badge-info { color: #1D4ED8; }
.table td, .table th { overflow-wrap: anywhere; }
.alert-warning code { background: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ===== Quick-contact: one call button that opens the icons ===== */
.contact-fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + 12px + 56px + 12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 40; }
@media (min-width: 960px) { .contact-fab { bottom: 88px; } }
body:not(:has(.app-shell)) .contact-fab { bottom: calc(20px + env(safe-area-inset-bottom)); }
.contact-fab-toggle { width: 52px; height: 52px; border-radius: 999px; display: grid; place-items: center; background: var(--primary); color: var(--primary-text); border: 1px solid var(--border-strong); box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: pointer; }
.contact-fab-toggle:hover { background: var(--primary-hover); }
.contact-fab-toggle .contact-ico-close { display: none; }
.contact-fab.is-open .contact-fab-toggle .contact-ico-open { display: none; }
.contact-fab.is-open .contact-fab-toggle .contact-ico-close { display: block; }
.contact-fab-list { display: flex; flex-direction: column; gap: 10px; }
.contact-fab-list[hidden] { display: none; }
.contact-fab.is-open .contact-fab-list { animation: fab-in 0.18s var(--ease); }
@keyframes fab-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.contact-fab-link { width: 48px; height: 48px; border-radius: 999px; display: grid; place-items: center; background: var(--primary); color: var(--primary-text); border: 1px solid var(--border-strong); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.contact-fab-link:hover { background: var(--primary-hover); }
.contact-fab-whatsapp { background: #25D366; color: #052e16; border-color: #25D366; }
.contact-fab-whatsapp:hover { background: #1ebe5b; }
.contact-fab-toggle i, .contact-fab-toggle svg, .contact-fab-link i, .contact-fab-link svg { width: 22px; height: 22px; }

/* ===== Public header ===== */
.pub-header { position: sticky; top: 0; z-index: var(--z-nav); background: var(--bg); border-bottom: 1px solid var(--border-default); }
.pub-nav { max-width: var(--container); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-4); }
.pub-brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; color: var(--text-primary); text-decoration: none; flex: none; }
.pub-brand-sub { font-size: 0.875rem; font-weight: 400; color: var(--text-secondary); }
.pub-links { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; }
.pub-link { display: inline-flex; align-items: center; min-height: var(--touch-target); padding: 0 var(--space-3); border-radius: var(--radius-md); font-size: 0.9375rem; color: var(--text-secondary); text-decoration: none; }
.pub-link:hover { background: var(--hover-bg); color: var(--text-primary); }
.pub-link.is-active { color: var(--text-primary); font-weight: 600; background: var(--primary-subtle); }
.pub-actions { display: flex; align-items: center; gap: var(--space-2); }
.pub-burger { display: none; min-width: var(--touch-target); padding: 0; }
.pub-menu { border-top: 1px solid var(--border-default); background: var(--bg); padding: var(--space-3) var(--space-4) var(--space-4); }
.pub-menu[hidden] { display: none; }
.pub-links-stack { flex-direction: column; align-items: stretch; }
.pub-links-stack .pub-link { width: 100%; }
.pub-menu-auth { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-3); }
@media (max-width: 959px) {
  .pub-links-wide, .pub-auth { display: none; }
  .pub-burger { display: inline-grid; place-items: center; }
}
@media (min-width: 960px) { .pub-menu { display: none !important; } }

/* ===== Sidebar drawer on phones (opened by the three-dot button) ===== */
.app-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: calc(var(--z-overlay) - 1); }
.app-scrim[hidden] { display: none; }
body.drawer-lock { overflow: hidden; }
@media (max-width: 959px) {
  .app-shell.drawer-open .app-sidebar { display: block; position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: var(--z-overlay); box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4); }
}

/* ===== Owner cards ===== */
.owner-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.owner-card { width: 100%; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); text-align: left; cursor: pointer; color: var(--text-primary); }
.owner-card:hover { background: var(--hover-bg); border-color: var(--border-strong); }
.owner-thumb { width: 64px; height: 64px; flex: none; border-radius: var(--radius-md); object-fit: cover; border: 1px solid var(--border-default); }
.owner-thumb-empty { display: grid; place-items: center; background: var(--primary-subtle); color: var(--text-primary); }
.owner-card-text { display: grid; gap: 2px; min-width: 0; }
.owner-card-title { font-weight: 600; overflow-wrap: anywhere; }
.owner-card-meta { font-size: 0.8125rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.owner-card-more { font-size: 0.8125rem; color: var(--primary); font-weight: 600; }
.owner-dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-elevated); color: var(--text-primary); padding: var(--space-4); }
.owner-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.owner-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.owner-full { display: block; margin-top: var(--space-3); max-width: 100%; max-height: 60vh; width: auto; height: auto; border-radius: var(--radius-md); border: 1px solid var(--border-default); }

/* ===== Project pictures (public) ===== */
.proj-cover { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-overlay); }
.proj-cover-empty { display: grid; place-items: center; color: var(--text-tertiary); }
.proj-gallery { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.proj-gallery a { display: block; }
.proj-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform 0.15s var(--ease); }
.proj-gallery a:hover .proj-img { transform: scale(1.02); }
.lightbox { max-width: min(96vw, 1100px); max-height: 94vh; padding: var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-elevated); color: var(--text-primary); }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.85); }
.lightbox img { display: block; max-width: 100%; max-height: 78vh; margin: var(--space-3) auto 0; object-fit: contain; }
.lightbox-cap { margin: var(--space-2) 0 0; text-align: center; font-size: 0.875rem; color: var(--text-secondary); }
.lightbox-close { display: block; margin-left: auto; }

/* ===== Time table ===== */
.tt-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; }
.tt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.tt-item { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg); }
.tt-item-own { border-color: var(--primary); background: var(--primary-subtle); }
.tt-time { flex: none; min-width: 6.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.tt-body { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.tt-sub { font-size: 0.8125rem; color: var(--text-secondary); }
.tt-is-today { border-color: var(--primary); }
.tt-today { border-left: 4px solid var(--primary); }
@media (max-width: 420px) { .tt-item { flex-direction: column; gap: 2px; } }

/* ===== Code pages (Original code / Fixed code) ===== */
.code-card { min-width: 0; }
.code-file { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: 1.0625rem; font-weight: 700; font-family: var(--font-mono); }
.code-file i, .code-file svg { width: 18px; height: 18px; flex: none; }
.code-icon-btn { min-width: var(--touch-target); padding: 0; }
.code-icon-btn.is-done { border-color: var(--success); color: var(--success); }
.code-spacer { flex: 1 1 0; }
.code-dialog { width: min(1000px, calc(100vw - 16px)); height: min(86vh, 900px); padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-elevated); color: var(--text-primary); }
.code-dialog[open] { display: flex; flex-direction: column; }
.code-dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.code-dialog-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-default); }
.code-view { flex: 1; margin: 0; padding: var(--space-3) 0; overflow: auto; background: var(--bg); color: var(--text-primary); font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.55; tab-size: 4; }
.code-line { display: flex; min-width: max-content; }
.code-line:hover { background: var(--hover-bg); }
.code-no { flex: none; padding: 0 var(--space-3); text-align: right; color: var(--text-tertiary); user-select: none; white-space: pre; border-right: 1px solid var(--border-default); margin-right: var(--space-3); }
.code-txt { white-space: pre; padding-right: var(--space-4); }
.ai-msg-files { background: var(--success-subtle); max-width: 100%; }
.ai-msg-files ul { margin: 6px 0 0; padding-left: 18px; list-style: disc; }

/* AI assistant: working animation and typing cursor */
.ai-thinking { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 10px; min-width: 190px; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: ai-bounce 1.1s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
.ai-thinking-label { font-size: .875rem; color: var(--text-secondary, inherit); }
.ai-progress { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: var(--border-default); overflow: hidden; position: relative; }
.ai-progress::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; background: var(--primary); border-radius: 2px; animation: ai-slide 1.4s infinite ease-in-out; }
.ai-typing::after { content: "\258C"; margin-left: 2px; color: var(--primary); animation: ai-blink .8s steps(2) infinite; }
@keyframes ai-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-6px); opacity: 1; } }
@keyframes ai-slide { 0% { left: -40%; } 100% { left: 100%; } }
@keyframes ai-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ai-dots i, .ai-progress::after, .ai-typing::after { animation: none; } }

/* Visitors who are not signed in: placeholder values are blurred. The real values are never sent to the browser. */
.gate-blur { filter: blur(7px); user-select: none; pointer-events: none; -webkit-user-select: none; }
.gate-dialog { width: min(440px, calc(100vw - 24px)); border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--surface-elevated); color: var(--text-primary); padding: var(--space-5, 20px); }
.gate-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

/* Cookie notice: fixed to the bottom, capped so it never hides most of a phone screen */
.cookie-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-overlay); background: var(--surface-elevated); color: var(--text-primary); border-top: 1px solid var(--border-strong); max-height: 45vh; overflow-y: auto; }
.cookie-banner[hidden] { display: none; }
@media (max-width: 639px) {
  .cookie-banner { max-height: 40vh; }
  .cookie-banner h2 { font-size: 1rem; }
  .cookie-banner p { font-size: 0.8125rem; line-height: 1.45; }
  .cookie-actions .btn { flex: 1 1 calc(50% - 0.25rem); padding: 0 var(--space-2); font-size: 0.875rem; }
  .cookie-actions .btn-ghost { flex-basis: 100%; }
}

/* Brand logo */
.brand-logo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: block; }
.brand-logo-lg { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto; }

/* Login and register pages */
.auth-page { max-width: 36rem; margin: 0 auto; padding: 1rem 0 2rem; }
.auth-card { padding: 1.5rem; }
.auth-card-wide { max-width: 36rem; }
.auth-brand { display: grid; justify-items: center; gap: 0.5rem; text-decoration: none; color: var(--text-primary); margin-bottom: 1.25rem; }
.auth-brand-name { font-weight: 700; font-size: 1.125rem; }
.auth-brand-sub { font-weight: 400; color: var(--text-secondary); }
.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin: 0; }
.auth-lead { margin: 0.5rem 0 0; text-align: center; font-size: 0.875rem; color: var(--text-secondary); }
.auth-links { margin-top: 1.25rem; display: grid; gap: 0.5rem; text-align: center; font-size: 0.875rem; }
.form-stack { display: grid; gap: 1rem; margin-top: 1.5rem; }
.form-section { border: 0; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.form-legend { font-weight: 600; font-size: 1rem; padding: 0; margin-bottom: 0.25rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .auth-card { padding: 2rem; } }
.field-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }
.field-optional { font-weight: 400; color: var(--text-secondary); }
.field-hint { margin: 0.25rem 0 0; font-size: 0.8125rem; color: var(--text-secondary); }
.field-error { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--error); }
.field-error:empty { display: none; }
.field-with-button { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.field-with-button .field { flex: 1 1 12rem; width: auto; }
.btn-block { width: 100%; }
.check-label { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.875rem; }
.check-label input { margin-top: 0.25rem; min-width: 1.25rem; min-height: 1.25rem; }

/* Logo editor in settings */
.logo-manager { display: grid; gap: 1.5rem; }
@media (min-width: 900px) { .logo-manager { grid-template-columns: 200px 1fr; align-items: start; } }
.logo-current { display: grid; place-items: center; min-height: 160px; border: 1px dashed var(--border-default); border-radius: var(--radius-md); padding: 1rem; }
.logo-current-img { width: 160px; height: 160px; object-fit: contain; }
.logo-canvas { width: 100%; max-width: 320px; height: auto; aspect-ratio: 1 / 1; border: 1px solid var(--border-default); border-radius: var(--radius-md); touch-action: none; cursor: grab; display: block; }
.logo-canvas:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Cloudflare Turnstile widget on the login form */
.auth-turnstile { display: flex; justify-content: center; min-height: 65px; }

/* Start-up loader: logo inside a ring in the Tanzanian flag colours. Hidden as soon as the page has loaded. */
:root { --nav-h: 72px; --flag-green: #1EB53A; --flag-yellow: #FCD116; --flag-blue: #00A3DD; --flag-black: #000000; }
.app-loader { display: none; position: fixed; inset: 0; z-index: 9999; place-items: center; background: var(--bg); transition: opacity .35s ease; }
html[data-native] .app-loader { display: grid; }
.app-loader.is-done { opacity: 0; pointer-events: none; }
.app-loader[hidden] { display: none; }
.app-loader-box { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.app-loader-ring { position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--flag-green) 0 25%, var(--flag-yellow) 0 50%, var(--flag-black) 0 75%, var(--flag-blue) 0 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  animation: app-loader-spin 1.2s linear infinite; }
.app-loader-logo { width: 52px; height: 52px; display: grid; place-items: center; color: var(--text-primary); }
.app-loader-logo img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
@keyframes app-loader-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .app-loader-ring { animation: none; } }

/* Show/hide password: eye icon only */
.pw-toggle { min-width: 44px; display: inline-grid; place-items: center; }
.pw-toggle svg { width: 20px; height: 20px; }
.pw-toggle[aria-pressed="false"] .pw-eye-off, .pw-toggle[aria-pressed="true"] .pw-eye { display: none; }

/* Inline icons used in project engagement */
.inline-icon { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; }
.is-liked { color: var(--error); fill: currentColor; }

/* Website skeleton loader: shown until the page has loaded. Not shown in the mobile app. */
.app-skeleton { position: fixed; inset: 0; z-index: 9998; background: var(--bg); display: flex; flex-direction: column; transition: opacity .3s ease; }
.app-skeleton.is-done { opacity: 0; pointer-events: none; }
.app-skeleton[hidden] { display: none; }
html[data-native] .app-skeleton { display: none; }
.skel-bar, .skel-line, .skel-card { background: var(--bg-overlay); border-radius: 8px; animation: skel-pulse 1.4s ease-in-out infinite; }
.skel-top { height: 56px; border-radius: 0; border-bottom: 1px solid var(--border-default); }
.skel-body { padding: 24px 16px; display: grid; gap: 14px; max-width: 960px; width: 100%; }
.skel-title { height: 32px; width: 45%; }
.skel-wide { height: 16px; width: 90%; }
.skel-short { height: 16px; width: 60%; }
.skel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.skel-card { height: 110px; }
@media (min-width: 960px) { .skel-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@keyframes skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .skel-bar, .skel-line, .skel-card { animation: none; } }

/* Install banner: shown only where the browser allows installing the app */
.install-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-elevated); padding: 12px 16px; margin-bottom: 16px; }
.install-banner[hidden] { display: none; }
.install-text { margin: 0; font-size: .95rem; }
.install-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.install-banner svg { width: 18px; height: 18px; }
