:root {
  color-scheme: dark;
  --bg: #061126;
  --panel: #0b1831;
  --panel-2: #112243;
  --panel-pop: #172d55;
  --line: #24426d;
  --text: #f7fbff;
  --muted: #9db1d2;
  --accent: #3377ff;
  --accent-2: #ff526f;
  --accent-3: #08a7c9;
  --accent-soft: #eef5cb;
  --accent-text: #061126;
  --danger: #ff6b7f;
  --good: #57dfa1;
  --shadow: 0 18px 48px rgb(0 20 62 / 34%);
  --pop-shadow: 0 5px 0 #071a3f;
  --radius: 16px;
  --ui-font: "LINE Seed JP", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--ui-font);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef5ff;
  --panel: #ffffff;
  --panel-2: #eaf2ff;
  --panel-pop: #dceaff;
  --line: #b8cff2;
  --text: #0a1d3f;
  --muted: #597096;
  --accent: #1761ee;
  --accent-2: #ee4966;
  --accent-3: #078eab;
  --accent-soft: #f3f7d5;
  --accent-text: #ffffff;
  --danger: #d83451;
  --good: #07845a;
  --shadow: 0 18px 44px rgb(36 83 158 / 16%);
  --pop-shadow: 0 5px 0 #b6cbed;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% -12%, rgb(51 119 255 / 26%), transparent 28rem),
    radial-gradient(circle at 92% 4%, rgb(255 82 111 / 14%), transparent 25rem),
    radial-gradient(circle at 54% 115%, rgb(8 167 201 / 13%), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button, input { font-family: var(--ui-font); }

button { color: inherit; }

.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  z-index: 50;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-text);
}

.app-header {
  position: relative;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-logo {
  width: clamp(142px, 13vw, 180px);
  height: 50px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 5px 12px rgb(0 78 255 / 20%));
}

.popcorn-logo {
  width: clamp(150px, 14vw, 194px);
  height: 48px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 5px 12px rgb(255 165 20 / 18%));
}

.header-status {
  display: flex;
  align-items: center;
  padding: 6px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: 999px;
  background: linear-gradient(105deg, rgb(51 119 255 / 10%), rgb(255 82 111 / 7%));
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.toolbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
}

.button, .icon-button {
  min-height: 33px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}

.button { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; white-space: nowrap; font-size: 12px; }
.icon-button { min-width: 34px; padding: 4px 7px; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { border-color: var(--accent); background: var(--panel-pop); box-shadow: 0 5px 18px rgb(26 100 255 / 15%); transform: translateY(-2px); }
.button:focus-visible, .icon-button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button:disabled, .icon-button:disabled { cursor: wait; opacity: .45; }
.button.primary {
  border-color: transparent;
  background: linear-gradient(110deg, var(--accent), #2263ef 58%, var(--accent-3));
  color: #fff;
  font-weight: 900;
  box-shadow: var(--pop-shadow);
}
.button.primary:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(110deg, #276cf5, #1858dd 58%, #078dab);
  color: #fff;
  box-shadow: 0 3px 0 #071a3f, 0 8px 22px rgb(51 119 255 / 25%);
  transform: translateY(1px);
}
.button.danger { color: var(--danger); }
.button kbd { color: rgb(255 255 255 / 72%); font: 700 10px/1 ui-monospace, monospace; }
.format-button { border-color: color-mix(in srgb, var(--accent-2) 54%, var(--line)); }
.format-button > span { color: var(--accent-2); font-size: 15px; }
.file-button input { display: none; }
.toolbar-separator { width: 1px; height: 22px; margin: 0 2px; background: var(--line); }
.toolbar-spacer { flex: 1; }

.workspace {
  height: calc(100vh - 131px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(360px, 1.25fr) minmax(300px, .9fr);
}

body.lesson-open .workspace {
  grid-template-columns: minmax(300px, 340px) minmax(360px, 1.2fr) minmax(300px, .85fr);
}

.sidebar, .editor-column, .result-column { min-width: 0; min-height: 0; background: color-mix(in srgb, var(--panel) 96%, transparent); }
.sidebar, .editor-column { border-right: 1px solid var(--line); }
.sidebar { display: flex; flex-direction: column; }
.editor-column, .result-column { display: flex; flex-direction: column; }

.side-tabs, .result-tabs {
  min-height: 42px;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}

.side-tab, .result-tab, .copy-result {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.side-tab { flex: 1; }
.side-tab.lesson-tab { flex: 1.45; }
.result-tab { padding: 0 14px; }
.side-tab.active, .result-tab.active {
  border-bottom-color: var(--accent-2);
  color: var(--text);
  background: linear-gradient(180deg, transparent, rgb(51 119 255 / 9%));
}
.copy-result { margin-left: auto; padding: 0 12px; }
.copy-result:hover { color: var(--text); }

.side-panel { min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 10px; }
.search-box { display: block; margin-bottom: 9px; }
.search-box input, .terminal-input input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
}
.search-box input { padding: 8px 9px; font-size: 12px; }

.card-list, .reference-list { display: grid; gap: 6px; }
.example-card, .reference-card {
  width: 100%;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: var(--panel-2);
  text-align: left;
  cursor: pointer;
}
.example-card:hover, .reference-card:hover { border-color: var(--accent); box-shadow: 0 8px 22px rgb(17 81 203 / 12%); transform: translateY(-1px); }
.example-card strong, .reference-card strong { display: block; overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.example-card code { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font: 10px/1.4 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.example-card p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.example-meta { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
.example-category, .example-interactive {
  padding: 2px 5px;
  border-radius: 999px;
  background: rgb(51 119 255 / 15%);
  color: var(--accent);
  font-size: 9px;
}
.example-interactive { margin-left: auto; background: rgb(97 214 144 / 9%); color: var(--good); }
.reference-card { cursor: default; }
.reference-card p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.reference-card .category { float: right; color: var(--accent); font-size: 9px; }

.lesson-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

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

.tutor-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 2px 7px;
}

.tutor-header > div:last-child { display: grid; gap: 3px; }
.tutor-header strong { font-size: 13px; }

.tutor-reset {
  margin-left: auto;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

.tutor-reset:hover {
  border-color: var(--accent);
  color: var(--text);
}

.tutor-session {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
}

.tutor-session[hidden] { display: none; }

.lesson-tuning {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 26px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 35%, rgb(51 119 255 / 16%), transparent 42%),
    var(--panel);
  text-align: center;
}

.lesson-tuning[hidden] { display: none; }

.lesson-tuning-icon {
  display: flex;
  width: 58px;
  height: 58px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 16px;
  border: 1px solid rgb(51 119 255 / 30%);
  border-radius: 20px;
  background: linear-gradient(145deg, rgb(51 119 255 / 22%), rgb(0 194 212 / 12%));
  box-shadow: 0 14px 34px rgb(20 85 220 / 18%);
}

.lesson-tuning-icon i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-3);
  animation: thinking-dot .8s ease-in-out infinite alternate;
}

.lesson-tuning-icon i:nth-child(2) { animation-delay: .15s; }
.lesson-tuning-icon i:nth-child(3) { animation-delay: .3s; }
.lesson-tuning strong { font-size: 14px; }
.lesson-tuning p {
  max-width: 220px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.tutor-online {
  color: var(--muted);
  font-size: 10px;
}

.tutor-online i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--good);
}

.tutor-online.busy i {
  background: #ffd45d;
  animation: tutor-pulse .7s ease-in-out infinite alternate;
}

@keyframes tutor-pulse {
  to { transform: scale(1.45); opacity: .55; }
}

.tutor-welcome {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
  justify-content: center;
  padding: 18px 4px 8px;
  text-align: center;
}

.tutor-welcome[hidden] { display: none; }
.welcome-intro[hidden] { display: none; }

.tutor-welcome::before,
.tutor-welcome::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(2px);
}

.tutor-welcome::before {
  width: 180px;
  height: 180px;
  top: 8%;
  left: 50%;
  background: rgb(51 119 255 / 16%);
  transform: translateX(-50%);
}

.tutor-welcome::after {
  width: 130px;
  height: 130px;
  right: -55px;
  bottom: 9%;
  background: rgb(255 82 111 / 12%);
}

.tutor-welcome h2 {
  margin: 82px 0 8px;
  font-size: clamp(25px, 2.4vw, 34px);
  line-height: 1.05;
  letter-spacing: -.04em;
}

.tutor-welcome p {
  max-width: 230px;
  margin: 0 auto 22px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.tutor-welcome button {
  display: flex;
  width: min(100%, 248px);
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
  padding: 15px 17px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(105deg, var(--accent), var(--accent-3) 58%, var(--accent-2));
  box-shadow: 0 9px 0 color-mix(in srgb, var(--accent) 38%, #061126), 0 18px 34px rgb(30 94 235 / 24%);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  transition: transform .16s ease, box-shadow .16s ease;
}

.tutor-welcome button:hover {
  transform: translateY(-2px);
  box-shadow: 0 11px 0 color-mix(in srgb, var(--accent) 38%, #061126), 0 21px 38px rgb(30 94 235 / 28%);
}

.tutor-welcome button:active {
  transform: translateY(5px);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 38%, #061126);
}

.tutor-welcome button span { font-size: 20px; }

.tutor-welcome small {
  margin-top: 17px;
  color: var(--muted);
  font-size: 9px;
}

.tutor-profile {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 17px;
  text-align: left;
}

.tutor-profile[hidden] { display: none; }

.tutor-profile h2 {
  margin: 0 0 3px;
  text-align: center;
}

.tutor-profile fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

.tutor-profile legend,
.profile-goal > span {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

.level-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.level-options label { cursor: pointer; }
.level-options input { position: absolute; opacity: 0; pointer-events: none; }

.level-options span {
  display: grid;
  min-height: 42px;
  place-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}

.level-options input:checked + span {
  border-color: var(--accent);
  background: rgb(51 119 255 / 16%);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgb(51 119 255 / 24%);
}

.level-options input:focus-visible + span {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

.profile-goal input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
}

.profile-goal input:focus { border-color: var(--accent); }

.profile-optional {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-2) 76%, transparent);
}

.profile-optional summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px;
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.profile-optional summary::-webkit-details-marker { display: none; }

.profile-optional summary::after {
  content: "＋";
  color: var(--accent-3);
  font-size: 14px;
}

.profile-optional[open] summary::after { content: "−"; }

.profile-optional summary span {
  margin-left: auto;
  margin-right: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgb(51 119 255 / 14%);
  color: var(--muted);
  font-size: 8px;
}

.profile-optional > p {
  margin: -2px 12px 10px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.profile-optional-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 0 12px 12px;
}

.profile-optional-grid label > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.profile-optional-grid select {
  width: 100%;
  min-width: 0;
  padding: 9px 26px 9px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 9px;
}

.profile-optional-grid select:focus { border-color: var(--accent); }
.tutor-profile button { margin-top: 2px; }

.welcome-spark {
  position: absolute;
  color: var(--accent-2);
  font-weight: 900;
  animation: welcome-float 2.2s ease-in-out infinite alternate;
}

.spark-one { top: 17%; left: 18%; font-size: 21px; }
.spark-two { top: 29%; right: 18%; color: var(--accent-3); font-size: 8px; animation-delay: -.8s; }

@keyframes welcome-float {
  to { transform: translateY(-8px) rotate(18deg); }
}

.lesson-panel.welcome-mode {
  flex: 1;
  min-height: 0;
}

.lesson-panel.welcome-mode .tutor-header {
  position: static;
  flex-direction: column;
  padding: 20px 2px 8px;
  transform: none;
}

.lesson-panel.welcome-mode .tutor-header > div:last-child { text-align: center; }
.lesson-panel.welcome-mode .tutor-header strong { font-size: 14px; }
.lesson-panel.welcome-mode .tutor-online { display: none; }
.lesson-panel.welcome-mode .tutor-reset { display: none; }
.lesson-panel.welcome-mode .robot-avatar {
  margin: 14px 0 22px;
  transform: scale(1.75);
}

.lesson-panel.welcome-mode .tutor-welcome {
  justify-content: flex-start;
  padding: 18px 4px 16px;
}

.lesson-panel.welcome-mode .tutor-welcome h2 { margin-top: 0; }
.lesson-panel.welcome-mode .welcome-intro { transform: none; }
.lesson-panel.profile-mode .tutor-header { display: none; }

.lesson-panel.profile-mode .tutor-welcome {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 16px;
}

.lesson-panel:not(.welcome-mode):not(.profile-mode) .tutor-header {
  padding-top: 8px;
}

.robot-avatar {
  position: relative;
  width: 48px;
  height: 38px;
  flex: 0 0 auto;
  border: 2px solid #09255b;
  border-radius: 15px 15px 18px 18px;
  background: linear-gradient(155deg, var(--accent-soft) 4%, #8ec7ff 36%, var(--accent) 72%, var(--accent-3));
  box-shadow: inset -3px -4px 0 rgb(5 36 91 / 14%), 0 6px 18px rgb(32 102 244 / 20%);
}

.robot-avatar.happy {
  animation: robot-celebrate .42s ease-in-out 3;
}

.robot-avatar.happy .robot-eye {
  height: 6px;
  border-bottom: 3px solid #09255b;
  border-radius: 50%;
  background: transparent;
  animation: none;
}

.robot-avatar.happy .robot-mouth {
  left: 13px;
  bottom: 4px;
  width: 18px;
  height: 10px;
  border: 0;
  border-bottom: 3px solid #09255b;
  border-radius: 50%;
}

.robot-avatar.thinking .robot-antenna {
  transform-origin: bottom;
  animation: robot-think .55s ease-in-out infinite alternate;
}

.robot-avatar.encourage {
  animation: robot-nod .38s ease-in-out 2;
}

.robot-avatar.sad {
  animation: robot-sigh .7s ease-in-out 1;
}

.robot-avatar.sad .robot-eye {
  top: 14px;
  height: 3px;
  border-radius: 50%;
  transform: rotate(10deg);
  animation: none;
}

.robot-avatar.sad .robot-eye.right { transform: rotate(-10deg); }

.robot-avatar.sad .robot-mouth {
  bottom: 4px;
  height: 8px;
  border-top: 2px solid #071b48;
  border-bottom: 0;
}

.robot-avatar.sad::after {
  content: "";
  position: absolute;
  top: 20px;
  right: 7px;
  width: 5px;
  height: 8px;
  border-radius: 60% 40% 55% 55%;
  background: #d9f4ff;
  box-shadow: 0 1px 0 rgb(7 27 72 / 18%);
  animation: robot-tear .7s ease-in 1;
}

.robot-avatar.surprised {
  animation: robot-pop .38s ease-out 2;
}

.robot-avatar.surprised .robot-eye {
  width: 8px;
  height: 9px;
  top: 10px;
  animation: none;
}

.robot-avatar.surprised .robot-mouth {
  left: 19px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border: 2px solid #071b48;
  border-radius: 50%;
}

@keyframes robot-celebrate {
  50% { transform: translateY(-5px) rotate(3deg); }
}

@keyframes robot-think {
  to { transform: rotate(18deg); }
}

@keyframes robot-nod {
  50% { transform: translateY(3px); }
}

@keyframes robot-sigh {
  50% { transform: translateY(3px) rotate(-2deg); }
}

@keyframes robot-tear {
  from { opacity: 0; transform: translateY(-3px) scale(.65); }
}

@keyframes robot-pop {
  50% { transform: translateY(-4px) scale(1.06); }
}

.robot-antenna {
  position: absolute;
  top: -11px;
  left: 22px;
  width: 2px;
  height: 10px;
  background: var(--accent);
}

.robot-antenna::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgb(255 82 111 / 16%);
}

.robot-eye {
  position: absolute;
  top: 12px;
  width: 6px;
  height: 7px;
  border-radius: 50%;
  background: #071b48;
  animation: robot-blink 5s infinite;
}

.robot-eye.left { left: 11px; }
.robot-eye.right { right: 11px; }

.robot-mouth {
  position: absolute;
  bottom: 7px;
  left: 18px;
  width: 10px;
  height: 4px;
  border-bottom: 2px solid #071b48;
  border-radius: 50%;
}

@keyframes robot-blink {
  0%, 46%, 50%, 100% { transform: scaleY(1); }
  48% { transform: scaleY(.1); }
}

.lesson-progress {
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(115deg, var(--panel-2), rgb(51 119 255 / 9%));
}

.lesson-progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
}

.lesson-progress-label strong { color: var(--text); }

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-3), var(--accent-2));
  transition: width .35s ease;
}

.lesson-picker {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 5px;
}

.lesson-arrow, .lesson-title-button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
}

.lesson-arrow { padding: 0 4px; color: var(--muted); font-size: 9px; font-weight: 700; }
.lesson-arrow:disabled { cursor: default; opacity: .35; }

.lesson-title-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 9px;
  text-align: left;
}

.lesson-title-button span {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, rgb(51 119 255 / 20%), rgb(255 82 111 / 14%));
  color: var(--accent-soft);
  font: 800 9px ui-monospace, monospace;
}

.lesson-title-button strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-goal {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 9px 10px;
  border-left: 4px solid var(--accent-2);
  border-radius: 4px 12px 12px 4px;
  background: linear-gradient(100deg, rgb(255 82 111 / 10%), rgb(51 119 255 / 8%));
  font-size: 11px;
  line-height: 1.55;
}

.lesson-goal > span:first-child { color: var(--accent-2); font-weight: 900; }

.lesson-chat {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  padding: 4px 2px;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.chat-current-section {
  display: flex;
  min-height: calc(100% - 2px);
  flex-direction: column;
}

.chat-current-marker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 2px 2px 10px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.chat-current-marker::before,
.chat-current-marker::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.chat-message {
  display: flex;
  gap: 7px;
  margin-bottom: 9px;
  animation: chat-arrive .18s ease-out;
}

.chat-message.user { justify-content: flex-end; }

.chat-bubble {
  max-width: 92%;
  padding: 8px 9px;
  border-radius: 4px 10px 10px;
  background: var(--panel-2);
  font-size: 10px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-message.user .chat-bubble {
  border-radius: 10px 4px 10px 10px;
  background: linear-gradient(115deg, rgb(51 119 255 / 18%), rgb(8 167 201 / 10%));
}

.chat-message.success .chat-bubble {
  border: 1px solid rgb(97 214 144 / 30%);
  background: rgb(97 214 144 / 9%);
}

.chat-message.streaming .chat-bubble::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 1em;
  margin-left: 3px;
  background: var(--pink);
  vertical-align: -2px;
  animation: stream-caret .7s steps(1) infinite;
}

@keyframes stream-caret {
  50% { opacity: 0; }
}

.chat-context {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.tutor-thinking {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 25px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.tutor-thinking[hidden] { display: none; }

.thinking-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px 10px 10px 3px;
  background: var(--panel-2);
}

.thinking-icon i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-3);
  animation: thinking-dot .8s ease-in-out infinite alternate;
}

.thinking-icon i:nth-child(2) { animation-delay: .15s; }
.thinking-icon i:nth-child(3) { animation-delay: .3s; }

@keyframes thinking-dot {
  to { transform: translateY(-3px); background: var(--accent-2); }
}

@keyframes chat-arrive {
  from { opacity: 0; transform: translateY(4px); }
}

.lesson-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.lesson-actions .button { justify-content: center; }
.lesson-actions .lesson-check {
  grid-column: 1 / -1;
  padding-block: 10px;
  border-color: rgb(97 214 144 / 42%);
  background: rgb(97 214 144 / 9%);
  color: var(--good);
  font-weight: 900;
}

.advance-lesson {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(100deg, var(--accent), var(--accent-3) 56%, var(--accent-2));
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 7px 22px rgb(26 93 235 / 24%);
  animation: next-arrive .25s ease-out;
}

.advance-lesson[hidden] { display: none; }
.advance-lesson span { font-size: 18px; }

@keyframes next-arrive {
  from { opacity: 0; transform: translateY(5px); }
}

.lesson-question {
  display: grid;
  grid-template-columns: 1fr 32px;
  gap: 5px;
}

.lesson-question input {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
}

.lesson-question button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), var(--accent-3));
  color: #fff;
  cursor: pointer;
}

.pane-title {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  font: 12px ui-monospace, SFMono-Regular, Consolas, monospace;
  background: linear-gradient(90deg, rgb(51 119 255 / 9%), transparent 45%, rgb(255 82 111 / 5%));
}

#editor, #editorFallback { flex: 1; min-height: 0; }

#editor .ace_variable.ace_assignment.ace_final {
  font-style: italic !important;
  font-weight: 800 !important;
}
#editorFallback {
  display: none;
  width: 100%;
  resize: none;
  border: 0;
  padding: 14px;
  outline: 0;
  background: var(--panel);
  color: var(--text);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.editor-statusbar, .run-meta {
  min-height: 27px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-2) 78%, transparent);
  color: var(--muted);
  font: 10px ui-monospace, SFMono-Regular, Consolas, monospace;
}
.editor-statusbar span:nth-child(2) { margin-left: auto; }

.result-body { position: relative; flex: 1; min-height: 0; }
.result-panel {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: auto;
  padding: 14px;
  background:
    linear-gradient(rgb(9 19 42 / 96%), rgb(7 15 34 / 98%)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgb(51 119 255 / 4%) 23px 24px);
  color: #e8ecef;
  font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.result-body.input-active .result-panel { padding-bottom: 58px; }
[data-theme="light"] .result-panel { background: #f8fbff; color: #102344; }
.result-panel.error { color: var(--danger); }
.result-value { color: #70a7ff; font-weight: 800; }
[data-theme="light"] .result-value { color: var(--accent); }
.muted { color: var(--muted); }
.count { display: inline-grid; min-width: 16px; place-items: center; margin-left: 3px; padding: 1px 4px; border-radius: 999px; background: var(--panel-2); font-size: 9px; }

.terminal-input {
  position: absolute;
  z-index: 3;
  right: 10px;
  bottom: 9px;
  left: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid rgb(112 167 255 / 48%);
  border-radius: 10px;
  background: rgb(10 24 52 / 96%);
  box-shadow: 0 8px 22px rgb(2 9 24 / 28%);
}
.terminal-input[hidden] { display: none; }
.terminal-input label {
  max-width: 190px;
  overflow: hidden;
  color: #8fb8ff;
  font: 700 12px ui-monospace, SFMono-Regular, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.terminal-input label::before { content: "› "; color: var(--accent-2); }
.terminal-input input {
  min-width: 0;
  padding: 3px 2px;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: #f4f8ff;
  font: 12px ui-monospace, SFMono-Regular, Consolas, monospace;
  caret-color: var(--accent-2);
}
.terminal-input button {
  width: 28px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: rgb(51 119 255 / 20%);
  color: #a9c8ff;
  font: 800 15px/1 ui-monospace, monospace;
}
.terminal-input button:hover {
  background: var(--accent);
  color: white;
}
[data-theme="light"] .terminal-input {
  border-color: rgb(51 119 255 / 38%);
  background: rgb(248 251 255 / 97%);
  box-shadow: 0 8px 22px rgb(35 78 150 / 14%);
}
[data-theme="light"] .terminal-input input { color: #102344; }
[data-theme="light"] .terminal-input label { color: #285eb8; }
.run-meta span:nth-child(2) { margin-left: auto; }

.toast {
  position: fixed;
  z-index: 30;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  border-radius: 13px;
  background: linear-gradient(115deg, var(--panel-pop), var(--panel-2));
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 190px minmax(330px, 1fr) minmax(270px, .8fr); }
  body.lesson-open .workspace { grid-template-columns: 280px minmax(330px, 1fr) minmax(270px, .8fr); }
  .button kbd { display: none; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-header { height: auto; min-height: 70px; padding: 9px 12px; }
  .brand { gap: 7px; }
  .brand-logo { width: 118px; height: 40px; }
  .popcorn-logo { width: 126px; height: 38px; }
  .header-status { display: none; }
  .toolbar { position: sticky; top: 0; z-index: 10; }
  .workspace { height: auto; min-height: calc(100vh - 120px); grid-template-columns: 1fr; grid-template-rows: 180px 55vh 42vh; }
  body.lesson-open .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(430px, 62vh) 55vh 42vh; }
  .sidebar, .editor-column { border-right: 0; border-bottom: 1px solid var(--line); }
}
