/*
 * PopCorn Playground — visual refinement layer
 *
 * This file intentionally sits after playground.css. It keeps the existing
 * layout and behaviour intact while making the everyday workspace quieter.
 * Pop is reserved for the logo colours, small print-like offsets and moments
 * that deserve attention.
 */

:root {
  --pv-blue: #3979f6;
  --pv-cyan: #16b3d1;
  --pv-yellow: #ffd55a;
  --pv-pink: #ff5b78;
  --pv-lime: #e9f2aa;
  --pv-paper: #071226;
  --pv-sheet: #0b1830;
  --pv-sheet-raised: #10203d;
  --pv-code: #060f20;
  --pv-border: rgb(143 174 222 / 23%);
  --pv-border-strong: rgb(143 174 222 / 38%);
  --pv-offset-blue: rgb(57 121 246 / 36%);
  --pv-offset-pink: rgb(255 91 120 / 34%);
  --workspace-sidebar-width: 290px;
  --workspace-result-width: 350px;
  --mobile-result-height: 280px;

  --bg: var(--pv-paper);
  --panel: var(--pv-sheet);
  --panel-2: var(--pv-sheet-raised);
  --panel-pop: #142848;
  --line: var(--pv-border);
  --text: #f6f9ff;
  --muted: #a5b6d2;
  --accent: var(--pv-blue);
  --accent-2: var(--pv-pink);
  --accent-3: var(--pv-cyan);
  --accent-soft: var(--pv-lime);
  --danger: #ff667d;
  --good: #55d9a0;
  --shadow: 0 16px 38px rgb(0 8 25 / 30%);
  --pop-shadow: 3px 3px 0 var(--pv-offset-blue);
}

[data-theme="light"] {
  --pv-paper: #f2f6fd;
  --pv-sheet: #fbfdff;
  --pv-sheet-raised: #eef4fc;
  --pv-code: #f7faff;
  --pv-border: rgb(45 78 126 / 18%);
  --pv-border-strong: rgb(45 78 126 / 31%);
  --pv-offset-blue: rgb(57 121 246 / 21%);
  --pv-offset-pink: rgb(255 91 120 / 20%);

  --bg: var(--pv-paper);
  --panel: var(--pv-sheet);
  --panel-2: var(--pv-sheet-raised);
  --panel-pop: #e5eefb;
  --line: var(--pv-border);
  --text: #10203b;
  --muted: #617493;
  --accent: #286be9;
  --accent-2: #e94d69;
  --accent-3: #078da9;
  --accent-soft: #ecf3b9;
  --danger: #d93c57;
  --good: #087f58;
  --shadow: 0 16px 34px rgb(39 71 119 / 14%);
}

body {
  background: var(--bg);
  font-feature-settings: "palt" 1;
}

/* Header: the logo carries the character, the surrounding chrome stays calm. */
.app-header {
  height: 60px;
  gap: 18px;
  padding: 0 18px;
  border-bottom-color: var(--pv-border);
  background: color-mix(in srgb, var(--panel) 97%, transparent);
  backdrop-filter: none;
}

.brand {
  gap: 9px;
}

.brand-logo {
  width: clamp(126px, 11vw, 158px);
  height: 40px;
  filter: drop-shadow(2px 2px 0 rgb(57 121 246 / 15%));
}

.popcorn-logo {
  width: clamp(132px, 12vw, 168px);
  height: 38px;
  filter: drop-shadow(2px 2px 0 rgb(255 213 90 / 15%));
}

.header-status {
  position: relative;
  padding: 4px 2px 4px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.header-status::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 6px;
  height: 6px;
  background: var(--pv-yellow);
  box-shadow: 2px 2px 0 rgb(255 91 120 / 28%);
  transform: translateY(-50%) rotate(5deg);
}

/* Command bar: one obvious action, everything else quiet. */
.toolbar {
  min-height: 46px;
  gap: 6px;
  padding: 6px 11px;
  overflow: visible;
  border-bottom-color: var(--pv-border);
  background: var(--panel);
}

.toolbar-primary,
.toolbar-view-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.run-feedback {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  max-width: 0;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  white-space: nowrap;
  transition:
    max-width .2s ease,
    opacity .16s ease,
    padding .2s ease;
}

.run-feedback.visible {
  max-width: 150px;
  padding-inline: 6px;
  opacity: 1;
}

.run-feedback::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pv-cyan);
}

body[data-run-feedback="running"] .run-feedback::before,
body[data-run-feedback="waiting"] .run-feedback::before {
  animation: pv-status-pulse 1s ease-in-out infinite;
}

body[data-run-feedback="waiting"] .run-feedback::before {
  background: var(--pv-yellow);
}

body[data-run-feedback="success"] .run-feedback::before,
body[data-run-feedback="ready"] .run-feedback::before {
  background: var(--good);
}

body[data-run-feedback="error"] .run-feedback::before,
body[data-run-feedback="stopped"] .run-feedback::before {
  background: var(--pv-pink);
}

#stopButton {
  display: none;
}

body.is-running #runButton {
  display: none;
}

body.is-running #stopButton {
  display: inline-flex;
}

.view-button[aria-pressed="true"] {
  border-color: var(--pv-yellow);
  background: rgb(255 213 90 / 8%);
  color: var(--pv-yellow);
}

[data-theme="light"] .view-button[aria-pressed="true"] {
  color: #826000;
}

.tool-menu {
  position: relative;
  flex: 0 0 auto;
}

.tool-menu > summary {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--pv-border);
  border-radius: 8px 5px 9px 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  list-style: none;
}

.tool-menu > summary::-webkit-details-marker {
  display: none;
}

.tool-menu[open] > summary {
  border-color: var(--pv-border-strong);
  background: var(--panel-2);
  box-shadow: 2px 2px 0 var(--pv-offset-pink);
  color: var(--text);
}

.tool-menu-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--pv-border-strong);
  border-radius: 5px 11px 6px 9px;
  background: var(--panel);
  box-shadow: 5px 5px 0 var(--pv-offset-blue), var(--shadow);
}

.tool-menu-popover .button {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
}

.tool-menu-rule {
  height: 1px;
  margin: 4px 3px;
  background: var(--pv-border);
}

.tool-menu-heading {
  padding: 2px 5px 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .04em;
}

.layout-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.layout-preset {
  min-height: 54px;
  display: grid;
  place-content: center;
  gap: 3px;
  padding: 5px 3px;
  border: 1px solid var(--pv-border);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
}

.layout-preset > span:first-child {
  color: var(--pv-cyan);
  font-size: 15px;
}

.layout-preset:hover,
.layout-preset.active {
  border-color: var(--pv-border-strong);
  background: rgb(57 121 246 / 9%);
  color: var(--text);
}

.layout-preset.active {
  box-shadow: inset 0 -2px 0 var(--pv-pink);
}

.button,
.icon-button {
  min-height: 34px;
  border-color: var(--pv-border);
  border-radius: 8px;
  background: transparent;
  font-weight: 650;
  transition:
    color .14s ease,
    border-color .14s ease,
    background .14s ease,
    box-shadow .14s ease,
    transform .14s ease;
}

.button {
  padding: 6px 10px;
  font-size: 12px;
}

.icon-button {
  min-width: 34px;
  padding: 4px 7px;
}

.button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  border-color: var(--pv-border-strong);
  background: var(--panel-2);
  box-shadow: 2px 2px 0 var(--pv-offset-blue);
  transform: translate(-1px, -1px);
}

.button:active:not(:disabled),
.icon-button:active:not(:disabled) {
  box-shadow: none;
  transform: translate(1px, 1px);
}

.button.primary {
  border-color: var(--accent);
  border-radius: 5px 9px 4px 7px;
  background: var(--accent);
  box-shadow: 3px 3px 0 var(--pv-offset-pink);
  color: #fff;
  font-weight: 800;
}

.button.primary:hover:not(:disabled) {
  border-color: #5b91fb;
  background: #2f70ed;
  box-shadow: 4px 4px 0 var(--pv-offset-pink);
  color: #fff;
  transform: translate(-1px, -1px);
}

.button.danger {
  border-color: transparent;
  color: var(--muted);
}

.button.danger:not(:disabled):hover {
  border-color: rgb(255 102 125 / 40%);
  color: var(--danger);
  box-shadow: 2px 2px 0 rgb(255 102 125 / 18%);
}

.format-button {
  border-color: var(--pv-border);
}

.format-button > span {
  color: var(--pv-pink);
}

.toolbar-separator {
  height: 20px;
  background: var(--pv-border);
}

/* Workspace: editor first, support panes stable and deliberately quieter. */
.workspace {
  position: relative;
  height: calc(100vh - 106px);
  height: calc(100dvh - 106px);
  grid-template-columns:
    minmax(230px, var(--workspace-sidebar-width))
    minmax(460px, 1fr)
    minmax(280px, var(--workspace-result-width));
}

body.lesson-open .workspace {
  grid-template-columns:
    minmax(230px, var(--workspace-sidebar-width))
    minmax(460px, 1fr)
    minmax(280px, var(--workspace-result-width));
}

body.sidebar-collapsed .workspace {
  grid-template-columns: 0 minmax(460px, 1fr) minmax(280px, var(--workspace-result-width));
}

body.result-collapsed .workspace {
  grid-template-columns: minmax(230px, var(--workspace-sidebar-width)) minmax(460px, 1fr) 0;
}

body.sidebar-collapsed.result-collapsed .workspace {
  grid-template-columns: 0 minmax(460px, 1fr) 0;
}

body.sidebar-collapsed .sidebar,
body.result-collapsed .result-column {
  display: none;
}

.workspace-resizer {
  position: absolute;
  z-index: 12;
  top: 0;
  bottom: 0;
  width: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.workspace-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: transparent;
  transform: translateX(-50%);
  transition:
    width .14s ease,
    background .14s ease;
}

.workspace-resizer:hover::before,
.workspace-resizer:focus-visible::before,
body.is-resizing-workspace .workspace-resizer::before {
  width: 3px;
  background: linear-gradient(var(--pv-cyan), var(--pv-blue), var(--pv-pink));
}

.sidebar-resizer {
  left: var(--workspace-sidebar-width);
  transform: translateX(-50%);
}

.result-resizer {
  right: var(--workspace-result-width);
  transform: translateX(50%);
}

body.sidebar-collapsed .sidebar-resizer,
body.result-collapsed .result-resizer {
  display: none;
}

body.is-resizing-workspace {
  cursor: col-resize;
  user-select: none;
}

.sidebar,
.editor-column,
.result-column {
  background: var(--panel);
}

.sidebar {
  grid-column: 1;
}

.editor-column {
  position: relative;
  z-index: 1;
  grid-column: 2;
  box-shadow:
    -2px 0 0 rgb(22 179 209 / 7%),
    2px 0 0 rgb(57 121 246 / 7%);
}

.result-column {
  grid-column: 3;
}

.sidebar,
.editor-column {
  border-right-color: var(--pv-border);
}

.side-tabs,
.result-tabs {
  min-height: 40px;
  border-bottom-color: var(--pv-border);
  background: var(--panel);
}

.result-tabs {
  justify-content: space-between;
}

.result-tab-list {
  min-width: 0;
  display: flex;
  align-items: stretch;
}

.side-tab,
.result-tab,
.copy-result {
  border-bottom-width: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.side-tab:hover,
.result-tab:hover,
.copy-result:hover {
  color: var(--text);
  background: rgb(57 121 246 / 5%);
}

.side-tab.active,
.result-tab.active {
  border-bottom-color: var(--pv-pink);
  background: rgb(57 121 246 / 7%);
  box-shadow: inset 0 -1px 0 rgb(22 179 209 / 22%);
  color: var(--text);
  font-weight: 750;
}

.side-tab.active {
  transform: translateY(1px);
}

.side-panel {
  padding: 12px;
  scrollbar-color: var(--pv-border-strong) transparent;
}

.search-box {
  margin-bottom: 10px;
}

.search-box input,
.terminal-input input {
  border-color: var(--pv-border);
  border-radius: 5px 9px 5px 7px;
  background: var(--bg);
}

.search-box input {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 12px;
}

.card-list,
.reference-list {
  gap: 8px;
}

.example-card,
.reference-card {
  position: relative;
  padding: 11px 10px;
  border-color: var(--pv-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-2) 74%, var(--panel));
  transition:
    border-color .14s ease,
    background .14s ease;
}

.example-card:hover,
.reference-card:hover {
  border-color: var(--pv-border-strong);
  background: var(--panel-2);
}

.example-card:focus-visible {
  border-radius: 5px 9px 6px 8px;
  box-shadow: 3px 3px 0 rgb(22 179 209 / 17%);
}

.example-card strong,
.reference-card strong {
  font-size: 13px;
}

.example-card code,
.example-card p,
.reference-card p {
  font-size: 11px;
}

.example-category,
.example-interactive {
  border-radius: 3px 7px 3px 6px;
  background: rgb(57 121 246 / 11%);
  font-size: 10px;
}

.example-interactive {
  background: rgb(85 217 160 / 10%);
}

/* Editor and terminal belong to one visual family. */
.pane-title {
  min-height: 40px;
  padding: 0 13px;
  border-bottom-color: var(--pv-border);
  background: var(--panel);
  font-size: 12px;
}

.pane-title > span:first-child::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 11px;
  margin-right: 8px;
  background: var(--pv-cyan);
  box-shadow: 2px 2px 0 rgb(255 213 90 / 26%);
  vertical-align: -1px;
  transform: rotate(2deg);
}

#editorFallback {
  padding: 16px 18px;
  background: var(--pv-code);
  font-size: 15px;
  line-height: 1.65;
}

.ace-monokai,
.ace-monokai .ace_scroller {
  background-color: var(--pv-code) !important;
  color: #eef5ff !important;
}

.ace-monokai .ace_gutter {
  background: #09162b !important;
  color: #7186a8 !important;
}

.ace-monokai .ace_gutter-active-line,
.ace-monokai .ace_marker-layer .ace_active-line {
  background: rgb(57 121 246 / 10%) !important;
}

.ace-monokai .ace_marker-layer .ace_selection {
  background: rgb(57 121 246 / 29%) !important;
}

.ace-monokai .ace_cursor {
  border-left-color: var(--pv-pink) !important;
}

.ace-monokai .ace_keyword,
.ace-monokai .ace_keyword.ace_operator {
  color: #65a1ff !important;
}

.ace-monokai .ace_support.ace_function {
  color: #36c2d9 !important;
}

.ace-monokai .ace_string {
  color: #f3df79 !important;
}

.ace-monokai .ace_constant.ace_numeric,
.ace-monokai .ace_constant.ace_language {
  color: #ff7f98 !important;
}

.ace-monokai .ace_comment {
  color: #7185a6 !important;
  font-style: normal !important;
}

.ace-github,
.ace-github .ace_scroller {
  background-color: var(--pv-code) !important;
  color: #172b49 !important;
}

.ace-github .ace_gutter {
  background: #edf3fb !important;
  color: #71819a !important;
}

.ace-github .ace_gutter-active-line,
.ace-github .ace_marker-layer .ace_active-line {
  background: rgb(57 121 246 / 9%) !important;
}

.ace-github .ace_marker-layer .ace_selection {
  background: rgb(57 121 246 / 20%) !important;
}

.ace-github .ace_cursor {
  color: var(--pv-pink) !important;
}

.editor-statusbar,
.run-meta {
  min-height: 27px;
  border-top-color: var(--pv-border);
  background: var(--panel);
  color: var(--muted);
  font-size: 10px;
}

.result-body {
  background: var(--pv-code);
}

.mobile-result-grip {
  display: none;
}

.result-panel {
  padding: 16px;
  background: var(--pv-code);
  color: #eaf2ff;
  font-size: 13px;
  line-height: 1.65;
}

[data-theme="light"] .result-panel {
  background: var(--pv-code);
  color: #172b49;
}

.result-value {
  color: #70a9ff;
}

[data-theme="light"] .result-value {
  color: #1d62d9;
}

.diagnostics-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  white-space: normal;
}

.diagnostics-panel[hidden] {
  display: none;
}

.diagnostic-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgb(255 91 120 / 25%);
  border-radius: 7px;
  background: rgb(255 91 120 / 6%);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.diagnostic-item:hover,
.diagnostic-item:focus-visible {
  border-color: rgb(255 91 120 / 52%);
  background: rgb(255 91 120 / 10%);
}

.diagnostic-location {
  padding: 2px 5px;
  border-radius: 4px;
  background: rgb(255 91 120 / 13%);
  color: var(--pv-pink);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

[data-theme="light"] .diagnostic-location {
  color: #bd2947;
}

.diagnostic-message {
  min-width: 0;
  color: var(--text);
  line-height: 1.55;
}

.terminal-input {
  right: 12px;
  bottom: 11px;
  left: 12px;
  border-color: rgb(22 179 209 / 45%);
  border-radius: 5px 10px 5px 8px;
  background: color-mix(in srgb, var(--pv-code) 95%, var(--pv-cyan));
  box-shadow: 3px 3px 0 rgb(57 121 246 / 19%);
}

[data-theme="light"] .terminal-input {
  background: color-mix(in srgb, var(--pv-code) 96%, white);
}

.run-meta #runState {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.run-meta #runState::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

body[data-run-feedback="running"] .run-meta #runState::before {
  background: var(--pv-cyan);
  animation: pv-status-pulse 1s ease-in-out infinite;
}

body[data-run-feedback="waiting"] .run-meta #runState::before {
  background: var(--pv-yellow);
  animation: pv-status-pulse 1s ease-in-out infinite;
}

body[data-run-feedback="success"] .run-meta #runState::before {
  background: var(--good);
}

body[data-run-feedback="error"] .run-meta #runState::before,
body[data-run-feedback="stopped"] .run-meta #runState::before {
  background: var(--pv-pink);
}

body[data-run-feedback="success"] .result-column {
  animation: pv-result-pop .42s cubic-bezier(.2, .85, .3, 1);
}

body[data-run-feedback="error"] .result-column {
  box-shadow: inset 0 3px 0 rgb(255 91 120 / 72%);
}

/* Tutor: warm and characterful, but never louder than the code. */
.lesson-panel {
  gap: 9px;
  padding: 12px 14px;
}

.tutor-header {
  min-height: 48px;
  gap: 10px;
  padding: 2px 1px 7px;
  border-bottom: 1px solid var(--pv-border);
}

.tutor-header strong {
  font-size: 13px;
}

.tutor-online {
  font-size: 11px;
}

.tutor-reset {
  padding: 5px 7px;
  border-color: transparent;
  border-radius: 3px 7px 4px 6px;
  color: var(--muted);
  font-size: 10px;
}

.tutor-reset:hover {
  border-color: var(--pv-border);
  background: var(--panel-2);
}

.robot-avatar {
  border-color: #0b2c63;
  border-radius: 13px 12px 16px 14px;
  background: #7db9ff;
  box-shadow:
    inset -6px -5px 0 #3979f6,
    3px 3px 0 rgb(22 179 209 / 23%),
    -2px -1px 0 rgb(233 242 170 / 14%);
}

.robot-antenna {
  background: var(--pv-blue);
}

.robot-antenna::before {
  background: var(--pv-pink);
  box-shadow: 2px 1px 0 rgb(255 213 90 / 35%);
}

.tutor-welcome {
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 4px 26px;
}

.tutor-welcome::before {
  width: 18px;
  height: 6px;
  top: 22%;
  left: 17%;
  border-radius: 0;
  background: var(--pv-pink);
  filter: none;
  transform: rotate(-8deg);
}

.tutor-welcome::after {
  width: 7px;
  height: 7px;
  right: 16%;
  bottom: 24%;
  border-radius: 1px;
  background: var(--pv-cyan);
  filter: none;
  transform: rotate(7deg);
}

.tutor-welcome h2 {
  margin: 70px 0 9px;
  font-size: clamp(26px, 2.3vw, 33px);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.tutor-welcome p {
  max-width: 245px;
  margin-bottom: 21px;
  font-size: 12px;
  line-height: 1.65;
}

.tutor-welcome button {
  width: min(100%, 250px);
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px 11px 5px 9px;
  background: var(--accent);
  box-shadow: 4px 4px 0 var(--pv-offset-pink);
  font-size: 14px;
}

.tutor-welcome button:hover {
  background: #2f70ed;
  box-shadow: 5px 5px 0 var(--pv-offset-pink);
  transform: translate(-1px, -1px);
}

.tutor-welcome button:active {
  box-shadow: 1px 1px 0 var(--pv-offset-pink);
  transform: translate(2px, 2px);
}

.tutor-welcome small {
  margin-top: 16px;
  font-size: 11px;
}

.lesson-panel.welcome-mode .tutor-header {
  padding: 12px 2px 7px;
  border-bottom: 0;
}

.lesson-panel.welcome-mode .robot-avatar {
  margin: 10px 0 16px;
  transform: scale(1.65);
}

.lesson-panel.welcome-mode .tutor-welcome {
  justify-content: center;
  padding: 10px 4px 28px;
}

.lesson-panel.welcome-mode .tutor-welcome h2 {
  margin-top: 0;
}

.lesson-panel.profile-mode .tutor-welcome {
  padding-top: 14px;
}

.tutor-profile {
  gap: 16px;
}

.tutor-profile h2 {
  font-size: 23px;
  line-height: 1.15;
}

.tutor-profile legend,
.profile-goal > span {
  font-size: 12px;
}

.level-options span {
  min-height: 44px;
  border-color: var(--pv-border);
  border-radius: 5px 9px 5px 7px;
  background: var(--panel-2);
  font-size: 11px;
}

.level-options label:nth-child(2) span {
  border-radius: 8px 4px 9px 5px;
}

.level-options label:nth-child(3) span {
  border-radius: 5px 8px 4px 10px;
}

.level-options input:checked + span {
  border-color: var(--accent);
  background: rgb(57 121 246 / 12%);
  box-shadow: 2px 2px 0 var(--pv-offset-blue);
}

.profile-goal input,
.profile-optional,
.profile-optional-grid select {
  border-color: var(--pv-border);
  border-radius: 5px 9px 5px 7px;
}

.profile-goal input {
  font-size: 12px;
}

.profile-optional summary,
.profile-optional-grid select {
  font-size: 11px;
}

.profile-optional > p,
.profile-optional-grid label > span {
  font-size: 10px;
}

.lesson-tuning {
  border-color: var(--pv-border);
  border-radius: 5px 11px 6px 9px;
  background: var(--panel);
}

.lesson-tuning-icon {
  border-color: var(--pv-border);
  border-radius: 8px 13px 7px 11px;
  background: var(--panel-2);
  box-shadow: 3px 3px 0 var(--pv-offset-blue);
}

.lesson-tuning p {
  font-size: 11px;
}

.lesson-progress {
  padding: 8px 9px;
  border-color: var(--pv-border);
  border-radius: 4px 9px 4px 7px;
  background: transparent;
}

.lesson-progress-label {
  font-size: 11px;
}

.progress-track {
  height: 4px;
  background: var(--pv-border);
}

.progress-track span {
  border-radius: 0;
  background: var(--pv-blue);
  box-shadow: 2px 0 0 var(--pv-cyan);
}

.lesson-picker {
  grid-template-columns: 40px 1fr 40px;
  gap: 6px;
}

.lesson-arrow,
.lesson-title-button {
  border-color: var(--pv-border);
  border-radius: 5px 9px 5px 7px;
  background: transparent;
}

.lesson-arrow {
  min-height: 38px;
  font-size: 12px;
}

.lesson-title-button {
  min-height: 38px;
}

.lesson-title-button span {
  border-radius: 4px 8px 4px 7px;
  background: rgb(255 213 90 / 13%);
  color: var(--pv-yellow);
  font-size: 10px;
}

[data-theme="light"] .lesson-title-button span {
  color: #8c6800;
}

.lesson-title-button strong {
  font-size: 12px;
}

.lesson-goal {
  padding: 9px 10px;
  border-left-color: var(--pv-pink);
  border-radius: 0 8px 4px 0;
  background: rgb(255 91 120 / 6%);
  font-size: 12px;
}

.lesson-chat {
  min-height: 130px;
  padding: 6px 3px;
  scrollbar-color: var(--pv-border-strong) transparent;
}

.chat-current-marker {
  font-size: 10px;
}

.chat-bubble {
  max-width: 90%;
  padding: 9px 10px;
  border: 1px solid var(--pv-border);
  border-radius: 3px 9px 8px 6px;
  background: var(--panel-2);
  font-size: 12px;
  line-height: 1.6;
}

.chat-message:nth-child(even):not(.user) .chat-bubble {
  border-radius: 6px 4px 9px 5px;
}

.chat-message.user .chat-bubble {
  border-color: rgb(57 121 246 / 26%);
  border-radius: 8px 3px 6px 9px;
  background: rgb(57 121 246 / 10%);
}

.chat-message.success .chat-bubble {
  border-color: rgb(85 217 160 / 32%);
  background: rgb(85 217 160 / 7%);
  box-shadow: 2px 2px 0 rgb(85 217 160 / 12%);
}

.chat-message.streaming .chat-bubble::after {
  width: 4px;
  background: var(--pv-cyan);
}

.chat-context {
  font-size: 10px;
}

.tutor-thinking {
  font-size: 11px;
}

.thinking-icon {
  border-color: var(--pv-border);
  border-radius: 7px 8px 8px 3px;
  background: var(--panel-2);
}

.lesson-actions {
  gap: 7px;
}

.lesson-actions .button {
  min-height: 37px;
}

.lesson-actions .lesson-check {
  padding-block: 9px;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 3px 3px 0 var(--pv-offset-blue);
  color: #fff;
  font-weight: 800;
}

.lesson-actions .lesson-check:hover:not(:disabled) {
  border-color: #5b91fb;
  background: #2f70ed;
}

#aiLessonButton {
  border-color: rgb(22 179 209 / 34%);
}

.advance-lesson {
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 5px 10px 5px 8px;
  background: var(--accent);
  box-shadow: 3px 3px 0 var(--pv-offset-pink);
}

.lesson-question {
  grid-template-columns: 1fr 36px;
  gap: 6px;
}

.lesson-question input,
.lesson-question button {
  min-height: 36px;
  border-radius: 5px 9px 5px 7px;
}

.lesson-question input {
  border-color: var(--pv-border);
  background: var(--bg);
  font-size: 12px;
}

.lesson-question button {
  border: 1px solid var(--accent);
  background: var(--accent);
  box-shadow: 2px 2px 0 var(--pv-offset-blue);
}

.toast {
  border-color: var(--pv-border-strong);
  border-radius: 5px 10px 5px 8px;
  background: var(--panel-2);
  box-shadow: 4px 4px 0 var(--pv-offset-blue), var(--shadow);
  font-size: 12px;
}

.detail-tab {
  color: color-mix(in srgb, var(--muted) 76%, transparent);
}

.mobile-dock {
  display: none;
}

/* Keyboard focus is strong without making every idle control loud. */
.button:focus-visible,
.icon-button:focus-visible,
.side-tab:focus-visible,
.result-tab:focus-visible,
.copy-result:focus-visible,
.lesson-arrow:focus-visible,
.lesson-title-button:focus-visible,
.tutor-reset:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--pv-yellow);
  outline-offset: 2px;
}

[data-theme="light"] .button:focus-visible,
[data-theme="light"] .icon-button:focus-visible,
[data-theme="light"] .side-tab:focus-visible,
[data-theme="light"] .result-tab:focus-visible,
[data-theme="light"] .copy-result:focus-visible,
[data-theme="light"] button:focus-visible,
[data-theme="light"] input:focus-visible,
[data-theme="light"] select:focus-visible,
[data-theme="light"] summary:focus-visible {
  outline-color: #2459a8;
}

/* Mid-size screens: preserve the run → result loop instead of squeezing 3 panes. */
@media (max-width: 1080px) and (min-width: 901px) {
  .workspace-resizer {
    display: none;
  }

  .workspace,
  body.lesson-open .workspace {
    grid-template-columns: minmax(230px, 300px) minmax(420px, 1fr);
    grid-template-rows: minmax(320px, 1.15fr) minmax(210px, .72fr);
  }

  .sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
  }

  .editor-column {
    grid-column: 2;
    grid-row: 1;
    border-bottom: 1px solid var(--pv-border);
  }

  .result-column {
    grid-column: 2;
    grid-row: 2;
  }

  .button kbd {
    display: none;
  }

  body.sidebar-collapsed .workspace,
  body.sidebar-collapsed.lesson-open .workspace {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .editor-column,
  body.sidebar-collapsed .result-column {
    grid-column: 1;
  }

  body.result-collapsed .workspace,
  body.result-collapsed.lesson-open .workspace {
    grid-template-rows: 1fr;
  }

  body.result-collapsed .editor-column {
    grid-row: 1 / -1;
    border-bottom: 0;
  }

  body.sidebar-collapsed.result-collapsed .workspace,
  body.sidebar-collapsed.result-collapsed.lesson-open .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  body.sidebar-collapsed.result-collapsed .editor-column {
    grid-column: 1;
    grid-row: 1;
  }
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
  }

  .app-header {
    height: 54px;
    min-height: 54px;
    padding: 7px 10px;
  }

  .brand-logo {
    width: 108px;
    height: 36px;
  }

  .popcorn-logo {
    width: 114px;
    height: 34px;
  }

  .toolbar {
    position: relative;
    top: auto;
    min-height: 46px;
    padding: 6px 9px;
    overflow: visible;
  }

  .button,
  .icon-button {
    min-height: 40px;
  }

  .toolbar-primary {
    min-width: 0;
  }

  .toolbar-view-actions {
    display: none;
  }

  .tool-menu-label {
    display: none;
  }

  .tool-menu > summary {
    width: 42px;
    min-height: 40px;
    justify-content: center;
    padding: 4px 7px;
  }

  .tool-menu-popover {
    position: fixed;
    top: 106px;
    right: 9px;
    width: min(250px, calc(100vw - 18px));
    max-height: calc(100dvh - 180px);
    overflow-y: auto;
  }

  .workspace,
  body.lesson-open .workspace {
    height: calc(100dvh - 158px);
    min-height: 0;
    display: block;
  }

  .workspace > .sidebar,
  .workspace > .editor-column,
  .workspace > .result-column {
    width: 100%;
    height: 100%;
    border: 0;
  }

  .workspace-resizer {
    display: none;
  }

  body[data-mobile-pane="learn"] .editor-column,
  body[data-mobile-pane="code"] .sidebar,
  body[data-mobile-pane="result"] .sidebar,
  body[data-mobile-pane="result"] .editor-column {
    display: none;
  }

  body.sidebar-collapsed .sidebar,
  body.result-collapsed .result-column {
    display: flex;
  }

  body[data-mobile-pane="code"].sidebar-collapsed .sidebar,
  body[data-mobile-pane="result"].sidebar-collapsed .sidebar,
  body[data-mobile-pane="learn"].result-collapsed:not(.mobile-result-open) .result-column,
  body[data-mobile-pane="code"].result-collapsed:not(.mobile-result-open) .result-column {
    display: none;
  }

  body[data-mobile-pane="learn"] .result-column,
  body[data-mobile-pane="code"] .result-column {
    position: fixed;
    z-index: 24;
    right: 0;
    bottom: 58px;
    left: 0;
    width: 100%;
    height: var(--mobile-result-height);
    display: flex;
    overflow: hidden;
    border: 1px solid var(--pv-border-strong);
    border-bottom: 0;
    border-radius: 13px 13px 0 0;
    background: var(--panel);
    box-shadow:
      0 -8px 30px rgb(0 8 25 / 22%),
      0 -3px 0 rgb(57 121 246 / 12%);
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 16px));
    visibility: hidden;
    transition:
      transform .24s cubic-bezier(.2, .82, .28, 1),
      opacity .18s ease,
      visibility 0s linear .24s;
  }

  body.mobile-result-open[data-mobile-pane="learn"] .result-column,
  body.mobile-result-open[data-mobile-pane="code"] .result-column {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    visibility: visible;
    transition:
      transform .24s cubic-bezier(.2, .82, .28, 1),
      opacity .18s ease;
  }

  body.is-resizing-result .result-column {
    transition: none !important;
  }

  .mobile-result-grip {
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px 2px;
    border-bottom: 1px solid var(--pv-border);
    background: var(--panel);
  }

  .mobile-result-grip #resultDrawerHandle {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 5px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: ns-resize;
    font: inherit;
    font-size: 10px;
    font-weight: 750;
    touch-action: none;
  }

  .drawer-grip {
    width: 28px;
    height: 4px;
    border-radius: 999px;
    background: var(--pv-border-strong);
  }

  #closeResultDrawerButton {
    width: 30px;
    height: 28px;
    display: grid;
    place-content: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: 18px/1 sans-serif;
  }

  #closeResultDrawerButton:hover,
  #closeResultDrawerButton:focus-visible {
    background: var(--panel-2);
    color: var(--text);
  }

  body[data-mobile-pane="result"] .mobile-result-grip {
    display: none;
  }

  .mobile-dock {
    position: fixed;
    z-index: 25;
    right: 0;
    bottom: 0;
    left: 0;
    height: 58px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 5px max(7px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
    border-top: 1px solid var(--pv-border);
    background: color-mix(in srgb, var(--panel) 96%, transparent);
  }

  .mobile-pane-button {
    position: relative;
    display: grid;
    grid-template-columns: auto auto;
    place-content: center;
    gap: 7px;
    border: 0;
    border-radius: 5px 9px 4px 8px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-pane-button.active {
    background: rgb(57 121 246 / 10%);
    color: var(--text);
  }

  .mobile-pane-button.active::after {
    content: "";
    position: absolute;
    right: 24%;
    bottom: 2px;
    left: 24%;
    height: 2px;
    background: var(--pv-pink);
    box-shadow: 2px 0 0 var(--pv-cyan);
    transform: rotate(-1deg);
  }

  .side-panel {
    padding: 10px;
  }

  .lesson-panel {
    overflow: hidden;
  }

  .lesson-session,
  .tutor-session {
    min-height: 0;
  }

  .tutor-welcome h2 {
    font-size: 28px;
  }
}

@media (max-width: 440px) {
  .brand-logo {
    width: 100px;
  }

  .popcorn-logo {
    width: 106px;
  }

  .button kbd {
    display: none;
  }

  .toolbar .button {
    padding-inline: 9px;
  }

  .run-feedback {
    font-size: 0;
  }

  .run-feedback.visible {
    max-width: 22px;
    padding-inline: 5px;
  }
}

@keyframes pv-status-pulse {
  0%,
  100% {
    opacity: .48;
    transform: scale(.82);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes pv-result-pop {
  0% {
    transform: translateY(4px);
  }

  55% {
    transform: translateY(-2px);
  }

  100% {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .button:hover:not(:disabled),
  .icon-button:hover:not(:disabled),
  .example-card:hover,
  .reference-card:hover,
  .tutor-welcome button:hover {
    transform: none;
  }
}
