:root {
  --bg-main: #FAF5EE;
  --bg-card: #FFFFFF;
  --text-dark: #381C0B;
  --text-muted: #8D7768;
  --bao-brown: #4A2810;
  --bao-brown-dark: #361D0C;
  --bao-gold: #C58940;
  --bao-honey: #D4A373;
  --bao-cream: #F5ECE1;

  --accent-emerald: #10B981;
  --accent-cyan: #06B6D4;
  --accent-indigo: #6366F1;
  --accent-coral: #FF6B6B;
  --accent-amber: #F59E0B;

  --shadow-soft: 0 10px 30px -10px rgba(74, 40, 16, 0.08);
  --shadow-hover: 0 20px 40px -12px rgba(74, 40, 16, 0.16);
  --shadow-pill: 0 4px 14px rgba(74, 40, 16, 0.08);
}

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

body {
  font-family: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-dark);
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(212, 163, 115, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 25%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 85%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Universal Vietnamese Typography Consistency - Zero Glitch */
input, textarea, select, button {
  font-family: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

#antigravityPromptInput, .antigravity-chat-input, .antigravity-chat-box {
  font-family: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-size: 13px;
  line-height: 1.5;
}

.borderless-card {
  border: none !important;
  box-shadow: var(--shadow-soft);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.borderless-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.circle-btn {
  border-radius: 9999px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none !important;
  transition: all 0.25s ease;
  cursor: pointer;
  box-shadow: var(--shadow-pill);
}

.circle-btn:hover {
  transform: scale(1.05);
}

.circle-btn:active {
  transform: scale(0.95);
}

.bao-logo-ring {
  width: 54px;
  height: 54px;
  border-radius: 9999px;
  object-fit: cover;
  box-shadow: 0 6px 20px rgba(74, 40, 16, 0.2);
  transition: transform 0.5s ease;
}

.bao-logo-ring:hover {
  transform: rotate(360deg) scale(1.06);
}

.pulse-dot {
  animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.4;
  }
}

.terminal-box {
  background: #140E0A;
  color: #A7F3D0;
  font-family: 'JetBrains Mono', Consolas, monospace;
  border-radius: 24px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}


/* ===================================================================
   IPHONE 16 PRO MAX & PWA OPTIMIZATIONS
   =================================================================== */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(130px, calc(env(safe-area-inset-bottom) + 105px)) !important;
  }
}

.mobile-bottom-bar {
  padding-top: 10px !important;
  padding-bottom: max(26px, calc(env(safe-area-inset-bottom) + 18px)) !important;
}

header.sticky {
  padding-top: max(14px, calc(env(safe-area-inset-top) + 6px)) !important;
}

.blur-locked {
  filter: blur(4px) grayscale(60%);
  pointer-events: none !important;
  user-select: none !important;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Custom scrollbars for clean look */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(197, 137, 64, 0.25);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(197, 137, 64, 0.45);
}

/* Radar Sub-Tabs & History Timeline Styling */
.radar-sub-btn {
  border: 1px solid #EADDCD;
  cursor: pointer;
}
.radar-sub-btn.active {
  background-color: var(--bao-brown) !important;
  color: #FFFFFF !important;
  border-color: var(--bao-gold) !important;
  box-shadow: 0 4px 12px rgba(74, 40, 16, 0.18) !important;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Device Adaptive Optimization */
@media (min-width: 1024px) {
  .device-desktop main, .device-desktop section {
    max-width: 1380px;
  }
}

.device-iphone-promax body {
  padding-bottom: max(100px, calc(env(safe-area-inset-bottom) + 85px));
}

.device-samsung-note9 body,
.device-oppo body {
  padding-bottom: 95px;
}

/* Responsive Desktop Header Navigation & Controls */
#navTabsContainer {
  display: none;
}
@media (min-width: 768px) {
  #navTabsContainer {
    display: flex !important;
  }
}

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

/* Header Logout Buttons */
#desktopHeaderGuestBtn.hidden,
#mobileHeaderGuestBtn.hidden {
  display: none !important;
}

@media (min-width: 768px) {
  #desktopHeaderGuestBtn:not(.hidden) {
    display: inline-flex !important;
  }
}

@media (max-width: 767px) {
  #mobileHeaderGuestBtn:not(.hidden) {
    display: inline-flex !important;
  }
}

/* Ensure no accidental horizontal overflow */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ===================================================================
   HIGH DEFINITION LIVE VIEW & ANTIGRAVITY CRISP RENDERING ENGINE
   =================================================================== */
.stream-screen-sharp {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: high-quality;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.text-clarity-boost {
  filter: contrast(1.08) brightness(1.02) saturate(1.05);
}

.text-clarity-ultra {
  filter: contrast(1.18) brightness(1.04) saturate(1.10) drop-shadow(0 0 1px rgba(0,0,0,0.6));
}

.text-clarity-raw {
  filter: none !important;
}

/* ===================================================================
   MULTI-HARNESS AI STUDIO (IPHONE 16 PRO MAX & MOBILE-FIRST)
   =================================================================== */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.harness-feed-scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.harness-composer-sticky {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + 74px);
  z-index: 30;
}

@media (min-width: 768px) {
  .harness-composer-sticky {
    bottom: 12px;
  }
}

/* Prevent iOS Safari zoom on input focus */
@media (max-width: 639px) {
  #harnessPromptInput,
  #harnessWorkspaceInput,
  #harnessSessionSearchInput {
    font-size: 16px !important;
  }
}

.harness-msg-body p {
  margin: 0.25rem 0;
  line-height: 1.55;
}
.harness-msg-body p:first-child {
  margin-top: 0;
}
.harness-msg-body p:last-child {
  margin-bottom: 0;
}
.harness-msg-body h1,
.harness-msg-body h2,
.harness-msg-body h3 {
  font-weight: 800;
  color: #381C0B;
  margin: 0.55rem 0 0.25rem;
  line-height: 1.3;
}
.harness-msg-body h1 { font-size: 1.05rem; }
.harness-msg-body h2 { font-size: 0.98rem; }
.harness-msg-body h3 { font-size: 0.92rem; }
.harness-msg-body ul,
.harness-msg-body ol {
  margin: 0.3rem 0 0.4rem 1.25rem;
  padding: 0;
}
.harness-msg-body ul {
  list-style-type: disc;
}
.harness-msg-body ol {
  list-style-type: decimal;
}
.harness-msg-body li {
  margin: 0.15rem 0;
  line-height: 1.5;
}
.harness-msg-body blockquote {
  border-left: 3px solid #D4A373;
  padding-left: 0.65rem;
  margin: 0.35rem 0;
  color: #6E5647;
}

/* ===================================================================
   MOBILE WEB IDE & INTERACTIVE CLI (IPHONE 16 PRO MAX)
   =================================================================== */
.ide-mono {
  font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace !important;
  font-variant-ligatures: none;
}

.ide-cli-output {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

#ideFileTree {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

@media (max-width: 639px) {
  #ideCliInput,
  #ideWorkspaceInput,
  #ideCurrentPath,
  #ideFileEditor,
  #liveHarnessInput {
    font-size: 16px !important;
  }
}

/* ===================================================================
   LIVE HARNESS WINDOW STREAM & AGY TRANSCRIPT (IPHONE 16 PRO MAX)
   =================================================================== */
.live-harness-tap-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  border: 2.5px solid #F59E0B;
  background: rgba(245, 158, 11, 0.32);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18), 0 2px 8px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%) scale(0.75);
  animation: liveHarnessTapRipple 0.55s ease-out forwards;
  z-index: 20;
}

@keyframes liveHarnessTapRipple {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.65);
  }
  70% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.35);
  }
}

.live-harness-transcript {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ===================================================================
   COMMAND PALETTE (CTRL+K), ADMIN BENTO GRID & MOBILE APP SHEET (v4.2)
   =================================================================== */
.bento-card {
  background: var(--bg-card);
  border: 1px solid #EADDCD;
  border-radius: 1.5rem;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.bento-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: rgba(197, 137, 64, 0.45);
}

.bento-progress-track {
  height: 0.45rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bento-progress-track-light {
  height: 0.45rem;
  border-radius: 9999px;
  background: #F5ECE1;
  overflow: hidden;
  border: 1px solid #EADDCD;
}

.bento-progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
}

.cmd-item-active {
  background-color: #F5ECE1 !important;
  border-color: #C58940 !important;
  box-shadow: 0 2px 10px rgba(74, 40, 16, 0.08);
}

@keyframes sheetSlideUp {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-sheet-panel {
  animation: sheetSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
}

.mobile-dock-btn {
  min-width: 56px;
  min-height: 50px;
  border-radius: 14px;
}

.mobile-dock-btn:active {
  background-color: rgba(197, 137, 64, 0.12);
}

@media (max-width: 639px) {
  #commandPaletteInput {
    font-size: 16px !important;
  }
}
