/* ── Demo view ──────────────────────────────────────────────────────── */

body:has(.demo-view) {
  height: 100vh;
  overflow: hidden;
}

.demo-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.demo-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: 18.75rem;
  flex-shrink: 0;
  background: var(--mantle);
  border-inline-end: 1px solid var(--surface0);
  padding: 0.5rem 0;
  overflow-y: auto;
}

.sidebar-heading {
  padding: 0.5rem 1rem 1rem;
  font-weight: 600;
  color: var(--subtext0);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.12s;
  border-block-start: 1px solid var(--surface0);
  border-inline-start: 0.25rem solid transparent;
}

.sidebar-item:hover {
  background: var(--surface0);
}

.sidebar-item.active {
  background: color-mix(in oklch, var(--overlay2), transparent 80%);
  border-inline-start-color: var(--lavender);
}

.sidebar-badge {
  width: 1.875rem;
  height: 1.375rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--mantle);
}

.sidebar-badge.lang-JS {
  background: var(--yellow);
}
.sidebar-badge.lang-PY {
  background: var(--blue);
}
.sidebar-badge.lang-RB {
  background: var(--red);
}
.sidebar-badge.lang-TS {
  background: var(--sapphire);
}
.sidebar-badge.lang-GO {
  background: var(--green);
}

.sidebar-info {
  min-width: 0;
}

.sidebar-name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  padding-block-end: 0.25rem;
  text-overflow: ellipsis;
}

.sidebar-desc {
  font-size: 0.75rem;
  color: var(--text);
}

/* Terminal */
.terminal-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.terminal {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 1rem 1.25rem;
  overflow-y: scroll;
  outline: none;
  line-height: 1.6;
  cursor: text;
}

.terminal-hidden-input {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  font-size: 16px; /* >= 16px prevents iOS auto-zoom on focus */
}

.terminal::-webkit-scrollbar {
  width: 0.375rem;
}
.terminal::-webkit-scrollbar-track {
  background: transparent;
}
.terminal::-webkit-scrollbar-thumb {
  background: var(--surface1);
  border-radius: 0.1875rem;
}

/* Terminal line types */
.t-line {
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 1.6em;
}

.t-prompt {
  color: var(--overlay0);
}

.t-prompt .t-input {
  color: var(--text);
}

.t-cursor {
  display: inline-block;
  width: 0.5rem;
  height: 1.1em;
  background: var(--text);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.t-header {
  color: var(--sapphire);
  font-weight: 700;
}

.t-subheader {
  color: var(--mauve);
  font-weight: 700;
}

.t-command {
  color: var(--green);
}

.t-prose {
  color: var(--overlay0);
}

.t-dim {
  color: var(--subtext0);
}

.t-yellow {
  color: var(--yellow);
}

.t-green {
  color: var(--green);
}

.t-bold {
  font-weight: 700;
}

.t-title-line {
  color: var(--text);
  font-weight: 700;
}

/* Picker */
.picker-row {
  white-space: pre;
  min-height: 1.6em;
}

.picker-row.selected {
  background: var(--surface0);
  border-radius: 0.1875rem;
}

.picker-row .arrow {
  color: var(--yellow);
  font-weight: 700;
}

.picker-footer {
  color: var(--subtext0);
  min-height: 1.6em;
  white-space: pre;
}

.flash-msg {
  color: var(--green);
  font-weight: 600;
}

.flash-msg.flash-execute {
  color: var(--yellow);
  font-style: italic;
}

/* Hints bar */
.hints {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--mantle);
  border-block-start: 0.0625rem solid var(--surface0);
  color: var(--subtext0);
  flex-shrink: 0;
  line-height: 2;
}

.hints code {
  background: var(--surface0);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  color: var(--text);
}

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 43.75rem) {
  /* Demo */
  .demo-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-inline-end: none;
    border-block-end: 0.0625rem solid var(--surface0);
    padding: 0rem 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
  }
  .sidebar-item {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-inline-start: none;
    border-block-end: 0.25rem solid transparent;
  }
  .sidebar-item.active {
    border-inline-start-color: transparent;
    border-block-end-color: var(--sapphire);
  }

  .sidebar-name {
    padding: 0;
  }

  .sidebar-heading {
    flex-shrink: 0;
    padding: 0.25rem 1rem;
    display: flex;
    align-items: center;
  }
  .sidebar-desc {
    display: none;
  }
}
