/* ====================================================================
   Brimup — Glassmorphism design system
   All selectors preserved. Visual layer redesigned.
   ==================================================================== */

:root {
  color-scheme: dark;
  --bg:         #080812;
  --bg-2:       rgba(255,255,255,0.07);
  --bg-3:       rgba(255,255,255,0.04);
  --fg:         #f4f4f5;
  --fg-2:       #c4c4cc;
  --muted:      #9090a0;
  --muted-2:    #606070;
  --card:       rgba(255,255,255,0.08);
  --border:     rgba(255,255,255,0.12);
  --line:       rgba(255,255,255,0.09);
  --line-2:     rgba(255,255,255,0.16);
  --accent:     #D97706;
  --accent-muted: rgba(217,119,6,0.18);
  --on-accent:  #ffffff;
  --ok:         #22c55e;
  --warn:       #f59e0b;
  --bad:        #ef4444;
  --info:       #60a5fa;
  --radius:     14px;
  --tap:        44px;
  --blur:       18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 15% 15%, rgba(109,40,217,0.28) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(29,78,216,0.22) 0%, transparent 50%),
    radial-gradient(ellipse at 65% 5%,  rgba(8,145,178,0.15) 0%, transparent 45%);
  color: var(--fg);
  font-family: 'Outfit', Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
body { display: flex; flex-direction: column; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; }

/* ---------- BACKGROUND BLOBS ---------- */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.38;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.blob-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  top: -160px; left: -120px;
  animation: blob-drift 20s ease-in-out infinite alternate;
}
.blob-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, #1d4ed8 0%, transparent 70%);
  bottom: -130px; right: -90px;
  animation: blob-drift 25s ease-in-out infinite alternate-reverse;
  animation-delay: -7s;
}
.blob-3 {
  width: 360px; height: 360px;
  background: radial-gradient(circle, #0891b2 0%, transparent 70%);
  top: 45%; left: 58%;
  animation: blob-drift 17s ease-in-out infinite alternate;
  animation-delay: -11s;
}
@keyframes blob-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(35px, 25px) scale(1.09); }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

/* ---------- AUTH ---------- */
body.auth {
  justify-content: center; align-items: center;
  padding: 24px; min-height: 100dvh;
}
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 22px;
  padding: 32px 26px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.14),
    inset 0 -1px 0 rgba(0,0,0,0.10);
}
.login-card .brand {
  margin: 0 0 24px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800; letter-spacing: 0.10em;
  font-size: 20px; line-height: 1.2;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.65) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input[type="password"] {
  height: var(--tap);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 11px;
  padding: 0 14px; outline: none; color: var(--fg);
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.login-card input[type="password"]::placeholder { color: var(--muted); }
.login-card input[type="password"]:focus {
  border-color: rgba(255,255,255,0.32);
  background: rgba(255,255,255,0.11);
  box-shadow: 0 0 0 3px rgba(217,119,6,0.18);
}
.login-card button {
  height: var(--tap);
  background: linear-gradient(135deg, #D97706 0%, #B45309 100%);
  color: var(--on-accent);
  border: none; border-radius: 11px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700; letter-spacing: 0.08em; font-size: 14px;
  box-shadow: 0 4px 18px rgba(217,119,6,0.38), 0 1px 0 rgba(255,255,255,0.12) inset;
  transition: transform 80ms ease, opacity 150ms ease, box-shadow 150ms ease;
}
.login-card button:hover {
  opacity: 0.93;
  box-shadow: 0 6px 24px rgba(217,119,6,0.50), 0 1px 0 rgba(255,255,255,0.12) inset;
}
.login-card button:active { transform: scale(0.97); }
.error {
  margin: 6px 0 0; min-height: 1.2em;
  color: var(--bad); font-size: 14px;
}
.error.shake { animation: shake 0.35s linear; }
@keyframes shake {
  10%,90% { transform: translateX(-1px); }
  20%,80% { transform: translateX(2px); }
  30%,50%,70% { transform: translateX(-4px); }
  40%,60% { transform: translateX(4px); }
}

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(8,8,18,0.72);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand { font-size: 14px; font-weight: 900; letter-spacing: 0.18em; }
.topbar nav { display: flex; align-items: center; gap: 6px; }
.tab {
  background: transparent; color: var(--muted);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 999px;
  height: 32px; padding: 0 12px;
  font-size: 13px; font-weight: 700;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, #D97706, #B45309);
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(217,119,6,0.35);
}
.logout {
  margin-left: 8px; color: var(--muted);
  text-decoration: none; font-size: 12px;
  transition: color 120ms;
}
.logout:hover { color: var(--fg); }

/* ---------- DASHBOARD ---------- */
.dashboard {
  position: relative; z-index: 1;
  display: grid; gap: 16px;
  grid-template-columns: 1fr;
  padding: 16px;
  max-width: 1400px; margin: 0 auto; width: 100%;
}
@media (min-width: 960px) {
  .dashboard { grid-template-columns: 1fr 1fr; }
  .panel[hidden] { display: block !important; }
  .topbar nav .tab { display: none; }
}

.panel {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.28),
              inset 0 1px 0 rgba(255,255,255,0.08);
}
.panel h2 {
  font-size: 13px; letter-spacing: 0.16em;
  color: var(--muted); font-weight: 700;
  text-transform: uppercase;
}

.row { display: block; }
.row.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.row.inline > * { flex: 1; min-width: 140px; }

/* ---------- DROP ZONES ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  width: 100%; min-height: 120px;
  background: rgba(255,255,255,0.04);
  border: 1.5px dashed rgba(255,255,255,0.14); border-radius: var(--radius);
  text-align: center; padding: 18px;
  user-select: none; cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 80ms ease;
}
.drop.drag {
  background: rgba(217,119,6,0.09);
  border-color: rgba(217,119,6,0.55);
  border-style: solid;
}
.drop:active { transform: scale(0.995); }
.drop-title { font-weight: 800; letter-spacing: 0.04em; font-size: 15px; }
.drop-sub { font-size: 12px; color: var(--muted); }

/* ---------- IMAGE GRID ---------- */
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  min-height: 0;
}
@media (min-width: 720px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1 / 1;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.08); border-radius: 8px;
  overflow: hidden;
  transition: border-color 120ms ease, transform 80ms ease;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .x {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 999px;
  background: rgba(0,0,0,0.72); color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: none; font-size: 14px; line-height: 1;
  transition: background 120ms;
}
.tile .x:hover { background: rgba(239,68,68,0.85); }
.tile .status {
  position: absolute; left: 4px; bottom: 4px;
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: rgba(0,0,0,0.72); color: #fff; display: none;
}
.tile.busy .status, .tile.ok .status, .tile.bad .status { display: inline-block; }
.tile.ok  .status { background: var(--ok); color: #04140a; }
.tile.bad .status { background: var(--bad); }
.tile.busy::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(0,0,0,0.35);
  background-image: linear-gradient(110deg,
    rgba(255,255,255,0.04) 30%,
    rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.04) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- SUGGESTED TAGS ---------- */
.suggested { display: flex; flex-wrap: wrap; gap: 6px; }
.suggested[hidden] { display: none; }
.sug-chip {
  background: rgba(255,255,255,0.06); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.sug-chip:hover {
  background: linear-gradient(135deg, #D97706, #B45309);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(217,119,6,0.30);
}

/* ---------- MATERIAL FILE LIST ---------- */
.file-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.file-list:empty { display: none; }
.file-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09); border-radius: 10px;
  font-size: 13px;
  transition: background 120ms;
}
.file-list li .icon {
  width: 28px; height: 28px; flex: 0 0 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: rgba(255,255,255,0.09);
  font-weight: 800; font-size: 11px; color: var(--muted);
  border: 1px solid rgba(255,255,255,0.10);
}
.file-list li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list li button { background: transparent; border: none; color: var(--muted); transition: color 120ms; }
.file-list li button:hover { color: var(--bad); }

/* ---------- INPUTS ---------- */
.text-input, .textarea {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 10px;
  padding: 10px 12px; outline: none;
  color: var(--fg);
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.text-input { height: var(--tap); }
.textarea { resize: vertical; min-height: 70px; line-height: 1.4; }
.text-input::placeholder, .textarea::placeholder { color: var(--muted); }
.text-input:focus, .textarea:focus {
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(217,119,6,0.15);
}

/* ---------- BUTTONS ---------- */
.primary, .ghost {
  height: var(--tap); padding: 0 16px;
  border-radius: 10px; font-weight: 800; letter-spacing: 0.04em;
  transition: transform 80ms ease, opacity 120ms ease, box-shadow 150ms ease;
}
.primary {
  background: linear-gradient(135deg, #D97706 0%, #B45309 100%);
  color: var(--on-accent);
  border: none;
  box-shadow: 0 4px 18px rgba(217,119,6,0.32),
              inset 0 1px 0 rgba(255,255,255,0.15);
}
.primary:hover:not([disabled]) {
  opacity: 0.92;
  box-shadow: 0 6px 24px rgba(217,119,6,0.44),
              inset 0 1px 0 rgba(255,255,255,0.15);
}
.ghost {
  background: rgba(255,255,255,0.07); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.13);
}
.ghost:hover:not([disabled]) { background: rgba(255,255,255,0.11); }
.ghost.small { height: 30px; padding: 0 10px; font-size: 12px; }
.primary:active, .ghost:active { transform: scale(0.97); }
.primary[disabled], .ghost[disabled] { opacity: 0.45; cursor: not-allowed; }
.big { width: 100%; height: 50px; font-size: 14px; letter-spacing: 0.08em; }
.big .spin {
  display: inline-block; width: 14px; height: 14px;
  margin-right: 8px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,0.85); border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-line {
  margin: 0; min-height: 1.2em;
  font-size: 12px; color: var(--muted);
}

/* ---------- RECENT ---------- */
.recent {
  position: relative; z-index: 1;
  max-width: 1400px; margin: 0 auto; width: 100%;
  padding: 0 16px 32px;
}
.recent-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 8px 0 12px;
}
.recent-head h2 {
  font-size: 13px; color: var(--muted);
  letter-spacing: 0.16em; text-transform: uppercase; font-weight: 700;
}
.recent-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px;
}
.recent-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.09); border-radius: 12px;
  font-size: 13px;
  transition: background 120ms, border-color 120ms;
}
.recent-list li:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.15);
}
.recent-list .thumb {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 8px; overflow: hidden;
  background: rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11px; color: var(--muted);
  border: 1px solid rgba(255,255,255,0.09);
}
.recent-list .meta {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.recent-list .title {
  font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-list .sub {
  font-size: 11px; color: var(--muted);
  display: flex; gap: 6px; align-items: center;
}
.recent-list .pill {
  display: inline-block;
  padding: 1px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
}
.recent-list .pill.ok   { color: var(--ok);   border-color: rgba(34,197,94,0.30); }
.recent-list .pill.warn { color: var(--warn);  border-color: rgba(245,158,11,0.30); }
.recent-list .pill.bad  { color: var(--bad);   border-color: rgba(239,68,68,0.30); }
.recent-list a {
  color: var(--muted); text-decoration: none;
  padding: 6px 8px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  font-size: 11px; font-weight: 700;
  transition: color 120ms, background 120ms;
}
.recent-list a:hover { color: var(--fg); background: rgba(255,255,255,0.07); }
.recent-empty {
  text-align: center; color: var(--muted);
  padding: 24px; font-size: 13px;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom));
  transform: translate(-50%, 24px);
  background: rgba(14,10,28,0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--fg);
  padding: 10px 20px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  font-size: 13px; font-weight: 700;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease, transform 200ms cubic-bezier(.2,.8,.2,1);
  z-index: 9; white-space: nowrap;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad  {
  border-color: rgba(239,68,68,0.35);
  color: #fca5a5;
}

/* ---------- CHAT BUBBLES ---------- */
.chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.chat-bubble.user {
  background: linear-gradient(135deg, #D97706, #B45309);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 14px rgba(217,119,6,0.32);
}
.chat-bubble.assistant {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.10);
  border-bottom-left-radius: 4px;
}
.chat-bubble.error {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.26);
  border-bottom-left-radius: 4px;
}
.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 13px; font-weight: 700;
}
.chat-avatar.user {
  background: linear-gradient(135deg, #D97706, #B45309);
  color: #fff;
}
.chat-avatar.assistant {
  background: rgba(255,255,255,0.10);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.12);
}
.chat-avatar.error {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
}
.chat-bubble.assistant pre {
  background: rgba(0,0,0,0.32);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12px;
}
.chat-bubble.assistant code {
  font-family: monospace;
  font-size: 12px;
  background: rgba(0,0,0,0.28);
  padding: 1px 5px;
  border-radius: 4px;
}
.dot-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  animation: dotpulse 1s ease-in-out infinite;
}
@keyframes dotpulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.1); }
}

/* ---------- DROPDOWN / MOVE MENU ---------- */
.dropdown-menu {
  background: rgba(12,8,24,0.90);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 13px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  overflow: hidden;
}
.dropdown-menu button {
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 100ms;
}
.dropdown-menu button:hover {
  background: rgba(255,255,255,0.07);
}
