:root {
  --text: #f3f4f6;
  --text-soft: rgba(255, 255, 255, 0.72);
  --muted: rgba(255, 255, 255, 0.52);
  --glass-bg: rgba(26, 30, 38, 0.52);
  --glass-sidebar: rgba(18, 21, 27, 0.68);
  --glass-card: rgba(255, 255, 255, 0.065);
  --glass-card-hover: rgba(255, 255, 255, 0.11);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-strong: rgba(255, 255, 255, 0.2);
  --accent: #6366f1;
  --accent2: #3b82f6;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  background: #0b1220;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }

/* Atmospheric blurred wallpaper matching macOS glass backdrop */
.wallpaper-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(56, 130, 185, 0.55) 0%, transparent 48%),
    radial-gradient(circle at 82% 24%, rgba(168, 120, 86, 0.42) 0%, transparent 46%),
    radial-gradient(circle at 52% 82%, rgba(92, 114, 138, 0.48) 0%, transparent 55%),
    radial-gradient(circle at 8% 84%, rgba(190, 165, 145, 0.28) 0%, transparent 40%),
    linear-gradient(135deg, #1b2f45 0%, #2d3e4f 38%, #47413d 72%, #192534 100%);
  filter: saturate(115%);
}

.thinking-pill {
  position: absolute;
  top: 10px;
  right: 20px;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid rgba(99, 102, 241, 0.4);
  backdrop-filter: blur(8px);
  z-index: 10;
}

/* Main centered frosted glass window on desktop */
.app-frame {
  position: relative;
  z-index: 1;
  display: flex;
  width: calc(100vw - 36px);
  height: calc(100vh - 36px);
  margin: 18px auto;
  border-radius: 22px;
  background: var(--glass-bg);
  backdrop-filter: blur(42px) saturate(150%);
  -webkit-backdrop-filter: blur(42px) saturate(150%);
  border: 1px solid var(--glass-border-strong);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 242px;
  flex-shrink: 0;
  background: var(--glass-sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  gap: 14px;
  overflow: hidden;
}

.sidebar-top-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text-soft);
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid transparent;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-btn.active {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
}
.nav-ic { font-size: 13px; width: 16px; text-align: center; opacity: 0.85; }

.side-section { display: flex; flex-direction: column; gap: 5px; }
.side-history { flex: 1; min-height: 0; }
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.side-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 100%;
}
.side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  border: 1px solid transparent;
}
.side-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-item.active {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
}
.side-item-label {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.side-item-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.side-item:hover .side-item-actions { opacity: 1; }

.side-status-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 13px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.side-status-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.side-status-desc { margin: 0; font-size: 11px; line-height: 1.45; color: var(--muted); }

.side-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 4px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.profile-meta { flex: 1; min-width: 0; }
.profile-name { font-size: 12.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-plan { font-size: 10.5px; color: var(--muted); }

.orb-avatar {
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #a5b4fc, #6366f1 55%, #1e1b4b 100%);
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.7);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.orb-avatar::after {
  content: "✦";
  font-size: 24px;
  color: white;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  animation: hyper-dance 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes hyper-dance {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.3) rotate(180deg); opacity: 0.8; }
}
.orb-avatar.xs { width: 20px; height: 20px; }
.orb-avatar.sm { width: 28px; height: 28px; }
.orb-avatar.lg { width: 48px; height: 48px; margin: 0 auto 10px; }

/* Buttons & Inputs */
button { font-family: inherit; cursor: pointer; border: none; transition: all .15s ease; }
.icon-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1.2;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.icon-btn.xs { font-size: 11px; padding: 1px 4px; }

.glass-pill-btn {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
}
.glass-pill-btn:hover { background: rgba(255, 255, 255, 0.16); }
.glass-pill-btn.sm { padding: 5px 10px; font-size: 11.5px; border-radius: 8px; }
.glass-pill-btn.full { width: 100%; }

.btn-orb-primary {
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  color: #fff;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}
.btn-orb-primary:hover { filter: brightness(1.08); }
.btn-orb-primary.sm { padding: 7px 13px; font-size: 12px; }

input, textarea, select {
  background: rgba(15, 20, 28, 0.55);
  border: 1px solid var(--glass-border);
  color: #fff;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: rgba(129, 140, 248, 0.7); }

/* Main area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.mobile-header, .mobile-project-bar, .bottom-nav { display: none; }

.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 18px 24px;
  gap: 14px;
}
.tab-panel.active { display: flex; }

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-header h2, .tab-panel h2 {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-size: 18px;
  font-weight: 600;
}

/* Chat top breadcrumb */
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
}
.chat-crumb { display: flex; align-items: center; gap: 8px; font-size: 12px; min-width: 0; }
.crumb-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.11);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
}
.crumb-title { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-top-actions { display: flex; gap: 6px; }

/* HERO WELCOME SCREEN (matches reference screenshot!) */
.home-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 660px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 0 18px;
}

.hero-greeting { text-align: center; margin-bottom: 2px; }
.hero-greeting h1 {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-size: 31px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: #ffffff;
}
.hero-greeting p {
  margin: 5px 0 0;
  font-size: 14.5px;
  color: var(--text-soft);
  font-weight: 400;
}

.composer-slot, .bottom-composer-mount { width: 100%; max-width: 660px; margin: 0 auto; }

/* Glass Composer Box */
.glass-composer {
  width: 100%;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 12px 14px 10px;
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}
.glass-composer textarea {
  background: transparent;
  border: none;
  padding: 2px 2px;
  resize: none;
  font-size: 13.5px;
  line-height: 1.45;
  max-height: 130px;
  color: #fff;
}
.glass-composer textarea::placeholder { color: rgba(255, 255, 255, 0.45); }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.model-pill {
  width: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--text-soft);
}
.composer-right { display: flex; align-items: center; gap: 6px; }
.send-orb-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #60a5fa, #6366f1);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.65);
}
.send-orb-btn:disabled { opacity: 0.5; }

/* Action Chips */
.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
}
.glass-chip {
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 500;
}
.glass-chip:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* Glass Cards */
.glass-card {
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(16px);
}
.glass-card h3 { margin: 0; font-size: 14.5px; font-weight: 600; }

.hero-cards-row {
  display: grid;
  grid-template-columns: 185px 1fr;
  gap: 10px;
  width: 100%;
}
.hero-stat-card { justify-content: space-between; min-height: 98px; }
.stat-card-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-soft); }
.hero-clock {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.stat-card-sub { font-size: 11px; color: var(--muted); }

.hero-feature-card { min-height: 98px; justify-content: center; }
.feature-top { display: flex; justify-content: space-between; align-items: center; }
.new-badge {
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10.5px;
  color: var(--text-soft);
}
.feature-title { font-size: 13px; font-weight: 600; color: #fff; }
.feature-desc { font-size: 11.5px; color: var(--muted); line-height: 1.45; }

/* Recent Chats Grid */
.recent-section { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.recent-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-soft); font-weight: 500; }
.recent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.recent-card {
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.recent-card:hover { background: var(--glass-card-hover); border-color: var(--glass-border-strong); }
.recent-card-title { font-size: 12px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-card-time { font-size: 10.5px; color: var(--muted); }

/* Active Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 740px;
  width: 100%;
  margin: 0 auto;
  padding: 4px 4px 8px;
}
.msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.52;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.78), rgba(59, 130, 246, 0.78));
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-left-radius: 4px;
}

.msg-meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.trace-toggle {
  background: rgba(255, 255, 255, 0.08);
  color: #c7d2fe;
  padding: 3px 8px;
  font-size: 10.5px;
  border-radius: 6px;
  border: 1px solid rgba(165, 180, 252, 0.25);
}
.trace-box {
  margin-top: 6px;
  background: rgba(10, 14, 22, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px;
  font-size: 11px;
  color: #cbd5e1;
  overflow-x: auto;
}
.fb-btn {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}
.fb-btn.active { border-color: var(--accent); color: #fff; }

/* Auth & Utility */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(18px);
}
.auth-card { width: 100%; max-width: 360px; text-align: center; padding: 26px; }
.auth-card h1 { margin: 0 0 4px; font-family: "Plus Jakarta Sans", sans-serif; font-size: 20px; }
.auth-card input { margin: 10px 0 12px; }

.banner-warn {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12px;
}
.banner-warn a { color: #fff; font-weight: 600; }
.err-msg { background: rgba(239, 68, 68, 0.16); border: 1px solid rgba(239, 68, 68, 0.4); color: #fecaca; padding: 9px; border-radius: 8px; margin-top: 8px; font-size: 12px; }
.ok-msg { background: rgba(34, 197, 94, 0.16); border: 1px solid rgba(34, 197, 94, 0.4); color: #bbf7d0; padding: 8px 11px; border-radius: 8px; margin-top: 8px; font-size: 12px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cards-stack, .items-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.badge.pending { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge.in_progress { background: rgba(59, 130, 246, 0.22); color: #93c5fd; }
.badge.completed { background: rgba(34, 197, 94, 0.22); color: #86efac; }
.badge.failed { background: rgba(239, 68, 68, 0.22); color: #fca5a5; }

.inline-add, .copy-row { display: flex; gap: 8px; align-items: center; }
.row-end { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.inline-lbl { display: flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.inline-lbl input { width: 68px; }
.checkbox-lbl { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 4px 0; cursor: pointer; }
.checkbox-lbl input { width: auto; }
label { font-size: 12px; color: var(--text-soft); font-weight: 500; margin-top: 4px; }
.code-box { background: rgba(10, 14, 22, 0.65); border: 1px solid var(--glass-border); border-radius: 10px; padding: 10px; font-size: 11.5px; overflow-x: auto; }
.code-box pre { margin: 5px 0 0; white-space: pre-wrap; color: #c7d2fe; }

/* Custom subtle scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 999px; }

/* Mobile Responsive */
@media (max-width: 860px) {
  .app-frame {
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    border: none;
  }
  .sidebar { display: none; }
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(18, 21, 27, 0.65);
    border-bottom: 1px solid var(--glass-border);
  }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
  .mobile-actions { display: flex; align-items: center; gap: 6px; }
  .mobile-project-bar { display: flex; gap: 6px; align-items: center; }
  .mobile-project-bar select { flex: 1; padding: 6px 8px; font-size: 12px; }
  .chat-topbar { display: none; }
  .tab-panel { padding: 12px 12px 72px; }
  .hero-greeting h1 { font-size: 24px; }
  .hero-cards-row, .recent-grid, .two-col { grid-template-columns: 1fr; }
  .msg { max-width: 94%; }
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    background: rgba(18, 21, 27, 0.85);
    backdrop-filter: blur(24px);
    border-top: 1px solid var(--glass-border);
    justify-content: space-around;
    padding: 6px 0;
  }
  .bottom-nav .nav-btn { width: auto; justify-content: center; padding: 7px 12px; font-size: 16px; }
}
