/* SGT Lab — Solver IDE shell (inner framework) */
html.solver-ide {
  height: 100%;
  --ide-bg: #0d0d12;
  --ide-surface: #14141f;
  --ide-sidebar: #12121a;
  --ide-activity: #0a0a10;
  --ide-chrome: #181824;
  --ide-border: #2a2a3a;
  --ide-border-soft: #1e1e2e;
  --ide-accent: #00d4ff;
  --ide-accent-dim: rgba(0, 212, 255, 0.12);
  --ide-text: #e8e8f0;
  --ide-muted: #7a7a92;
  --ide-mono: "Cascadia Code", "Consolas", "Courier New", monospace;
  --ide-ui: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ide-status-h: 24px;
  --ide-title-h: 38px;
  --ide-activity-w: 48px;
  --ide-sidebar-w: 248px;
  --ide-tabbar-h: 36px;
  overflow: hidden;
}

html.solver-ide body {
  font-family: var(--ide-ui);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

html.solver-ide a { color: var(--ide-accent); text-decoration: none; }
html.solver-ide a:hover { text-decoration: underline; }

.ide-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--ide-bg);
  color: var(--ide-text);
}

/* ── Title bar ── */
.ide-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--ide-title-h);
  min-height: var(--ide-title-h);
  padding: 0 12px 0 8px;
  background: var(--ide-chrome);
  border-bottom: 1px solid var(--ide-border);
  font-size: 0.78rem;
  z-index: 120;
}

.ide-titlebar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.ide-titlebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ide-accent);
  white-space: nowrap;
}

  .ide-titlebar-portal {
    font-size: 0.68rem;
    color: var(--ide-muted);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .ide-titlebar-portal:hover {
    color: var(--ide-accent);
    text-decoration: none;
  }

.ide-titlebar-brand img {
  width: 18px;
  height: 18px;
  opacity: 0.95;
}

.ide-titlebar-sep { color: var(--ide-muted); opacity: 0.6; }

.ide-titlebar-workbench {
  color: var(--ide-muted);
  font-family: var(--ide-mono);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ide-titlebar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ide-titlebar-nav {
  display: none;
}

.ide-sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--ide-border);
  border-radius: 3px;
  background: var(--ide-surface);
  color: var(--ide-muted);
  cursor: pointer;
  font-size: 0.85rem;
}

@media (min-width: 960px) {
  .ide-sidebar-toggle { display: none; }
}

html.solver-ide .lang-switch { display: flex; gap: 3px; }
html.solver-ide .lang-switch button {
  padding: 3px 8px;
  font-size: 0.68rem;
  border: 1px solid var(--ide-border);
  background: var(--ide-bg);
  color: var(--ide-muted);
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--ide-ui);
}
html.solver-ide .lang-switch button.active {
  border-color: var(--ide-accent);
  color: var(--ide-accent);
  background: var(--ide-accent-dim);
}

/* ── Body grid ── */
.ide-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Activity bar (decorative chrome only) ── */
.ide-activity {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: var(--ide-activity-w);
  min-width: var(--ide-activity-w);
  padding: 8px 0;
  background: var(--ide-activity);
  border-right: 1px solid var(--ide-border);
}

@media (min-width: 960px) {
  .ide-activity { display: flex; }
}

.ide-activity-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ide-muted);
  font-size: 1rem;
  position: relative;
  pointer-events: none;
  cursor: default;
  user-select: none;
}

.ide-activity-btn.active {
  color: var(--ide-accent);
  background: var(--ide-accent-dim);
}

.ide-activity-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--ide-accent);
  border-radius: 0 2px 2px 0;
}

.ide-sidebar-backdrop {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  top: var(--ide-title-h);
  bottom: var(--ide-status-h);
  background: rgba(0, 0, 0, 0.55);
  z-index: 105;
  -webkit-tap-highlight-color: transparent;
}

.ide-sidebar-backdrop.is-visible {
  display: block;
}

@media (min-width: 960px) {
  .ide-sidebar-backdrop { display: none !important; }
}

/* ── Sidebar ── */
.ide-sidebar {
  display: flex;
  flex-direction: column;
  width: var(--ide-sidebar-w);
  min-width: var(--ide-sidebar-w);
  background: var(--ide-sidebar);
  border-right: 1px solid var(--ide-border);
  overflow: hidden;
}

.ide-sidebar.is-collapsed {
  display: none;
}

@media (max-width: 959px) {
  .ide-sidebar {
    position: fixed;
    left: 0;
    top: var(--ide-title-h);
    bottom: var(--ide-status-h);
    z-index: 110;
    width: min(var(--ide-sidebar-w), 86vw);
    min-width: 0;
    max-width: 86vw;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  }
  .ide-sidebar.is-collapsed { display: none; }
}

.ide-sidebar-head {
  padding: 10px 14px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ide-muted);
  border-bottom: 1px solid var(--ide-border-soft);
  text-transform: uppercase;
}

.ide-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 12px;
}

.ide-tree-section { margin-bottom: 4px; }

.ide-tree-label {
  display: block;
  padding: 8px 14px 4px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ide-muted);
  text-transform: uppercase;
}

.ide-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 14px 5px 22px;
  border: none;
  background: transparent;
  color: var(--ide-text);
  font-family: var(--ide-mono);
  font-size: 0.72rem;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}

.ide-tree-item::before {
  content: '◆';
  font-size: 0.5rem;
  color: var(--ide-muted);
  flex-shrink: 0;
}

.ide-tree-item:hover {
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
  color: var(--ide-text);
}

.ide-tree-item.active {
  background: var(--ide-accent-dim);
  color: var(--ide-accent);
}

.ide-tree-item.active::before { color: var(--ide-accent); }

.ide-tree-item.is-link::before { content: '◇'; }

.ide-tree-item.is-locked::after {
  content: '🔒';
  margin-left: auto;
  font-size: 0.6rem;
  opacity: 0.7;
}

.ide-tree-item.is-public::after {
  content: '●';
  margin-left: auto;
  font-size: 0.45rem;
  color: var(--dev-low, #6a9a7a);
}

.ide-sidebar-readme {
  border-top: 1px solid var(--ide-border-soft);
  max-height: 42%;
  overflow-y: auto;
}

.ide-sidebar-readme summary {
  padding: 10px 14px;
  font-size: 0.72rem;
  color: var(--ide-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.ide-sidebar-readme summary::-webkit-details-marker { display: none; }
.ide-sidebar-readme summary::before { content: '▸ '; opacity: 0.6; }
.ide-sidebar-readme[open] summary::before { content: '▾ '; }

.ide-readme-body {
  padding: 0 14px 14px;
  font-size: 0.72rem;
  color: #a8a8bc;
  line-height: 1.65;
}

.ide-readme-body p { margin-bottom: 0.6em; }
.ide-readme-body strong { color: var(--ide-text); }
.ide-readme-body .ide-readme-note {
  font-size: 0.68rem;
  color: var(--ide-muted);
}

/* ── Main editor area ── */
.ide-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--ide-bg);
}

.ide-editor-chrome {
  flex-shrink: 0;
  background: var(--ide-chrome);
  border-bottom: 1px solid var(--ide-border);
}

.ide-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 0;
  font-family: var(--ide-mono);
  font-size: 0.68rem;
  color: var(--ide-muted);
}

.ide-breadcrumb-sep { opacity: 0.45; }
.ide-breadcrumb-leaf { color: var(--ide-accent); }

/* IDE tab bar (replaces pill tabs) */
html.solver-ide .solver-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin: 0;
  padding: 0 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

html.solver-ide .solver-tab {
  position: relative;
  padding: 8px 18px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ide-muted);
  font-family: var(--ide-mono);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

html.solver-ide .solver-tab:hover {
  color: var(--ide-text);
  background: rgba(255, 255, 255, 0.03);
}

html.solver-ide .solver-tab.active {
  color: var(--ide-text);
  background: var(--ide-bg);
  border-bottom-color: var(--ide-accent);
}

html.solver-ide .solver-tab[data-tab="blackhole"].active::after,
html.solver-ide .solver-tab[data-tab="orbit"].active::after,
html.solver-ide .solver-tab[data-tab="gravity"].active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ide-border);
}

/* Scrollable editor content */
.ide-editor-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 24px;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(var(--ide-border-soft) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--ide-border-soft) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--ide-bg);
  background-color: var(--ide-bg);
}

html.solver-ide .solver-wrap {
  max-width: none;
  margin: 0;
  padding: 0;
}

html.solver-ide .solver-hero { display: none; }

html.solver-ide .solver-tool-panel {
  max-width: 720px;
  margin: 0 auto;
}

/* Top token bar (below tabs) */
html.solver-ide .token-panel {
  flex-shrink: 0;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--ide-border);
  background: rgba(18, 18, 26, 0.95);
  padding: 8px 14px;
}

html.solver-ide .ide-token-bar {
  position: relative;
  z-index: 20;
}

html.solver-ide .token-panel h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--ide-muted);
}

html.solver-ide .solver-footer {
  margin: 0;
  padding: 16px 0 8px;
  border-top: none;
  text-align: left;
  font-size: 0.7rem;
}

html.solver-ide .token-panel.is-hidden {
  display: none;
}

.thought-panel {
  max-width: 820px;
  margin: 0 auto;
}

/* ── Mobile layout ── */
@media (max-width: 640px) {
  :root {
    --ide-title-h: 44px;
  }

  .ide-titlebar {
    padding: 0 8px 0 6px;
    gap: 8px;
  }

  .ide-titlebar-sep,
  .ide-titlebar-workbench {
    display: none;
  }

  .ide-titlebar-brand span {
    font-size: 0.82rem;
  }

  .ide-titlebar-portal {
    font-size: 0.65rem;
  }

  .ide-breadcrumb {
    padding: 4px 10px 0;
    font-size: 0.62rem;
    overflow: hidden;
  }

  .ide-breadcrumb > span:not(.ide-breadcrumb-leaf):not(.ide-breadcrumb-sep) {
    display: none;
  }

  .ide-breadcrumb-sep {
    display: none;
  }

  html.solver-ide .solver-tabs {
    padding: 0 4px;
  }

  html.solver-ide .solver-tab {
    padding: 8px 12px;
    font-size: 0.65rem;
  }

  .ide-editor-scroll {
    padding: 10px 10px 16px;
  }

  html.solver-ide .token-panel {
    padding: 8px 10px;
  }

  .ide-token-bar-row {
    gap: 6px 8px;
  }

  .token-row {
    max-width: none;
    width: 100%;
  }

  html.solver-ide .solver-footer {
    padding: 12px 0 4px;
  }

  .thought-panel {
    max-width: none;
  }
}

@media (max-width: 380px) {
  .ide-titlebar-brand span {
    display: none;
  }

  html.solver-ide .lang-switch button {
    padding: 3px 6px;
  }
}

/* ── Status bar ── */
.ide-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--ide-status-h);
  min-height: var(--ide-status-h);
  padding: 0 10px;
  background: var(--ide-accent);
  color: #0a0a0f;
  font-family: var(--ide-mono);
  font-size: 0.68rem;
  font-weight: 500;
  z-index: 120;
}

.ide-statusbar.is-offline {
  background: #4a3a2a;
  color: #f0e6d8;
}

.ide-status-left,
.ide-status-center,
.ide-status-right {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ide-status-center { flex: 1; justify-content: center; min-width: 0; }
.ide-status-right { justify-content: flex-end; }

.ide-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.ide-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.ide-status-dot.is-live { background: #2ecc71; box-shadow: 0 0 4px #2ecc71; }
.ide-status-dot.is-dead { background: #e07050; }

@media (max-width: 640px) {
  .ide-status-left span.ide-status-hide-sm { display: none; }
  .ide-status-right { display: none; }
}
