  :root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --panel-soft: #fafbfe;
    --border: #e5e9f2;
    --text: #1b2333;
    --muted: #8a93a6;
    --accent: #4f6ef7;
    --accent-hover: #3f5ce0;
    --accent-soft: #eef2ff;
    --ok: #16a06a;
    --err: #d93a3a;
    --err-soft: #fff3f3;
    --shadow: 0 1px 2px rgba(27, 35, 51, .04), 0 6px 18px rgba(27, 35, 51, .05);
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; overflow-x: hidden; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
  }
  header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(27, 35, 51, .03);
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--mono);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.02em;
    margin-right: auto;
  }
  .brand-mark {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 3px 8px rgba(79, 110, 247, .26);
  }
  .toolbar { display: contents; }
  button {
    font: inherit;
    font-size: 13px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color .15s, background .15s, color .15s, transform .1s, box-shadow .15s;
  }
  button:hover { border-color: #c9d2e8; background: #fbfcff; }
  button:active { transform: translateY(1px); }
  button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(79, 110, 247, .24);
  }
  button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
  button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
  .status {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 96px;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
  }
  .dot { width: 8px; height: 8px; border-radius: 50%; background: #d0a020; flex-shrink: 0; }
  .dot.ready { background: var(--ok); }
  .dot.busy { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
  @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

  main { flex: 1; display: flex; min-height: 0; gap: 10px; padding: 10px; }
  .pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .pane-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--panel-soft);
    flex-shrink: 0;
  }
  .pane-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
  .pane-dot.out-dot { background: var(--ok); }
  .pane-label { color: var(--text); font-weight: 600; }
  .pane-badge {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 3px 9px;
    border-radius: 999px;
  }
  #editor { flex: 1; min-height: 0; }
  .cursor-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    min-height: 44px;
    border-top: 1px solid var(--border);
    background: var(--panel-soft);
    flex-shrink: 0;
  }
  .cursor-pos { font-family: var(--mono); font-size: 11px; color: var(--muted); }
  .cursor-controls { display: flex; gap: 6px; }
  .icon-btn {
    width: 36px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
  }
  .icon-btn:hover { background: var(--accent-soft); border-color: #c9d2e8; color: var(--accent); }
  .icon-btn:active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .icon-btn svg { display: block; }
  #output {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 14px 16px;
    background: var(--panel);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
  }
  #output .err {
    color: var(--err);
    background: var(--err-soft);
    border-left: 3px solid var(--err);
    padding: 4px 11px;
    margin: 0;
  }
  #output .err:first-child { border-radius: 0 8px 0 0; padding-top: 9px; }
  #output .err:last-child { border-radius: 0 0 8px 0; padding-bottom: 9px; }
  #output img {
    display: block;
    max-width: 100%;
    margin: 12px 0 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(27, 35, 51, .08);
  }
  #output .empty {
    color: var(--muted);
    background: var(--panel-soft);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    line-height: 1.6;
  }
  footer {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .05em;
    padding: 7px 18px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .7);
  }
  kbd { background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; font-size: 11px; }

  /* 手机 / 窄屏：编辑器与输出上下排列，长代码自动折行，按钮区可横向滑动 */
  @media (max-width: 768px) {
    header { gap: 8px; padding: 8px 10px; }
    .brand { order: 0; font-size: 16px; }
    .brand-mark { width: 22px; height: 22px; border-radius: 7px; }
    .status { order: 1; min-width: 0; max-width: 58%; font-size: 11px; flex: 0 1 auto; padding: 4px 9px; }
    #status-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .toolbar {
      display: flex;
      order: 2;
      flex: 0 0 100%;
      gap: 8px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .toolbar::-webkit-scrollbar { display: none; }
    button { font-size: 12px; padding: 7px 11px; }
    main { flex-direction: column; gap: 8px; padding: 8px; }
    .pane { flex: 1 1 50%; border-radius: 12px; }
    .pane-title { padding: 8px 12px; }
    #output { font-size: 12px; padding: 12px; }
    .cursor-bar { min-height: 48px; padding: 5px 8px; }
    .icon-btn { width: 42px; height: 38px; }
    .cursor-pos { font-size: 11px; }
    footer { font-size: 10px; padding: 5px 12px; }
  }
