/* Shared Blubuntu visual foundation. Page styles can extend these tokens. */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-solid: #2563eb;          /* fill behind white text (5.2:1) */
  --accent-solid-hover: #1d4ed8;
  --danger-solid: #dc2626;          /* fill behind white text (4.8:1) */
  --danger-solid-hover: #b91c1c;
  --danger: #ef4444;
  --success: #10b981;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #475569;

  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ui-radius-sm: 8px;
  --ui-radius-md: 10px;
  --ui-radius-lg: 14px;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-shadow-card: 0 8px 25px rgb(0 0 0 / 16%);
  --ui-focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-solid: #2563eb;
  --accent-solid-hover: #1d4ed8;
  --danger-solid: #dc2626;
  --danger-solid-hover: #b91c1c;
  --danger: #dc2626;
  --success: #059669;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #cbd5e1;
}

html {
  font-family: var(--ui-font);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--ui-font);
  color: var(--text-main);
  background-color: var(--bg-primary);
}

/* Shared app shell used by Dashboard, Notes, and Settings. */
body > header {
  position: sticky;
  z-index: 100;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: calc(var(--ui-space-3) + env(safe-area-inset-top)) var(--ui-space-4) var(--ui-space-3);
  border-bottom: 0 !important;
  background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.logo-group,
.user-info,
.notif-wrap {
  display: flex;
  align-items: center;
}

.logo-group { gap: var(--ui-space-3); }
.dashboard-profile-link { display:grid; place-items:center; width:40px; height:40px; flex:0 0 40px; overflow:hidden; border:1px solid var(--border); border-radius:var(--ui-radius-sm); background:var(--bg-secondary); color:var(--text-main); text-decoration:none; }
.dashboard-profile-link:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.dashboard-profile-avatar { display:grid; place-items:center; width:100%; height:100%; object-fit:cover; }
.dashboard-profile-initial { color:#fff; background:var(--accent); font-size:1rem; font-weight:750; text-transform:uppercase; }
.user-info { gap: var(--ui-space-2); }
.notif-wrap { position: relative; gap:4px; }
.notif-wrap .header-search-btn { order:-1; }
.notif-wrap .activity-btn,
.notif-wrap .bell-btn { width:44px; height:44px; min-width:44px; min-height:44px; margin:0; padding:0; color:#fff !important; display:inline-grid; place-items:center; border:0; border-radius:50%; background:transparent; }
.notif-wrap .activity-btn { margin-right:0; }
.notif-wrap .activity-btn i,
.notif-wrap .bell-btn i { color:inherit; font-size:1.22rem; }
.notif-wrap .activity-btn:hover,
.notif-wrap .bell-btn:hover { color:#fff !important; background:color-mix(in srgb,#fff 12%,transparent); }
.notif-wrap .activity-btn.is-working,
.notif-wrap .activity-btn.is-working i { color:#fff !important; }
.notif-wrap .activity-btn.is-done,
.notif-wrap .activity-btn.is-done i { color:#fff !important; }
.notif-wrap .bell-btn.has-unread,
.notif-wrap .bell-btn.has-unread i { color:#fff !important; }

.logo {
  color: var(--accent);
  font-size: clamp(1.6rem, 3.6vw, 1.85rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.logo.page-title { color:#fff; font-size: clamp(2.1rem, 4.8vw, 2.45rem); }

.hamburger-btn,
.bell-btn,
.activity-btn,
.close-drawer-btn {
  color: var(--text-main);
  border: none;
  border-radius: 0;
  background: transparent;
}

.hamburger-btn {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  cursor: pointer;
}

.bell-btn,
.activity-btn {
  position: relative;
  display: inline-grid;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  place-items: center;
  cursor: pointer;
  border: none;
  background: transparent;
  border-radius: 0;
}

.notif-badge { position:absolute; top:2px; right:2px; width:9px; height:9px; padding:0; border:2px solid var(--bg-primary); border-radius:50%; background:var(--danger); }
.notif-badge.hidden { display:none; }
.notif-panel {
  position:absolute;
  top:calc(100% + 6px);
  right:0;
  z-index:4000;
  display:none;
  flex-direction:column;
  width:min(290px, 88vw);
  max-height:70vh;
  overflow-y:auto;
  color:var(--text-main);
  background:var(--bg-secondary);
  border:1px solid var(--border);
  border-radius:var(--ui-radius-md);
  box-shadow:var(--ui-shadow-card);
}
.notif-panel.active { display:flex; }
.notif-panel-header { display:flex; align-items:center; justify-content:space-between; padding:10px 12px; border-bottom:1px solid var(--border); font-size:.8rem; font-weight:600; }
.notif-clear-btn { padding:4px 8px; color:var(--accent); background:transparent; border:0; font-size:.72rem; font-weight:600; cursor:pointer; }
.notif-panel-list { display:flex; flex-direction:column; gap:6px; padding:8px; }
.notif-item { display:flex; align-items:flex-start; gap:8px; padding:8px 10px; color:var(--text-main); background:var(--bg-primary); border:1px solid var(--border); border-radius:8px; font-size:.78rem; line-height:1.4; }
.notif-item span { flex:1; min-width:0; overflow-wrap:anywhere; }
.notif-item i { flex-shrink:0; margin-top:2px; }
.notif-item.error { border-color:var(--danger); }
.notif-item.success { border-color:var(--success); }
.notif-panel .empty-state { padding:16px; color:var(--text-muted); text-align:center; font-size:.8rem; }

.drawer-overlay {
  position: fixed;
  z-index: 1100;
  inset: 0;
  background: rgb(2 6 23 / 58%);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.side-drawer {
  position: fixed;
  z-index: 1200;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: min(320px, 88vw);
  height: 100vh;
  height: 100dvh;
  padding: var(--ui-space-4);
  color: var(--text-main);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  box-shadow: var(--ui-shadow-card);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--ui-space-3);
  border-bottom: 1px solid var(--border);
}

.drawer-title { color: var(--text-main); font-size: 1.05rem; font-weight: 700; }
.close-drawer-btn { width: 36px; height: 36px; cursor: pointer; }
.drawer-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: var(--ui-space-2); min-height: 0; padding: var(--ui-space-3) 0; overflow-y: auto; }
.user-profile-card,
.storage-box,
.drawer-nav-link {
  color: var(--text-main);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-md);
}
.user-profile-card { display: flex; align-items: center; gap: var(--ui-space-3); padding: var(--ui-space-3); text-decoration: none; }
.drawer-nav-link { display: flex; align-items: center; gap: var(--ui-space-3); min-height: 46px; padding: 10px 12px; text-decoration: none; }
.drawer-nav-link:hover,
.user-profile-card:hover { border-color: var(--accent); }

.bottom-nav {
  position: fixed !important;
  z-index: 10000 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-around !important;
  width: 100% !important;
  height: calc(68px + env(safe-area-inset-bottom)) !important;
  min-height: 68px !important;
  margin: 0 !important;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom)) !important;
  background: color-mix(in srgb, var(--bg-secondary) 94%, transparent) !important;
  border-top: 1px solid var(--border) !important;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.bottom-nav .nav-item {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  max-width: 140px;
  height: 100%;
  min-height: 48px;
  padding: 6px 8px;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--ui-radius-md);
  font-size: .72rem;
  text-decoration: none;
  cursor: pointer;
}

.bottom-nav .nav-item i { font-size: 1.2rem; }
.bottom-nav .nav-item:hover,
.bottom-nav .nav-item.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.bottom-nav .nav-fab {
  display: grid;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  margin-top: -22px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-hover));
  border: 4px solid var(--bg-primary);
  border-radius: 50%;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  cursor: pointer;
}

/* Shared cards and controls; layout-specific class rules remain in page CSS. */
.settings-card,
.note-item {
  border-radius: var(--ui-radius-lg);
}

.settings-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--ui-shadow-card);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  color: var(--text-main);
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-md);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ui-focus-ring);
}

:where(.btn-primary, .btn-danger, .btn-secondary, .action-btn, .btn-action) {
  min-height: 40px;
  border-radius: var(--ui-radius-md);
  font-family: var(--ui-font);
  font-weight: 600;
}

:where(button, input, select, textarea) {
  font: inherit;
}

:where(button, input, select, textarea, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:where(button, input, select, textarea):disabled {
  cursor: not-allowed;
}

/* Shared page-level polish across feature, account, and public pages. */
:where(h1, h2, h3, h4) {
  color: var(--text-main);
  letter-spacing: -0.015em;
}
:where(h1) { font-size: clamp(1.8rem, 4vw, 2.25rem); line-height: 1.15; }
:where(h2) { font-size: clamp(1.4rem, 3.2vw, 1.75rem); line-height: 1.2; }
:where(h3) { font-size: clamp(1.12rem, 2.4vw, 1.35rem); line-height: 1.25; }

:where(p, small, .text-muted, .description) {
  line-height: 1.55;
}

:where(.btn-primary, .btn-danger, .btn-secondary, .action-btn, .btn-action, .btn-submit, .btn-post, .upl-submit) {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}

:where(.btn-primary, .btn-submit, .btn-post, .upl-submit) {
  background-color: var(--accent);
  border-color: var(--accent);
}

:where(.btn-primary, .btn-submit, .btn-post, .upl-submit):hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

:where(.settings-card, .panel, .card, .modal-card) {
  border-color: var(--border);
}

:where(.modal-card, .settings-card) {
  color: var(--text-main);
}

:where(.empty-state) {
  color: var(--text-muted);
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

body > .container {
  width: min(100% - 32px, 1120px);
  margin-right: auto;
  margin-left: auto;
}
body > .container.dashboard-home-container,
body > .container.docs-container,
body > .container.photos-container {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

@media (max-width: 520px) {
  .logo { font-size: 1.32rem; }
  .logo.page-title { color:#fff; font-size: clamp(1.8rem, 5.6vw, 2rem); }
}

@media (min-width: 900px) {
  .side-drawer { width: 320px; }
  .bottom-nav { padding-right: max(24px, calc((100vw - 1120px) / 2)) !important; padding-left: max(24px, calc((100vw - 1120px) / 2)) !important; }
}

@media (max-width: 700px) {
  body > header {
    min-height: 56px;
    padding-right: 12px;
    padding-left: 12px;
  }
  .logo { font-size: 1.08rem; }
  .logo.page-title { color:#fff; font-size: clamp(1.7rem, 5.7vw, 1.9rem); }
  .user-info { gap: 6px; }
  .notif-wrap { gap: 2px; }
  body > .container {
    width: 100%;
    padding-right: 12px;
    padding-left: 12px;
  }
  .side-drawer { width: min(320px, 88vw); }
  .bottom-nav .nav-item { font-size: .68rem; }
}

@media (max-width: 380px) {
  .bottom-nav { padding-right: 6px !important; padding-left: 6px !important; }
  .bottom-nav .nav-item { padding-right: 3px; padding-left: 3px; }
  .bottom-nav .nav-item i { font-size: 1.08rem; }
  /* The upload button keeps its full 56px size here. It used to shrink to 50px, but bottom-nav.css (more specific) kept its width at 56px,
     so on phones 380px wide or narrower it was squashed into an oval. */
}

@media (prefers-color-scheme: dark) {
  [data-theme="dark"] { color-scheme: dark; }
}

@media (prefers-color-scheme: light) {
  [data-theme="light"] { color-scheme: light; }
}

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


/* ==========================================================================
   Accessibility and consistency layer (loaded on every page)
   ========================================================================== */

/* Contrast: secondary text and the light-theme success green were just under the 4.5:1 readability line.
   Higher specificity than each page's own copy of the theme colours, so one edit fixes every page. */
html[data-theme="dark"] { --text-muted: #9faec3; }
html[data-theme="light"] { --text-muted: #607087; --success: #047857; }

/* Filled buttons: white text needs a deeper fill than the shared accent has. */
html .btn-primary { background: var(--accent-solid); color: #fff; }
html .btn-primary:hover:not(:disabled) { background: var(--accent-solid-hover); }

/* Screen-reader-only text (still read aloud, not shown). */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* One look for "nothing here yet", loading and errors. Low specificity, so a page's own version still wins. */
:where(.empty-state) {
  padding: 22px 16px; text-align: center; color: var(--text-muted);
  font-size: 0.9rem; line-height: 1.5;
}
:where(.empty-state i) { display: block; margin-bottom: 8px; font-size: 1.6rem; opacity: 0.7; }
:where(.inline-error) {
  display: block; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
  border-radius: var(--ui-radius-sm); background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--text-main); font-size: 0.85rem; line-height: 1.45;
}
:where(.inline-error)[role="alert"]:empty { display: none; }
.ui-spinner {
  display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -0.2em;
  border: 2px solid color-mix(in srgb, var(--text-muted) 40%, transparent);
  border-top-color: var(--accent); border-radius: 50%; animation: ui-spin 0.8s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* Keyboard users see where they are on controls that are not real buttons, too. */
:where([role="button"][tabindex], [role="tab"][tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* People who ask their device for less motion get it (spinners keep turning: they show that work is happening). */
@media (prefers-reduced-motion: reduce) {
  *:not(.fa-spin):not(.ui-spinner), *:not(.fa-spin):not(.ui-spinner)::before, *:not(.fa-spin):not(.ui-spinner)::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}
