/* ==========================================================================
   Google AI Studio — Material 3 Design System
   ========================================================================== */

:root {
  /* Light Theme (Default fallback) */
  --bg-base: #ffffff;
  --bg-surface: #f0f4f9;
  --bg-surface-variant: #e1e3e1;
  --bg-hover: #e9eef6;
  --bg-active: #d3e3fd;
  --text-primary: #1f1f1f;
  --text-secondary: #444746;
  --text-tertiary: #747775;
  --border-subtle: #e0e2e0;
  --border-color: #c4c7c5;
  --border-focus: #0b57d0;
  --accent-primary: #0b57d0;
  --accent-primary-hover: #0842a0;
  --accent-surface: #d3e3fd;
  --gemini-gradient: linear-gradient(135deg, #1a73e8 0%, #8ab4f8 50%, #ea4335 100%);
  --gemini-sparkle: linear-gradient(135deg, #4285F4 0%, #9B72CB 50%, #D96570 100%);
  --thinking-bg: #f8fafd;
  --code-bg: #1e1f20;
  --code-text: #c4c7c5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --font-family: 'Google Sans', 'Pretendard', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-code: 'Google Sans Code', SFMono-Regular, Consolas, Monaco, monospace;
}

[data-theme="dark"] {
  --bg-base: #131314;
  --bg-surface: #1e1f20;
  --bg-surface-variant: #282a2c;
  --bg-hover: #333538;
  --bg-active: #004a77;
  --text-primary: #e3e3e3;
  --text-secondary: #c4c7c5;
  --text-tertiary: #8e918f;
  --border-subtle: #282a2c;
  --border-color: #3c4043;
  --border-focus: #a8c7fa;
  --accent-primary: #a8c7fa;
  --accent-primary-hover: #c2e7ff;
  --accent-surface: #004a77;
  --gemini-gradient: linear-gradient(135deg, #a8c7fa 0%, #d0bcff 50%, #f28b82 100%);
  --gemini-sparkle: linear-gradient(135deg, #4285F4 0%, #9B72CB 50%, #D96570 100%);
  --thinking-bg: #18191a;
  --code-bg: #0e0e0f;
  --code-text: #e3e3e3;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
}

/* Reset & Basics */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-family);
  background-color: var(--bg-base);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

/* App Shell (3-Column Studio Grid) */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-base);
  overflow: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   1. NAVIGATION RAIL (LEFT)
   -------------------------------------------------------------------------- */
.nav-rail {
  width: 260px;
  min-width: 260px;
  height: 100%;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.nav-rail.collapsed {
  width: 68px;
  min-width: 68px;
}

.nav-rail.collapsed .brand-text,
.nav-rail.collapsed .label,
.nav-rail.collapsed .menu-section-label,
.nav-rail.collapsed .item-title,
.nav-rail.collapsed .rail-link span:not(.link-icon),
.nav-rail.collapsed .theme-label,
.nav-rail.collapsed .user-info {
  display: none !important;
}

.nav-rail.collapsed .create-dropdown-box {
  padding: 12px 8px;
}
.nav-rail.collapsed .btn-create-prompt {
  justify-content: center;
  padding: 10px;
}
.nav-rail.collapsed .prompt-item,
.nav-rail.collapsed .rail-link {
  justify-content: center;
  padding: 10px 0;
}

.rail-top {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.brand-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.create-dropdown-box {
  padding: 16px;
}

.btn-create-prompt {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background-color: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-create-prompt:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.btn-create-prompt .plus-icon {
  font-size: 18px;
  color: var(--accent-primary);
  font-weight: bold;
}

.rail-menu {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.menu-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  padding: 14px 8px 6px;
}

.recent-prompts-list, .resource-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prompt-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
}

.prompt-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.prompt-item.active {
  background-color: var(--accent-surface);
  color: var(--accent-primary);
  font-weight: 500;
}

.prompt-item .item-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  transition: all 0.15s ease;
}

.rail-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.rail-bottom {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gemini-sparkle);
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-tier {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   2. MAIN CHAT WORKSPACE (CENTER)
   -------------------------------------------------------------------------- */
.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-base);
}

/* Header */
.workspace-header {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background-color: var(--bg-surface);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.mobile-hamburger {
  display: none;
}

.prompt-title-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  transition: background-color 0.15s ease;
}

.prompt-title-container:hover {
  background-color: var(--bg-hover);
}

.prompt-title-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  width: 280px;
}

.edit-hint-icon {
  font-size: 12px;
  opacity: 0.6;
}

.auto-save-pill {
  font-size: 12px;
  color: #34a853;
  background-color: rgba(52, 168, 83, 0.12);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-variant);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.header-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent-primary);
}

#btnSavePrompt {
  background-color: var(--accent-primary);
  color: #041e49;
  border-color: var(--accent-primary);
  font-weight: 600;
}

[data-theme="dark"] #btnSavePrompt {
  color: #041e49;
  background-color: #a8c7fa;
}

#btnSavePrompt:hover {
  opacity: 0.9;
}

/* System Instructions Accordion */
.system-instruction-box {
  padding: 12px 24px 0;
  background-color: var(--bg-base);
}

.instruction-details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  transition: border-color 0.2s ease;
}

.instruction-details[open] {
  border-color: var(--border-color);
}

.instruction-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  user-select: none;
}

.instruction-summary::-webkit-details-marker {
  display: none;
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-title {
  font-weight: 500;
  color: var(--text-primary);
}

.summary-hint {
  color: var(--text-tertiary);
  font-size: 12px;
}

.chevron-arrow {
  font-size: 14px;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
}

.instruction-details[open] .chevron-arrow {
  transform: rotate(180deg);
}

.instruction-content {
  padding: 0 16px 14px;
}

.instruction-content textarea {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-base);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.instruction-content textarea:focus {
  border-color: var(--border-focus);
}

.instruction-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.btn-subtle {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
}

/* Chat Timeline */
.chat-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}

/* Welcome Center Placeholder */
.welcome-container {
  margin: auto;
  max-width: 640px;
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gemini-welcome-icon {
  margin-bottom: 20px;
  animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 12px rgba(66, 133, 244, 0.4)); }
  50% { transform: scale(1.06); filter: drop-shadow(0 0 24px rgba(155, 114, 203, 0.6)); }
}

.welcome-heading {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.welcome-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 30px;
}

.quick-sample-prompts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.sample-prompt-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sample-prompt-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.sample-prompt-btn .btn-icon {
  font-size: 20px;
}

.sample-prompt-btn .btn-texts {
  display: flex;
  flex-direction: column;
}

.sample-prompt-btn strong {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.sample-prompt-btn span {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Dynamic Messages Flow */
.messages-flow {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.chat-turn {
  display: flex;
  gap: 16px;
  width: 100%;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-turn.user-turn {
  justify-content: flex-end;
}

.chat-turn.user-turn .turn-body {
  background-color: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  border-radius: 18px 18px 4px 18px;
  padding: 14px 18px;
  max-width: 78%;
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.6;
}

.chat-turn.model-turn {
  justify-content: flex-start;
}

.model-avatar-box {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-surface-variant);
  box-shadow: var(--shadow-sm);
  margin-top: 2px;
}

.chat-turn.model-turn .turn-body {
  flex: 1;
  background-color: transparent;
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.65;
}

/* Thinking Box (Chain-of-Thought) */
.thinking-accordion {
  background-color: var(--thinking-bg);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid #9B72CB;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  overflow: hidden;
}

.thinking-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12.5px;
  color: #9B72CB;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.thinking-accordion summary::-webkit-details-marker {
  display: none;
}

.thinking-accordion summary .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #9B72CB;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.thinking-inner {
  padding: 8px 14px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  border-top: 1px dashed var(--border-subtle);
  font-family: var(--font-code);
}

/* Model text formatting & Code Blocks */
.turn-body pre {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 13px;
  margin: 12px 0;
  border: 1px solid var(--border-color);
  position: relative;
}

.code-header-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-bottom: none;
  padding: 6px 14px;
  font-size: 11.5px;
  color: var(--text-secondary);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-family: var(--font-code);
}

.turn-body code:not(pre code) {
  background-color: var(--bg-surface-variant);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-code);
  font-size: 13px;
}

/* Composer Container (Bottom) */
.composer-container {
  padding: 10px 24px 20px;
  background-color: var(--bg-base);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* Multimodal preview tray */
.attachment-tray {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 6px;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 12.5px;
  color: var(--text-primary);
}

.attach-chip img {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 4px;
}

.attach-chip .btn-remove-attach {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.attach-chip .btn-remove-attach:hover {
  color: #ea4335;
}

/* Token Status Bar */
.token-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.token-pill {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grounding-status {
  color: #1a73e8;
  background: rgba(26, 115, 232, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

/* Composer Input Box */
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 8px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.2);
}

.composer-tools-left, .composer-tools-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.icon-tool-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-tool-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.composer-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  padding: 6px 4px;
}

.composer-textarea::placeholder {
  color: var(--text-tertiary);
}

.btn-run-prompt {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--gemini-sparkle);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.btn-run-prompt:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

.btn-run-prompt:active {
  transform: translateY(0);
}

.btn-stop-generation {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #ea4335;
  background: rgba(234, 67, 53, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.stop-square {
  width: 10px;
  height: 10px;
  background-color: #ea4335;
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   3. RIGHT PARAMETER CONFIGURATION PANEL
   -------------------------------------------------------------------------- */
.config-panel {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin-right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 90;
}

.config-panel.collapsed {
  margin-right: -320px;
}

.panel-header {
  height: 56px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.config-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.field-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* Custom Select */
.select-wrapper {
  position: relative;
}

.custom-select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
  cursor: pointer;
}

.custom-select:focus {
  border-color: var(--border-focus);
}

/* Sliders */
.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.num-input {
  width: 68px;
  padding: 4px 8px;
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  text-align: right;
  outline: none;
}

.num-input:focus {
  border-color: var(--border-focus);
}

.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 4px;
  background: var(--border-color);
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
}

.config-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: 4px 0;
}

.config-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

/* Switches */
.tool-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tool-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tool-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.tool-desc {
  font-size: 11.5px;
  color: var(--text-tertiary);
  line-height: 1.35;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  min-width: 44px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-color);
  transition: 0.25s;
  border-radius: 34px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: var(--accent-primary);
}

[data-theme="dark"] input:checked + .slider.round:before {
  background-color: #041e49;
}

input:checked + .slider.round:before {
  transform: translateX(20px);
}

/* Safety Button */
.btn-safety-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-safety-settings:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent-primary);
}

/* --------------------------------------------------------------------------
   4. MODALS (Get Code, Safety, API Key)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-tag {
  color: var(--accent-primary);
  font-family: var(--font-code);
  font-weight: bold;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-sub {
  padding: 12px 24px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Code Tabs */
.code-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.code-tab {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.code-tab:hover {
  color: var(--text-primary);
}

.code-tab.active {
  color: var(--accent-primary);
  font-weight: 500;
  border-bottom-color: var(--accent-primary);
}

.code-display-wrapper {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background-color: var(--bg-surface-variant);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-bottom: none;
}

.btn-copy-code {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-primary);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-copy-code:hover {
  background-color: var(--bg-hover);
}

.code-pre {
  margin: 0;
  padding: 16px;
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  overflow-y: auto;
  max-height: 380px;
}

.code-block {
  font-family: var(--font-code);
  font-size: 12.5px;
  color: var(--code-text);
  line-height: 1.55;
  white-space: pre;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.btn-primary {
  padding: 9px 20px;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary);
  color: #041e49;
  border: none;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* Safety Settings Specific */
.safety-categories {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.safety-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.cat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-info strong {
  font-size: 13.5px;
  color: var(--text-primary);
}

.cat-info span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.safety-select {
  width: 170px;
}

/* API Key Modal Specific */
.api-key-input-box {
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-key-input-box input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.api-key-input-box input:focus {
  border-color: var(--border-focus);
}

/* --------------------------------------------------------------------------
   5. RESPONSIVE DESIGN
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .config-panel {
    position: absolute;
    right: 0;
    top: 0;
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 768px) {
  .nav-rail {
    position: absolute;
    left: 0;
    top: 0;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
  }

  .nav-rail.mobile-open {
    transform: translateX(0);
  }

  .mobile-hamburger {
    display: flex;
  }

  .header-btn span {
    display: none;
  }
}

/* ==========================================================================
   Apps Build Mode & Gallery Upgrades (Google AI Studio Material 3)
   ========================================================================== */
#vibeCodeEditor {
  outline: none;
  border: none;
  font-family: 'Google Sans Code', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  tab-size: 2;
  transition: background-color 0.2s ease;
}

#vibeCodeEditor:focus {
  background-color: #0d0f14 !important;
}

.gallery-card {
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: rgba(66, 133, 244, 0.5) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.agency-link-badge:hover {
  background: rgba(56, 189, 248, 0.25) !important;
  border-color: #38bdf8 !important;
  transform: translateY(-1px);
}

#btnApplyCodeLive:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 10px rgba(35, 134, 54, 0.4);
}

/* Custom Scrollbars */
#vibeCodeEditor::-webkit-scrollbar,
.gallery-workspace::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#vibeCodeEditor::-webkit-scrollbar-thumb,
.gallery-workspace::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

#vibeCodeEditor::-webkit-scrollbar-thumb:hover,
.gallery-workspace::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}
