:root {
  --bg: #f0f8ff;
  --card: #ffffff;
  --ink: #0a2a44;
  --accent: #1e90ff;
  --accent-deep: #0b6ccb;
  --line: #0a2a44;
  --ok: #1f9d55;
  --warn: #d97706;
  --bad: #dc2626;
  --surface: #fbfdff;
  --gutter: #e5f1ff;
  --dot: #cbd5e1;
  --screen: #0b6ccb;
  --placeholder: #9db6cf;
  --muted: #64748b;
  --tok-keyword: #ff7700;
  --tok-builtin: #900090;
  --tok-definition: #0000ff;
  --tok-string: #00aa00;
  --tok-comment: #dd0000;
  --bubble-bg: #ffffff;
  --bubble-border: #000000;
  --bubble-ink: var(--ink);
  --bubble-tail-border: #000000;
  --bubble-tail-fill: #ffffff;
  --pixel: "Press Start 2P", "Microsoft YaHei", "PingFang SC", sans-serif;
  --text: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16213e;
  --card: #1e2a44;
  --surface: #182338;
  --gutter: #22304d;
  --ink: #e0e6f0;
  --accent: #3a5f8a;
  --accent-deep: #7fb2e5;
  --line: #4a5870;
  --ok: #4caf50;
  --warn: #f0a13a;
  --bad: #ef5350;
  --dot: #33415e;
  --screen: #1d4e86;
  --placeholder: #8aa2c0;
  --muted: #8fa3bf;
  --tok-keyword: #ffa94d;
  --tok-builtin: #c792ea;
  --tok-definition: #82aaff;
  --tok-string: #7ee787;
  --tok-comment: #ff7b72;
  --bubble-bg: #2a3a5c;
  --bubble-border: #ffffff;
  --bubble-ink: #f0f0f0;
  --bubble-tail-border: #ffffff;
  --bubble-tail-fill: #2a3a5c;
}

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

body {
  min-height: 100vh;
  padding: 40px 16px 64px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
}

.shell {
  width: 100%;
  max-width: calc(100vw - 64px);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 4px 24px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #ffffff;
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 var(--line);
  font-family: var(--pixel);
  font-size: 18px;
}

.brand-copy h1 {
  font-family: var(--pixel);
  font-size: 20px;
  line-height: 1.5;
  letter-spacing: 0;
}

.brand-copy p {
  margin-top: 8px;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--accent-deep);
}

.panel {
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 6px 6px 0 var(--line);
  padding: 22px;
  margin-bottom: 28px;
}

.panel:not([hidden]) {
  animation: pop-in 0.35s ease-out;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-head h2 {
  font-family: var(--pixel);
  font-size: 14px;
  letter-spacing: 0;
}

.dot {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  background: var(--dot);
}

.dot.busy {
  background: var(--accent);
  animation: blink 0.8s steps(2, start) infinite, ring 1.2s ease-out infinite;
}

.dot.ok {
  background: var(--ok);
}

.dot.error {
  background: var(--bad);
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

@keyframes ring {
  0% {
    box-shadow: 0 0 0 0 rgba(30, 144, 255, 0.55);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(30, 144, 255, 0);
  }
}

textarea {
  width: 100%;
  min-height: 240px;
  padding: 14px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.code-editor {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 200px;
  border: 2px solid var(--line);
  background: var(--surface);
}

.code-editor:focus-within {
  background: var(--card);
  box-shadow: 4px 4px 0 rgba(30, 144, 255, 0.35);
}

.editor-stage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

.code-editor textarea {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  -webkit-text-fill-color: transparent;
  tab-size: 4;
}

.code-editor textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
  -webkit-text-fill-color: var(--placeholder);
}

.highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 14px;
  overflow: hidden;
  pointer-events: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 4;
}

.tok-keyword {
  color: var(--tok-keyword);
}

.tok-builtin {
  color: var(--tok-builtin);
}

.tok-definition {
  color: var(--tok-definition);
}

.tok-string {
  color: var(--tok-string);
}

.tok-comment {
  color: var(--tok-comment);
}

.line-numbers {
  flex: 0 0 auto;
  min-width: 46px;
  padding: 14px 10px 14px 0;
  border-right: 2px solid var(--line);
  background: var(--gutter);
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  text-align: right;
  overflow: hidden;
  white-space: pre;
  user-select: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.pixel-btn {
  position: relative;
  min-width: 160px;
  padding: 14px 20px;
  border: 2px solid var(--line);
  background: var(--accent);
  color: #ffffff;
  font-family: var(--pixel);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  box-shadow: 4px 4px 0 var(--line);
  cursor: pointer;
  letter-spacing: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}

.pixel-btn:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translate(-1px, -1px);
  animation: btn-glow 1.4s ease-in-out infinite;
}

.pixel-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--line);
}

.pixel-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pixel-btn.ghost {
  background: var(--card);
  color: var(--ink);
}

.pixel-btn.ghost:hover:not(:disabled) {
  background: var(--bg);
}

.hint {
  min-height: 24px;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.2s ease;
}

.hint.pop {
  animation: msg-in 0.3s ease-out;
}

.hint.loading {
  color: var(--accent-deep);
}

.hint.success {
  color: var(--ok);
}

.hint.error {
  color: var(--bad);
}

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

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

.badge {
  padding: 8px 10px;
  border: 2px solid var(--line);
  background: var(--gutter);
  color: var(--accent-deep);
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 0;
}

.badge.bounce {
  animation: bounce 0.5s ease;
}

.practice-question {
  margin-bottom: 16px;
  padding: 14px;
  border: 2px dashed var(--accent);
  background: var(--gutter);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.result-card {
  border: 2px solid var(--line);
  background: var(--bg);
  padding: 16px;
}

.result-card h3 {
  margin-bottom: 10px;
  font-family: var(--pixel);
  font-size: 11px;
  color: var(--accent-deep);
  letter-spacing: 0;
}

.result-card p {
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-panel.ok .badge {
  background: var(--ok);
  color: #ffffff;
}

.result-panel.warning .badge {
  background: var(--warn);
  color: #ffffff;
}

.result-panel.error .badge {
  background: var(--bad);
  color: #ffffff;
}

.practice-panel.ok .badge {
  background: var(--ok);
  color: #ffffff;
}

.practice-panel.warning .badge {
  background: var(--warn);
  color: #ffffff;
}

.practice-panel.error .badge {
  background: var(--bad);
  color: #ffffff;
}

.shake {
  animation: shake 0.4s ease;
}

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  60% {
    opacity: 1;
    transform: translateY(-2px) scale(1.005);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
  60% {
    transform: translateY(3px);
  }
}

@keyframes btn-glow {
  0%,
  100% {
    box-shadow: 4px 4px 0 var(--line), 0 0 0 rgba(30, 144, 255, 0);
  }
  50% {
    box-shadow: 4px 4px 0 var(--line), 0 0 14px rgba(30, 144, 255, 0.55);
  }
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  body {
    padding-top: 24px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-copy h1 {
    font-size: 16px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .pixel-btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* ===== AI 悬浮助手 ===== */
.ai-assistant {
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  --ai-hl-x: 0px;
  --ai-hl-y: 0px;
  --ai-hl-r: -14deg;
  --ai-hr-x: 0px;
  --ai-hr-y: 0px;
  --ai-hr-r: 14deg;
  position: fixed;
  right: 30px;
  bottom: 30px;
  width: 150px;
  height: 165px;
  z-index: 900;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--mono);
}

.ai-assistant.ai-dragging {
  cursor: grabbing;
}

.ai-assistant.ai-dragging .ai-hand {
  cursor: grabbing;
}

.ai-monitor {
  position: relative;
  width: 132px;
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 0;
  box-shadow: 3px 3px 0 #000000;
  padding: 6px;
  z-index: 2;
  cursor: grab;
  image-rendering: pixelated;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== 显示器边框指示灯 ===== */
.ai-indicator {
  position: absolute;
  top: 3px;
  right: 1px;
  width: 4px;
  height: 4px;
  background: #4CAF50;
  border: 1px solid #000000;
  z-index: 5;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.ai-indicator.indicator-idle {
  background: #4CAF50;
}

.ai-indicator.indicator-thinking {
  background: #F9A825;
  animation: indicator-blink-yellow 1s step-end infinite;
}

.ai-indicator.indicator-listening {
  background: #3F7FBF;
  animation: indicator-blink-blue 1s step-end infinite;
}

.ai-indicator.indicator-dragging {
  background: #FFFFFF;
}

.ai-indicator.indicator-trivia {
  background: #F9A825;
  animation: indicator-breathe-yellow 1s ease-in-out infinite;
}

.ai-indicator.indicator-wander-start {
  background: #26C6DA;
  animation: indicator-blink-cyan 0.4s step-end 3;
}

.ai-indicator.indicator-wander-end {
  background: #26C6DA;
  animation: indicator-cyan-once 0.6s step-end 1;
}

.ai-indicator.indicator-night-toggle {
  background: #FFF3E0;
  animation: indicator-breathe-warm 1s ease-in-out 2;
}

.ai-indicator.indicator-boot {
  background: #FFF3E0;
  animation: indicator-fade-in-warm 0.5s ease-out 1;
}

.ai-indicator.indicator-pink {
  background: #F48FB1;
  animation: indicator-blink-pink 0.4s step-end 3;
}

.ai-indicator.indicator-easter-egg {
  background: #E53935;
}

.ai-indicator.ai-indicator-tap {
  filter: brightness(1.8);
}

/* ===== 保存按钮三选一菜单 ===== */
.export-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 230px;
  z-index: 40;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--line);
  padding: 6px;
}

.export-menu[hidden] {
  display: none;
}

.export-menu-item {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  font-size: 10px;
  line-height: 1.5;
  text-align: left;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  cursor: pointer;
  transition: background 0.15s ease;
}

.export-menu-item:hover {
  background: var(--gutter);
}

@keyframes indicator-blink-yellow {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}

@keyframes indicator-blink-blue {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.2; }
}

@keyframes indicator-blink-cyan {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.1; }
}

@keyframes indicator-cyan-once {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.1; }
}

@keyframes indicator-breathe-warm {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

@keyframes indicator-breathe-yellow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@keyframes indicator-fade-in-warm {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes indicator-blink-pink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.2; }
}

@keyframes indicator-rainbow {
  0% { background: #E53935; }
  16.66% { background: #FB8C00; }
  33.33% { background: #FDD835; }
  50% { background: #43A047; }
  66.66% { background: #1E88E5; }
  83.33% { background: #8E24AA; }
  100% { background: #E53935; }
}

/* ===== 灵动感深化 ===== */
.ai-stand-bounce {
  animation: ai-stand-bounce 0.3s ease;
}

@keyframes ai-stand-bounce {
  0% { transform: translateY(0); }
  50% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

.ai-screen-dim {
  filter: brightness(0.6);
}

.ai-screen-celebrate {
  animation: ai-screen-breathe 3s ease-in-out;
}

@keyframes ai-screen-breathe {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

.ai-dragging .ai-monitor {
  transform: scale(1.05);
}

.ai-hover .ai-monitor {
  transform: scale(1.03);
}

.ai-monitor.ai-pressed {
  transform: scale(0.95) translateY(2px);
}

.ai-monitor-pop {
  animation: ai-monitor-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ai-monitor-pop {
  0% {
    transform: scale(0.95) translateY(2px);
  }
  60% {
    transform: scale(1.05) translateY(-2px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

.ai-monitor-settle {
  animation: ai-settle 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ai-settle {
  0% {
    transform: scale(1.05);
  }
  40% {
    transform: scale(0.97) translateY(2px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

.ai-screen {
  height: 64px;
  background-color: var(--screen);
  transition: background-color 0.5s ease, filter 0.4s ease;
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 4px);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  image-rendering: pixelated;
}

.ai-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0px;
  color: #ffffff;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  transform: translate(var(--ai-eye-x, 0px), var(--ai-eye-y, 0px));
  transform-origin: center;
  -webkit-font-smoothing: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-eye {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  line-height: 20px;
  transform: translate(
    var(--ai-eye-shift-x, 0px),
    calc(var(--ai-eye-comp-y, 0px) + var(--ai-eye-shift-y, 0px))
  );
}

.ai-eye[data-eye="^^"] {
  --ai-eye-comp-y: 2px;
}

.ai-eye[data-eye="00"] {
  --ai-eye-comp-y: 1px;
}

.ai-eye[data-eye="><"] {
  --ai-eye-comp-y: 1px;
}

.ai-eye[data-eye="--"] {
  --ai-eye-comp-y: 2px;
}

.ai-mouth {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  line-height: 20px;
  transform: rotate(90deg);
}

.ai-face-pop {
  animation: ai-face-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ai-face-pop {
  0% {
    transform: translate(var(--ai-eye-x, 0px), var(--ai-eye-y, 0px)) scale(0.9);
  }
  60% {
    transform: translate(var(--ai-eye-x, 0px), var(--ai-eye-y, 0px)) scale(1.08);
  }
  100% {
    transform: translate(var(--ai-eye-x, 0px), var(--ai-eye-y, 0px)) scale(1);
  }
}

.ai-stand {
  width: 44px;
  height: 10px;
  margin: -2px auto 0;
  background: #e2e8f0;
  border: 2px solid #000000;
  border-radius: 0;
  box-shadow: 2px 2px 0 #000000;
  z-index: 1;
}

.ai-hand {
  position: absolute;
  bottom: 56px;
  width: 26px;
  height: 29px;
  z-index: 3;
  cursor: grab;
  pointer-events: auto;
  --ai-stretch-x: 0px;
  --ai-stretch-y: 0px;
  image-rendering: pixelated;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), translate 0.4s ease;
}

.ai-assistant.ai-hands-near .ai-hand {
  translate: 0 -2px;
}

.ai-hand-dragging {
  transition: none;
}

.ai-hand-left {
  left: 9px;
  transform-origin: 0 0;
  transform: translate(
    calc(var(--ai-hl-x) + var(--ai-stretch-x)),
    calc(var(--ai-hl-y) + var(--ai-stretch-y))
  )
  rotate(var(--ai-hl-r));
}

.ai-hand-right {
  right: 9px;
  transform-origin: 100% 0;
  transform: translate(
    calc(var(--ai-hr-x) + var(--ai-stretch-x)),
    calc(var(--ai-hr-y) + var(--ai-stretch-y))
  )
  rotate(var(--ai-hr-r));
}

.ai-hand-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-hand-svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(3px 3px 0 #000000);
}

.ai-hand-right .ai-hand-svg {
  transform: scaleX(-1);
}

.ai-bubble {
  position: fixed;
  left: 50%;
  top: auto;
  bottom: auto;
  --ai-bubble-x: -50%;
  transform: translateX(var(--ai-bubble-x)) translateY(0) scale(0.8);
  transform-origin: 50% 100%;
  background: var(--bubble-bg);
  border: 2px solid var(--bubble-border);
  border-radius: 0;
  box-shadow: 3px 3px 0 #000000;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--bubble-ink);
  min-width: 80px;
  min-height: 40px;
  max-width: min(400px, 80vw);
  width: auto;
  height: auto;
  display: inline-block;
  max-height: 50vh;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  opacity: 0;
  pointer-events: auto;
  z-index: 950;
  -webkit-font-smoothing: none;
  transition: width 0.25s ease-out, height 0.25s ease-out, opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-bubble-right {
  left: auto;
  right: 0;
  --ai-bubble-x: 0%;
}

.ai-bubble-left {
  left: 0;
  right: auto;
  --ai-bubble-x: 0%;
}

.ai-bubble::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--bubble-tail-border);
}

.ai-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--bubble-tail-fill);
  margin-top: -2px;
}

.ai-bubble-show {
  opacity: 1;
  transform: translateX(var(--ai-bubble-x, -50%)) translateY(0) scale(1);
  animation: ai-bubble-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-bubble-hide {
  opacity: 0;
  transform: translateX(var(--ai-bubble-x, -50%)) translateY(4px) scale(0.9);
}

@keyframes ai-bubble-pop {
  0% {
    opacity: 0;
    transform: translateX(var(--ai-bubble-x, -50%)) translateY(10px) scale(0.8);
  }
  60% {
    opacity: 1;
    transform: translateX(var(--ai-bubble-x, -50%)) translateY(0) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateX(var(--ai-bubble-x, -50%)) translateY(0) scale(1);
  }
}

.ai-type-char {
  display: inline-block;
  animation: ai-type-pop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ai-type-pop {
  0% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* 状态：空闲 */
.ai-state-idle .ai-hand-inner {
  animation: ai-idle-float 5s ease-in-out infinite;
}

@keyframes ai-idle-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.ai-long-idle .ai-hand-inner {
  animation: ai-idle-quiet 7s ease-in-out infinite;
}

@keyframes ai-idle-quiet {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

.ai-state-thinking {
  --ai-hl-x: 0px;
  --ai-hl-y: -24px;
  --ai-hl-r: 16deg;
  --ai-hr-x: 0px;
  --ai-hr-y: -24px;
  --ai-hr-r: -16deg;
}

.ai-state-thinking .ai-hand-left .ai-hand-inner {
  animation: ai-think-left 2s ease-in-out infinite;
}

.ai-state-thinking .ai-hand-right .ai-hand-inner {
  animation: ai-think-right 2s ease-in-out infinite;
}

@keyframes ai-think-left {
  0%,
  100% {
    transform: translateX(2px);
  }
  50% {
    transform: translateX(16px);
  }
}

@keyframes ai-think-right {
  0%,
  100% {
    transform: translateX(-2px);
  }
  50% {
    transform: translateX(-16px);
  }
}

.ai-state-success {
  --ai-hl-x: -10px;
  --ai-hl-y: -88px;
  --ai-hl-r: 165deg;
  --ai-hr-x: 10px;
  --ai-hr-y: -88px;
  --ai-hr-r: -165deg;
}

.ai-state-success .ai-hand-inner {
  animation: ai-cheer-sway 2.4s ease-in-out infinite;
}

@keyframes ai-cheer-sway {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  10% {
    transform: translateY(-7px) rotate(-9deg);
  }
  20% {
    transform: translateY(0) rotate(0deg);
  }
  30% {
    transform: translateY(-7px) rotate(9deg);
  }
  40% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-4px) rotate(-6deg);
  }
  60% {
    transform: translateY(-2px) rotate(5deg);
  }
  70% {
    transform: translateY(-4px) rotate(-4deg);
  }
  80% {
    transform: translateY(0) rotate(0deg);
  }
}

.ai-state-error {
  --ai-hl-x: -28px;
  --ai-hl-y: 0px;
  --ai-hl-r: -40deg;
  --ai-hr-x: 28px;
  --ai-hr-y: 0px;
  --ai-hr-r: 40deg;
}

.ai-state-error .ai-hand-inner {
  animation: ai-shrug 1.8s ease-in-out 2;
}

@keyframes ai-shrug {
  0%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-7px);
  }
  55% {
    transform: translateY(0);
  }
  75% {
    transform: translateY(-4px);
  }
}

/* 悬停 */
.ai-hover .ai-hand-inner {
  animation: none !important;
  transform: translateY(-4px) !important;
}

/* 拖拽时另一只手轻摆 */
.ai-sway-other .ai-hand-inner {
  animation: ai-sway-other-anim 0.7s ease-in-out infinite !important;
}

@keyframes ai-sway-other-anim {
  0%,
  100% {
    transform: rotate(0deg) translateY(0);
  }
  50% {
    transform: rotate(6deg) translateY(-3px);
  }
}
/* ===== 待机动画辅助 ===== */
.ai-question {
  position: absolute;
  top: -22px;
  right: 16px;
  z-index: 6;
  display: none;
  padding: 2px 7px;
  background: #ffffff;
  border: 2px solid #000000;
  box-shadow: 2px 2px 0 #000000;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-deep);
}

.ai-question.ai-show {
  display: inline-block;
  animation: ai-question-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ai-question-pop {
  0% {
    transform: scale(0.6);
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

/* 思考状态：显示器微抖动 */
.ai-think-shake .ai-monitor {
  animation: ai-think-shake 1.5s ease-in-out infinite;
}

@keyframes ai-think-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(0.5px, 0);
  }
  50% {
    transform: translate(0, 0.5px);
  }
  75% {
    transform: translate(-0.5px, 0);
  }
}

/* 思考状态 JS 编排时关闭 CSS 手部动画，避免冲突 */
.ai-think-js .ai-hand-inner {
  animation: none;
}
/* ===== 对话输入框 ===== */
.ai-chat-input {
  position: absolute;
  z-index: 7;
  display: none;
  width: 140px;
  min-height: 40px;
  max-height: 30vh;
  border: 2px solid #000000;
  border-radius: 0;
  background: var(--screen);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 6px;
  outline: none;
  resize: none;
  overflow: hidden;
  overflow-wrap: break-word;
  word-wrap: break-word;
  box-shadow: 3px 3px 0 #000000;
}

.ai-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0;
  white-space: nowrap;
}

.ai-chat-input.ai-show {
  display: block;
  animation: ai-input-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-input.ai-shrink {
  width: 64px;
  font-size: 10px;
}

@keyframes ai-input-pop {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  60% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* 倾听状态：身体前倾 + 手部微晃 */
.ai-listening .ai-monitor {
  transform: translateY(4px);
}

.ai-listening .ai-hand-inner {
  animation: ai-nod 0.9s ease-in-out infinite;
}

@keyframes ai-nod {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

/* 对话思考状态：关闭 CSS 手部动画，由 JS 编排 */
.ai-chat .ai-hand-inner {
  animation: none;
}

/* 回复完成：点头弹跳 */
.ai-chat-nod .ai-monitor {
  animation: ai-chat-nod 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ai-chat-nod {
  0% {
    transform: translateY(4px);
  }
  50% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}
/* ===== 对话记忆：气泡按钮与提示 ===== */
.ai-chat-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.ai-chat-actions[hidden],
.ai-bubble-hint[hidden],
.ai-chat-clear[hidden] {
  display: none;
}

.ai-pixel-btn {
  padding: 4px 10px;
  border: 2px solid #000000;
  border-radius: 0;
  background: var(--screen);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.4;
  box-shadow: 2px 2px 0 #000000;
  cursor: pointer;
}

.ai-pixel-btn:hover {
  background: var(--accent);
}

.ai-pixel-btn.ghost {
  background: var(--card);
  color: var(--ink);
}

.ai-pixel-btn.ghost:hover {
  background: var(--bg);
}

.ai-bubble-hint {
  display: block;
  margin-top: 6px;
  text-align: right;
  font-size: 10px;
  color: var(--muted);
}

/* 保存提醒：招手 */
.ai-reminder-wave .ai-hand-inner {
  animation: ai-wave 0.8s ease-in-out infinite;
}

@keyframes ai-wave {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-6px) rotate(12deg);
  }
}

/* 对话记忆：清空按钮 */
.ai-chat-clear {
  position: absolute;
  z-index: 7;
  display: none;
  padding: 2px 8px;
  border: 2px solid #000000;
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.4;
  box-shadow: 2px 2px 0 #000000;
  cursor: pointer;
}

.ai-chat-clear:hover {
  background: var(--bg);
}
/* ===== 学习功能 ===== */
.learn-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  text-align: left;
  margin-bottom: 30px;
  padding-left: 2px;
}

.learn-title {
  font-family: var(--pixel);
  font-size: 28px;
  color: var(--accent-deep);
  letter-spacing: 1px;
  line-height: 1.4;
  -webkit-font-smoothing: none;
}

.learn-subtitle {
  margin-top: 10px;
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--muted);
  letter-spacing: 0;
  -webkit-font-smoothing: none;
}

.learn-subtitle .star {
  color: var(--accent-deep);
}

.learn-underline {
  width: 60%;
  max-width: 420px;
  border-bottom: 2px dashed var(--accent-deep);
  margin-top: 12px;
}

.app-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(8px, 2vw, 24px);
}


.learn-sidebar {
  flex: 0 0 220px;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 var(--line);
  padding: 16px;
}

.learn-sidebar h2 {
  font-family: var(--pixel);
  font-size: 12px;
  line-height: 1.7;
  color: var(--accent-deep);
  margin-bottom: 14px;
  letter-spacing: 0;
}

.learn-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.learn-sidebar li {
  padding: 9px 10px;
  margin-bottom: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.learn-sidebar li:hover {
  background: var(--bg);
  border-color: var(--line);
}

.learn-sidebar li.active {
  background: var(--gutter);
  border-color: var(--accent-deep);
}

.learn-sidebar li .topic-done {
  margin-left: 6px;
  color: var(--ok);
}

.app-main {
  flex: 0 1 calc(57.8% - 155px);
  min-width: 0;
}

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

.learn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.learn-head h2 {
  font-family: var(--pixel);
  font-size: 15px;
  color: var(--accent-deep);
  letter-spacing: 0;
}

.learn-back {
  min-width: auto;
  font-size: 10px;
  padding: 10px 14px;
}

.learn-concept {
  margin-bottom: 14px;
  padding: 14px;
  border: 2px dashed var(--accent);
  background: var(--gutter);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.learn-code-block {
  margin: 0 0 14px;
  padding: 14px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 4;
}

.learn-lines {
  margin: 0 0 6px;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
}

.learn-lines li {
  margin-bottom: 6px;
}

/* 授课姿态 */
.ai-teaching .ai-hand-inner {
  animation: ai-teach-sway 1.6s ease-in-out infinite;
}

@keyframes ai-teach-sway {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-3px) rotate(6deg);
  }
}

@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
  }

  .learn-sidebar {
    position: static;
    flex: 1 1 auto;
    width: 100%;
  }

  .app-main {
    flex: 1 1 auto;
    margin-left: 0;
  }

  .learn-title {
    font-size: 22px;
  }
}
/* 新用户引导：独立于气泡，显示在显示器下方 */
.ai-guide {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--pixel);
  font-size: 10px;
  line-height: 1.4;
  color: #aaaaaa;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  -webkit-font-smoothing: none;
  transition: opacity 0.5s ease;
}

.ai-guide.ai-show {
  opacity: 0.8;
}

/* ===== 顶部功能按钮：帮助提示 + 日夜模式 ===== */
#inputPanel {
  position: relative;
  display: flex;
  flex-direction: column;
}

#inputPanel[hidden] {
  display: none;
}

.input-tools {
  position: relative;
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 30;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-family: var(--pixel);
  font-weight: 700;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--screen);
  color: #f2f7ff;
  font-size: 18px;
  line-height: 1;
  box-shadow: 2px 2px 0 var(--line);
  cursor: pointer;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
  background: var(--accent);
}

.icon-btn:active {
  transform: translate(1px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

#starBtn .btn-glyph,
#themeBtn .btn-glyph {
  font-size: 23px;
  transform: translateY(-2px);
  display: block;
  width: 23px;
  text-align: center;
}

.icon-btn-dl {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: none;
  text-underline-offset: 1px;
}

.help-pop {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 340px;
  max-width: 80vw;
  padding: 12px 14px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
  z-index: 5;
}

.help-pop[hidden] {
  display: none;
}

.help-pop::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: var(--pop-arrow, 24px);
  border: 10px solid transparent;
  border-bottom-color: var(--line);
}

.help-pop::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: calc(var(--pop-arrow, 24px) + 2px);
  border: 8px solid transparent;
  border-bottom-color: var(--card);
  margin-bottom: -2px;
}

.help-pop.help-pop-down {
  top: auto;
  bottom: calc(100% + 10px);
}

.help-pop.help-pop-down::before {
  bottom: auto;
  top: 100%;
  border-bottom-color: transparent;
  border-top-color: var(--line);
}

.help-pop.help-pop-down::after {
  bottom: auto;
  top: 100%;
  border-bottom-color: transparent;
  border-top-color: var(--card);
  margin-bottom: 0;
  margin-top: -2px;
}

.help-pop.help-pop-left {
  right: auto;
  left: 0;
}

.help-pop.help-pop-left::before {
  right: auto;
  left: 8px;
}

.help-pop.help-pop-left::after {
  right: auto;
  left: 10px;
}

/* 日夜模式平滑过渡 */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease !important;
}

/* 夜间模式下 Mr. Blue 主体微光 */
html[data-theme="dark"] .ai-monitor {
  box-shadow: 3px 3px 0 #000000, 0 0 14px rgba(110, 160, 255, 0.28);
}




/* ===== 游走寻物待机动画 ===== */
.ai-assistant {
  transition: opacity 0.3s ease;
}

.ai-roam-hidden {
  opacity: 0;
}

.ai-toy {
  position: absolute;
  width: 2px;
  height: 2px;
  pointer-events: none;
  z-index: 4;
  image-rendering: pixelated;
  opacity: 0;
}

.ai-toy.ai-toy-visible {
  opacity: 1;
}

.ai-toy.ai-toy-appear {
  transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

.ai-toy-flame {
  position: absolute;
  left: 2px;
  top: -5px;
  width: 2px;
  height: 2px;
  background: #ff6b35;
  box-shadow: 2px 0 0 #ff6b35, 0 -2px 0 #ff6b35, 1px -2px 0 #ffd54a;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ai-toy-flame.ai-show {
  opacity: 1;
}

.ai-throw-windup .ai-monitor {
  transform: translateY(6px);
}

.ai-throw-release .ai-monitor {
  transform: translateY(-3px);
}

@keyframes ai-toy-arc {
  0% {
    transform: translate(0px, 0px) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: translate(calc(var(--tx) * 0.5), calc(var(--ty) * 0.5 - var(--arc))) rotate(calc(var(--rot) * 0.5));
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot));
    opacity: 0;
  }
}

.ai-toy-flying {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  animation: ai-toy-arc 0.45s cubic-bezier(0.35, 0.1, 0.6, 1) forwards;
}


/* ===== 星星按钮悬停提示 ===== */
.star-tip {
  position: absolute;
  top: calc(100% + 10px);
  bottom: auto;
  right: 52px;
  width: 200px;
  max-width: 70vw;
  padding: 8px 10px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 40;
  pointer-events: none;
}

.star-tip.ai-show {
  opacity: 1;
  visibility: visible;
}

.star-tip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  right: 0;
  border: 10px solid transparent;
  border-bottom-color: var(--line);
}

.star-tip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  right: 2px;
  border: 8px solid transparent;
  border-bottom-color: var(--card);
  margin-bottom: -2px;
}

.export-tip {
  right: 4px;
  width: 210px;
}

.ai-toy-glow {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.85) 0%, rgba(255, 215, 0, 0) 70%);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  z-index: 1;
}

.ai-toy-glow.ai-show {
  opacity: 1;
}

.ai-toy-glow-big {
  width: 46px;
  height: 46px;
}

.ai-roam-lookdown .ai-monitor {
  transform: translateY(3px) rotate(2deg);
}

.ai-roam-tilt-l .ai-monitor {
  transform: rotate(-4deg);
}

.ai-roam-tilt-r .ai-monitor {
  transform: rotate(4deg);
}

.ai-roam-leanback .ai-monitor {
  transform: translateY(-3px) rotate(-3deg);
}

.ai-roam-nod .ai-monitor {
  animation: ai-chat-nod 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}


/* ===== 学习栏分隔线 ===== */
.learn-divider {
  height: 2px;
  margin: 16px 0 12px;
  background: var(--line);
  opacity: 0.15;
}

.custom-learn {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.custom-learn-hint {
  margin-bottom: 8px;
  font-family: var(--pixel);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  letter-spacing: 0;
  -webkit-font-smoothing: none;
}

.custom-learn-input {
  width: 100%;
  height: 88px;
  min-height: 88px;
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  overflow-wrap: break-word;
  word-wrap: break-word;
  outline: none;
  -webkit-font-smoothing: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-learn-input:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.25);
}

.custom-learn-btn {
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 11px;
}

.custom-learn-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.custom-learn-random {
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 11px;
  background: var(--surface);
  color: var(--accent-deep);
  border-color: var(--accent);
}

.custom-learn-random:hover:not(:disabled) {
  background: var(--gutter);
  color: var(--accent-deep);
  transform: translate(-1px, -1px);
}

.custom-learn-random:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.custom-learn-random:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.custom-learn-fun {
  width: 100%;
  min-width: 0;
  margin: 8px 0 4px;
  padding: 14px 12px;
  font-size: 15px;
  line-height: 1.5;
  white-space: nowrap;
  -webkit-font-smoothing: none;
  background: var(--surface);
  color: var(--accent-deep);
  border-color: var(--accent);
}

.custom-learn-fun:hover:not(:disabled) {
  background: var(--gutter);
  color: var(--accent-deep);
  transform: translate(-1px, -1px);
}

.custom-learn-fun:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.custom-learn-fun:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.custom-learn-msg {
  min-height: 16px;
  font-size: 12px;
}


/* ===== 学习区布局 ===== */
.learn-layout {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.learn-main {
  flex: 1 1 auto;
  min-width: 0;
}

.learn-feedback {
  flex: 0 1 calc(32% - 86px);
  align-self: flex-start;
  position: sticky;
  top: 0;
  font-size: 16px;
  -webkit-font-smoothing: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-height: 200px;
  max-height: max(200px, calc(100vh - 170px));
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--line);
  padding: 12px;
}

.learn-feedback-title {
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1.6;
  color: var(--accent-deep);
  letter-spacing: 0;
  margin-bottom: 6px;
  -webkit-font-smoothing: none;
}

.learn-feedback-hint {
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 8px;
}

.learn-feedback-input {
  width: 100%;
  min-height: 80px;
  max-height: 30vh;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  overflow-wrap: break-word;
  word-wrap: break-word;
  outline: none;
  -webkit-font-smoothing: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.learn-feedback-input:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.25);
}

.learn-feedback-btn {
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 16px;
}

.learn-feedback-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.learn-feedback-msg {
  min-height: 16px;
  font-size: 16px;
}

.learn-feedback-history {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 8px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.learn-feedback-history::-webkit-scrollbar {
  width: 8px;
}

.learn-feedback-history::-webkit-scrollbar-track {
  background: var(--gutter);
}

.learn-feedback-history::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 2px solid var(--card);
}

.feedback-empty {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.6;
}

.feedback-q {
  align-self: flex-end;
  max-width: 90%;
  padding: 6px 8px;
  background: var(--gutter);
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.feedback-a {
  position: relative;
  align-self: flex-start;
  max-width: 90%;
  padding: 6px 8px;
  background: var(--bubble-bg);
  border: 2px solid var(--bubble-border);
  border-radius: 0;
  color: var(--bubble-ink);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.feedback-a::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 10px;
  border: 6px solid transparent;
  border-top-color: var(--bubble-tail-border);
}

.feedback-a::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 12px;
  border: 4px solid transparent;
  border-top-color: var(--bubble-tail-fill);
  margin-top: -2px;
}

@media (max-width: 900px) {
  .learn-layout {
    flex-direction: column;
  }

  .learn-feedback {
    flex: 1 1 auto;
    width: 100%;
  }
}


#learnFeedback[hidden] {
  display: none;
}

@media (max-width: 1180px) {
  .app-layout {
    flex-wrap: wrap;
  }

  .app-main {
    flex: 1 1 0;
    margin-left: 0;
    min-width: 0;
  }

  .learn-feedback {
    flex: 1 1 100%;
  }
}


.learn-feedback-input,
.learn-feedback-btn,
.learn-feedback-msg {
  flex-shrink: 0;
}


#learnExercise {
  margin-top: 14px;
}

/* ===== 桌宠版布局覆盖 ===== */
body {
  min-height: 100vh;
  padding: 0;
  background: transparent;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pet-stage {
  position: relative;
  width: 100%;
  height: 100vh;
}

.pet-toolbar {
  position: fixed;
  top: 12px;
  right: 16px;
}

.pet-fact-btn {
  margin-left: 8px;
  padding: 8px 10px;
  font-size: 11px;
  background: var(--surface);
  color: var(--accent-deep);
  border: 2px solid var(--accent);
  box-shadow: 2px 2px 0 var(--line);
}

.pet-fact-btn:hover {
  background: var(--gutter);
  transform: translate(-1px, -1px);
}
/* ===== 桌宠三击菜单：横向方块 + 弹性动画 + 悬停说明 ===== */
.pet-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 8px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--line);
  transform-origin: center top;
  -webkit-font-smoothing: none;
}

.pet-menu[hidden] {
  display: none;
}

.pet-menu.pet-menu-above {
  transform-origin: center bottom;
}

.pet-menu.pet-menu-open {
  animation: pet-menu-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.pet-menu.pet-menu-close {
  animation: pet-menu-fade 0.2s ease-out both;
}

@keyframes pet-menu-pop {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pet-menu-fade {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.92);
  }
}

.pet-menu-item {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--screen);
  color: #f2f7ff;
  font-family: var(--pixel);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  image-rendering: pixelated;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.pet-menu-item:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
  background: var(--accent);
}

.pet-menu-item:active {
  transform: translate(1px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.pet-menu-icon {
  font-family: var(--pixel);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: block;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0;
  color: inherit;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-variant-emoji: text;
}

.pet-menu-dl {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: none;
  text-underline-offset: 1px;
}

.pet-menu-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(3px) scale(0.92);
  white-space: nowrap;
  padding: 4px 6px;
  background: #ffffff;
  color: #0a2a44;
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 2px 2px 0 var(--line);
  font-family: var(--pixel);
  font-size: 9px;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  z-index: 61;
  -webkit-font-smoothing: none;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

.pet-menu-item:hover .pet-menu-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}