/* =========================================================
   Scooplore PWA — style.css
   Mobile-first, dark-first, env(safe-area-inset) for iOS
   ========================================================= */

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design Tokens — Dark Theme (default) ── */
:root,
[data-theme="dark"],
body.theme-dark {
  --bg:           #0F0F0F;
  --bg-alt:       #141414;
  --surface:      #1A1A1A;
  --surface-2:    #202020;
  --surface-3:    #2A2A2A;
  --border:       #2E2E2E;
  --border-subtle:#252525;
  --text:         #E8E8E8;
  --text-2:       #A0A0A0;
  --text-3:       #606060;
  --accent:       #C9A84C;
  --accent-dim:   #A88A3A;
  --accent-glow:  rgba(201,168,76,0.12);
  --danger:       #E05555;
  --success:      #4CAF7D;
  --info:         #5B9FD8;

  /* Sidebar */
  --sidebar-w:    260px;
  --sidebar-bg:   #111111;

  /* Header */
  --header-h:     52px;
  --header-bg:    #111111;

  /* Studio */
  --msg-user-bg:  #1E1E1E;
  --msg-ai-bg:    transparent;

  /* Stage */
  --stage-w:      340px;
  --stage-bg:     #111111;

  /* Typography */
  --font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'SF Mono', 'Fira Code', Consolas, 'Courier New', monospace;
  --font-serif:   Georgia, 'Times New Roman', serif;

  /* Spacing */
  --space-1:      4px;
  --space-2:      8px;
  --space-3:      12px;
  --space-4:      16px;
  --space-5:      20px;
  --space-6:      24px;
  --space-8:      32px;

  /* Border radius */
  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --radius-full:  9999px;

  /* Transitions */
  --transition:   150ms ease;
  --transition-md:250ms ease;
}

/* ── Light Theme ── */
[data-theme="light"],
body.theme-light {
  --bg:           #F7F5F0;
  --bg-alt:       #EFEDE8;
  --surface:      #FFFFFF;
  --surface-2:    #F3F1EC;
  --surface-3:    #E8E6E1;
  --border:       #D8D5CE;
  --border-subtle:#E0DDD7;
  --text:         #1A1A1A;
  --text-2:       #555550;
  --text-3:       #999890;
  --accent:       #A07828;
  --accent-dim:   #886520;
  --accent-glow:  rgba(160,120,40,0.10);
  --danger:       #C43A3A;
  --success:      #2E7D52;
  --info:         #2563A8;

  --sidebar-bg:   #EDEAE4;
  --header-bg:    #EDEAE4;
  --msg-user-bg:  #F0EDE7;
  --msg-ai-bg:    transparent;
  --stage-bg:     #EDEAE4;
}

/* ── HTML & Body ── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family:    var(--font-ui);
  background:     var(--bg);
  color:          var(--text);
  height:         100%;
  min-height:     100dvh;
  overflow:       hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Utility ── */
.hidden     { display: none !important; }
.sr-only    { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Scrollbars ── */
::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover  { background: var(--text-3); }


/* ════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════ */

.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             var(--space-2);
  padding:         var(--space-2) var(--space-4);
  font-family:     var(--font-ui);
  font-size:       14px;
  font-weight:     500;
  border:          none;
  border-radius:   var(--radius-md);
  cursor:          pointer;
  text-decoration: none;
  transition:      background var(--transition), color var(--transition), opacity var(--transition);
  white-space:     nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-accent {
  background: var(--accent);
  color:      #0F0F0F;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-dim); }

.btn-ghost {
  background: transparent;
  color:      var(--text-2);
  border:     1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color:      #fff;
}

.btn-sm { padding: var(--space-1) var(--space-3); font-size: 13px; }

.btn-icon {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  width:           36px;
  height:          36px;
  border:          none;
  border-radius:   var(--radius-md);
  background:      transparent;
  color:           var(--text-2);
  cursor:          pointer;
  font-size:       18px;
  line-height:     1;
  transition:      background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
  flex-shrink:     0;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.btn-sm { width: 28px; height: 28px; font-size: 14px; }


/* ════════════════════════════════════════════════
   FORM FIELDS
   ════════════════════════════════════════════════ */

.field        { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.field-row    { flex-direction: row; align-items: center; justify-content: space-between; }
.field-label  { font-size: 13px; color: var(--text-2); font-weight: 500; }
.field-hint   { font-size: 12px; color: var(--text-3); }

.field-input,
.field-select,
.field-textarea {
  width:         100%;
  padding:       var(--space-2) var(--space-3);
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  color:         var(--text);
  font-family:   var(--font-ui);
  font-size:     14px;
  line-height:   1.5;
  transition:    border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline:      none;
  border-color: var(--accent);
  box-shadow:   0 0 0 3px var(--accent-glow);
}
.field-textarea { resize: vertical; min-height: 72px; }

/* Toggle switch */
.toggle {
  position:      relative;
  width:         44px;
  height:        24px;
  border:        none;
  border-radius: var(--radius-full);
  background:    var(--surface-3);
  cursor:        pointer;
  transition:    background var(--transition-md);
  flex-shrink:   0;
}
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle-thumb {
  position:      absolute;
  top:           3px;
  left:          3px;
  width:         18px;
  height:        18px;
  border-radius: 50%;
  background:    #fff;
  transition:    transform var(--transition-md);
}
.toggle[aria-checked="true"] .toggle-thumb { transform: translateX(20px); }


/* ════════════════════════════════════════════════
   LOADING SCREEN
   ════════════════════════════════════════════════ */

.loading-screen {
  position:       fixed;
  inset:          0;
  background:     var(--bg);
  display:        flex;
  align-items:    center;
  justify-content:center;
  z-index:        1000;
  transition:     opacity 0.4s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-inner {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            var(--space-4);
}

.loading-wordmark {
  font-size:   28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color:       var(--text);
}

.loading-tagline {
  font-size:  13px;
  color:      var(--text-3);
  letter-spacing: 0.3px;
}

.loading-spinner {
  width:         32px;
  height:        32px;
  border:        2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation:     spin 0.8s linear infinite;
}

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


/* ════════════════════════════════════════════════
   PLATFORM WARNING & FS PERMISSION
   ════════════════════════════════════════════════ */

.platform-warning,
.fs-permission {
  position:       fixed;
  inset:          0;
  background:     rgba(0,0,0,0.75);
  display:        flex;
  align-items:    center;
  justify-content:center;
  padding:        var(--space-4);
  z-index:        900;
  backdrop-filter:blur(4px);
}

.platform-warning-inner,
.fs-permission-inner {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-xl);
  padding:       var(--space-8);
  max-width:     400px;
  width:         100%;
  text-align:    center;
  display:       flex;
  flex-direction:column;
  gap:           var(--space-4);
}

.pw-icon,
.fsp-icon {
  font-size: 32px;
}

.pw-title,
.fsp-title {
  font-size:   20px;
  font-weight: 600;
  color:       var(--text);
}

.pw-message,
.fsp-message {
  font-size:   14px;
  color:       var(--text-2);
  line-height: 1.6;
}

.pw-actions,
.fsp-actions {
  display:        flex;
  flex-direction: column;
  gap:            var(--space-2);
}

@media (min-width: 480px) {
  .pw-actions,
  .fsp-actions {
    flex-direction: row;
    justify-content:center;
  }
}


/* ════════════════════════════════════════════════
   SETTINGS SCREEN
   ════════════════════════════════════════════════ */

.settings-screen {
  position:       fixed;
  inset:          0;
  background:     rgba(0,0,0,0.6);
  display:        flex;
  align-items:    flex-end;
  justify-content:center;
  z-index:        800;
  backdrop-filter:blur(4px);
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 640px) {
  .settings-screen {
    align-items:    center;
  }
}

.settings-inner {
  background:     var(--surface);
  border:         1px solid var(--border);
  border-radius:  var(--radius-xl) var(--radius-xl) 0 0;
  width:          100%;
  max-width:      520px;
  max-height:     90dvh;
  display:        flex;
  flex-direction: column;
  overflow:       hidden;
}

@media (min-width: 640px) {
  .settings-inner {
    border-radius: var(--radius-xl);
    max-height:    80dvh;
  }
}

.settings-header {
  display:        flex;
  align-items:    center;
  justify-content:space-between;
  padding:        var(--space-4) var(--space-5);
  border-bottom:  1px solid var(--border);
  flex-shrink:    0;
}

.settings-title {
  font-size:   18px;
  font-weight: 600;
}

.settings-body {
  flex:       1;
  overflow-y: auto;
  padding:    var(--space-5);
}

.settings-section {
  margin-bottom: var(--space-6);
}

.settings-section-title {
  font-size:     11px;
  font-weight:   600;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:         var(--text-3);
  margin-bottom: var(--space-3);
}

.settings-footer {
  display:        flex;
  align-items:    center;
  justify-content:flex-end;
  gap:            var(--space-2);
  padding:        var(--space-4) var(--space-5);
  border-top:     1px solid var(--border);
  flex-shrink:    0;
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
}


/* ════════════════════════════════════════════════
   APP SHELL
   ════════════════════════════════════════════════ */

.app {
  display:        flex;
  flex-direction: column;
  height:         100dvh;
  overflow:       hidden;
  padding-top:    env(safe-area-inset-top);
}


/* ════════════════════════════════════════════════
   HEADER
   ════════════════════════════════════════════════ */

.app-header {
  height:         var(--header-h);
  background:     var(--header-bg);
  border-bottom:  1px solid var(--border);
  display:        flex;
  align-items:    center;
  justify-content:space-between;
  padding:        0 var(--space-3);
  gap:            var(--space-2);
  flex-shrink:    0;
  padding-left:   calc(var(--space-3) + env(safe-area-inset-left));
  padding-right:  calc(var(--space-3) + env(safe-area-inset-right));
  z-index:        100;
}

.header-left,
.header-right {
  display:    flex;
  align-items:center;
  gap:        var(--space-1);
  min-width:  80px;
}

.header-right { justify-content: flex-end; }

.header-wordmark {
  font-size:      16px;
  font-weight:    700;
  letter-spacing: -0.3px;
  color:          var(--text);
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

/* Mode tabs */
.mode-tabs {
  display:        flex;
  align-items:    center;
  gap:            2px;
  background:     var(--surface-2);
  border-radius:  var(--radius-md);
  padding:        2px;
}

.mode-tab {
  padding:       6px 14px;
  font-size:     13px;
  font-weight:   500;
  border:        none;
  border-radius: calc(var(--radius-md) - 2px);
  background:    transparent;
  color:         var(--text-2);
  cursor:        pointer;
  transition:    background var(--transition), color var(--transition);
  white-space:   nowrap;
  -webkit-tap-highlight-color: transparent;
}

.mode-tab.active,
.mode-tab[aria-selected="true"] {
  background: var(--surface);
  color:      var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.mode-tab:hover:not(.active) { color: var(--text); }

.icon-hamburger {
  display:        flex;
  flex-direction: column;
  gap:            4px;
  width:          18px;
}
.icon-hamburger span {
  display:       block;
  height:        1.5px;
  background:    currentColor;
  border-radius: var(--radius-full);
  transition:    transform var(--transition-md), opacity var(--transition-md);
}

/* Hamburger → X when sidebar open */
.sidebar-toggle.active .icon-hamburger span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.sidebar-toggle.active .icon-hamburger span:nth-child(2) { opacity: 0; }
.sidebar-toggle.active .icon-hamburger span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }


/* ════════════════════════════════════════════════
   APP BODY
   ════════════════════════════════════════════════ */

.app-body {
  display:  flex;
  flex:     1;
  overflow: hidden;
  position: relative;
}


/* ════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════ */

.sidebar {
  width:           var(--sidebar-w);
  background:      var(--sidebar-bg);
  border-right:    1px solid var(--border);
  display:         flex;
  flex-direction:  column;
  overflow:        hidden;
  flex-shrink:     0;
  transition:      transform var(--transition-md);

  /* Mobile: off-canvas by default */
  position:        absolute;
  top:             0;
  left:            0;
  bottom:          0;
  transform:       translateX(-100%);
  z-index:         50;
  padding-bottom:  env(safe-area-inset-bottom);
}

.sidebar.open { transform: translateX(0); }

/* Desktop: always visible */
@media (min-width: 768px) {
  .sidebar {
    position:  relative;
    transform: none;
    z-index:   auto;
  }
}

.sidebar-overlay {
  position:   absolute;
  inset:      0;
  background: rgba(0,0,0,0.5);
  z-index:    40;
  backdrop-filter: blur(2px);
}

.sidebar-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         var(--space-3) var(--space-4);
  border-bottom:   1px solid var(--border-subtle);
  flex-shrink:     0;
}

.sidebar-section-label {
  font-size:     11px;
  font-weight:   600;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:         var(--text-3);
}

.project-list {
  flex:       1;
  overflow-y: auto;
  padding:    var(--space-2);
}

.project-list-empty {
  padding:    var(--space-5);
  text-align: center;
  color:      var(--text-3);
  font-size:  13px;
  display:    flex;
  flex-direction: column;
  gap:        var(--space-3);
}

.project-item {
  display:       flex;
  align-items:   center;
  gap:           var(--space-2);
  padding:       var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor:        pointer;
  transition:    background var(--transition);
  font-size:     14px;
  color:         var(--text-2);
  -webkit-tap-highlight-color: transparent;
}

.project-item:hover     { background: var(--surface-2); color: var(--text); }
.project-item.active    { background: var(--surface-3); color: var(--text); }

.project-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item-icon { font-size: 14px; flex-shrink: 0; }

.sidebar-footer {
  padding:      var(--space-2) var(--space-3);
  border-top:   1px solid var(--border-subtle);
  flex-shrink:  0;
  display:      flex;
  gap:          var(--space-1);
}


/* ════════════════════════════════════════════════
   CONTENT AREA
   ════════════════════════════════════════════════ */

.content {
  flex:     1;
  overflow: hidden;
  display:  flex;
  flex-direction: column;
}

.mode-panel {
  display:        none;
  flex:           1;
  overflow:       hidden;
}

.mode-panel.active { display: flex; }


/* ════════════════════════════════════════════════
   STUDIO MODE
   ════════════════════════════════════════════════ */

.studio-layout {
  display:   flex;
  flex:      1;
  overflow:  hidden;
  height:    100%;
}

/* ── Studio conversation (left / main) ── */
.studio-conversation {
  display:        flex;
  flex-direction: column;
  flex:           1;
  overflow:       hidden;
  min-width:      0;
}

.studio-messages {
  flex:       1;
  overflow-y: auto;
  padding:    var(--space-5) var(--space-4);
  display:    flex;
  flex-direction: column;
  gap:        var(--space-4);
}

/* Welcome state */
.studio-welcome {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  justify-content:center;
  gap:            var(--space-4);
  flex:           1;
  text-align:     center;
  padding:        var(--space-8) var(--space-4);
  color:          var(--text-2);
}

.studio-welcome-icon {
  font-size: 36px;
  color:     var(--accent);
}

.studio-welcome-title {
  font-size:   24px;
  font-weight: 700;
  color:       var(--text);
}

.studio-welcome-sub {
  font-size:   15px;
  line-height: 1.6;
  max-width:   380px;
}

/* Messages */
.msg {
  display:       flex;
  flex-direction:column;
  gap:           var(--space-1);
  max-width:     780px;
  width:         100%;
  margin:        0 auto;
}

.msg-role {
  font-size:     11px;
  font-weight:   600;
  text-transform:uppercase;
  letter-spacing:0.06em;
  color:         var(--text-3);
}

.msg.msg-user { align-items: flex-end; }
.msg.msg-user .msg-role { color: var(--accent); }

.msg-body {
  padding:       var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size:     15px;
  line-height:   1.7;
  word-break:    break-word;
}

.msg-user .msg-body {
  background:    var(--msg-user-bg);
  border:        1px solid var(--border);
  border-bottom-right-radius: var(--radius-sm);
  max-width:     480px;
}

.msg-ai .msg-body {
  background:    var(--msg-ai-bg);
  color:         var(--text);
}

/* Markdown in messages */
.msg-md h1, .msg-md h2, .msg-md h3 {
  font-weight: 600;
  margin: var(--space-4) 0 var(--space-2);
  color: var(--text);
}
.msg-md h1 { font-size: 20px; }
.msg-md h2 { font-size: 17px; }
.msg-md h3 { font-size: 15px; }
.msg-md p  { margin-bottom: var(--space-3); }
.msg-md p:last-child { margin-bottom: 0; }
.msg-md ul, .msg-md ol { padding-left: var(--space-5); margin-bottom: var(--space-3); }
.msg-md li { margin-bottom: var(--space-1); line-height: 1.6; }
.msg-md strong { font-weight: 600; color: var(--text); }
.msg-md em { font-style: italic; }
.msg-md code {
  font-family:   var(--font-mono);
  font-size:     13px;
  background:    var(--surface-2);
  border:        1px solid var(--border);
  padding:       1px 5px;
  border-radius: var(--radius-sm);
}
.msg-md pre {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  padding:       var(--space-3) var(--space-4);
  overflow-x:    auto;
  margin-bottom: var(--space-3);
}
.msg-md pre code { background: none; border: none; padding: 0; }
.msg-md blockquote {
  border-left:   3px solid var(--accent);
  padding-left:  var(--space-3);
  margin:        var(--space-3) 0;
  color:         var(--text-2);
  font-style:    italic;
}
.msg-md hr {
  border:        none;
  border-top:    1px solid var(--border);
  margin:        var(--space-4) 0;
}

/* Typing indicator */
.msg-typing .msg-body {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── Studio input ── */
.studio-input-wrap {
  border-top:     1px solid var(--border);
  padding:        var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  flex-shrink:    0;
  display:        flex;
  flex-direction: column;
  gap:            var(--space-2);
}

.attachment-bar {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  padding:       var(--space-2) var(--space-3);
}

.attachment-list {
  display:   flex;
  flex-wrap: wrap;
  gap:       var(--space-2);
}

.attachment-chip {
  display:       flex;
  align-items:   center;
  gap:           var(--space-1);
  background:    var(--surface-3);
  border:        1px solid var(--border);
  border-radius: var(--radius-full);
  padding:       2px var(--space-2);
  font-size:     12px;
  color:         var(--text-2);
}

.attachment-chip button {
  background: none;
  border:     none;
  color:      var(--text-3);
  cursor:     pointer;
  line-height:1;
  padding:    0 2px;
  font-size:  14px;
}
.attachment-chip button:hover { color: var(--danger); }

.studio-input-row {
  display:     flex;
  align-items: flex-end;
  gap:         var(--space-2);
}

.studio-input {
  flex:          1;
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       var(--space-2) var(--space-3);
  color:         var(--text);
  font-family:   var(--font-ui);
  font-size:     15px;
  line-height:   1.5;
  resize:        none;
  overflow:      hidden;
  max-height:    160px;
  overflow-y:    auto;
  transition:    border-color var(--transition), box-shadow var(--transition);
}

.studio-input:focus {
  outline:      none;
  border-color: var(--accent);
  box-shadow:   0 0 0 3px var(--accent-glow);
}

.studio-input::placeholder { color: var(--text-3); }

.btn-send {
  width:         40px;
  height:        40px;
  padding:       0;
  border-radius: var(--radius-full);
  font-size:     18px;
  flex-shrink:   0;
}

.btn-attach {
  width:      36px;
  height:     36px;
  flex-shrink:0;
  font-size:  18px;
}

.studio-input-hint {
  font-size: 12px;
  color:     var(--text-3);
  text-align:center;
}


/* ════════════════════════════════════════════════
   STAGE PANEL
   ════════════════════════════════════════════════ */

.stage-panel {
  width:          var(--stage-w);
  background:     var(--stage-bg);
  border-left:    1px solid var(--border);
  display:        flex;
  flex-direction: column;
  overflow:       hidden;
  flex-shrink:    0;

  /* Hidden on mobile by default */
  display:        none;
}

@media (min-width: 900px) {
  .stage-panel { display: flex; }
}

.stage-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         var(--space-3) var(--space-4);
  border-bottom:   1px solid var(--border);
  flex-shrink:     0;
}

.stage-title {
  font-size:   13px;
  font-weight: 600;
  color:       var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stage-actions {
  display: flex;
  gap:     var(--space-1);
}

.stage-content {
  flex:       1;
  overflow-y: auto;
  padding:    var(--space-4);
  font-size:  14px;
  line-height:1.8;
  color:      var(--text);
}

.stage-empty {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  justify-content:center;
  height:         100%;
  gap:            var(--space-4);
  color:          var(--text-3);
  text-align:     center;
  font-size:      13px;
  line-height:    1.6;
}

/* Doc-dot animation */
.doc-dot-wrap {
  display: flex;
  gap:     6px;
  align-items: center;
  margin-bottom: var(--space-2);
}

.doc-dot {
  width:         8px;
  height:        8px;
  border-radius: 50%;
  background:    var(--border);
  animation:     doc-pulse 2s infinite ease-in-out;
}

.doc-dot:nth-child(2) { animation-delay: 0.4s; background: var(--text-3); }
.doc-dot:nth-child(3) { animation-delay: 0.8s; background: var(--accent); }

@keyframes doc-pulse {
  0%, 100% { transform: scale(1);   opacity: 0.5; }
  50%       { transform: scale(1.4); opacity: 1;   }
}

/* Stage content: markdown rendering */
.stage-content h1,
.stage-content h2,
.stage-content h3 {
  font-weight: 600;
  margin: var(--space-5) 0 var(--space-2);
  color: var(--text);
}
.stage-content h1 { font-size: 18px; }
.stage-content h2 { font-size: 16px; }
.stage-content h3 { font-size: 14px; }
.stage-content p  { margin-bottom: var(--space-3); }
.stage-content ul,
.stage-content ol { padding-left: var(--space-5); margin-bottom: var(--space-3); }
.stage-content li { margin-bottom: var(--space-1); }
.stage-content strong { font-weight: 600; color: var(--text); }
.stage-content em { font-style: italic; }
.stage-content hr { border: none; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
.stage-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-3);
  color: var(--text-2);
  font-style: italic;
  margin: var(--space-3) 0;
}


/* ════════════════════════════════════════════════
   COMING SOON PLACEHOLDER
   ════════════════════════════════════════════════ */

.coming-soon {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  justify-content:center;
  flex:           1;
  gap:            var(--space-4);
  color:          var(--text-2);
  text-align:     center;
  padding:        var(--space-8);
}

.coming-soon-icon { font-size: 48px; }
.coming-soon h2   { font-size: 20px; font-weight: 600; color: var(--text); }
.coming-soon p    { font-size: 14px; line-height: 1.6; max-width: 320px; }


/* ════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ════════════════════════════════════════════════ */

.toast-container {
  position:       fixed;
  bottom:         calc(var(--space-5) + env(safe-area-inset-bottom));
  left:           50%;
  transform:      translateX(-50%);
  display:        flex;
  flex-direction: column;
  gap:            var(--space-2);
  z-index:        950;
  pointer-events: none;
  width:          min(340px, 90vw);
}

.toast {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       var(--space-3) var(--space-4);
  font-size:     14px;
  color:         var(--text);
  box-shadow:    0 4px 20px rgba(0,0,0,0.4);
  animation:     toast-in 0.25s ease forwards;
  pointer-events:auto;
}

.toast.success { border-color: var(--success); }
.toast.danger  { border-color: var(--danger);  }
.toast.info    { border-color: var(--info);    }

.toast.fade-out { animation: toast-out 0.25s ease forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(8px); } }


/* ════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ════════════════════════════════════════════════ */

/* Very small screens */
@media (max-width: 380px) {
  .mode-tab { padding: 6px 10px; font-size: 12px; }
  .header-wordmark { font-size: 14px; }
  .studio-messages { padding: var(--space-3); }
  .studio-input-wrap { padding: var(--space-2) var(--space-3); padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom)); }
}

/* Tablet */
@media (min-width: 640px) and (max-width: 899px) {
  :root { --stage-w: 300px; }
  .stage-panel { display: flex; }
}

/* Large desktop */
@media (min-width: 1200px) {
  :root { --stage-w: 380px; }
  .studio-messages { padding: var(--space-6) var(--space-8); }
}


/* Fix 7 — Documentation animation hidden by default */
#doc-animation { display: none; }
#doc-animation.active { display: block; }
.doc-dot { opacity: 0.2; }
#doc-animation.active .doc-dot { opacity: 1; }
