/* ============================================================
   Graphico Pro — styles.css (Ultra‑Premium Edition)
   Dark enterprise dashboard with glass, ripples & animations.
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS (CSS Custom Properties)
   ============================================================ */

:root {
  /* ── Cool-tone psychology palette ──
     Trust · Clarity · Depth · Intelligence
     Arctic navy + glacier cyan + soft aurora violet
  */
  --color-canvas:         #060A12;
  --color-surface:        #0C1220;
  --color-surface-2:      #121A2B;
  --color-surface-3:      #1A2438;
  --color-hairline:       #243049;
  --color-hairline-soft:  rgba(94, 234, 212, 0.12);

  --color-ink:            #E8F0FA;
  --color-ink-muted:      #8BA3C7;
  --color-ink-faint:      rgba(139, 163, 199, 0.42);
  --color-ink-inverse:    #061018;

  /* Accent retained as --color-brass for compatibility; cool glacier cyan */
  --color-brass:          #5EEAD4;
  --color-brass-dim:      #2DD4BF;
  --color-brass-glow:     rgba(94, 234, 212, 0.28);
  --color-brass-subtle:   rgba(94, 234, 212, 0.09);

  --color-violet:         #818CF8;
  --color-violet-glow:    rgba(129, 140, 248, 0.22);

  --color-ice:            #7DD3FC;
  --color-ice-glow:       rgba(125, 211, 252, 0.25);
  --color-aurora-mid:     #A78BFA;

  --color-success:        #34D399;
  --color-success-bg:     rgba(52, 211, 153, 0.12);
  --color-warning:        #FBBF24;
  --color-warning-bg:     rgba(251, 191, 36, 0.12);
  --color-danger:         #F87171;
  --color-danger-bg:      rgba(248, 113, 113, 0.12);
  --color-info:           #38BDF8;
  --color-info-bg:        rgba(56, 189, 248, 0.12);

  --color-code-bg:        #080E18;
  --color-code-border:    #1A2438;
  --color-code-text:      #D6E4F5;
  --color-inline-code-bg: rgba(129, 140, 248, 0.16);

  --font-display:   "Outfit", "Space Grotesk", sans-serif;
  --font-body:      "DM Sans", "Inter", sans-serif;
  --font-mono:      "IBM Plex Mono", monospace;

  --text-2xs:  0.6875rem;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semi:    600;
  --weight-bold:    700;

  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-normal: 1.5;
  --leading-relaxed:1.65;

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --radius-sm:  0.375rem;
  --radius-md:  0.5rem;
  --radius-lg:  0.75rem;
  --radius-xl:  1rem;
  --radius-2xl: 1.25rem;
  --radius-full: 9999px;

  --shadow-sm:  0 1px 2px rgba(0, 8, 20, 0.45);
  --shadow-md:  0 4px 16px rgba(0, 8, 20, 0.5);
  --shadow-lg:  0 12px 40px rgba(0, 8, 20, 0.55);
  --shadow-xl:  0 24px 64px rgba(0, 10, 28, 0.65);
  --shadow-brass: 0 0 0 3px var(--color-brass-glow);
  --shadow-card-hover: 0 12px 40px rgba(0, 12, 32, 0.55), 0 0 0 1px var(--color-brass-glow);

  --duration-fast:   150ms;
  --duration-normal: 250ms;
  --duration-slow:   400ms;
  --ease-out:        cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:     cubic-bezier(0.4, 0, 0.2, 1);

  --z-base:     1;
  --z-dropdown: 20;
  --z-sticky:   30;
  --z-overlay:  40;
  --z-modal:    50;
  --z-toast:    60;
  --z-loading:  70;

  --sidebar-width:   16rem;
  --header-height:   4rem;
  --content-max-w:   72rem;

  /* Cool radiant system */
  --color-brass-2:        #99F6E4;
  --color-brass-radiant:  linear-gradient(135deg, #99F6E4 0%, #5EEAD4 40%, #2DD4BF 100%);
  --color-violet-2:       #A5B4FC;
  --color-aurora:         linear-gradient(125deg, #5EEAD4 0%, #7DD3FC 35%, #818CF8 70%, #A78BFA 100%);
  --color-aurora-soft:    linear-gradient(160deg, rgba(94,234,212,.15) 0%, rgba(125,211,252,.08) 40%, rgba(129,140,248,.12) 100%);
  --color-glass-fill:     rgba(125, 211, 252, 0.04);
  --color-glass-border:   rgba(148, 200, 255, 0.12);
  --color-glass-sheen:    rgba(255, 255, 255, 0.06);
  --noise-opacity:        .035;

  --shadow-xs:      0 1px 1px rgba(0, 8, 20, 0.4);
  --shadow-2xl:     0 32px 90px rgba(0, 10, 28, 0.75), 0 4px 16px rgba(0, 8, 20, 0.5);
  --shadow-inset-hairline: inset 0 1px 0 rgba(180, 220, 255, 0.06);
  --shadow-glow-brass: 0 0 28px rgba(94, 234, 212, 0.35), 0 0 2px rgba(94, 234, 212, 0.55);
  --shadow-glow-violet: 0 0 28px rgba(129, 140, 248, 0.32), 0 0 2px rgba(129, 140, 248, 0.5);
  --shadow-glow-ice: 0 0 32px rgba(125, 211, 252, 0.3);
  --shadow-focus-ring: 0 0 0 1px var(--color-canvas), 0 0 0 4px var(--color-brass-glow);

  --duration-xfast:   80ms;
  --duration-xslow:   450ms;
  --ease-silk:        cubic-bezier(.16,1,.3,1);
  --ease-snap:        cubic-bezier(.5,0,.1,1);
  --ease-elastic:     cubic-bezier(.68,-0.55,.27,1.55);

  --tilt-perspective: 900px;
}


/* ============================================================
   2. RESET & BASE
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html.dark {
  color-scheme: dark;
}

body {
  background-color: var(--color-canvas);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  position: relative;
  overflow: hidden;  /* For ripple */
  transition: transform var(--duration-fast) var(--ease-standard);
}

button:active {
  transform: scale(0.96);
}

/* Ripple effect via pseudo‑element */
button::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

button:active::after {
  opacity: 1;
  transition: none;
}

a {
  color: var(--color-brass);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul, ol {
  list-style: revert;
  padding-left: 1.5rem;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  line-height: var(--leading-tight);
}

p {
  line-height: var(--leading-relaxed);
}

dialog {
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
}

::selection {
  background-color: var(--color-brass-glow);
  color: var(--color-ink);
}


/* ============================================================
   3. CUSTOM SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-hairline);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-ink-faint);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-hairline) transparent;
}


/* ============================================================
   4. FOCUS STATES
   ============================================================ */

:focus {
  outline: none;
}

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

.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--color-brass);
  color: var(--color-canvas);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  z-index: var(--z-loading);
  transform: translateY(-200%);
  transition: transform var(--duration-fast) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: none;
}


/* ============================================================
   5. GLOBAL LOADING BAR
   ============================================================ */

#loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-brass-glow);
  z-index: var(--z-loading);
  display: none;
  overflow: hidden;
}

#loading-bar.is-active {
  display: block;
}

#loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--color-brass), var(--color-violet), var(--color-brass));
  background-size: 200% 100%;
  animation: loading-sweep 1.4s ease-in-out infinite;
}

@keyframes loading-sweep {
  0%   { left: -40%; width: 40%; }
  50%  { left: 40%;  width: 50%; }
  100% { left: 110%; width: 40%; }
}


/* ============================================================
   6. TOAST NOTIFICATIONS
   ============================================================ */

#toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  width: 100%;
  max-width: 22rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-hairline);
  background: rgba(23,24,28,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--color-hairline-soft);
  font-size: var(--text-sm);
  animation: toast-in var(--duration-slow) var(--ease-spring) both;
}

.toast.is-removing {
  animation: toast-out var(--duration-normal) var(--ease-out) both;
}

.toast--success { border-left: 3px solid var(--color-success); }
.toast--error   { border-left: 3px solid var(--color-danger); }
.toast--warning { border-left: 3px solid var(--color-warning); }
.toast--info    { border-left: 3px solid var(--color-info); }

.toast__icon {
  font-size: var(--text-base);
  line-height: 1;
  flex-shrink: 0;
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-weight: var(--weight-medium);
  color: var(--color-ink);
  line-height: var(--leading-snug);
}

.toast__message {
  color: var(--color-ink-muted);
  margin-top: 2px;
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}

.toast__close {
  flex-shrink: 0;
  color: var(--color-ink-muted);
  padding: 0;
  line-height: 1;
  opacity: .6;
  transition: opacity var(--duration-fast);
}

.toast__close:hover { opacity: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(2rem) scale(.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(2rem) scale(.9); }
}


/* ============================================================
   7. APP WRAPPER
   ============================================================ */

#app {
  min-height: 100vh;
  background: radial-gradient(ellipse 60% 40% at 20% 30%, var(--color-brass-subtle) 0%, transparent 70%),
              radial-gradient(ellipse 60% 40% at 80% 70%, var(--color-violet-glow) 0%, transparent 70%),
              var(--color-canvas);
  background-attachment: fixed;
}


/* ============================================================
   8. LOGIN / AUTH SCREEN
   ============================================================ */

#view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background:
    radial-gradient(ellipse 60% 40% at 50% -10%, var(--color-brass-subtle) 0%, transparent 70%),
    var(--color-canvas);
}

.login-card-accent {
  height: 2px;
  background: linear-gradient(90deg, var(--color-brass) 0%, var(--color-violet) 50%, var(--color-brass) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: shimmer 3s linear infinite;
}

.login-card {
  width: 100%;
  max-width: 22rem;
}

.login-card__inner {
  background: rgba(23,24,28,.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-hairline);
  border-top: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: var(--space-8) var(--space-8) var(--space-10);
  box-shadow: var(--shadow-xl), 0 0 40px var(--color-brass-glow);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.login-logo__dot {
  height: 10px;
  width: 10px;
  border-radius: var(--radius-full);
  background: var(--color-brass);
  box-shadow: 0 0 12px var(--color-brass-glow);
  animation: pulse-glow 2s ease-in-out infinite;
}

.login-logo__name {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: var(--text-lg);
  letter-spacing: -.01em;
}

.login-heading {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semi);
  margin-bottom: var(--space-2);
  line-height: var(--leading-snug);
}

.login-subheading {
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-8);
}

.login-note {
  color: var(--color-ink-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  margin-top: var(--space-6);
}


/* ============================================================
   9. DASHBOARD SHELL
   ============================================================ */

#view-dashboard {
  display: flex;
  min-height: 100vh;
}

#view-dashboard.hidden {
  display: none;
}


/* ============================================================
   10. SIDEBAR
   ============================================================ */

#sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: var(--z-sidebar);
  width: min(var(--sidebar-width), 85vw);
  max-width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(23,24,28,.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--color-hairline);
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-out),
              box-shadow var(--duration-slow) var(--ease-out);
  will-change: transform;
  /* Fallback in case JS toggles visibility instead of transform */
  visibility: visible;
}

/* Open state — matches whichever class convention the JS uses.
   !important guarantees this always wins over the closed base rule
   regardless of stylesheet load order. */
#sidebar.is-open,
#sidebar.translate-x-0,
#sidebar.open,
#sidebar.sidebar-open,
#sidebar.show,
#sidebar.active,
#sidebar[data-open="true"],
#sidebar[aria-hidden="false"],
body.sidebar-open #sidebar {
  transform: translateX(0) !important;
  box-shadow: var(--shadow-xl);
}

/* Explicit closed state, in case JS toggles this class on/off
   instead of simply removing the open class */
#sidebar.-translate-x-full,
#sidebar.is-closed,
#sidebar.closed {
  transform: translateX(-100%) !important;
}

@media (min-width: 768px) {
  #sidebar {
    position: static;
    width: var(--sidebar-width);
    max-width: none;
    transform: none !important;
    box-shadow: none;
    will-change: auto;
    backdrop-filter: none;
    background: var(--color-surface);
  }
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--color-hairline);
  flex-shrink: 0;
}

.sidebar-logo-dot {
  height: 10px;
  width: 10px;
  border-radius: var(--radius-full);
  background: var(--color-brass);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--color-brass-glow);
}

.sidebar-logo-name {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  letter-spacing: -.01em;
  font-size: var(--text-base);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
}

.sidebar-nav__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-ink-muted);
  border-left: 2px solid transparent;
  transition:
    background var(--duration-normal),
    color var(--duration-normal),
    border-color var(--duration-normal),
    transform var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-normal);
  text-align: left;
  letter-spacing: -.005em;
  position: relative;
}

.sidebar-nav__item:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.sidebar-nav__item[aria-selected="true"],
.sidebar-nav__item.is-active {
  background: var(--color-surface-2);
  color: var(--color-ink);
  border-left-color: var(--color-brass);
  box-shadow: inset 0 0 0 1px var(--color-brass-glow);
}

.sidebar-nav__item:focus-visible {
  outline: 2px solid var(--color-brass);
  outline-offset: 1px;
}

.sidebar-nav__icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: .75;
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}

.sidebar-nav__item:hover .sidebar-nav__icon,
.sidebar-nav__item.is-active .sidebar-nav__icon {
  opacity: 1;
  transform: scale(1.1);
}

.sidebar-section-label {
  padding: var(--space-5) var(--space-3) var(--space-2);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-ink-faint);
}

.sidebar-divider {
  border-top: 1px solid var(--color-hairline);
  margin: var(--space-3) 0;
}

.sidebar-nav__item--disabled {
  cursor: not-allowed;
  pointer-events: none;
  color: rgba(154,156,165,.3);
}

.sidebar-nav__badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-ink-faint);
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: var(--z-overlay);
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

#sidebar-backdrop.is-visible,
#sidebar-backdrop.show,
#sidebar-backdrop.active,
body.sidebar-open #sidebar-backdrop {
  display: block;
  opacity: 1;
}

@media (max-width: 767px) {
  #sidebar-backdrop:not(.hidden) {
    display: block;
  }
}

/* Prevent the page from scrolling behind the sidebar while it's
   open on mobile — add/remove the .sidebar-open class on <body> */
@media (max-width: 767px) {
  body.sidebar-open {
    overflow: hidden;
  }
}

@media (min-width: 768px) {
  #sidebar-backdrop {
    display: none !important;
  }
}


/* ============================================================
   11. HEADER (Glassmorphism)
   ============================================================ */

#app-header {
  height: var(--header-height);
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-hairline);
  background: rgba(23,24,28,.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  position: sticky;
  top: 0;
  z-index: var(--z-raised);
  box-shadow: 0 2px 16px rgba(0,0,0,.2);
}

@media (min-width: 768px) {
  #app-header {
    padding: 0 var(--space-6);
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

#panel-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  #panel-title {
    font-size: var(--text-lg);
  }
}

#user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-hairline);
  object-fit: cover;
  background: var(--color-surface-2);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--color-brass-glow);
}

.user-meta {
  display: none;
  flex-direction: column;
  line-height: var(--leading-tight);
  text-align: right;
}

@media (min-width: 640px) {
  .user-meta {
    display: flex;
  }
}

#user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-ink);
  line-height: 1.2;
}

#user-email {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  line-height: 1.2;
}

#sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
  width: 2.25rem;
  border-radius: var(--radius-md);
  color: var(--color-ink-muted);
  transition: background var(--duration-fast), color var(--duration-fast);
  position: relative;
  z-index: calc(var(--z-sidebar) + 1);
  cursor: pointer;
}

#sidebar-toggle-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
}

@media (min-width: 768px) {
  #sidebar-toggle-btn {
    display: none;
  }
}


/* ============================================================
   12. MAIN CONTENT AREA
   ============================================================ */

.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#main-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}


/* ============================================================
   13. PROJECTS PANEL
   ============================================================ */

#panel-projects {
  padding: var(--space-4);
  animation: panel-in var(--duration-slow) var(--ease-out) both;
}

@media (min-width: 768px) {
  #panel-projects {
    padding: var(--space-8);
  }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.panel-heading {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semi);
  line-height: var(--leading-snug);
}

.panel-subheading {
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  margin-top: var(--space-1);
  line-height: var(--leading-relaxed);
}

#project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  width: 100%;
  min-width: 0;
}

@media (min-width: 480px) {
  #project-grid {
    gap: var(--space-4);
  }
}

@media (min-width: 640px) {
  #project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1280px) {
  #project-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1536px) {
  #project-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.project-card {
  border-top: 2px solid rgba(201,161,91,.5);
  background: var(--color-surface);
  border-left: 1px solid var(--color-hairline);
  border-right: 1px solid var(--color-hairline);
  border-bottom: 1px solid var(--color-hairline);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition:
    border-color var(--duration-normal),
    box-shadow var(--duration-normal),
    transform var(--duration-normal) var(--ease-standard);
  cursor: pointer;
  overflow: visible;
  position: relative;
}

.project-card:hover {
  border-top-color: var(--color-brass);
  box-shadow: var(--shadow-card-hover), 0 8px 30px rgba(201,161,91,.15);
  transform: translateY(-4px) scale(1.01);
}

.project-card:active {
  transform: scale(0.98);
}

.project-card:has(.project-actions-menu:not(.hidden)),
.project-card.is-menu-open {
  z-index: 20;
  overflow: visible;
}

/* Project actions (⋮) menu */
.project-actions {
  position: relative;
  flex-shrink: 0;
  z-index: 5;
}

.project-actions-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.75rem;
  width: 1.75rem;
  min-height: 1.75rem;
  min-width: 1.75rem;
  border-radius: var(--radius-md);
  color: var(--color-ink-muted);
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 6;
  transition: background var(--duration-fast), color var(--duration-fast), transform var(--duration-fast);
}

.project-actions-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
  transform: scale(1.1);
}

.project-actions-btn[aria-expanded="true"] {
  background: var(--color-surface-2);
  color: var(--color-ink);
}

.project-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 10rem;
  padding: var(--space-1) 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-hairline);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  animation: scale-in var(--duration-fast) var(--ease-spring) both;
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.project-actions-menu.hidden {
  display: none !important;
}

.project-actions-menu button,
.project-actions-menu [role="menuitem"] {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-ink);
  background: transparent;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--duration-fast);
}

.project-actions-menu button:hover,
.project-actions-menu [role="menuitem"]:hover {
  background: var(--color-surface);
  transform: none;
}

.project-actions-menu .delete-project-btn {
  color: var(--color-danger);
}

.project-actions-menu .delete-project-btn:hover {
  background: var(--color-danger-bg);
}

#project-grid {
  overflow: visible;
  position: relative;
}

.project-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.project-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  line-height: var(--leading-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  flex-shrink: 0;
}

.project-status-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-success);
  flex-shrink: 0;
}

.project-status-dot--archived { background: var(--color-warning); }
.project-status-dot--deleted  { background: var(--color-danger); }
.project-status-dot--draft    { background: var(--color-ink-muted); }

.project-description {
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  line-height: var(--leading-relaxed);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.project-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-hairline);
  margin-top: auto;
}

.project-updated {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-faint);
}

.open-project-btn {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-brass);
  transition: color var(--duration-fast), transform var(--duration-fast);
}

.open-project-btn:hover {
  color: var(--color-brass-dim);
  transform: translateX(4px);
}

#project-empty-state {
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  border: 1px dashed var(--color-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  line-height: var(--leading-relaxed);
}

.empty-state-icon {
  margin: 0 auto var(--space-3);
  opacity: .3;
}


/* ============================================================
   14. CHAT / WORKSPACE PANEL (Locked composer)
   ============================================================ */

#panel-chat {
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

#panel-chat.hidden {
  display: none;
}

@media (min-width: 768px) {
  #panel-chat {
    padding: var(--space-8) var(--space-8) 0;
  }
}

@media (max-width: 767px) {
  #panel-chat {
    padding: var(--space-4) var(--space-4) 0;
  }
}

/* Workspace header & controls — fixed at top of panel */
#panel-chat > .flex-wrap:first-of-type,
#panel-chat > [role="radiogroup"],
#image-options {
  flex-shrink: 0;
}

/* Mode toggle */
.mode-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-hairline);
  background: var(--color-surface-2);
  margin-bottom: var(--space-4);
  align-self: flex-start;
}

.mode-toggle__btn {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-ink-muted);
  transition:
    background var(--duration-fast),
    color var(--duration-fast),
    transform var(--duration-fast);
}

.mode-toggle__btn:hover {
  color: var(--color-ink);
  transform: scale(1.05);
}

.mode-toggle__btn[aria-checked="true"] {
  background: var(--color-brass);
  color: var(--color-canvas);
  box-shadow: 0 2px 8px var(--color-brass-glow);
}

.mode-toggle__btn:focus-visible {
  outline: 2px solid var(--color-brass);
  outline-offset: 1px;
}

.workspace-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

#image-options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-hairline);
  background: rgba(30,32,36,.7);
  backdrop-filter: blur(8px);
}

#image-options.hidden { display: none; }

.image-option-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.image-option-label {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  font-weight: var(--weight-medium);
}

/* Chat history — scrollable area */
#chat-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-hairline);
  background: var(--color-surface);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  scroll-behavior: smooth;
}

#chat-history:empty::after {
  content: "No messages yet. Say something to get started.";
  display: block;
  color: var(--color-ink-faint);
  font-size: var(--text-sm);
  text-align: center;
  margin: auto;
}

/* Image results */
#image-results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-shrink: 0;
}

#image-results.hidden { display: none; }

@media (min-width: 768px) {
  #image-results {
    grid-template-columns: repeat(3, 1fr);
  }
}

.image-result {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-hairline);
  background: var(--color-surface-2);
  aspect-ratio: 1;
  animation: msg-in var(--duration-slow) var(--ease-standard) both;
  transition: transform var(--duration-normal) var(--ease-standard), box-shadow var(--duration-normal);
}

.image-result:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.image-result-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Chat message bubble */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-width: 85%;
  animation: msg-in var(--duration-normal) var(--ease-standard) both;
}

.chat-message--user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message--assistant,
.chat-message--system {
  align-self: flex-start;
  align-items: flex-start;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.message-role {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
}

.message-timestamp {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-ink-faint);
}

.message-content {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  word-break: break-word;
}

.chat-message--user .message-content {
  background: var(--color-brass-glow);
  border: 1px solid var(--color-brass-dim);
  color: var(--color-ink);
  white-space: pre-wrap;
}

.chat-message--assistant .message-content {
  background: var(--color-surface-2);
  border: 1px solid var(--color-hairline);
  color: var(--color-ink);
}

.chat-message--system .message-content {
  background: transparent;
  border: 1px dashed var(--color-hairline);
  color: var(--color-ink-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* ============================================================
   14b. MARKDOWN CONTENT STYLING (inside .message-content)
   ============================================================ */

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  color: var(--color-ink);
  margin: var(--space-3) 0 var(--space-1);
  line-height: var(--leading-snug);
}

.message-content h1 { font-size: var(--text-xl); }
.message-content h2 { font-size: var(--text-lg); }
.message-content h3 { font-size: var(--text-base); }

.message-content p {
  margin: var(--space-1) 0;
  color: var(--color-ink);
}

.message-content ul,
.message-content ol {
  margin: var(--space-1) 0;
  padding-left: 1.25rem;
}

.message-content li {
  margin: 2px 0;
  color: var(--color-ink);
}

.message-content a {
  color: var(--color-violet);
  text-decoration: underline;
}

.message-content blockquote {
  border-left: 2px solid var(--color-brass-dim);
  padding-left: var(--space-3);
  margin: var(--space-2) 0;
  color: var(--color-ink-muted);
  font-style: italic;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-2) 0;
  font-size: var(--text-xs);
}

.message-content th,
.message-content td {
  border: 1px solid var(--color-hairline);
  padding: var(--space-1) var(--space-2);
  text-align: left;
}

.message-content th {
  background: var(--color-surface-3);
  font-weight: var(--weight-medium);
}

.message-content strong {
  color: var(--color-ink);
  font-weight: var(--weight-semi);
}

.message-content em {
  font-style: italic;
}

/* Inline code */
.message-content code:not(pre code) {
  background: var(--color-inline-code-bg);
  color: var(--color-violet);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: .85em;
}

/* Code blocks */
.message-content pre {
  position: relative;
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-lg);
  margin: var(--space-2) 0;
  overflow-x: auto;
}

.message-content pre code {
  display: block;
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--color-code-text);
  white-space: pre;
}

/* Copy button on code blocks */
.code-block-wrapper {
  position: relative;
}

.copy-code-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--space-2);
  background: var(--color-surface-3, #1a2336);
  border: 1px solid var(--color-hairline, #243049);
  border-radius: var(--radius-sm, 4px);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10px;
  color: var(--color-ink-muted, #8BA3C7);
  cursor: pointer;
  opacity: 1; /* always visible — was 0 and only on hover */
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  z-index: 2;
}

.code-block-wrapper:hover .copy-code-btn,
.code-block-wrapper:focus-within .copy-code-btn {
  opacity: 1;
  color: var(--color-ink, #E8F0FA);
}

.copy-code-btn:hover {
  color: var(--color-ink);
  border-color: var(--color-ink-muted);
}

.copy-code-btn.copied {
  color: var(--color-success);
  border-color: var(--color-success);
}

/* Typing indicator */
.chat-message--typing .message-content {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: var(--space-3) var(--space-3);
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-ink-muted);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chat form — pinned at bottom (column: preview chips + input row) */
#chat-form {
  flex-shrink: 0;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  background: rgba(23,24,28,.7);
  backdrop-filter: blur(8px);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast),
    background var(--duration-fast);
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 2;
}

#chat-form:focus-within {
  border-color: var(--color-brass);
  box-shadow: 0 0 0 4px var(--color-brass-glow);
  background: rgba(30,32,36,.8);
}

#chat-input {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-ink);
  line-height: var(--leading-relaxed);
  max-height: 10rem;
  overflow-y: auto;
  min-height: 2.25rem;
}

#chat-input::placeholder {
  color: var(--color-ink-muted);
}

/* ============================================================
   14c. DATA ANALYSIS PANEL
   ============================================================ */

#panel-data {
  padding: var(--space-4);
  animation: panel-in var(--duration-slow) var(--ease-out) both;
}

@media (min-width: 768px) {
  #panel-data {
    padding: var(--space-8);
  }
}

#panel-data.hidden {
  display: none;
}

/* Data stats cards */
#data-stats .stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast);
}

#data-stats .stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card__label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-ink-muted);
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semi);
  color: var(--color-ink);
  line-height: var(--leading-tight);
}

.stat-card__sub {
  font-size: var(--text-xs);
  color: var(--color-ink-faint);
}

/* Data table */
#data-table-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

#data-table-container thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

#data-table-container th {
  background: var(--color-surface-3);
  color: var(--color-ink-muted);
  font-weight: var(--weight-medium);
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-hairline);
  white-space: nowrap;
}

#data-table-container td {
  padding: var(--space-1) var(--space-3);
  color: var(--color-ink);
  border-bottom: 1px solid var(--color-hairline-soft);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#data-table-container tr:hover td {
  background: var(--color-surface-2);
}

#data-table-container tr:nth-child(even) td {
  background: rgba(255,255,255,.01);
}

/* Data plot */
#data-plot-container {
  animation: fade-in var(--duration-normal) var(--ease-out) both;
}

#data-plot .plotly .main-svg {
  border-radius: var(--radius-lg);
}

/* Data actions bar */
#data-workspace .btn {
  font-size: var(--text-xs);
}

/* Data empty state */
#data-empty-state {
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  border: 1px dashed var(--color-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  line-height: var(--leading-relaxed);
}

#data-empty-state p {
  margin-top: var(--space-2);
}

/* ============================================================
   15. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--duration-fast),
    color var(--duration-fast),
    border-color var(--duration-fast),
    box-shadow var(--duration-fast),
    opacity var(--duration-fast),
    transform var(--duration-fast) var(--ease-standard);
  cursor: pointer;
  user-select: none;
  letter-spacing: -.005em;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .4;
  pointer-events: none;
}

.btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

.btn:active {
  transform: scale(0.96);
}

.btn--primary {
  background: var(--color-brass);
  color: var(--color-canvas);
  border: 1px solid transparent;
}

.btn--primary:hover {
  background: var(--color-brass-dim);
  box-shadow: 0 4px 20px var(--color-brass-glow);
}

.btn--primary:focus-visible {
  outline: 2px solid var(--color-brass);
  outline-offset: 2px;
}

.btn--secondary {
  background: transparent;
  color: var(--color-ink-muted);
  border: 1px solid var(--color-hairline);
}

.btn--secondary:hover {
  color: var(--color-ink);
  border-color: var(--color-ink-muted);
  background: var(--color-surface-2);
}

.btn--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(229,103,90,.25);
}

.btn--danger:hover {
  background: rgba(229,103,90,.18);
  box-shadow: 0 4px 16px rgba(229,103,90,.2);
}

.btn--ghost {
  background: transparent;
  color: var(--color-ink-muted);
  border: 1px solid transparent;
}

.btn--ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
}

.btn--xs { padding: 4px var(--space-2); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn--sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn--lg { padding: var(--space-3) var(--space-6); font-size: var(--text-base); }

.btn.is-loading {
  pointer-events: none;
  opacity: .7;
}

.btn.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: spin .7s linear infinite;
  margin-left: var(--space-1);
}


/* ============================================================
   16. INPUTS & SELECTS
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-ink-muted);
}

.field-label--required::after {
  content: " *";
  color: var(--color-danger);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--color-ink-faint);
  line-height: var(--leading-relaxed);
}

.field-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  line-height: var(--leading-snug);
}

.input,
.select,
.textarea {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-ink);
  line-height: var(--leading-normal);
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast);
  -webkit-appearance: none;
  appearance: none;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: rgba(154,156,165,.5);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  border-color: var(--color-brass-dim);
  box-shadow: var(--shadow-brass);
  outline: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-ink-muted);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.textarea {
  resize: vertical;
  min-height: 5rem;
  line-height: var(--leading-relaxed);
}

.select {
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 7L11 1' stroke='%239A9CA5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 10px;
  cursor: pointer;
}

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

.input.is-invalid:focus-visible,
.select.is-invalid:focus-visible,
.textarea.is-invalid:focus-visible {
  box-shadow: 0 0 0 3px var(--color-danger-bg);
}

.input--mono,
.select--mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .01em;
}


/* ============================================================
   17. LOGOUT BUTTON
   ============================================================ */

#logout-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-hairline);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-ink-muted);
  transition:
    color var(--duration-fast),
    border-color var(--duration-fast),
    background var(--duration-fast),
    transform var(--duration-fast);
}

#logout-btn:hover {
  color: var(--color-ink);
  border-color: var(--color-ink-muted);
  background: var(--color-surface-2);
  transform: scale(1.05);
}


/* ============================================================
   18. NEW PROJECT BUTTON
   ============================================================ */

#new-project-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-brass);
  color: var(--color-canvas);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast);
  flex-shrink: 0;
}

#new-project-btn:hover {
  background: var(--color-brass-dim);
  transform: scale(1.05);
  box-shadow: 0 4px 20px var(--color-brass-glow);
}


/* ============================================================
   19. SEND / SUBMIT BUTTON
   ============================================================ */

#send-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-brass);
  color: var(--color-canvas);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  flex-shrink: 0;
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast);
}

#send-chat-btn:hover {
  background: var(--color-brass-dim);
  transform: scale(1.05);
  box-shadow: 0 4px 20px var(--color-brass-glow);
}

#send-chat-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}


/* ============================================================
   20. GOOGLE LOGIN BUTTON
   ============================================================ */

#google-login-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-ink);
  color: var(--color-canvas);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: 10px var(--space-4);
  border: 1px solid transparent;
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast);
}

#google-login-btn:hover {
  background: #ffffff;
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(255,255,255,.1);
}

#google-login-btn:focus-visible {
  outline: 2px solid var(--color-brass);
  outline-offset: 2px;
}

#google-login-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}


/* ============================================================
   21. MODAL / DIALOG
   ============================================================ */

dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-modal);
  width: 100%;
  max-width: 28rem;
  border: none;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: backdrop-in var(--duration-normal) var(--ease-out) both;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

dialog[open] {
  animation: dialog-in var(--duration-slow) var(--ease-spring) both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 20px)) scale(.92); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.dialog-accent {
  height: 2px;
  background: linear-gradient(90deg, var(--color-brass) 0%, var(--color-violet) 50%, var(--color-brass) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: shimmer 3s linear infinite;
}

.dialog-inner {
  background: rgba(23,24,28,.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-hairline);
  border-top: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: var(--space-6);
}

.dialog-heading {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  margin-bottom: var(--space-4);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

@media (max-width: 420px) {
  dialog {
    top: auto;
    left: 0;
    bottom: 0;
    transform: none;
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  dialog[open] {
    animation: sheet-in var(--duration-slow) var(--ease-spring) both;
  }

  @keyframes sheet-in {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }
}


/* ============================================================
   22. BADGES & STATUS PILLS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge--info    { background: var(--color-info-bg);    color: var(--color-info); }
.badge--neutral { background: var(--color-surface-3);  color: var(--color-ink-muted); }


/* ============================================================
   23. DIVIDERS & STRUCTURE
   ============================================================ */

.divider {
  border: none;
  border-top: 1px solid var(--color-hairline);
  margin: var(--space-4) 0;
}

.section-label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-ink-faint);
  margin-bottom: var(--space-3);
}


/* ============================================================
   24. ANIMATIONS & KEYFRAMES
   ============================================================ */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--color-brass-glow); }
  50%       { box-shadow: 0 0 0 6px transparent; }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

.animate-spin    { animation: spin 1s linear infinite; }
.animate-fade-in { animation: fade-in var(--duration-normal) var(--ease-out) both; }
.animate-pulse   { animation: pulse-glow 2s ease-in-out infinite; }

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-2) 0%,
    var(--color-surface-3) 45%,
    var(--color-surface-2) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-card { height: 9rem; border-radius: var(--radius-lg); }
.skeleton-text { height: .85em; border-radius: var(--radius-sm); }
.skeleton-text--short { width: 45%; }
.skeleton-text--long  { width: 85%; }


/* ============================================================
   25. REDUCED MOTION
   ============================================================ */

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


/* ============================================================
   26. UTILITIES
   ============================================================ */

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

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-display { font-family: var(--font-display); }
.font-mono    { font-family: var(--font-mono); }

.text-muted  { color: var(--color-ink-muted); }
.text-faint  { color: var(--color-ink-faint); }
.text-brass  { color: var(--color-brass); }
.text-danger { color: var(--color-danger); }
.text-success{ color: var(--color-success); }

.hidden { display: none !important; }
.invisible { visibility: hidden; }


/* ============================================================
   27. RESPONSIVE HARDENING (mobile-first additions)
   ============================================================ */

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

#view-dashboard {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.main-column,
#main-content {
  min-width: 0;
  max-width: 100%;
}

/* Touch-friendly tap targets on small screens */
@media (max-width: 767px) {
  .sidebar-nav__item,
  .btn,
  #send-chat-btn,
  #voice-input-btn,
  #logout-btn,
  #new-project-btn,
  #data-refresh-btn,
  #data-file-delete-btn {
    min-height: 44px;
  }

  #voice-input-btn {
    min-width: 44px;
  }

  #toast-container {
    left: var(--space-3);
    right: var(--space-3);
    max-width: none;
    width: auto;
  }

  #app-header {
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }

  #chat-form {
    margin-bottom: var(--space-2);
  }

  #chat-input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  select,
  .select,
  .input,
  .textarea {
    max-width: 100%;
  }
}

/* Landscape phones: tighter vertical chrome */
@media (max-width: 900px) and (orientation: landscape) {
  #panel-chat {
    height: calc(100dvh - var(--header-height));
  }

  #chat-history {
    min-height: 6rem;
  }
}

/* Large monitors: constrain ultra-wide content slightly for readability */
@media (min-width: 1600px) {
  #panel-projects,
  #panel-data {
    max-width: var(--content-max-w);
    margin-inline: auto;
  }
}

/* Forms & dialogs never overflow viewport */
#new-project-dialog,
dialog {
  max-width: min(28rem, calc(100vw - 1.5rem));
}

@media (max-width: 420px) {
  #new-project-dialog form,
  dialog form {
    max-height: min(85dvh, 85vh);
    overflow-y: auto;
  }
}

/* Image gallery */
#image-results img,
.image-result-img {
  max-width: 100%;
  height: auto;
}

/* Data dropzone */
#data-dropzone {
  max-width: 100%;
}

/* Horizontal scroll only inside explicit scroll containers */
#data-table-container,
.overflow-x-auto {
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}


/* ============================================================
   28. CHAT FILE ATTACHMENTS
   ============================================================ */

#chat-attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
  max-width: 100%;
  max-height: 9rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  margin-bottom: var(--space-2);
  scrollbar-width: thin;
}

#chat-attachments-preview.hidden {
  display: none !important;
}

#chat-attachments-preview:not(.hidden):empty {
  display: none !important;
}

/* Composer drop-target highlight */
#chat-form[data-dropzone="chat"] {
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast),
    background-color var(--duration-fast);
}

#chat-form.is-dragover,
#chat-form.chat-form--dragover {
  border-color: var(--color-brass) !important;
  background-color: var(--color-brass-subtle);
  box-shadow: var(--shadow-brass);
}

#chat-drop-hint {
  font-size: var(--text-2xs);
  color: var(--color-ink-muted);
  line-height: var(--leading-snug);
  padding: 0 var(--space-2) var(--space-1);
}

#chat-drop-hint:not(.hidden) {
  display: block;
}

#chat-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
  width: 2.25rem;
  min-height: 2.25rem;
  min-width: 2.25rem;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-hairline);
  color: var(--color-ink-muted);
  background: transparent;
  cursor: pointer;
  position: relative;
  z-index: 5;
  pointer-events: auto;
  transition:
    background var(--duration-fast),
    color var(--duration-fast),
    border-color var(--duration-fast);
}

#chat-attach-btn svg {
  pointer-events: none;
}

#chat-attach-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

#chat-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

#chat-attach-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
  transform: none;
}

#chat-attach-btn:focus-visible {
  outline: 2px solid var(--color-brass);
  outline-offset: 2px;
}

#chat-attach-btn[aria-pressed="true"],
#chat-attach-btn.is-active {
  color: var(--color-brass);
  border-color: var(--color-brass-dim);
  background: var(--color-brass-subtle);
}

/* Attachment chip / card */
.chat-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  min-width: 0;
  padding: 0.25rem 0.25rem 0.25rem 0.375rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-hairline);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  animation: chat-attach-in var(--duration-normal) var(--ease-out) both;
  transition:
    border-color var(--duration-fast),
    background var(--duration-fast),
    box-shadow var(--duration-fast);
}

.chat-attachment-chip:hover {
  border-color: rgba(154, 156, 165, 0.55);
  background: var(--color-surface-3);
}

.chat-attachment-chip.is-uploading {
  opacity: 0.75;
  pointer-events: none;
}

.chat-attachment-chip.is-error {
  border-color: rgba(229, 103, 90, 0.35);
  background: var(--color-danger-bg);
}

@keyframes chat-attach-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Icon / thumbnail slot */
.chat-attachment-icon {
  position: relative;
  flex-shrink: 0;
  height: 2rem;
  width: 2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-hairline);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--color-ink-muted);
}

.chat-attachment-file-icon {
  height: 1rem;
  width: 1rem;
  flex-shrink: 0;
}

.chat-attachment-thumb {
  display: none;
  height: 100%;
  width: 100%;
  object-fit: cover;
}

.chat-attachment-chip.has-thumb .chat-attachment-file-icon {
  display: none;
}

.chat-attachment-chip.has-thumb .chat-attachment-thumb {
  display: block;
}

/* Type-tinted generic icons (optional data-type attribute) */
.chat-attachment-chip[data-type="pdf"] .chat-attachment-icon {
  color: var(--color-danger);
}

.chat-attachment-chip[data-type="image"] .chat-attachment-icon {
  color: var(--color-info);
}

.chat-attachment-chip[data-type="code"] .chat-attachment-icon,
.chat-attachment-chip[data-type="json"] .chat-attachment-icon,
.chat-attachment-chip[data-type="csv"] .chat-attachment-icon {
  color: var(--color-violet);
}

.chat-attachment-chip[data-type="doc"] .chat-attachment-icon {
  color: var(--color-brass);
}

/* Filename + size */
.chat-attachment-name {
  display: block;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-ink);
  font-weight: var(--weight-medium);
  font-size: var(--text-xs);
}

.chat-attachment-size {
  display: block;
  color: var(--color-ink-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.01em;
}

/* Remove button */
.chat-attachment-remove {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.5rem;
  width: 1.5rem;
  border-radius: var(--radius-sm);
  color: var(--color-ink-muted);
  opacity: 0.7;
  transition:
    color var(--duration-fast),
    background var(--duration-fast),
    opacity var(--duration-fast);
}

.chat-attachment-remove:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
  opacity: 1;
  transform: none;
}

.chat-attachment-remove:focus-visible {
  outline: 2px solid var(--color-brass);
  outline-offset: 1px;
  opacity: 1;
}

/* Upload progress shimmer on chip */
.chat-attachment-chip.is-uploading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--color-brass-glow) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: chat-attach-shimmer 1.2s ease-in-out infinite;
  pointer-events: none;
}

.chat-attachment-chip {
  position: relative;
}

@keyframes chat-attach-shimmer {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* Responsive: tablet */
@media (min-width: 640px) {
  .chat-attachment-name {
    max-width: 14rem;
  }

  #chat-attachments-preview {
    max-height: 11rem;
  }
}

/* Responsive: desktop */
@media (min-width: 1024px) {
  .chat-attachment-name {
    max-width: 18rem;
  }
}

/* Responsive: mobile touch targets */
@media (max-width: 767px) {
  #chat-attach-btn {
    min-height: 44px;
    min-width: 44px;
    height: 2.75rem;
    width: 2.75rem;
  }

  .chat-attachment-chip {
    max-width: 100%;
  }

  .chat-attachment-name {
    max-width: min(10rem, 42vw);
  }

  .chat-attachment-remove {
    min-height: 32px;
    min-width: 32px;
    height: 2rem;
    width: 2rem;
  }

  #chat-attachments-preview {
    max-height: 7.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-attachment-chip,
  .chat-attachment-chip.is-uploading::after {
    animation: none !important;
  }
}

/* ============================================================
   29. GOD-TIER ENHANCEMENTS
   Additive premium layer — refines existing UI without touching
   any selector logic, IDs, or JS-facing class contracts above.
   ============================================================ */

/* --------------------------------------------
   29.1 Ambient grain — subtle cinematic texture
   -------------------------------------------- */
#app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-base);
  pointer-events: none;
  opacity: var(--noise-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --------------------------------------------
   29.2 Brass radiant text (opt-in utility)
   -------------------------------------------- */
.text-brass-radiant {
  background: var(--color-brass-radiant);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.text-aurora {
  background: var(--color-aurora);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: aurora-sweep 6s linear infinite;
}

@keyframes aurora-sweep {
  to { background-position: 200% center; }
}

/* --------------------------------------------
   29.3 Refined focus ring (layers atop base :focus-visible)
   -------------------------------------------- */
:focus-visible {
  box-shadow: var(--shadow-focus-ring);
  transition: box-shadow var(--duration-fast) var(--ease-out);
}

/* --------------------------------------------
   29.4 Scrollbar — polished hover glow
   -------------------------------------------- */
::-webkit-scrollbar-thumb {
  background-clip: padding-box;
  transition: background-color var(--duration-normal);
}

/* --------------------------------------------
   29.5 Loading bar — luminous edge glow
   -------------------------------------------- */
#loading-bar::before {
  content: "";
  position: absolute;
  inset: -6px 0 auto 0;
  height: 8px;
  background: radial-gradient(ellipse at center, var(--color-brass-glow) 0%, transparent 75%);
  filter: blur(2px);
  pointer-events: none;
}

/* --------------------------------------------
   29.6 Glass panel sheen — diagonal light pass
   Applied to key glass surfaces on hover-capable devices
   -------------------------------------------- */
@media (hover: hover) {
  .login-card__inner,
  .dialog-inner,
  #chat-form,
  .toast {
    position: relative;
    isolation: isolate;
  }

  .login-card__inner::after,
  .dialog-inner::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 20%, var(--color-glass-sheen) 45%, transparent 60%);
    background-size: 250% 250%;
    background-position: 120% 0%;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-out);
    z-index: 1;
  }

  .login-card:hover .login-card__inner::after,
  dialog[open] .dialog-inner::after {
    opacity: 1;
    animation: sheen-pass 1.1s var(--ease-silk) both;
  }
}

@keyframes sheen-pass {
  from { background-position: 120% -20%; }
  to   { background-position: -20% 120%; }
}

/* --------------------------------------------
   29.7 Project cards — magnetic depth + gleam edge
   -------------------------------------------- */
.project-card {
  transform-style: preserve-3d;
}

.project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, var(--color-brass-glow), transparent 35%, transparent 65%, var(--color-violet-glow));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  pointer-events: none;
}

.project-card:hover::before {
  opacity: 1;
}

.project-card:hover {
  box-shadow: var(--shadow-2xl), 0 0 0 1px var(--color-brass-glow), var(--shadow-inset-hairline);
}

/* --------------------------------------------
   29.8 Buttons — shine sweep on primary CTAs
   -------------------------------------------- */
.btn--primary,
#new-project-btn,
#send-chat-btn {
  background: var(--color-brass-radiant);
  background-size: 160% 160%;
  background-position: 0% 50%;
  transition: background-position var(--duration-slow) var(--ease-silk),
              transform var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast);
}

.btn--primary:hover,
#new-project-btn:hover,
#send-chat-btn:hover {
  background-position: 100% 50%;
  box-shadow: var(--shadow-glow-brass);
}

/* --------------------------------------------
   29.9 Sidebar active item — living indicator
   -------------------------------------------- */
.sidebar-nav__item[aria-selected="true"]::before,
.sidebar-nav__item.is-active::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 20%;
  bottom: 20%;
  width: 2px;
  border-radius: var(--radius-full);
  background: var(--color-brass);
  box-shadow: 0 0 10px var(--color-brass-glow);
  animation: indicator-pulse 2.4s ease-in-out infinite;
}

@keyframes indicator-pulse {
  0%, 100% { opacity: .7; }
  50%      { opacity: 1; }
}

/* --------------------------------------------
   29.10 Avatar — living ring
   -------------------------------------------- */
#user-avatar {
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

#user-avatar:hover {
  box-shadow: 0 0 0 2px var(--color-brass), var(--shadow-glow-brass);
}

/* --------------------------------------------
   29.11 Chat bubbles — soft directional glow
   -------------------------------------------- */
.chat-message--user .message-content {
  box-shadow: 0 4px 20px -8px var(--color-brass-glow);
}

.chat-message--assistant .message-content {
  box-shadow: 0 4px 20px -10px rgba(0,0,0,.5);
}

/* --------------------------------------------
   29.12 Badges — inner glow refinement
   -------------------------------------------- */
.badge--success,
.badge--warning,
.badge--danger,
.badge--info {
  box-shadow: inset 0 0 0 1px currentColor;
  filter: saturate(1.1);
}

/* --------------------------------------------
   29.13 Stat cards — brass top accent on hover
   -------------------------------------------- */
#data-stats .stat-card {
  position: relative;
  overflow: hidden;
}

#data-stats .stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-brass-radiant);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-normal) var(--ease-silk);
}

#data-stats .stat-card:hover::after {
  transform: scaleX(1);
}

/* --------------------------------------------
   29.14 Empty states — gentle breathing icon
   -------------------------------------------- */
.empty-state-icon {
  animation: breathe 3.5s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: .25; transform: scale(1); }
  50%      { opacity: .4;  transform: scale(1.04); }
}

/* --------------------------------------------
   29.15 Code blocks — luminous top hairline
   -------------------------------------------- */
.message-content pre {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), var(--shadow-xs);
}

/* --------------------------------------------
   29.16 Toasts — brass-accented icon glow
   -------------------------------------------- */
.toast--success .toast__icon { filter: drop-shadow(0 0 6px var(--color-success)); }
.toast--error   .toast__icon { filter: drop-shadow(0 0 6px var(--color-danger)); }
.toast--warning .toast__icon { filter: drop-shadow(0 0 6px var(--color-warning)); }
.toast--info    .toast__icon { filter: drop-shadow(0 0 6px var(--color-info)); }

/* --------------------------------------------
   29.17 Selection & cursor refinement
   -------------------------------------------- */
::selection {
  box-shadow: 0 0 0 4px var(--color-brass-glow);
}

/* --------------------------------------------
   29.18 High-refresh-rate smoothing
   Keeps transforms on the compositor for silky motion
   -------------------------------------------- */
.project-card,
.btn,
.sidebar-nav__item,
.image-result,
#data-stats .stat-card {
  will-change: transform;
}

/* --------------------------------------------
   29.19 Reduced motion — disable new decorative layers too
   -------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  #app::before,
  .text-aurora,
  .login-card__inner::after,
  .dialog-inner::after,
  .sidebar-nav__item[aria-selected="true"]::before,
  .sidebar-nav__item.is-active::before,
  .empty-state-icon {
    animation: none !important;
  }
}


/* ============================================================
   COOL TONE — GRAND TEXTURES & ATMOSPHERE (2026)
   ============================================================ */

body {
  background-color: var(--color-canvas);
  background-image:
    radial-gradient(ellipse 90% 55% at 15% -10%, rgba(94, 234, 212, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 10%, rgba(129, 140, 248, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 110%, rgba(125, 211, 252, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Film grain / frost texture overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
}

/* Soft vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(ellipse 75% 75% at 50% 45%, transparent 40%, rgba(4, 8, 16, 0.55) 100%);
}

#three-background {
  opacity: 0.85;
  filter: saturate(1.15) contrast(1.05);
}

/* Frosted glass panels */
.glass-panel,
#auth-screen .auth-card,
.project-card,
#chat-form,
.data-workspace-card {
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.project-card {
  background: linear-gradient(165deg, rgba(18, 26, 43, 0.92) 0%, rgba(12, 18, 32, 0.88) 100%);
  border: 1px solid var(--color-glass-border);
  box-shadow: var(--shadow-inset-hairline), var(--shadow-md);
  transition: transform var(--duration-normal) var(--ease-silk),
              box-shadow var(--duration-normal) var(--ease-silk),
              border-color var(--duration-normal) var(--ease-silk);
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: rgba(94, 234, 212, 0.35);
  box-shadow: var(--shadow-glow-brass), var(--shadow-lg);
}

/* Sidebar cool edge glow */
#sidebar {
  background: linear-gradient(180deg, rgba(12, 18, 32, 0.96) 0%, rgba(8, 12, 22, 0.98) 100%);
  border-right: 1px solid var(--color-glass-border);
  box-shadow: 4px 0 32px rgba(0, 10, 30, 0.4);
}

/* Primary CTA — glacier gradient */
.btn-primary,
button.bg-brass,
#send-chat-btn,
#login-submit-btn,
#register-submit-btn {
  background: var(--color-brass-radiant) !important;
  color: var(--color-ink-inverse) !important;
  border: none;
  box-shadow: 0 4px 20px rgba(45, 212, 191, 0.25);
  transition: transform var(--duration-fast) var(--ease-silk),
              box-shadow var(--duration-fast) var(--ease-silk),
              filter var(--duration-fast) var(--ease-silk);
}

.btn-primary:hover,
button.bg-brass:hover,
#send-chat-btn:hover {
  filter: brightness(1.08);
  box-shadow: var(--shadow-glow-brass);
  transform: translateY(-1px);
}

/* Nav tab active — cool underline glow */
nav[role="tablist"] [role="tab"][aria-selected="true"],
nav[role="tablist"] .nav-item.active {
  color: var(--color-brass);
  background: rgba(94, 234, 212, 0.08);
  box-shadow: inset 3px 0 0 var(--color-brass);
}

/* Chat bubbles cool glass */
.message-bubble--assistant,
.chat-message.assistant .message-content {
  background: linear-gradient(145deg, rgba(18, 26, 43, 0.9), rgba(14, 22, 38, 0.85));
  border: 1px solid var(--color-glass-border);
}

.message-bubble--user,
.chat-message.user .message-content {
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.18), rgba(129, 140, 248, 0.12));
  border: 1px solid rgba(94, 234, 212, 0.25);
}

/* Inputs with ice focus */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--color-brass) !important;
  box-shadow: var(--shadow-focus-ring) !important;
}

/* Loading bar aurora */
#loading-bar > div {
  background: var(--color-aurora) !important;
  background-size: 200% 100%;
  animation: auroraShift 2s linear infinite;
}

@keyframes auroraShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* Auth card elevated frost */
#auth-screen {
  background:
    radial-gradient(ellipse 50% 40% at 50% 0%, rgba(94, 234, 212, 0.1) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(129, 140, 248, 0.08) 0%, transparent 50%),
    var(--color-canvas);
}

#auth-screen .auth-card,
#login-card,
#register-card {
  border: 1px solid var(--color-glass-border);
  background: linear-gradient(165deg, rgba(18, 26, 43, 0.85) 0%, rgba(10, 14, 24, 0.9) 100%);
  box-shadow: var(--shadow-2xl), 0 0 60px rgba(94, 234, 212, 0.08);
  border-radius: var(--radius-xl);
}

/* Data dropzone cool dashed */
#data-dropzone,
#workspace-data-dropzone {
  border-color: rgba(94, 234, 212, 0.25) !important;
  background: rgba(94, 234, 212, 0.03);
  transition: border-color var(--duration-normal) var(--ease-silk),
              background var(--duration-normal) var(--ease-silk),
              box-shadow var(--duration-normal) var(--ease-silk);
}

#data-dropzone:hover,
#workspace-data-dropzone:hover,
.chat-form--dragover {
  border-color: var(--color-brass) !important;
  background: rgba(94, 234, 212, 0.08) !important;
  box-shadow: var(--shadow-glow-brass);
}

/* Scrollbar cool */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(94, 234, 212, 0.25) transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(94, 234, 212, 0.25);
  border-radius: var(--radius-full);
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(94, 234, 212, 0.45);
}

/* Stat cards / data */
.stat-card {
  background: linear-gradient(160deg, rgba(18, 26, 43, 0.9), rgba(12, 18, 32, 0.85));
  border: 1px solid var(--color-glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-inset-hairline);
}

/* Selection */
::selection {
  background: rgba(94, 234, 212, 0.3);
  color: var(--color-ink);
}


/* Avatar context menu — always above page chrome */
#app-header {
  z-index: 40;
  overflow: visible;
}
#user-avatar-wrap {
  z-index: 50;
  overflow: visible;
}
#avatar-context-menu {
  z-index: 200;
  pointer-events: auto;
}
#avatar-context-menu:not(.hidden) {
  display: block;
}

/* HTML code blocks — Preview / Source */
.html-preview-widget {
  box-shadow: var(--shadow-md, 0 4px 16px rgba(0,0,0,.35));
}
.html-preview-widget .hp-tab {
  transition: background 0.15s ease, color 0.15s ease;
}
.html-preview-widget .hp-panel-source pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  border-radius: 0;
}
.html-preview-widget iframe {
  background: #fff;
}