  html, body { height: 100%; overflow: hidden; background: var(--app-bg); }

  body {
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* ===== TOP MENU BAR ===== */
  #menu-bar {
    display: flex;
    align-items: center;
    background: var(--title-bg);
    border-bottom: 1px solid var(--border);
    height: 30px;
    flex-shrink: 0;
    user-select: none;
    padding: 0 4px;
    -webkit-app-region: drag;
  }
  #menu-bar .menu-item {
    padding: 0 12px;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
    position: relative;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
    -webkit-app-region: no-drag;
  }
  #menu-bar .menu-item:hover { background: var(--scrollbar-thumb); color: var(--text-bright); }
  #menu-bar .menu-item:active { background: var(--sel-bg); }
  .menu-title {
    display: flex;
    align-items: center;
    padding: 0 14px 0 10px;
    border-right: 1px solid var(--border);
    margin-right: 4px;
    -webkit-app-region: no-drag;
  }
  .menu-title .gz-logo { --gz-size: 13px; }

  /* ===== MAIN LAYOUT ===== */
  #main {
    display: flex;
    flex: 1;
    overflow: hidden;
    transition: background-color 0.3s ease;
    background: var(--mode-bg);
  }

  #left-container {
    width: 220px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  #left-container #left-panel {
    flex: 1;
    height: 100%;
    overflow-y: scroll;
  }

  #right-container {
    flex-shrink: 0;
    display: flex;
    overflow: hidden;
  }

  #editor-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }

  #tab-container { flex-shrink: 0; }

  #editor-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }


  /* ===== MENU ACTION BUTTONS ===== */
  .menu-spacer { flex: 1; }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    margin-right: 6px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 11px;
    letter-spacing: 0.2px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.14s, border-color 0.14s, background 0.14s, transform 0.14s;
    -webkit-app-region: no-drag;
  }
  .menu-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
  .menu-btn:hover {
    color: var(--text-bright);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
  }
  .menu-btn:active { transform: translateY(1px); }
  .menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

  #btn-connect:hover  { border-color: var(--cyan);    background: color-mix(in srgb, var(--cyan) 14%, transparent);    color: var(--cyan); }
  #btn-feedback:hover { border-color: var(--magenta); background: color-mix(in srgb, var(--magenta) 14%, transparent); color: var(--magenta); }

  .menu-btn-primary {
    border-color: color-mix(in srgb, var(--orange) 45%, transparent);
    color: var(--orange);
  }
  .menu-btn-primary:hover {
    border-color: var(--orange);
    background: color-mix(in srgb, var(--orange) 16%, transparent);
    color: var(--orange);
  }

  /* Below this width the labels go and the icons carry the buttons. */
  @media (max-width: 1100px) {
    .menu-btn span { display: none; }
    .menu-btn { padding: 0 8px; }
  }

  /* ===== TABLET (max-width: 1024px) ===== */
  @media (max-width: 1024px) {
    #left-container { width: 180px; }
    #left-panel { font-size: 10px; }
    .cheat-key { font-size: 10px; min-width: 60px; }
    .cheat-desc { font-size: 9px; }
    .cheat-section { padding: 4px 8px; }
  }

  /* ===== MOBILE (max-width: 768px) ===== */
  @media (max-width: 768px) {
    #menu-bar {
      height: 36px;
      padding: 0 2px;
      overflow-x: auto;
      overflow-y: hidden;
      flex-wrap: nowrap;
      scrollbar-width: none;
    }
    #menu-bar::-webkit-scrollbar { display: none; }
    .menu-title { padding: 0 10px; flex-shrink: 0; }
    .menu-title .gz-logo { --gz-size: 12px; }
    .menu-item {
      padding: 0 10px;
      font-size: 11px;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .menu-spacer { flex: 0 0 auto; width: 0; }
    .menu-btn {
      height: 20px;
      padding: 0 7px;
      margin-right: 4px;
      flex-shrink: 0;
    }

    #left-container { display: none; }
    #main { flex-direction: column; }

    #editor-canvas { font-size: 12px; }
    #line-numbers { min-width: 36px; padding: 0 6px 0 4px; font-size: 11px; }

    #status-bar { height: 26px; font-size: 10px; }
    #mode-indicator { min-width: 90px; font-size: 10px; padding: 0 6px; }
    #status-file { font-size: 10px; padding: 0 4px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #status-pos { font-size: 10px; padding: 0 6px; }
    #status-filetype { display: none !important; }
    #message-line { min-height: 20px; max-height: 20px; font-size: 11px; padding: 0 8px; }

    #cmdline-bar { height: 24px; font-size: 12px; padding: 0 8px; }

    .help-grid { grid-template-columns: 1fr; }
    #help-overlay { padding: 16px; }
    #help-content { padding: 20px 16px; }
    .help-key { min-width: 70px; font-size: 10px; }

    #about-overlay, #vimrc-overlay { padding: 16px; }
    #about-content { border-radius: 8px; }
    .about-hero { padding: 24px 20px 18px; }
    .about-logo { font-size: 26px; }
    .about-info-grid { grid-template-columns: 1fr; }
    .about-body { padding: 16px 20px; }

    #vimrc-content { border-radius: 8px; }
    .vimrc-hero { padding: 24px 20px 18px; }
    .vimrc-hero-title { font-size: 24px; }
    #vimrc-code { font-size: 11px; padding: 12px 14px; }
    .vimrc-actions { padding: 12px 16px; flex-wrap: wrap; }
    .vimrc-btn { flex: 1; justify-content: center; min-width: 120px; }
  }

  /* ===== SMALL MOBILE (max-width: 480px) ===== */
  @media (max-width: 480px) {
    .menu-title { padding: 0 8px; }
    .menu-title .gz-logo { --gz-size: 11px; }
    .menu-item { font-size: 10px; padding: 0 8px; }
    .menu-btn { height: 18px; padding: 0 6px; }
    #menu-bar { height: 32px; }

    #editor-canvas { font-size: 11px; line-height: 18px; }
    #line-numbers { font-size: 10px; line-height: 18px; }

    #status-bar { height: 24px; }
    #mode-indicator { min-width: 70px; font-size: 9px; }
    #status-file { display: none; }

    .vimrc-hero-tags { gap: 4px; }
    .vimrc-tag { font-size: 9px; padding: 3px 8px; }
  }

  /* ===== REDUCED MOTION =====
     One global guard, so an animation added later is covered without
     having to remember this. The blinking cursor is left alone: it is a
     position indicator, not decoration. */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
      scroll-behavior: auto !important;
    }
  }

  /* ===== FOCUS =====
     Every interactive control gets a visible ring when reached by
     keyboard, which is the only way some of this UI can be reached. */
  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  [tabindex]:focus-visible,
  .palette-row:focus-visible,
  .tab-item:focus-visible,
  .cmd-opt:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }
