/* Software Inc Mod Studio — Complete Design System */

:root {
  /* Light theme */
  --bg:          #f8fafc;
  --bg-surface:  #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover:    #f1f5f9;
  --bg-inset:    #f1f5f9;

  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #64748b;

  --border:      #e2e8f0;
  --border-2:    #cbd5e1;

  --blue:        #2563eb;
  --blue-light:  #dbeafe;
  --blue-dark:   #1d4ed8;
  --blue-soft:   #eff6ff;
  --purple:      #7c3aed;
  --purple-light:#ede9fe;
  --green:       #059669;
  --green-light: #d1fae5;
  --amber:       #d97706;
  --amber-light: #fef3c7;
  --red:         #dc2626;
  --red-light:   #fee2e2;
  --orange:      #ea580c;
  --orange-light:#ffedd5;

  --radius:      0.75rem;
  --radius-sm:   0.5rem;
  --radius-lg:   1rem;
  --radius-xl:   1.25rem;

  --shadow-xs:   0 1px 2px rgb(0 0 0 / 0.05);
  --shadow-sm:   0 1px 3px rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-md:   0 4px 12px -2px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg:   0 12px 32px -6px rgb(0 0 0 / 0.14), 0 4px 8px -4px rgb(0 0 0 / 0.06);
  --shadow-inset: inset 0 2px 4px rgb(0 0 0 / 0.04);

  --font-sans:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;

  --header-h:    56px;
  --tab-h:       48px;

  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg:          #0f172a;
  --bg-surface:  #1a2536;
  --bg-elevated: #1e293b;
  --bg-hover:    #293548;
  --bg-inset:    #0f172a;

  --text:        #f1f5f9;
  --text-2:      #94a3b8;
  --text-3:      #64748b;

  --border:      #2d3b50;
  --border-2:    #3d4d63;

  --blue:        #60a5fa;
  --blue-light:  #1e3a5f;
  --blue-dark:   #3b82f6;
  --blue-soft:   #1e293b;
  --purple:      #a78bfa;
  --purple-light:#2e1065;
  --green:       #34d399;
  --green-light: #064e3b;
  --amber:       #fbbf24;
  --amber-light: #451a03;
  --red:         #f87171;
  --red-light:   #450a0a;
  --orange:      #fb923c;
  --orange-light:#451a03;

  --shadow-xs:   0 1px 2px rgb(0 0 0 / 0.2);
  --shadow-sm:   0 1px 3px rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.2);
  --shadow-md:   0 4px 12px -2px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.15);
  --shadow-lg:   0 12px 32px -6px rgb(0 0 0 / 0.4), 0 4px 8px -4px rgb(0 0 0 / 0.2);
  --shadow-inset: inset 0 2px 4px rgb(0 0 0 / 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  transition: background 0.25s, color 0.25s;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

h1,h2,h3,h4,h5,h6 { font-weight: 700; line-height: 1.25; }
p { line-height: 1.6; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== HEADER ========== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

[data-theme="dark"] .app-header {
  background: rgba(15, 23, 42, 0.85);
}

.app-header-brand {
  display: flex; align-items: center; gap: 0.625rem;
  font-size: 1rem; font-weight: 700; color: var(--text);
  text-decoration: none;
  transition: opacity 0.15s;
}
.app-header-brand:hover { opacity: 0.8; text-decoration: none; }
.app-header-brand svg { width: 26px; height: 26px; color: var(--blue); flex-shrink: 0; }
.app-header-actions { display: flex; align-items: center; gap: 0.375rem; }

/* ========== TABS ========== */
.tab-bar {
  position: sticky; top: var(--header-h); z-index: 90;
  display: flex; gap: 0.25rem;
  padding: 0 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
  padding: 0.875rem 1rem;
  font-size: 0.875rem; font-weight: 600; color: var(--text-3);
  cursor: pointer; white-space: nowrap; border: none; background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  display: inline-flex; align-items: center; gap: 0.375rem;
}
.tab-item:hover { color: var(--text-2); }
.tab-item.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-item .tab-icon { width: 16px; height: 16px; opacity: 0.7; }
.tab-item.active .tab-icon { opacity: 1; }

/* ========== LAYOUT ========== */
.page { max-width: 720px; margin: 0 auto; padding: 1.5rem 1.25rem 6rem; }
.page-wide { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.home-container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

.split-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 6rem;
}

.split-left { min-width: 0; }
.split-right {
  position: sticky;
  top: calc(var(--header-h) + var(--tab-h) + 1.5rem);
  height: calc(100vh - var(--header-h) - var(--tab-h) - 3rem);
  overflow-y: auto;
}

@media (max-width: 1024px) {
  .split-layout { grid-template-columns: 1fr; }
  .split-right { position: static; height: auto; }
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  margin-bottom: 1rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.card:hover { border-color: var(--border-2); }
.card-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 1rem 1.25rem;
  font-size: 0.9375rem; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.card-header-icon { width: 20px; height: 20px; color: var(--blue); flex-shrink: 0; }
.card-body { padding: 1.25rem; }
.card-body-compact { padding: 1rem; }

/* ========== SECTIONS ========== */
.section-block { margin-bottom: 1.5rem; }
.section-title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 0.75rem;
}
.section-desc { font-size: 0.875rem; color: var(--text-2); margin-bottom: 1rem; }

.form-section {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; }
.form-section-label {
  font-size: 0.8125rem; font-weight: 600; color: var(--text-2);
  margin-bottom: 0.875rem; display: flex; align-items: center; gap: 0.375rem;
}

/* ========== FIELD GRID ========== */
.field-grid { display: grid; gap: 1rem; }
.field-grid-2 { grid-template-columns: 1fr 1fr; }
.field-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.field-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) {
  .field-grid-2, .field-grid-3, .field-grid-4 { grid-template-columns: 1fr; }
}

/* ========== FIELDS ========== */
.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field-label {
  font-size: 0.8125rem; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 0.25rem;
}
.field-label .req { color: var(--red); }
.field-desc {
  font-size: 0.75rem; color: var(--text-3); line-height: 1.4;
}
.field-hint {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.6875rem; color: var(--text-3);
  background: var(--bg-inset);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  margin-top: 0.125rem;
  font-weight: 500;
}

.input, select, textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover, select:hover, textarea:hover { border-color: var(--border-2); }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 72px; line-height: 1.6; }
select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  padding-right: 2rem;
}
.input-sm { padding: 0.375rem 0.5rem; font-size: 0.8125rem; }

.field-check {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; font-size: 0.875rem; font-weight: 500;
  padding: 0.5rem 0;
}
.field-check input {
  width: 1.125rem; height: 1.125rem;
  accent-color: var(--blue); cursor: pointer;
  border-radius: var(--radius-sm);
}

/* Validation states */
.input.is-invalid, textarea.is-invalid { border-color: var(--red); }
.input.is-invalid:focus, textarea.is-invalid:focus { box-shadow: 0 0 0 3px var(--red-light); }
.input.is-valid, textarea.is-valid { border-color: var(--green); }

/* Info Icon / Tooltip */
.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 0.875rem; height: 0.875rem; border-radius: 50%;
  background: var(--text-3); color: var(--bg-surface);
  font-size: 0.5625rem; font-weight: 700; cursor: help; flex-shrink: 0;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.625rem 1rem; font-size: 0.875rem; font-weight: 600;
  font-family: var(--font-sans); border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-surface); color: var(--text); border: 1.5px solid var(--border-2); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--text-3); transform: translateY(-1px); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 0.375rem; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-ai { background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%); color: #fff; font-weight: 600; }
.btn-ai:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35); transform: translateY(-1px); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; transform: translateY(-1px); }
.btn-sm { padding: 0.375rem 0.625rem; font-size: 0.8125rem; }
.btn-icon { padding: 0.375rem; width: 2.25rem; height: 2.25rem; }
.btn-block { width: 100%; }
.btn-link { background: none; color: var(--blue); padding: 0; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* ========== BADGES ========== */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.25rem 0.625rem; font-size: 0.6875rem; font-weight: 700;
  border-radius: 9999px; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-success { background: var(--green-light); color: var(--green); }
.badge-warning { background: var(--amber-light); color: var(--amber); }
.badge-danger { background: var(--red-light); color: var(--red); }
.badge-info { background: var(--blue-light); color: var(--blue); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-muted { background: var(--bg-inset); color: var(--text-3); border: 1px solid var(--border); }

/* ========== ALERTS ========== */
.alert {
  padding: 0.875rem 1rem; border-radius: var(--radius-sm); font-size: 0.875rem;
  display: flex; gap: 0.625rem; align-items: flex-start;
  border: 1.5px solid transparent;
}
.alert-warning { background: var(--amber-light); color: var(--amber); border-color: var(--amber); }
.alert-danger { background: var(--red-light); color: var(--red); border-color: var(--red); }
.alert-info { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }
.alert-success { background: var(--green-light); color: var(--green); border-color: var(--green); }

/* ========== FEATURE BLOCKS ========== */
.feature-block {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  margin-bottom: 0.875rem;
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.feature-block:hover { box-shadow: var(--shadow-sm); border-color: var(--border-2); }
.feature-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: pointer; user-select: none; transition: background 0.12s;
}
.feature-block-header:hover { background: var(--bg-hover); }
.feature-block-title {
  font-size: 0.875rem; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 0.375rem;
}
.feature-block-body { padding: 0.875rem 1rem; padding-top: 0; }
.chevron { transition: transform 0.2s var(--ease-out); flex-shrink: 0; color: var(--text-3); }
.chevron.open { transform: rotate(180deg); }

.subfeature-block {
  background: var(--bg-inset);
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--text-3);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  overflow: hidden;
  transition: border-color 0.15s;
}
.subfeature-block:hover { border-color: var(--border-2); }
.subfeature-block .feature-block-header { padding: 0.5rem 0.875rem; }
.subfeature-block .feature-block-title { font-size: 0.8125rem; color: var(--text-2); font-weight: 500; }
.subfeature-block .feature-block-body { padding: 0.75rem; padding-top: 0; }

/* Spec color coding */
.feature-block.spec-3d { border-left-color: var(--blue); }
.feature-block.spec-audio { border-left-color: var(--purple); }
.feature-block.spec-system { border-left-color: var(--green); }
.feature-block.spec-network { border-left-color: var(--orange); }

/* ========== CODE PREVIEW ========== */
.code-preview {
  background: #11121a;
  color: #a9b1d6;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #24263a;
}
[data-theme="dark"] .code-preview {
  background: #0a0a12;
  border-color: #1e1f2e;
}

/* ========== STICKY ACTION BAR ========== */
.action-bar {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex; gap: 0.5rem; z-index: 30;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
[data-theme="dark"] .action-bar { background: rgba(15, 23, 42, 0.9); }
.action-bar .btn { flex: 1; justify-content: center; }

/* ========== FLOATING AI CHAT ========== */
.chat-fab {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
  border: none; color: #fff; cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35); z-index: 45;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(37, 99, 235, 0.45); }
.chat-fab.open { display: none; }
.chat-fab-badge {
  position: absolute; top: 0; right: 0; width: 12px; height: 12px;
  border-radius: 50%; background: var(--green); border: 2px solid var(--bg-surface); display: none;
}
.chat-fab-badge.show { display: block; }

.chat-window {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  width: 380px; max-width: calc(100vw - 2rem);
  height: 540px; max-height: calc(100vh - 5rem);
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 46;
  display: none; flex-direction: column; overflow: hidden;
  animation: chat-pop 0.2s var(--ease-out);
}
.chat-window.open { display: flex; }
@keyframes chat-pop { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--blue-light) 0%, var(--purple-light) 100%);
}
.chat-header-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.875rem; }
.chat-header-actions { display: flex; gap: 0.125rem; }
.chat-body { flex: 1; overflow-y: auto; padding: 0.875rem; }
.chat-footer { padding: 0.625rem 0.875rem; border-top: 1px solid var(--border); }
@media (max-width: 480px) {
  .chat-window { bottom: 0; right: 0; width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
}

/* AI Messages */
.ai-message { padding: 0.625rem 0.875rem; border-radius: 0.875rem; margin-bottom: 0.5rem; font-size: 0.875rem; line-height: 1.5; max-width: 90%; animation: msg-in 0.2s var(--ease-out); }
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.ai-message-user { background: var(--blue); color: #fff; margin-left: auto; border-bottom-right-radius: 0.25rem; }
.ai-message-assistant { background: var(--bg-inset); color: var(--text); border-bottom-left-radius: 0.25rem; }
.ai-message-loading { display: flex; align-items: center; gap: 0.5rem; color: var(--text-3); }

.ai-quickreplies { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 0.5rem; max-width: 90%; }
.ai-quickreply {
  padding: 0.375rem 0.75rem; border-radius: 1rem; border: 1.5px solid var(--blue);
  background: var(--blue-light); color: var(--blue); font-size: 0.75rem; font-weight: 600;
  cursor: pointer; transition: all 0.12s; user-select: none; white-space: nowrap;
}
.ai-quickreply:hover { background: var(--blue); color: #fff; transform: translateY(-1px); }
.ai-quickreply:active { transform: translateY(0); }

.ai-changes { background: var(--green-light); color: var(--green); border: 1.5px solid var(--green); border-radius: var(--radius-sm); margin-bottom: 0.5rem; font-size: 0.75rem; max-width: 90%; overflow: hidden; }
.ai-changes-header { display: flex; align-items: center; gap: 0.375rem; padding: 0.5rem 0.75rem; cursor: pointer; user-select: none; font-weight: 700; }
.ai-changes-header:hover { background: rgba(5, 150, 105, 0.08); }
.ai-changes-chevron { margin-left: auto; transition: transform 0.2s; font-size: 0.5625rem; }
.ai-changes-chevron.open { transform: rotate(180deg); }
.ai-changes-list { display: none; flex-direction: column; gap: 0.1875rem; padding: 0 0.5rem 0.5rem; }
.ai-changes-list.open { display: flex; }
.ai-change-item { padding: 0.375rem 0.625rem; border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text); cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; gap: 0.375rem; transition: background 0.1s; }
.ai-change-item:hover { background: var(--blue-light); color: var(--blue); }
.ai-change-item-arrow { margin-left: auto; opacity: 0.4; font-size: 0.6875rem; }

/* AI Highlight */
@keyframes ai-highlight {
  0% { box-shadow: 0 0 0 0 var(--blue); }
  30% { box-shadow: 0 0 0 3px var(--blue-light); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.ai-highlight { animation: ai-highlight 1.5s ease-out 2; border-color: var(--blue) !important; }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s;
  padding: 1rem;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  transform: scale(0.95); transition: transform 0.2s var(--ease-out);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 1.25rem; }

/* ========== PRESET CARDS (Home) ========== */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.preset-card {
  background: var(--bg-surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; cursor: pointer; text-decoration: none; color: inherit;
  text-align: center; transition: all 0.2s; display: block;
}
.preset-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.preset-icon { font-size: 2.25rem; line-height: 1; margin-bottom: 0.75rem; }
.preset-name { font-weight: 700; font-size: 1rem; }
.preset-desc { font-size: 0.8125rem; color: var(--text-2); margin-top: 0.375rem; line-height: 1.45; }

/* ========== CONSOLE COMMANDS ========== */
.console-cmd {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.625rem 0.875rem; background: var(--bg-inset);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.8125rem;
}
.console-cmd code { flex: 1; overflow-x: auto; white-space: nowrap; }

/* ========== ANIMATIONS ========== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s var(--ease-out) forwards; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* ========== TAB PANELS ========== */
.tab-panel { display: none; animation: fadeIn 0.25s var(--ease-out); }
.tab-panel.active { display: block; }

/* ========== TOAST ========== */
.toast-container {
  position: fixed; top: calc(var(--header-h) + 0.75rem); right: 0.75rem;
  z-index: 110; display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--bg-surface); color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg); font-size: 0.875rem; font-weight: 500;
  display: flex; align-items: center; gap: 0.5rem;
  animation: toast-in 0.3s var(--ease-out) forwards;
  pointer-events: auto; max-width: 360px;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast-success { border-left: 3px solid var(--green); }
.toast-warning { border-left: 3px solid var(--amber); }
.toast-danger { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--blue); }

/* ========== HERO ========== */
.hero-section {
  text-align: center; padding: 2.5rem 1.5rem;
  max-width: 640px; margin: 0 auto;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0.875rem; font-size: 0.75rem; font-weight: 700;
  background: var(--blue-soft); color: var(--blue);
  border: 1.5px solid var(--blue-light); border-radius: 9999px;
  margin-bottom: 1rem;
}
.hero-title { font-size: 2.25rem; font-weight: 800; line-height: 1.15; margin-bottom: 1rem; }
.hero-desc { font-size: 1rem; color: var(--text-2); line-height: 1.65; max-width: 480px; margin: 0 auto; }

/* ========== BANNER ========== */
.banner-card {
  background: linear-gradient(135deg, var(--blue-soft) 0%, var(--purple-light) 100%);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.banner-card::before {
  content: ''; position: absolute; top: -50%; right: -10%;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(124, 58, 237, 0.06); pointer-events: none;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-3);
}

/* ========== PROJECT LIST ITEM ========== */
.project-item {
  background: var(--bg-surface);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.project-item:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }

/* ========== TOOL GRID ========== */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tool-card {
  background: var(--bg-surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; cursor: pointer; text-decoration: none; color: inherit;
  transition: all 0.2s; display: flex; flex-direction: column;
}
.tool-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tool-card-icon { font-size: 1.75rem; margin-bottom: 0.75rem; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: var(--bg-inset); border-radius: var(--radius-sm); }
.tool-card-name { font-weight: 700; font-size: 0.9375rem; }
.tool-card-desc { font-size: 0.8125rem; color: var(--text-2); margin-top: 0.25rem; line-height: 1.45; }

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
  .app-header { padding: 0 0.875rem; }
  .hero-title { font-size: 1.75rem; }
  .page, .page-wide, .home-container, .studio-container { padding-left: 0.875rem; padding-right: 0.875rem; }
  .preset-grid, .tool-grid { grid-template-columns: 1fr; }
}

/* ========== STUDIO CONTAINER (backward compat) ========== */
.studio-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 6rem;
}

/* ========== STUDIO SPLIT LAYOUT (backward compat) ========== */
.studio-split {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 6rem;
}
.studio-split-left { min-width: 0; }
.studio-split-right {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  height: calc(100vh - var(--header-h) - 3rem);
  overflow-y: auto;
}
@media (max-width: 1024px) {
  .studio-split { grid-template-columns: 1fr; }
  .studio-split-right { position: static; height: auto; }
}

/* ========== UTILITIES ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-3); }
.text-secondary { color: var(--text-2); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--amber); }
.rounded { border-radius: var(--radius); }
.border { border: 1px solid var(--border); }
.bg-secondary { background: var(--bg-inset); }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }
.white-space-nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.font-mono { font-family: var(--font-mono); }

/* ========== BACKWARD COMPAT ========== */
.studio-header, .app-header { position: sticky; top: 0; z-index: 50; height: var(--header-h); display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; background: var(--bg-surface); border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); }
.studio-header-brand, .app-header-brand { display: flex; align-items: center; gap: 0.625rem; font-size: 1rem; font-weight: 700; color: var(--text); text-decoration: none; }
.studio-header-brand svg, .app-header-brand svg { width: 26px; height: 26px; color: var(--blue); flex-shrink: 0; }
.studio-header-actions, .app-header-actions { display: flex; align-items: center; gap: 0.375rem; }

.studio-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; padding: 0.5625rem 1rem; font-size: 0.875rem; font-weight: 600; font-family: var(--font-sans); border: none; border-radius: var(--radius-sm); cursor: pointer; transition: all 0.12s; white-space: nowrap; text-decoration: none; }
.studio-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.studio-btn-primary { background: var(--blue); color: #fff; }
.studio-btn-primary:hover:not(:disabled) { background: var(--blue-dark); box-shadow: var(--shadow-sm); }
.studio-btn-secondary { background: var(--bg-surface); color: var(--text); border: 1px solid var(--border-2); }
.studio-btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--text-3); }
.studio-btn-danger { background: var(--red-light); color: var(--red); }
.studio-btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }
.studio-btn-ghost { background: transparent; color: var(--text-2); padding: 0.375rem; }
.studio-btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.studio-btn-ai { background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%); color: #fff; font-weight: 600; }
.studio-btn-icon { padding: 0.375rem; width: 2rem; height: 2rem; }
.studio-btn-sm { padding: 0.375rem 0.625rem; font-size: 0.8125rem; }

.studio-input, .studio-select, .studio-textarea { width: 100%; padding: 0.5625rem 0.75rem; font-size: 0.875rem; font-family: var(--font-sans); color: var(--text); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; transition: border-color 0.12s, box-shadow 0.12s; }
.studio-input:focus, .studio-select:focus, .studio-textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.studio-input::placeholder, .studio-textarea::placeholder { color: var(--text-3); }
.studio-textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.studio-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.625rem center; padding-right: 2rem; }
.studio-input-sm { padding: 0.375rem 0.5rem; font-size: 0.8125rem; }
.studio-checkbox { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.875rem; }
.studio-checkbox input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--blue); cursor: pointer; }
.studio-label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text); margin-bottom: 0.3125rem; }
.studio-label-row { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0.3125rem; }
.studio-hint { font-size: 0.75rem; color: var(--text-3); margin-top: 0.25rem; line-height: 1.4; }
.studio-info-icon { display: inline-flex; align-items: center; justify-content: center; width: 0.875rem; height: 0.875rem; border-radius: 50%; background: var(--text-3); color: var(--bg-surface); font-size: 0.5625rem; font-weight: 700; cursor: help; flex-shrink: 0; position: relative; }
.studio-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); }
.studio-card-body { padding: 1rem; }
.studio-preview, .code-preview { background: #11121a; color: #a9b1d6; font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.65; padding: 1rem; border-radius: var(--radius); overflow-x: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid #24263a; }
.studio-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 100; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
.studio-modal-overlay.open { opacity: 1; visibility: visible; }
.studio-modal { background: var(--bg-surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 90%; max-width: 480px; max-height: 90vh; overflow-y: auto; transform: scale(0.95); transition: transform 0.2s; }
.studio-modal-overlay.open .studio-modal { transform: scale(1); }
.studio-modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.studio-modal-body { padding: 1.25rem; }
.studio-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1875rem 0.5rem; font-size: 0.6875rem; font-weight: 700; border-radius: 9999px; text-transform: uppercase; letter-spacing: 0.025em; }
.studio-badge-success { background: var(--green-light); color: var(--green); }
.studio-badge-warning { background: var(--amber-light); color: var(--amber); }
.studio-badge-danger { background: var(--red-light); color: var(--red); }
.studio-badge-info { background: var(--blue-light); color: var(--blue); }
.studio-alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.875rem; display: flex; gap: 0.625rem; align-items: flex-start; }
.studio-alert-warning { background: var(--amber-light); color: var(--amber); border: 1px solid var(--amber); }
.studio-alert-danger { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }
.studio-alert-info { background: var(--blue-light); color: var(--blue); border: 1px solid var(--blue); }
.studio-pulse { animation: pulse 2s ease-in-out infinite; }
.studio-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.studio-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.studio-preset { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; cursor: pointer; text-decoration: none; color: inherit; text-align: center; transition: all 0.15s; display: block; }
.studio-preset:hover { border-color: var(--blue); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.studio-preset-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.studio-preset-name { font-weight: 600; font-size: 0.9375rem; }
.studio-preset-desc { font-size: 0.75rem; color: var(--text-2); margin-top: 0.25rem; }
.studio-fade-in { animation: fadeIn 0.25s ease forwards; }
.studio-console-command { display: flex; align-items: center; gap: 0.5rem; padding: 0.625rem 0.875rem; background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.8125rem; }
.studio-console-command code { flex: 1; overflow-x: auto; }

@media (max-width: 768px) { .studio-grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 1024px) { .studio-grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .studio-grid-3 { grid-template-columns: 1fr; } }

/* ──────────────────────────────────────────────────────────────
   Build variant gating (web vs local-deploy)
   js/runtime.js tags <html> with 'ai-enabled' (local) or
   'web-only' (github.io / file://) based on host detection.
   ────────────────────────────────────────────────────────────── */
html:not(.ai-enabled) .chat-fab,
html:not(.ai-enabled) .chat-window,
html:not(.ai-enabled) #ai-settings-modal,
html:not(.ai-enabled) .btn-ai {
  display: none !important;
}
html.ai-enabled [data-web-only] {
  display: none !important;
}

/* ──────────────────────────────────────────────────────────────
   Mod Studio — IDE-like file/folder explorer (studio.html)
   Three-pane layout: file tree | code editor | mod info
   ────────────────────────────────────────────────────────────── */
.studio-workspace {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 0;
  height: calc(100vh - 64px);
  min-height: 480px;
}
.studio-explorer {
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.studio-explorer-header {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-primary);
}
.studio-explorer-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
}
.studio-explorer-actions {
  display: flex;
  gap: 0.25rem;
}
.studio-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.375rem;
  font-size: 0.8125rem;
}
.tree-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  color: var(--text);
  white-space: nowrap;
}
.tree-item:hover { background: var(--bg-hover); }
.tree-item.selected { background: var(--blue-light, rgba(37, 99, 235, 0.12)); color: var(--blue); }
.tree-item .tree-chevron {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
  color: var(--text-3);
}
.tree-item.collapsed .tree-chevron { transform: rotate(-90deg); }
.tree-icon { font-size: 0.875rem; flex-shrink: 0; width: 16px; text-align: center; }
.tree-name { overflow: hidden; text-overflow: ellipsis; }
.tree-children { padding-left: 0.875rem; }
.tree-children.collapsed { display: none; }
.tree-item-actions {
  margin-left: auto;
  display: none;
  gap: 0.125rem;
}
.tree-item:hover .tree-item-actions { display: flex; }
.tree-item-actions button {
  background: transparent;
  border: none;
  color: var(--text-3);
  padding: 0.125rem 0.25rem;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.75rem;
  line-height: 1;
}
.tree-item-actions button:hover { background: var(--bg-inset); color: var(--text); }

.studio-editor-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
  min-width: 0;
}
.studio-editor-toolbar {
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-surface);
  min-height: 44px;
}
.studio-editor-path {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.studio-editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}
.studio-editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: var(--text-3);
  gap: 0.5rem;
}
.studio-code-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  background: var(--bg-primary);
  color: var(--text);
  tab-size: 4;
  white-space: pre;
  overflow: auto;
}
.studio-code-textarea:focus { background: var(--bg-primary); }
.studio-code-textarea::placeholder { color: var(--text-3); }

/* CodeMirror editor mount (replaces .studio-code-textarea for code files).
   Themed via the app's CSS variables so the editor follows the light/dark
   data-theme attribute automatically — no JS theme syncing required. */
.studio-editor-cm {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.studio-editor-cm .CodeMirror {
  flex: 1;
  height: 100%;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  background: var(--bg-surface);
  color: var(--text);
}
.studio-editor-cm .CodeMirror-gutters {
  background: var(--bg-inset);
  border-right: 1px solid var(--border);
}
.studio-editor-cm .CodeMirror-linenumber { color: var(--text-3); }
.studio-editor-cm .CodeMirror-cursor { border-left: 1px solid var(--text); }
.studio-editor-cm .CodeMirror-selected { background: var(--bg-hover); }
.studio-editor-cm .CodeMirror-activeline-background { background: var(--bg-inset); }
.studio-editor-cm .CodeMirror-matchingbracket { color: inherit; font-weight: 700; }
/* C# / XML token colors (light) */
.studio-editor-cm .cm-keyword { color: #0550ae; }
.studio-editor-cm .cm-string { color: #0a7d32; }
.studio-editor-cm .cm-comment { color: var(--text-3); font-style: italic; }
.studio-editor-cm .cm-number { color: #9333ea; }
.studio-editor-cm .cm-variable { color: var(--text); }
.studio-editor-cm .cm-variable-2 { color: #c2410c; }
.studio-editor-cm .cm-builtin { color: #7c3aed; }
.studio-editor-cm .cm-def { color: #1d4ed8; }
.studio-editor-cm .cm-operator { color: var(--text-2); }
.studio-editor-cm .cm-meta { color: var(--text-3); }
.studio-editor-cm .cm-attribute { color: #1d4ed8; }
.studio-editor-cm .cm-tag { color: #be123c; }
.studio-editor-cm .cm-bracket { color: var(--text-2); }
/* token colors (dark) */
[data-theme="dark"] .studio-editor-cm .cm-keyword { color: #79c0ff; }
[data-theme="dark"] .studio-editor-cm .cm-string { color: #7ee787; }
[data-theme="dark"] .studio-editor-cm .cm-comment { color: #6b7280; }
[data-theme="dark"] .studio-editor-cm .cm-number { color: #d2a8ff; }
[data-theme="dark"] .studio-editor-cm .cm-variable-2 { color: #ffa657; }
[data-theme="dark"] .studio-editor-cm .cm-builtin { color: #d2a8ff; }
[data-theme="dark"] .studio-editor-cm .cm-def { color: #79c0ff; }
[data-theme="dark"] .studio-editor-cm .cm-attribute { color: #79c0ff; }
[data-theme="dark"] .studio-editor-cm .cm-tag { color: #ff7b72; }

.studio-info-pane {
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.studio-info-section h4 {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}
.studio-info-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  padding: 0.25rem 0;
}
.studio-info-stat-label { color: var(--text-2); }
.studio-info-stat-value { font-weight: 600; }
.studio-info-checks { display: flex; flex-direction: column; gap: 0.375rem; }
.studio-info-check {
  font-size: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 0.375rem;
  line-height: 1.4;
}
.studio-info-check.ok { background: var(--green-light, rgba(34, 197, 94, 0.1)); color: var(--green, #16a34a); }
.studio-info-check.warn { background: var(--amber-light, rgba(245, 158, 11, 0.1)); color: var(--amber, #d97706); }
.studio-info-check.err { background: var(--red-light, rgba(239, 68, 68, 0.1)); color: var(--red, #dc2626); }

.studio-empty-hero {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 1.5rem;
}
.studio-empty-hero-icon { font-size: 3.5rem; line-height: 1; }
.studio-empty-hero h2 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.studio-empty-hero p { color: var(--text-2); max-width: 480px; margin: 0; }
.studio-empty-hero-actions { display: flex; gap: 0.625rem; flex-wrap: wrap; justify-content: center; }

.studio-recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 540px;
}
.studio-recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.studio-recent-item:hover { border-color: var(--blue); transform: translateY(-1px); }
.studio-recent-name { font-weight: 600; font-size: 0.875rem; }
.studio-recent-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 0.125rem; }

@media (max-width: 1024px) {
  .studio-workspace { grid-template-columns: 220px 1fr; }
  .studio-info-pane { display: none; }
}
@media (max-width: 720px) {
  .studio-workspace { grid-template-columns: 1fr; height: auto; }
  .studio-explorer { max-height: 280px; border-right: none; border-bottom: 1px solid var(--border); }
  .studio-editor-body { min-height: 360px; }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .fade-in, .studio-fade-in, .pulse, .studio-pulse, .tab-panel, .ai-message, .studio-modal { animation: none !important; }
}
