/**
 * AISA COMPANION - CORE DESIGN SYSTEM & SANCTUARY THEME
 * Miyazaki Haruto Entertainment Co., Ltd. - Project MHEnt. Universe
 */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Colors */
  --bg-void: #05070b;
  --bg-deep: #080c14;
  --bg-surface: #0e1420;
  --bg-surface-elevated: #151d2d;
  --bg-glass: rgba(12, 17, 27, 0.75);
  --bg-glass-card: rgba(18, 25, 39, 0.6);
  --bg-glass-input: rgba(10, 14, 23, 0.9);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-focus: rgba(236, 72, 153, 0.5);

  /* Dual Persona Themes */
  --harmony-primary: #ec4899;
  --harmony-soft: #f472b6;
  --harmony-glow: rgba(236, 72, 153, 0.35);
  --harmony-bg: rgba(236, 72, 153, 0.08);
  --harmony-border: rgba(236, 72, 153, 0.25);

  --echo-primary: #8b5cf6;
  --echo-soft: #a855f7;
  --echo-glow: rgba(139, 92, 246, 0.35);
  --echo-bg: rgba(139, 92, 246, 0.08);
  --echo-border: rgba(139, 92, 246, 0.25);

  --cyan-primary: #06b6d4;
  --cyan-soft: #38bdf8;
  --cyan-glow: rgba(6, 182, 212, 0.35);

  --text-high: #f8fafc;
  --text-medium: #cbd5e1;
  --text-muted: #64748b;

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-glow: 0 0 24px rgba(236, 72, 153, 0.15);
  --transition-smooth: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-void);
  font-family: var(--font-body);
  color: var(--text-high);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 12% 15%, rgba(236, 72, 153, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 88% 20%, rgba(139, 92, 246, 0.09) 0%, transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ==========================================================================
   HEADER SANCTUARY
   ========================================================================== */
.sanctuary-header {
  height: 60px;
  padding: 0 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-medium);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.btn-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-high);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo-img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  box-shadow: 0 0 14px var(--harmony-glow);
  transition: var(--transition-smooth);
}
.brand-logo-img:hover {
  transform: scale(1.06);
}

.brand-info h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  background: linear-gradient(135deg, #ffffff 40%, #f472b6 80%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-info h1 span {
  font-weight: 400;
  font-size: 0.78rem;
  letter-spacing: 1px;
  opacity: 0.85;
}

/* Central Scope Selector Tabs */
.header-scope-tabs {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.scope-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 5px;
}
.scope-tab-btn:hover {
  color: var(--text-high);
}
.scope-tab-btn.active {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.28), rgba(139, 92, 246, 0.28));
  color: #ffffff;
  border: 1px solid rgba(244, 114, 182, 0.45);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.2);
}

/* Header Right Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-header-action {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-medium);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}
.btn-header-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-high);
  border-color: var(--border-medium);
}
.btn-header-action.active {
  background: rgba(236, 72, 153, 0.22);
  border-color: var(--harmony-primary);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.3);
}

.badge-counter {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  padding: 1px 6px;
  font-weight: 800;
}

/* ==========================================================================
   APP STAGE LAYOUT (3-COLUMN: SLIM LEFT + IMMERSIVE CENTER + SLIM RIGHT)
   ========================================================================== */
.sanctuary-stage {
  flex: 1;
  min-height: 0; /* CRUCIAL: Allow flex child to shrink properly */
  display: grid;
  grid-template-columns: 250px 1fr 240px;
  overflow: hidden;
  position: relative;
}

/* Sidebar Left: Sleek, Elegant & Collapsible */
.sanctuary-sidebar-left {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px;
  gap: 14px;
  z-index: 50;
}

.sanctuary-sidebar-left.collapsed {
  margin-left: -250px;
}

/* Center Stage: The Main Stage Where Conversation Breathes */
.sanctuary-chat-center {
  min-height: 0; /* CRUCIAL: Prevent vertical overflow beyond viewport */
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 20%, rgba(15, 21, 34, 0.4) 0%, rgba(5, 7, 11, 0.8) 100%);
  overflow: hidden;
  position: relative;
  height: 100%;
}

/* Sidebar Right: Slim Utility Panel */
.sanctuary-sidebar-right {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  gap: 14px;
  z-index: 40;
}

/* Responsive Media Queries */
@media (max-width: 1180px) {
  .sanctuary-stage {
    grid-template-columns: 250px 1fr;
  }
  .sanctuary-sidebar-right {
    display: none;
  }
}

@media (max-width: 820px) {
  .sanctuary-stage {
    grid-template-columns: 1fr;
  }
  .sanctuary-sidebar-left {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 260px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
  }
  .sanctuary-sidebar-left.collapsed {
    margin-left: -270px;
  }
}

@media (max-width: 680px) {
  .sanctuary-header {
    padding: 0 12px;
    height: 54px;
  }
  .header-scope-tabs {
    display: none;
  }
  .btn-header-action span:not(.badge-counter) {
    display: none;
  }
}
