/* ==========================================================================
   Trujillo AI Design System — Rewrite AI SaaS Studio Layout
   Matching ai.trujillomingorance.com (web_decoded.html) Pixel for Pixel
   ========================================================================== */

/* --- Default CSS Variables (Dark Base) --- */
:root {
  --bg: #000000;
  --sidebar: #0a0a0a;
  --elev: #141414;
  --elev-2: #1a1a1a;
  --card: #111111;
  --input: #0a0a0a;
  --invert: #ffffff;
  --invert-fg: #000000;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f5f5f5;
  --muted: #a1a1aa;
  --dim: #71717a;
  --blue: #38bdf8;
  --green: #34d399;
  --red: #f87171;
  --purple: #c084fc;
  --cyan: #22d3ee;
  --amber: #f59e0b;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sb: 272px;
}

/* --- The 13 Full Theme Definitions from Trujillo AI Studio --- */
html[data-theme="dark"] {
  --bg: #000000; --sidebar: #0a0a0a; --elev: #141414; --elev-2: #1a1a1a;
  --card: #111111; --input: #0a0a0a; --invert: #ffffff; --invert-fg: #000000;
  --line: rgba(255,255,255,0.08); --line-2: rgba(255,255,255,0.14);
  --text: #f5f5f5; --muted: #a1a1aa; --dim: #71717a;
}

html[data-theme="gray"] {
  --bg: #18181b; --sidebar: #121215; --elev: #27272a; --elev-2: #3f3f46;
  --card: #202024; --input: #121215; --invert: #fafafa; --invert-fg: #18181b;
  --line: rgba(255,255,255,0.08); --line-2: rgba(255,255,255,0.14);
  --text: #fafafa; --muted: #a1a1aa; --dim: #71717a;
}

html[data-theme="dim"] {
  --bg: #0d1117; --sidebar: #080c10; --elev: #161b22; --elev-2: #21262d;
  --card: #12171f; --input: #080c10; --invert: #f0f6fc; --invert-fg: #0d1117;
  --line: rgba(255,255,255,0.08); --line-2: rgba(255,255,255,0.14);
  --text: #f0f6fc; --muted: #8b949e; --dim: #6e7681;
}

html[data-theme="navy"] {
  --bg: #0b1220; --sidebar: #060a12; --elev: #152036; --elev-2: #1e2c4a;
  --card: #10192c; --input: #060a12; --invert: #e2e8f0; --invert-fg: #0b1220;
  --line: rgba(255,255,255,0.08); --line-2: rgba(255,255,255,0.14);
  --text: #f1f5f9; --muted: #94a3b8; --dim: #64748b;
}

html[data-theme="light"] {
  --bg: #f4f4f5; --sidebar: #ececef; --elev: #ffffff; --elev-2: #e4e4e7;
  --card: #ffffff; --input: #ececef; --invert: #18181b; --invert-fg: #ffffff;
  --line: rgba(0,0,0,0.08); --line-2: rgba(0,0,0,0.14);
  --text: #18181b; --muted: #71717a; --dim: #a1a1aa;
  --blue: #0284c7; --green: #15803d; --red: #dc2626; --purple: #9333ea;
}

html[data-theme="paper"] {
  --bg: #f4efe6; --sidebar: #ebe4d6; --elev: #ffffff; --elev-2: #e5dcce;
  --card: #ffffff; --input: #ebe4d6; --invert: #2c251e; --invert-fg: #f4efe6;
  --line: rgba(44,37,30,0.1); --line-2: rgba(44,37,30,0.18);
  --text: #2c251e; --muted: #7d7265; --dim: #a89c8d;
  --blue: #0369a1; --green: #15803d; --red: #b91c1c; --purple: #7e22ce;
}

html[data-theme="hacker"] {
  --bg: #000000; --sidebar: #040c04; --elev: #081a08; --elev-2: #0f2b0f;
  --card: #061406; --input: #020602; --invert: #22c55e; --invert-fg: #000000;
  --line: rgba(34,197,94,0.2); --line-2: rgba(34,197,94,0.35);
  --text: #4ade80; --muted: #22c55e; --dim: #15803d;
}

html[data-theme="cyberpunk"] {
  --bg: #0d021a; --sidebar: #07010e; --elev: #1a0533; --elev-2: #27084d;
  --card: #130324; --input: #07010e; --invert: #fcee0a; --invert-fg: #0d021a;
  --line: rgba(255,0,127,0.25); --line-2: rgba(255,0,127,0.4);
  --text: #00ffff; --muted: #ff007f; --dim: #a200ff;
}

html[data-theme="sunset"] {
  --bg: #1f101d; --sidebar: #140a13; --elev: #30192d; --elev-2: #43223e;
  --card: #251323; --input: #140a13; --invert: #fb923c; --invert-fg: #1f101d;
  --line: rgba(251,146,60,0.18); --line-2: rgba(251,146,60,0.3);
  --text: #ffedd5; --muted: #fdba74; --dim: #ea580c;
}

html[data-theme="ocean"] {
  --bg: #061325; --sidebar: #030b17; --elev: #0c2340; --elev-2: #11325b;
  --card: #081a32; --input: #030b17; --invert: #38bdf8; --invert-fg: #061325;
  --line: rgba(56,189,248,0.15); --line-2: rgba(56,189,248,0.25);
  --text: #f0f9ff; --muted: #7dd3fc; --dim: #0284c7;
}

html[data-theme="forest"] {
  --bg: #07130e; --sidebar: #040c08; --elev: #0e241b; --elev-2: #163628;
  --card: #0a1913; --input: #040c08; --invert: #22c55e; --invert-fg: #07130e;
  --line: rgba(34,197,94,0.15); --line-2: rgba(34,197,94,0.25);
  --text: #ecfdf5; --muted: #6ee7b7; --dim: #10b981;
}

html[data-theme="rose"] {
  --bg: #fff1f2; --sidebar: #ffe4e6; --elev: #ffffff; --elev-2: #fecdd3;
  --card: #ffffff; --input: #ffe4e6; --invert: #e11d48; --invert-fg: #ffffff;
  --line: rgba(225,29,72,0.12); --line-2: rgba(225,29,72,0.22);
  --text: #4c0519; --muted: #9f1239; --dim: #be123c;
  --blue: #0284c7; --green: #15803d; --red: #e11d48; --purple: #9333ea;
}

html[data-theme="lavender"] {
  --bg: #f8f6fc; --sidebar: #f3e8ff; --elev: #ffffff; --elev-2: #e9d5ff;
  --card: #ffffff; --input: #f3e8ff; --invert: #7e22ce; --invert-fg: #ffffff;
  --line: rgba(126,34,206,0.12); --line-2: rgba(126,34,206,0.22);
  --text: #3b0764; --muted: #7e22ce; --dim: #a855f7;
  --blue: #0284c7; --green: #15803d; --red: #dc2626; --purple: #7e22ce;
}

html[data-theme="light"], html[data-theme="paper"], html[data-theme="rose"], html[data-theme="lavender"] {
  color-scheme: light;
}

/* --- Font Scaling & Accessibility --- */
html[data-font="sm"] { font-size: 14px; }
html[data-font="md"] { font-size: 15px; }
html[data-font="lg"] { font-size: 16.5px; }

html.compact-sb { --sb: 220px; }
html.reduce-motion * {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body, #app {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(127, 127, 127, 0.22);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(127, 127, 127, 0.35);
}

.hidden {
  display: none !important;
}

/* --- App Shell (100vh) --- */
.ta-app {
  display: flex;
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* --- Mobile Sidebar Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 45;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
  display: block;
}

/* --- Sidebar --- */
.ta-sidebar {
  width: var(--sb);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  min-height: 0;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 860px) {
  .ta-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 310px);
    transform: translateX(-105%);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.85);
  }
  .ta-sidebar.open {
    transform: translateX(0);
  }
}

.sb-head {
  padding: 14px 12px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.brand-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line-2);
}

.brand-title {
  font-weight: 650;
  font-size: 0.92rem;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.brand-badge {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--elev-2);
  color: var(--blue);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.88rem;
}

.icon-btn:hover {
  background: var(--elev);
  color: var(--text);
}

.new-chat-btn {
  margin: 4px 12px 8px;
  padding: 8px 12px;
  background: var(--elev);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.new-chat-btn:hover {
  background: var(--elev-2);
  border-color: var(--line-2);
}

.hint {
  font-size: 0.7rem;
  color: var(--dim);
  font-family: var(--mono);
}

.history-search-box {
  padding: 0 12px 8px;
}

.history-search-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
}

.history-search-input:focus {
  border-color: var(--blue);
}

.sb-tabs {
  display: flex;
  padding: 0 12px 6px;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.sb-tab {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
}

.sb-tab:hover {
  color: var(--text);
  background: var(--elev);
}

.sb-tab.active {
  color: var(--text);
  background: var(--elev);
  font-weight: 650;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
}

.history-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  padding: 6px 8px 3px;
}

.history-item, .doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}

.history-item:hover, .doc-item:hover {
  background: var(--elev);
  color: var(--text);
}

.history-item.active {
  background: var(--elev);
  color: var(--text);
  font-weight: 600;
}

.history-title, .doc-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.history-del-btn {
  background: transparent;
  border: 0;
  color: var(--dim);
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  display: none;
  font-size: 0.72rem;
}

.history-item:hover .history-del-btn {
  display: block;
}

.history-del-btn:hover {
  color: var(--red);
  background: rgba(248, 113, 113, 0.12);
}

.guide-box {
  padding: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.guide-box h4 {
  color: var(--text);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.guide-box p {
  margin-bottom: 8px;
}

.guide-box ul {
  padding-left: 16px;
  margin-bottom: 8px;
}

.sb-foot {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sb-edge-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  color: var(--dim);
  padding: 4px 6px;
  font-family: var(--mono);
}

.edge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 550;
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.sb-link:hover {
  background: var(--elev);
  color: var(--text);
}

.user-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  margin-top: 4px;
  color: var(--text);
  transition: border-color 0.15s;
}

.user-pill:hover {
  border-color: var(--line-2);
}

.user-pill-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.avatar-letter {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--invert);
  color: var(--invert-fg);
  font-weight: 700;
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-pill-text {
  min-width: 0;
}

.user-info-name {
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info-tier {
  font-size: 0.68rem;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Main Layout --- */
.ta-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* --- Topbar --- */
.ta-topbar {
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg);
  z-index: 30;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-toggle-btn {
  display: none;
}

@media (max-width: 860px) {
  .menu-toggle-btn {
    display: flex;
  }
}

/* Model Picker */
.model-picker {
  position: relative;
}

.model-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--elev);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.model-picker-btn:hover {
  border-color: var(--line-2);
  background: var(--elev-2);
}

.model-picker-caret {
  width: 12px;
  height: 12px;
  color: var(--dim);
  transition: transform 0.15s ease;
}

.model-picker.open .model-picker-caret {
  transform: rotate(180deg);
}

.model-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  z-index: 100;
}

.model-picker.open .model-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-option {
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
}

.model-option:hover {
  background: var(--elev);
  color: var(--text);
}

.model-option.active {
  background: var(--elev);
  color: var(--text);
}

.model-option-name {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text);
}

.model-option-desc {
  font-size: 0.7rem;
  color: var(--dim);
  margin-top: 2px;
}

/* Mode Segmented Pills */
.mode-segmented-pill {
  display: flex;
  align-items: center;
  background: var(--elev);
  border: 1px solid var(--line);
  padding: 3px;
  border-radius: 999px;
  gap: 2px;
}

.mode-opt-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.mode-opt-btn:hover {
  color: var(--text);
}

.mode-opt-btn.active {
  background: var(--invert);
  color: var(--invert-fg);
  font-weight: 650;
}

@media (max-width: 900px) {
  .mode-segmented-pill {
    overflow-x: auto;
    max-width: 280px;
  }
}

.status-badge-edge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.22);
  color: var(--green);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-family: var(--mono);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px rgba(52, 211, 153, 0.9); }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.topbar-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.topbar-icon-btn:hover {
  border-color: var(--line-2);
  color: var(--text);
  background: var(--elev-2);
}

.topbar-icon-btn svg {
  width: 16px;
  height: 16px;
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 32px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 650;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.topbar-action-btn:hover {
  background: var(--elev-2);
  border-color: var(--line-2);
}

.topbar-action-btn.primary {
  background: var(--invert);
  color: var(--invert-fg);
  border-color: var(--invert);
}

.topbar-action-btn.primary:hover {
  opacity: 0.92;
}

/* --- Split Studio Workspace (Full Height) --- */
.studio-workspace {
  display: grid;
  grid-template-columns: 1fr 48px 1fr;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

@media (max-width: 900px) {
  .studio-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
    overflow-y: auto;
  }
}

/* Studio Panes */
.studio-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

.pane-header {
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.pane-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pane-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-warn {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.dot-success {
  background: var(--green);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
}

.pane-title {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane-stat {
  font-size: 0.72rem;
  color: var(--dim);
  font-family: var(--mono);
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pane-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}

.pane-btn:hover {
  background: var(--elev-2);
  color: var(--text);
  border-color: var(--line-2);
}

.pane-btn.primary {
  background: var(--invert);
  color: var(--invert-fg);
  border-color: var(--invert);
}

.pane-center-tabs {
  display: flex;
  align-items: center;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.view-tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.view-tab:hover {
  color: var(--text);
}

.view-tab.active {
  background: var(--elev-2);
  color: var(--text);
}

.pane-editor-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.studio-textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 16px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.65;
  resize: none;
  overflow-y: auto;
  caret-color: var(--text);
}

.studio-textarea::placeholder {
  color: var(--dim);
  font-family: var(--font);
  font-size: 0.86rem;
}

.studio-preview {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 20px 24px;
  overflow-y: auto;
  line-height: 1.7;
}

.pane-footer {
  height: 38px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg);
}

.pane-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}

.pane-status-pill strong {
  color: var(--text);
}

.pane-status-pill.success strong {
  color: var(--green);
}

/* Center Execute Bar */
.studio-center-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 10;
}

@media (max-width: 900px) {
  .studio-center-bar {
    border-left: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 8px 16px;
  }
}

.execute-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--invert);
  color: var(--invert-fg);
  border: 0;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.execute-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.execute-btn:active {
  transform: scale(0.98);
}

.execute-btn.loading {
  opacity: 0.75;
  pointer-events: none;
}

.execute-kbd {
  font-size: 0.65rem;
  opacity: 0.65;
  background: rgba(127, 127, 127, 0.2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--mono);
}

/* Markdown Rendering Engine */
.prose-ai {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.7;
}

.prose-ai h1, .prose-ai h2, .prose-ai h3, .prose-ai h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  color: var(--text);
}

.prose-ai p {
  margin-bottom: 0.9em;
}

.prose-ai strong {
  font-weight: 700;
  color: var(--text);
}

.prose-ai ul, .prose-ai ol {
  padding-left: 20px;
  margin-bottom: 1em;
}

.prose-ai li {
  margin-bottom: 0.35em;
}

.ta-blockquote {
  border-left: 3px solid var(--blue);
  padding: 6px 14px;
  margin: 1em 0;
  color: var(--muted);
  background: rgba(127, 127, 127, 0.05);
  border-radius: 0 8px 8px 0;
}

.ta-hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 1.5em 0;
}

.ta-inline-code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--elev);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--blue);
}

.code-block-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 1.2em 0;
  overflow: hidden;
}

.code-block-header {
  padding: 6px 12px;
  background: var(--elev);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--dim);
}

.code-copy-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.code-copy-btn:hover {
  background: var(--elev-2);
  color: var(--text);
}

.code-block-pre {
  padding: 12px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
}

.table-wrapper {
  overflow-x: auto;
  margin: 1.2em 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.ta-table th, .ta-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.ta-table th {
  background: var(--elev);
  font-weight: 650;
  color: var(--text);
}

.empty-studio-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--dim);
  padding: 30px 20px;
}

.empty-icon-svg {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--elev);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: 14px;
}

.empty-title {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.8rem;
  line-height: 1.55;
  max-width: 380px;
}

/* Diff Viewer */
.diff-viewer {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.diff-del {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
  text-decoration: line-through;
  padding: 1px 3px;
  border-radius: 3px;
}

.diff-ins {
  background: rgba(52, 211, 153, 0.18);
  color: #6ee7b7;
  padding: 1px 3px;
  border-radius: 3px;
}

html[data-theme="light"] .diff-del,
html[data-theme="paper"] .diff-del,
html[data-theme="rose"] .diff-del,
html[data-theme="lavender"] .diff-del {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

html[data-theme="light"] .diff-ins,
html[data-theme="paper"] .diff-ins,
html[data-theme="rose"] .diff-ins,
html[data-theme="lavender"] .diff-ins {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

/* --- Modals Base --- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
  position: relative;
  width: 100%;
}

.modal-close-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: 0;
  color: var(--dim);
  font-size: 1rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-icon:hover {
  background: var(--elev);
  color: var(--text);
}


/* Auth Social & Advanced Form Styling (ai.trujillomingorance.com Parity) */
.auth-social-wrap {
  margin-bottom: 16px;
}

.auth-social-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-social {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--elev);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-social:hover {
  background: var(--elev-2);
  border-color: var(--line-2);
}

.btn-social-google-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}

.google-btn-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.001;
  z-index: 2;
  overflow: hidden;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 14px 0 10px;
  color: var(--dim);
  font-size: 0.74rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--line);
}

.auth-divider span {
  padding: 0 10px;
}

.ghost-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.76rem;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
  text-decoration: none;
}

.ghost-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.otp-code-input {
  text-align: center;
  font-size: 1.6rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.16em !important;
  font-family: var(--mono) !important;
  width: 220px !important;
  margin: 6px auto 0 !important;
}

.alert-banner {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  margin-bottom: 14px;
  line-height: 1.45;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.auth-modal-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 0.74rem;
  color: var(--dim);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.auth-modal-footer a {
  color: var(--dim);
  text-decoration: none;
}

.auth-modal-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Auth Modal Specifics */
.auth-modal-card {
  max-width: 400px;
  padding: 28px 24px 20px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 20px;
}

.auth-brand img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  margin-bottom: 10px;
}

.auth-brand h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-brand p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.auth-tab-btn {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.auth-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--blue);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--muted);
}

.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--blue);
}

.input-with-eye {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-eye {
  position: absolute;
  right: 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  opacity: 0.6;
}

.btn-eye:hover {
  opacity: 1;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--dim);
  line-height: 1.4;
}

.btn-submit-auth {
  background: var(--invert);
  color: var(--invert-fg);
  font-weight: 650;
  font-size: 0.86rem;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}

.btn-submit-auth:hover {
  opacity: 0.92;
}

.guest-action-wrap {
  text-align: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.btn-guest-link {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-guest-link:hover {
  color: var(--text);
}

/* --- Multi-Pane Settings Modal (Matching Trujillo AI Studio) --- */
.modal-card.settings-wide {
  width: min(92vw, 780px);
  height: min(88vh, 640px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 0.96rem;
  font-weight: 700;
}

.settings-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.settings-nav {
  border-right: 1px solid var(--line);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--sidebar);
  overflow-y: auto;
}

.settings-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  padding: 8px 10px 3px;
}

.settings-nav-btn {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.settings-nav-btn:hover {
  background: rgba(127, 127, 127, 0.12);
  color: var(--text);
}

.settings-nav-btn.active {
  background: rgba(127, 127, 127, 0.18);
  color: var(--text);
}

.settings-main {
  padding: 20px 24px;
  overflow-y: auto;
  min-height: 0;
}

.settings-pane {
  display: none;
}

.settings-pane.active {
  display: block;
}

.settings-section-title {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.settings-section-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 18px;
}

/* Theme Grid & Swatches */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.theme-card:hover {
  border-color: var(--line-2);
}

.theme-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}

.theme-swatch {
  height: 38px;
  border-radius: 6px;
  border: 1px solid rgba(127, 127, 127, 0.22);
  background: linear-gradient(90deg, var(--sw-side) 30%, var(--sw-bg) 30%);
}

.theme-swatch[data-swatch="dark"] { --sw-bg: #000; --sw-side: #111; }
.theme-swatch[data-swatch="gray"] { --sw-bg: #18181b; --sw-side: #27272a; }
.theme-swatch[data-swatch="dim"] { --sw-bg: #0d1117; --sw-side: #161b22; }
.theme-swatch[data-swatch="navy"] { --sw-bg: #0b1220; --sw-side: #152036; }
.theme-swatch[data-swatch="light"] { --sw-bg: #f4f4f5; --sw-side: #ececef; }
.theme-swatch[data-swatch="paper"] { --sw-bg: #f4efe6; --sw-side: #ebe4d6; }
.theme-swatch[data-swatch="hacker"] { --sw-bg: #000000; --sw-side: #081a08; }
.theme-swatch[data-swatch="cyberpunk"] { --sw-bg: #0d021a; --sw-side: #ff007f; }
.theme-swatch[data-swatch="sunset"] { --sw-bg: #1f101d; --sw-side: #ea580c; }
.theme-swatch[data-swatch="ocean"] { --sw-bg: #061325; --sw-side: #0284c7; }
.theme-swatch[data-swatch="forest"] { --sw-bg: #07130e; --sw-side: #10b981; }
.theme-swatch[data-swatch="rose"] { --sw-bg: #fff1f2; --sw-side: #fecdd3; }
.theme-swatch[data-swatch="lavender"] { --sw-bg: #f8f6fc; --sw-side: #e9d5ff; }
.theme-swatch[data-swatch="system"] { --sw-bg: #71717a; --sw-side: #111; }

/* Accents */
.accent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.accent-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

.accent-dot:hover {
  transform: scale(1.1);
}

.accent-dot.active {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue);
}

/* Choice Row */
.choice-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.choice-pill {
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.choice-pill:hover {
  background: var(--elev-2);
}

.choice-pill.active {
  background: var(--invert);
  color: var(--invert-fg);
  border-color: var(--invert);
}

/* Toggle Row & Cards */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
  cursor: pointer;
}

.toggle-row:last-child {
  border-bottom: 0;
}

.settings-card {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}

.settings-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}

.settings-kv:last-child {
  border-bottom: 0;
}

.settings-kv-label {
  color: var(--muted);
}

.settings-kv-value {
  font-weight: 600;
  color: var(--text);
}

.settings-kv-sub {
  font-size: 0.76rem;
  color: var(--dim);
  margin: 4px 0 12px;
  line-height: 1.4;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(56, 189, 248, 0.12);
  color: var(--blue);
}

.logout-big-btn {
  width: 100%;
  padding: 9px 14px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 650;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.logout-big-btn:hover {
  background: rgba(248, 113, 113, 0.22);
}

.auth-error-msg {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fca5a5;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  margin-bottom: 12px;
}

.settings-hint {
  font-size: 0.75rem;
  color: var(--dim);
  line-height: 1.45;
  margin-top: 14px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-badge {
  font-size: 0.75rem;
  font-family: var(--mono);
  background: rgba(56, 189, 248, 0.12);
  color: var(--blue);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.form-range {
  width: 100%;
  accent-color: var(--blue);
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--dim);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-secondary {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--elev-2);
  color: var(--text);
}

.btn-primary {
  padding: 7px 16px;
  border-radius: 8px;
  border: 0;
  background: var(--invert);
  color: var(--invert-fg);
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}

.btn-primary:hover {
  opacity: 0.92;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--invert);
  border: 1px solid var(--line-2);
  color: var(--invert-fg);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 550;
  z-index: 120;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  animation: toastFade 0.2s ease;
}

@keyframes toastFade {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 720px) {
  .modal-card.settings-wide {
    width: 95vw;
    height: min(92vh, 760px);
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 6px;
  }
  .settings-nav-label {
    display: none;
  }
  .settings-nav-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 0.78rem;
  }
  .settings-main {
    padding: 14px 16px;
  }
}
