/* ═══════════════════════════════════════════════════════════════
   PyPTO IDE Assistant — Layout & Shell Styles
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Mapped to PTO design tokens ─────────────────────────────── */
  --bg-base:        var(--background);           /* #0b1220 */
  --bg-panel:       var(--background-elevated);  /* #14181f */
  --bg-panel2:      var(--surface-1);            /* #11161c */
  --bg-hover:       var(--surface-2);            /* #171d25 */
  --bg-active:      var(--surface-3);            /* #1d2530 */
  --bg-selected:    var(--state-selected);       /* rgba(67,105,239,0.14) */
  --border:         var(--border-default);       /* rgba(255,255,255,0.10) */
  --border-light:   var(--border-strong);        /* rgba(255,255,255,0.16) */

  --text-primary:   var(--foreground);           /* #eaeaea */
  --text-secondary: var(--foreground-secondary); /* #b3b3b3 */
  --text-muted:     var(--foreground-muted);     /* #8b8f97 */
  --text-accent:    var(--accent);               /* #7c8db8 */

  --accent-blue:    var(--primary);              /* #4369ef */
  --accent-green:   var(--success);              /* #04d793 */
  --accent-orange:  var(--warning);              /* #ffaa3b */
  --accent-purple:  #a78bfa;
  --accent-red:     var(--danger);               /* #ff4b7b */
  --accent-yellow:  var(--warning);              /* #ffaa3b */

  /* ── Layout ──────────────────────────────────────────────────── */
  --titlebar-h:     44px;
  --statusbar-h:    24px;
  --activity-w:     46px;
  --ai-panel-w:     360px;

  font-family: var(--font-mono);
  font-size: 13px;
  line-height: var(--line-height-body);
  color: var(--foreground);
  background: var(--background);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ──────────── SCROLLBAR ──────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ══════════════════════════════════════════════════════════════
   TOOLBAR (PTO unified)
   ══════════════════════════════════════════════════════════════ */
.toolbar {
  height: var(--titlebar-h);
  background: color-mix(in srgb, var(--bg-base) 92%, black);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  z-index: 100;
}

.toolbar-l,
.toolbar-r {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.home-link {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.home-link:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

.app-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.chip--blue  { background: #172554; color: #60a5fa; }
.chip--green { background: #064e3b; color: #34d399; }

.toolbar-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-base);
  border-radius: 6px;
  padding: 3px;
}

.tb-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 14px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.tb-tab:hover { background: var(--bg-hover); color: var(--text-secondary); }
.tb-tab.active { background: var(--bg-active); color: var(--text-primary); font-weight: 500; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  animation: pulse-green 2s ease-in-out infinite;
}
@keyframes pulse-green {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.status-text { font-size: 11px; color: var(--accent-green); }

.tb-btn {
  padding: 4px 12px;
  background: var(--bg-active);
  border: none;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.tb-btn:hover { background: var(--bg-hover); }

/* ══════════════════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════════════════ */
#main-layout {
  display: flex;
  flex-direction: row;
  height: calc(100vh - var(--titlebar-h) - var(--statusbar-h));
  overflow: hidden;
  padding: 12px;
  background: var(--bg-base);
}

/* ──────────── ACTIVITY BAR ──────────── */
#activity-bar { display: none; }
#activity-bar-hidden {
  width: var(--activity-w);
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  flex-shrink: 0;
  gap: 4px;
}

.ab-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}
.ab-group.ab-bottom { margin-top: auto; }

.ab-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.ab-btn svg { width: 18px; height: 18px; }
.ab-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.ab-btn.active {
  color: var(--accent-blue);
  background: var(--bg-active);
}
.ab-btn.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 2px; height: 20px;
  background: var(--accent-blue);
  border-radius: 0 2px 2px 0;
}

/* ──────────── EDITOR AREA ──────────── */
#editor-area {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* ──────────── SCENARIOS ──────────── */
.scenario {
  display: none;
  flex-direction: row;
  height: 100%;
  width: 100%;
  overflow: hidden;
  gap: 12px;
}
.scenario.active { display: flex; }

/* ──────────── PANELS (card style) ──────────── */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}
.panel-center { flex: 1 1 0; }
.flex-grow { flex: 1 1 0; min-width: 0; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 36px;
  background: transparent;
  flex-shrink: 0;
}

.panel-subheader {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 12px;
  flex-shrink: 0;
}

.panel-subheader-actions {
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 10px;
}

.ph-icon { font-size: 13px; line-height: 1; }
.ph-title { font-size: 12px; font-weight: 600; color: var(--text-primary); flex: 1 1 auto; }
.ph-badge {
  font-size: 10px; padding: 1px 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px; color: var(--text-muted);
}

.ph-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ph-act-btn {
  padding: 2px 8px;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ph-act-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.ph-act-btn.active-toggle { background: var(--bg-active); color: var(--accent-blue); }

.panel-body {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.panel-body.scroll { overflow-y: auto; padding: 14px; }
.panel-body.flex-col { display: flex; flex-direction: column; }

/* ══════════════════════════════════════════════════════════════
   STATUS BAR
   ══════════════════════════════════════════════════════════════ */
#statusbar {
  height: var(--statusbar-h);
  background: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--primary-foreground);
}

.sb-left, .sb-right { display: flex; align-items: center; gap: 12px; }
.sb-item { white-space: nowrap; }
.sb-branch { color: var(--primary-foreground); font-weight: 500; }

/* ══════════════════════════════════════════════════════════════
   AI SIDE PANEL
   ══════════════════════════════════════════════════════════════ */
#ai-side-panel {
  position: fixed;
  right: 0; top: var(--titlebar-h);
  width: var(--ai-panel-w);
  height: calc(100vh - var(--titlebar-h) - var(--statusbar-h));
  background: var(--bg-panel2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  transition: transform 0.2s ease;
}
#ai-side-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.asp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  flex-shrink: 0;
}
.asp-title { font-size: 13px; font-weight: 600; color: var(--accent-purple); }
.asp-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 2px;
  border-radius: 3px; transition: color 0.15s;
}
.asp-close:hover { color: var(--text-primary); }

.asp-tabs {
  display: flex;
  flex-shrink: 0;
  background: var(--bg-base);
  padding: 3px;
  gap: 2px;
}
.asp-tab {
  flex: 1;
  padding: 5px 0;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.asp-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.asp-tab.active { background: var(--bg-active); color: var(--accent-blue); }

.asp-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.asp-body.hidden { display: none; }

/* ══════════════════════════════════════════════════════════════
   CHAT UI
   ══════════════════════════════════════════════════════════════ */
.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-messages.short { max-height: 180px; min-height: 80px; }
.chat-messages.tall  { min-height: 0; flex: 1; }

.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.chat-msg.user { flex-direction: row-reverse; }

.cm-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-active);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: var(--accent-blue);
  flex-shrink: 0;
}
.chat-msg.user .cm-avatar {
  color: var(--accent-green);
}

.cm-bubble {
  max-width: 86%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-active);
  color: var(--text-secondary);
}
.chat-msg.user .cm-bubble {
  background: var(--bg-selected);
  color: var(--text-primary);
}
.cm-bubble code {
  background: var(--bg-base);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--text-accent);
}

.chat-input-area {
  display: flex;
  gap: 6px;
  padding: 8px;
  flex-shrink: 0;
  background: var(--bg-panel2);
}
.chat-input {
  flex: 1;
  background: var(--bg-base);
  border: none;
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  resize: none;
  height: 54px;
  line-height: 1.5;
}
.chat-input:focus { outline: none; }

.chat-send {
  width: 32px; height: 54px;
  background: var(--accent-blue);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.chat-send:hover { background: #2563eb; }

.chat-divider {
  padding: 6px 12px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-base);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   FILE TABS / CODE PANES
   ══════════════════════════════════════════════════════════════ */
.file-tabs {
  display: flex;
  gap: 2px;
  border-radius: 4px;
  padding: 2px;
  background: var(--bg-base);
}
.ftab {
  padding: 2px 10px;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.ftab.active { background: var(--bg-active); color: var(--text-primary); }
.ftab:hover:not(.active) { color: var(--text-secondary); }

.code-pane {
  display: none;
  height: 100%;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-base);
}
.code-pane.active { display: block; }
.code-pane pre {
  padding: 16px 20px;
  margin: 0;
  white-space: pre;
  font-family: inherit;
  counter-reset: lines;
}
.code-pane .line {
  display: block;
  padding-left: 44px;
  position: relative;
  min-height: 20px;
}
.code-pane .line::before {
  counter-increment: lines;
  content: counter(lines);
  position: absolute;
  left: 0; width: 36px;
  text-align: right;
  color: var(--text-muted);
  user-select: none;
  font-size: 11px;
}
.code-pane .line:hover { background: var(--bg-hover); }

/* Syntax tokens */
.tok-kw  { color: #ff7b72; }
.tok-fn  { color: #d2a8ff; }
.tok-str { color: #a5d6ff; }
.tok-num { color: #79c0ff; }
.tok-cmt { color: #8b949e; font-style: italic; }
.tok-dec { color: #ffa657; }
.tok-cls { color: #f0883e; }
.tok-id  { color: #c9d1d9; }

/* ══════════════════════════════════════════════════════════════
   GRAPH SVG
   ══════════════════════════════════════════════════════════════ */
#precision-graph {
  background: var(--bg-base);
  cursor: grab;
}
#precision-graph:active { cursor: grabbing; }

.graph-legend {
  position: absolute;
  bottom: 10px; left: 10px;
  display: flex;
  gap: 12px;
  background: rgba(11,18,32,0.88);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 10px;
  pointer-events: none;
}
.gl-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--text-secondary); }
.gl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════
   SWIMLANE CANVAS
   ══════════════════════════════════════════════════════════════ */
#swimlane-canvas {
  position: absolute;
  top: 0; left: 0;
  cursor: default;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}

.timeline-ruler {
  height: 28px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  font-size: 10px;
  color: var(--text-muted);
}

.task-tooltip {
  position: absolute;
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 50;
  min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.task-tooltip.hidden { display: none; }

/* ══════════════════════════════════════════════════════════════
   CONSTRAINT PANEL
   ══════════════════════════════════════════════════════════════ */
.constraint-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(11,18,32,0.96);
  border-top: 1px solid var(--border-light);
  padding: 10px 14px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
}
.constraint-panel.hidden { display: none; }

.ct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-yellow);
}
.ct-header button {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════
   MISC UTILITIES
   ══════════════════════════════════════════════════════════════ */
.code-placeholder, .cp-icon, .cp-text, .opt-placeholder { text-align: center; }
.code-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%;
  gap: 12px;
}
.cp-icon { font-size: 32px; color: var(--text-muted); opacity: 0.4; }
.cp-text { font-size: 12px; color: var(--text-muted); line-height: 1.7; }
.opt-placeholder { font-size: 12px; color: var(--text-muted); padding: 20px 0; }

.bubble-dot {
  width: 8px; height: 8px; border-radius: 2px;
  background: repeating-linear-gradient(45deg, #ef4444 0 2px, transparent 0 4px);
  border: 1px solid #ef4444;
}

.legend-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--text-secondary);
}
.lg-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* ==========================================================================
   Cohere Design.md theme overrides
   ========================================================================== */

:root {
  --bg-page: #f8f8fb;
  --bg-shell: rgba(255, 255, 255, 0.92);
  --bg-panel: rgba(255, 255, 255, 0.96);
  --bg-panel-strong: #ffffff;
  --bg-subtle: #eef0f6;
  --bg-subtle-2: #e7e9f0;
  --bg-selected: rgba(24, 99, 220, 0.1);
  --bg-selected-strong: rgba(24, 99, 220, 0.16);
  --border: rgba(33, 33, 33, 0.14);
  --border-strong: rgba(33, 33, 33, 0.22);
  --text-primary: #000000;
  --text-secondary: #16161b;
  --text-muted: #555561;
  --text-soft: #787886;
  --accent: #1863dc;
  --accent-strong: #0f56ca;
  --accent-purple: #9b60aa;
  --accent-green: #177245;
  --accent-orange: #b45c17;
  --accent-red: #b42318;
  --shadow-soft: 0 24px 72px rgba(48, 42, 76, 0.12);
  --shadow-card: 0 20px 40px rgba(22, 23, 28, 0.1);
  --font-display: "Space Grotesk", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, monospace;
  color: var(--text-primary);
  background:
    radial-gradient(circle at top left, rgba(155, 96, 170, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(24, 99, 220, 0.14), transparent 30%),
    linear-gradient(180deg, #fdfdff 0%, #f6f7fb 42%, #eceff6 100%);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

html,
body {
  overflow: hidden;
  background: transparent;
}

body.cohere-ui {
  position: relative;
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.cohere-aura {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 12%, rgba(155, 96, 170, 0.22), transparent 0 22rem),
    radial-gradient(circle at 88% 8%, rgba(24, 99, 220, 0.18), transparent 0 24rem),
    radial-gradient(circle at 72% 86%, rgba(155, 96, 170, 0.08), transparent 0 18rem);
  z-index: 0;
}

body > *:not(.cohere-aura) {
  position: relative;
  z-index: 1;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: rgba(33, 33, 33, 0.16);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(33, 33, 33, 0.24);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.toolbar {
  height: 64px;
  padding: 0 22px;
  background: transparent;
  border-bottom: none;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: none;
}

.toolbar-l,
.toolbar-r {
  gap: 12px;
}

.home-link {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-secondary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.home-link:hover {
  background: #ffffff;
  border-color: var(--border-strong);
  color: var(--accent);
}

.toolbar-sep {
  height: 26px;
  background: rgba(33, 33, 33, 0.08);
}

.app-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.chip--blue {
  background: rgba(24, 99, 220, 0.08);
  border-color: rgba(24, 99, 220, 0.14);
  color: var(--accent);
}

.chip--green {
  background: rgba(23, 114, 69, 0.08);
  border-color: rgba(23, 114, 69, 0.14);
  color: var(--accent-green);
}

.toolbar-tabs,
.file-tabs,
.asp-tabs {
  padding: 4px;
  gap: 4px;
  background: rgba(236, 238, 245, 0.92);
  border: 1px solid rgba(33, 33, 33, 0.1);
  border-radius: 999px;
}

.tb-tab,
.ftab,
.asp-tab {
  min-height: 36px;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
}

.tb-tab:hover,
.ftab:hover:not(.active),
.asp-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-secondary);
}

.tb-tab.active,
.ftab.active,
.asp-tab.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 8px 16px rgba(22, 23, 28, 0.08);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  box-shadow: 0 0 0 6px rgba(23, 114, 69, 0.1);
}

.status-text {
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-size: 11px;
}

.tb-btn,
.ph-act-btn,
.btn-secondary {
  min-height: 36px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.tb-btn:hover,
.ph-act-btn:hover,
.btn-secondary:hover {
  background: #ffffff;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.ph-act-btn.active-toggle {
  background: rgba(24, 99, 220, 0.1);
  border-color: rgba(24, 99, 220, 0.18);
  color: var(--accent);
}

#main-layout {
  height: calc(100vh - var(--titlebar-h) - var(--statusbar-h));
  padding: 0 8px 14px;
  background: transparent;
}

.scenario {
  gap: 8px;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(252, 252, 255, 0.94)),
    linear-gradient(135deg, rgba(155, 96, 170, 0.05), rgba(24, 99, 220, 0.04));
  border: 1px solid rgba(33, 33, 33, 0.1);
  border-radius: 28px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.panel-header {
  min-height: 68px;
  padding: 18px 20px;
  gap: 10px;
  border-bottom: 1px solid rgba(33, 33, 33, 0.08);
}

.ph-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(155, 96, 170, 0.16), rgba(24, 99, 220, 0.12));
  color: var(--accent-purple);
  font-size: 15px;
}

.ph-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.ph-badge,
#opt-score-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(243, 243, 247, 0.92);
  border: 1px solid rgba(33, 33, 33, 0.08);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.panel-body.scroll {
  padding: 20px;
}

.scenario-side {
  flex-shrink: 0;
}

.scenario-side--left {
  width: 320px !important;
  min-width: 320px !important;
  max-width: 320px !important;
}

.scenario-side--right {
  width: 320px !important;
  min-width: 320px !important;
  max-width: 320px !important;
}

.panel-footer {
  flex-shrink: 0;
}

.panel-footer--sticky {
  padding: 12px 20px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.96) 32%);
  border-top: 1px solid rgba(33, 33, 33, 0.06);
}

.coding-form-body {
  padding-bottom: 10px;
}

#statusbar {
  height: 42px;
  background: #17171c;
  color: #f8f8fb;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11px;
}

.sb-branch {
  color: #ffb1ee;
}

#ai-side-panel {
  top: 64px;
  height: calc(100vh - 64px - 42px);
  background: rgba(255, 255, 255, 0.96);
  border-left: 1px solid rgba(33, 33, 33, 0.08);
  box-shadow: -18px 0 40px rgba(22, 23, 28, 0.08);
}

.asp-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(33, 33, 33, 0.06);
}

.asp-title {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
}

.asp-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
}

.asp-close:hover {
  background: rgba(33, 33, 33, 0.05);
  color: var(--text-primary);
}

.asp-tabs {
  margin: 12px 18px 0;
}

.chat-messages {
  padding: 18px;
  gap: 14px;
}

.chat-msg {
  gap: 10px;
}

.cm-avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(155, 96, 170, 0.2), rgba(24, 99, 220, 0.12));
  color: var(--accent-purple);
  font-family: var(--font-mono);
  font-size: 11px;
}

.chat-msg.user .cm-avatar {
  background: rgba(24, 99, 220, 0.12);
  color: var(--accent);
}

.cm-bubble {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(33, 33, 33, 0.08);
  color: var(--text-secondary);
  box-shadow: 0 12px 24px rgba(22, 23, 28, 0.05);
}

.chat-msg.user .cm-bubble {
  background: linear-gradient(135deg, rgba(24, 99, 220, 0.12), rgba(155, 96, 170, 0.08));
  border-color: rgba(24, 99, 220, 0.12);
  color: var(--text-primary);
}

.cm-bubble code {
  background: rgba(243, 243, 247, 0.95);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.chat-divider {
  padding: 12px 18px;
  background: rgba(243, 243, 247, 0.75);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.chat-input-area {
  gap: 12px;
  padding: 16px 18px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(243, 243, 247, 0.8));
  border-top: 1px solid rgba(33, 33, 33, 0.06);
}

.chat-input {
  min-height: 56px;
  height: 56px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(33, 33, 33, 0.08);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 8px 24px rgba(22, 23, 28, 0.04);
}

.chat-input::placeholder {
  color: var(--text-soft);
}

.chat-input:focus {
  outline: none;
  border-color: rgba(24, 99, 220, 0.24);
  box-shadow: 0 0 0 4px rgba(24, 99, 220, 0.08), 0 10px 28px rgba(22, 23, 28, 0.06);
}

.chat-send {
  min-width: 92px;
  height: 56px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #111111, #2d2d32);
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 18px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.18);
}

.chat-send:hover {
  background: linear-gradient(135deg, #000000, #202026);
  transform: translateY(-1px);
}

.chat-send span:last-child {
  font-size: 15px;
  line-height: 1;
}

.code-pane {
  position: relative;
  background:
    radial-gradient(circle at top right, rgba(67, 105, 239, 0.08), transparent 30%),
    linear-gradient(180deg, #fbfcfe 0%, #f4f7fb 100%);
  color: #223046;
  border-top: 1px solid rgba(31, 41, 55, 0.06);
}

.code-pane::before {
  content: '';
  position: sticky;
  top: 0;
  z-index: 2;
  display: block;
  height: 38px;
  background:
    radial-gradient(circle at 18px 19px, #ff5f57 0 4px, transparent 5px),
    radial-gradient(circle at 34px 19px, #febc2e 0 4px, transparent 5px),
    radial-gradient(circle at 50px 19px, #28c840 0 4px, transparent 5px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 246, 251, 0.94));
  border-bottom: 1px solid rgba(31, 41, 55, 0.08);
}

.code-pane pre {
  display: inline-block;
  min-width: 100%;
  padding: 18px 0 28px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  white-space: pre;
  overflow-x: visible;
}

.code-pane .line {
  display: block;
  padding-left: 72px;
  padding-right: 24px;
  min-height: 22px;
  white-space: pre;
  width: max-content;
  min-width: 100%;
}

.code-pane .line::before {
  left: 18px;
  width: 34px;
  color: rgba(120, 133, 155, 0.86);
  border-right: 1px solid rgba(31, 41, 55, 0.08);
  padding-right: 10px;
}

.code-pane .line:hover {
  background: rgba(67, 105, 239, 0.06);
}

.tok-kw  { color: #7c3aed; }
.tok-fn  { color: #2563eb; }
.tok-str { color: #0f766e; }
.tok-num { color: #c2410c; }
.tok-cmt { color: #94a3b8; }
.tok-dec { color: #b45309; }
.tok-cls { color: #9333ea; }
.tok-id  { color: #1f2937; }

#precision-graph {
  background:
    radial-gradient(circle at top right, rgba(24, 99, 220, 0.08), transparent 0 14rem),
    linear-gradient(180deg, #ffffff 0%, #f6f6fa 100%);
}

.graph-legend,
.task-tooltip,
.constraint-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(33, 33, 33, 0.1);
  box-shadow: 0 14px 30px rgba(22, 23, 28, 0.1);
  color: var(--text-secondary);
}

.graph-legend {
  border-radius: 999px;
  padding: 8px 14px;
}

.timeline-ruler {
  height: 36px;
  background: rgba(248, 248, 251, 0.95);
  border-top: 1px solid rgba(33, 33, 33, 0.06);
  color: var(--text-soft);
  font-family: var(--font-mono);
}

.task-tooltip {
  border-radius: 20px;
  min-width: 200px;
}

.constraint-panel {
  border-top: 1px solid rgba(33, 33, 33, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ct-header {
  color: var(--accent-purple);
}

.cp-icon {
  color: rgba(155, 96, 170, 0.5);
}

.cp-text,
.opt-placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

.bubble-dot {
  background: repeating-linear-gradient(45deg, rgba(155, 96, 170, 0.6) 0 2px, transparent 0 4px);
  border-color: rgba(155, 96, 170, 0.75);
}

.legend-row {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

@media (max-width: 1280px) {
  .toolbar {
    padding: 0 14px;
  }

  #main-layout {
    padding: 12px;
  }

  .scenario {
    gap: 12px;
  }

  .panel {
    border-radius: 22px;
  }
}

/* Final layout fixes */
#main-layout {
  overflow: visible;
  padding: 0 8px 20px;
}

#editor-area {
  overflow: visible;
}

.scenario {
  overflow: visible;
}
