/* ==========================================================================
   Vibe Playground - Design System & Modern Stylesheet
   ========================================================================== */

/* 1. 디자인 시스템 토큰 & 테마 변수 */
:root {
  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'JetBrains Mono', Consolas, Monaco, monospace;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

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

  /* Z-index levels */
  --z-base: 1;
  --z-splitter: 10;
  --z-header: 20;
  --z-modal: 50;
  --z-toast: 100;
}

/* 다크 테마 (기본) */
[data-theme="dark"] {
  --bg-app: #0d1117;
  --bg-toolbar: #161b22;
  --bg-panel: #11141a;
  --bg-panel-header: #181d26;
  --bg-card: #1c212c;
  --bg-hover: #262c38;
  --bg-active: #2f3644;
  --bg-input: #12161f;

  --border-subtle: #21262d;
  --border-default: #30363d;
  --border-active: #484f58;

  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --text-dim: #6e7681;

  --accent-primary: #10b981;
  --accent-primary-hover: #059669;
  --accent-primary-dim: rgba(16, 185, 129, 0.15);

  --accent-blue: #3b82f6;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;

  /* Console colors */
  --console-bg: #0b0e14;
  --console-log: #e6edf3;
  --console-warn-bg: rgba(245, 158, 11, 0.12);
  --console-warn-border: rgba(245, 158, 11, 0.35);
  --console-warn-text: #fbbf24;
  --console-error-bg: rgba(239, 68, 68, 0.14);
  --console-error-border: rgba(239, 68, 68, 0.4);
  --console-error-text: #f87171;
  --console-info-text: #60a5fa;

  --splitter-bg: #21262d;
  --splitter-hover: #10b981;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* 라이트 테마 */
[data-theme="light"] {
  --bg-app: #f6f8fa;
  --bg-toolbar: #ffffff;
  --bg-panel: #ffffff;
  --bg-panel-header: #f3f4f6;
  --bg-card: #f9fafb;
  --bg-hover: #e5e7eb;
  --bg-active: #d1d5db;
  --bg-input: #ffffff;

  --border-subtle: #e5e7eb;
  --border-default: #d1d5db;
  --border-active: #9ca3af;

  --text-main: #1f2937;
  --text-muted: #4b5563;
  --text-dim: #9ca3af;

  --accent-primary: #059669;
  --accent-primary-hover: #047857;
  --accent-primary-dim: rgba(5, 150, 105, 0.1);

  --accent-blue: #2563eb;
  --accent-yellow: #d97706;
  --accent-red: #dc2626;
  --accent-purple: #7c3aed;

  /* Console colors */
  --console-bg: #f8fafc;
  --console-log: #1e293b;
  --console-warn-bg: #fffbeb;
  --console-warn-border: #fde68a;
  --console-warn-text: #b45309;
  --console-error-bg: #fef2f2;
  --console-error-border: #fecaca;
  --console-error-text: #b91c1c;
  --console-info-text: #1d4ed8;

  --splitter-bg: #e5e7eb;
  --splitter-hover: #059669;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* 2. 베이스 리셋 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* 3. 앱 전체 레이아웃 컨테이너 */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* 4. 상단 툴바 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 14px;
  background-color: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: var(--z-header);
  gap: 8px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.brand-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.brand-highlight {
  color: var(--accent-primary);
}

.version-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-muted);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-default);
  margin: 0 4px;
}

/* 버튼 컴포넌트 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  height: 32px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-ghost:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-default);
}

.btn-icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
}

.btn-icon-only:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-default);
}

.btn-icon {
  width: 15px;
  height: 15px;
}

.btn-kbd {
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  margin-left: 2px;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary-dim);
  color: var(--accent-primary);
}

/* 토글 체크박스 (자동 실행) */
.toggle-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.toggle-checkbox:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.toggle-checkbox input {
  display: none;
}

.toggle-switch {
  width: 28px;
  height: 16px;
  background-color: var(--border-active);
  border-radius: var(--radius-full);
  position: relative;
  transition: background-color var(--transition-fast);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-checkbox input:checked + .toggle-switch {
  background-color: var(--accent-primary);
}

.toggle-checkbox input:checked + .toggle-switch::after {
  transform: translateX(12px);
}

/* 모바일 탭 헤더 */
.mobile-tabs {
  display: none;
  align-items: center;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border-subtle);
}

.mobile-tab-btn {
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mobile-tab-btn.active {
  background: var(--bg-panel);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.badge-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-red);
  margin-left: 2px;
  display: none;
}

/* 5. 메인 워크스페이스 레이아웃 */
.workspace {
  display: flex;
  flex: 1;
  width: 100%;
  height: calc(100vh - 48px);
  overflow: hidden;
  position: relative;
}

/* 좌우 분할 (기본) */
.workspace.layout-horizontal {
  flex-direction: row;
}

.workspace.layout-horizontal .pane-editor {
  width: 50%;
  min-width: 250px;
  height: 100%;
}

.workspace.layout-horizontal .splitter-main {
  width: 6px;
  height: 100%;
  cursor: col-resize;
}

.workspace.layout-horizontal .pane-preview-console {
  flex: 1;
  min-width: 250px;
  height: 100%;
}

/* 상하 분할 */
.workspace.layout-vertical {
  flex-direction: column;
}

.workspace.layout-vertical .pane-editor {
  width: 100%;
  height: 50%;
  min-height: 180px;
}

.workspace.layout-vertical .splitter-main {
  width: 100%;
  height: 6px;
  cursor: row-resize;
}

.workspace.layout-vertical .pane-preview-console {
  flex: 1;
  width: 100%;
  min-height: 180px;
}

/* 6. 분할바 (Splitter) */
.splitter {
  background-color: var(--splitter-bg);
  flex-shrink: 0;
  position: relative;
  z-index: var(--z-splitter);
  transition: background-color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.splitter:hover, .splitter.dragging {
  background-color: var(--splitter-hover);
}

.splitter-grip {
  width: 2px;
  height: 24px;
  border-radius: 1px;
  background-color: var(--text-dim);
}

.workspace.layout-vertical .splitter-grip {
  width: 24px;
  height: 2px;
}

.splitter-console {
  width: 100%;
  height: 6px;
  cursor: row-resize;
}

.splitter-grip-h {
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background-color: var(--text-dim);
}

/* 7. 에디터 패널 영역 */
.pane-editor {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-panel);
  overflow: hidden;
  border-right: 1px solid var(--border-subtle);
}

.workspace.layout-vertical .pane-editor {
  border-right: none;
  border-bottom: 1px solid var(--border-subtle);
}

/* 탭 바 */
.editor-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  background-color: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 10px;
  user-select: none;
  flex-shrink: 0;
}

.tab-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-mono);
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.tab-btn.active {
  color: var(--text-main);
  background-color: var(--bg-panel);
  border-color: var(--border-subtle) var(--border-subtle) transparent var(--border-subtle);
  border-top: 2px solid var(--accent-primary);
  font-weight: 600;
}

.tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-html { background-color: #e44d26; }
.dot-css { background-color: #264de4; }
.dot-js { background-color: #f7df1e; }

.tab-badge {
  font-size: 10px;
  color: var(--text-dim);
}

.tab-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  height: 24px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-sm:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-default);
}

.btn-icon-xs {
  width: 12px;
  height: 12px;
}

/* 에디터 뷰포트 & 래퍼 */
.editors-viewport {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* 탭 모드일 때 에디터 표시 방식 */
.pane-editor.mode-tab .editors-viewport {
  flex-direction: column;
}

.pane-editor.mode-tab .editor-wrapper {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
}

.pane-editor.mode-tab .editor-wrapper.active {
  display: flex;
}

.pane-editor.mode-tab .editor-header {
  display: none; /* 탭 모드에서는 상단 탭 바로 대체 */
}

/* 세로 3단 모드일 때 에디터 표시 방식 */
.pane-editor.mode-stacked .editor-tabs-bar {
  display: none; /* 세로 3단 모드에서는 각 에디터 헤더로 대체 */
}

.pane-editor.mode-stacked .editors-viewport {
  flex-direction: column;
}

.pane-editor.mode-stacked .editor-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 80px;
  border-bottom: 1px solid var(--border-subtle);
}

.pane-editor.mode-stacked .editor-wrapper:last-child {
  border-bottom: none;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  background-color: var(--bg-panel-header);
  padding: 0 10px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
}

.editor-lang-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 11px;
}

.lang-icon {
  width: 14px;
  height: 14px;
}

.badge-html { color: #f97316; }
.badge-css { color: #3b82f6; }
.badge-js { color: #eab308; }

.editor-meta {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
}

.editor-content {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* CodeMirror 커스텀 오버라이드 */
.CodeMirror {
  width: 100%;
  height: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-panel) !important;
}

.cm-s-dracula.CodeMirror {
  background: var(--bg-panel) !important;
  color: #f8f8f2 !important;
}

.CodeMirror-gutters {
  background-color: var(--bg-panel-header) !important;
  border-right: 1px solid var(--border-subtle) !important;
}

.CodeMirror-linenumber {
  color: var(--text-dim) !important;
  padding: 0 8px 0 5px;
}

.CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.04) !important;
}

[data-theme="light"] .CodeMirror-activeline-background {
  background: rgba(0, 0, 0, 0.04) !important;
}

/* 8. 프리뷰 & 콘솔 패널 */
.pane-preview-console {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-panel);
  overflow: hidden;
  position: relative;
}

/* 미리보기 상단 영역 */
.preview-section {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background-color: #ffffff;
}

[data-theme="dark"] .preview-section {
  background-color: #0b0e14;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  background-color: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px;
  user-select: none;
  flex-shrink: 0;
}

.preview-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

.preview-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.preview-status-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.device-presets {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  padding: 2px;
}

.preset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  color: var(--text-main);
}

.preset-btn.active {
  background: var(--bg-hover);
  color: var(--accent-primary);
}

.preset-icon {
  width: 14px;
  height: 14px;
}

.btn-preview-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-preview-tool svg {
  width: 14px;
  height: 14px;
}

.btn-preview-tool:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-default);
}

/* iframe 뷰포트 */
.iframe-container {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#141822 0% 25%, #10131c 0% 50%) 50% / 20px 20px;
  overflow: auto;
  position: relative;
}

[data-theme="light"] .iframe-container {
  background: repeating-conic-gradient(#f0f2f5 0% 25%, #f8f9fa 0% 50%) 50% / 20px 20px;
}

.iframe-wrapper {
  width: 100%;
  height: 100%;
  background: #ffffff;
  transition: width var(--transition-normal);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  position: relative;
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* 전체화면 모드 */
.preview-section.fullscreen-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-modal);
  background: #ffffff;
}

/* 9. 콘솔 패널 영역 */
.console-section {
  height: 160px;
  min-height: 38px;
  display: flex;
  flex-direction: column;
  background-color: var(--console-bg);
  border-top: 1px solid var(--border-subtle);
  position: relative;
  transition: height var(--transition-fast);
}

.console-section.collapsed {
  height: 38px !important;
}

.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 12px;
  background-color: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
  flex-shrink: 0;
}

.console-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.console-icon {
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}

.console-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.console-filters {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--border-subtle);
}

.filter-btn {
  font-size: 11px;
  padding: 2px 8px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.filter-btn .cnt {
  font-size: 10px;
  opacity: 0.8;
}

.filter-btn.active {
  background: var(--bg-hover);
  color: var(--text-main);
  font-weight: 600;
}

.console-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 콘솔 출력 목록 */
.console-output {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 12px;
}

.console-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-style: italic;
  font-size: 11px;
  padding: 12px;
  text-align: center;
}

.console-entry {
  display: flex;
  align-items: flex-start;
  padding: 5px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  line-height: 1.5;
  word-break: break-all;
  gap: 10px;
}

[data-theme="light"] .console-entry {
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.console-entry.entry-log {
  color: var(--console-log);
}

.console-entry.entry-info {
  color: var(--console-info-text);
  background: rgba(59, 130, 246, 0.05);
}

.console-entry.entry-warn {
  color: var(--console-warn-text);
  background-color: var(--console-warn-bg);
  border-left: 3px solid var(--console-warn-text);
}

.console-entry.entry-error {
  color: var(--console-error-text);
  background-color: var(--console-error-bg);
  border-left: 3px solid var(--console-error-text);
}

.entry-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.badge-log { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); }
.badge-info { background: rgba(59, 130, 246, 0.2); color: var(--console-info-text); }
.badge-warn { background: rgba(245, 158, 11, 0.2); color: var(--console-warn-text); }
.badge-error { background: rgba(239, 68, 68, 0.25); color: var(--console-error-text); }

.entry-content {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.entry-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
  flex-shrink: 0;
}

.entry-location {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  padding: 0 4px;
  border-radius: var(--radius-sm);
  text-decoration: underline;
  cursor: pointer;
}

/* 콘솔 값 서식 */
.cv-string { color: #a5d6ff; }
.cv-number { color: #79c0ff; }
.cv-boolean { color: #ff7b72; }
.cv-null, .cv-undefined { color: #8b949e; font-style: italic; }
.cv-object { color: #d2a8ff; }

/* 10. 외부 라이브러리 모달 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 580px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}

.modal-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 65vh;
  overflow-y: auto;
}

.modal-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.quick-presets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-tag:hover {
  background: var(--accent-primary-dim);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.add-lib-form {
  display: flex;
  gap: 8px;
}

.form-select {
  width: 110px;
  height: 34px;
  padding: 0 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-main);
}

.form-input {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.active-libs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.lib-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  gap: 8px;
}

.lib-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.lib-badge-js { background: #f7df1e22; color: #f7df1e; }
.lib-badge-css { background: #3b82f622; color: #3b82f6; }

.lib-url {
  flex: 1;
  font-size: 11px;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-remove {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.lib-remove:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel-header);
}

/* 11. 토스트 알림 (Toast Notifications) */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 200ms cubic-bezier(0.16, 1, 0.3, 1), toastOut 200ms cubic-bezier(0.16, 1, 0.3, 1) 2.8s forwards;
}

.toast-success { border-left: 3px solid var(--accent-primary); }
.toast-info { border-left: 3px solid var(--accent-blue); }
.toast-error { border-left: 3px solid var(--accent-red); }

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

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

/* 12. 모바일 및 태블릿 미디어 쿼리 (<= 768px) */
@media (max-width: 768px) {
  .toolbar {
    height: auto;
    padding: 8px 10px;
    flex-wrap: wrap;
  }

  .toolbar-left, .toolbar-right {
    flex-wrap: wrap;
    gap: 4px;
  }

  .btn-text, .btn-kbd, .version-tag {
    display: none;
  }

  .mobile-tabs {
    display: flex;
    order: 3;
    width: 100%;
    margin-top: 6px;
    justify-content: space-around;
  }

  .workspace {
    height: calc(100vh - 90px);
    flex-direction: column !important;
  }

  .splitter-main, .splitter-console {
    display: none !important;
  }

  .pane-editor, .pane-preview-console, .preview-section, .console-section {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
  }

  /* 모바일 탭 상태에 따른 패널 토글 */
  .workspace[data-mobile-view="editor"] .pane-editor { display: flex !important; }
  .workspace[data-mobile-view="editor"] .pane-preview-console { display: none !important; }

  .workspace[data-mobile-view="preview"] .pane-editor { display: none !important; }
  .workspace[data-mobile-view="preview"] .pane-preview-console { display: flex !important; }
  .workspace[data-mobile-view="preview"] .preview-section { display: flex !important; flex: 1 !important; }
  .workspace[data-mobile-view="preview"] .console-section { display: none !important; }

  .workspace[data-mobile-view="console"] .pane-editor { display: none !important; }
  .workspace[data-mobile-view="console"] .pane-preview-console { display: flex !important; }
  .workspace[data-mobile-view="console"] .preview-section { display: none !important; }
  .workspace[data-mobile-view="console"] .console-section { display: flex !important; flex: 1 !important; }
}
