  :root {
    --sel-bg: #d3e3fd;
    --sel-underline: #0b57d0;
    --chip-bg: #e8eaf4;
    --num: #098658;
    --hero-name: #7b8cde;
    --chat-log-h: 84px;
    --chat-log-fade: 20px;
  }

  :root.dark {
    --sel-bg: #394f6b;
    --sel-underline: #8ab4f8;
    --chip-bg: #303134;
    --num: #81c995;
    --hero-name: #a9b6f0;
  }

  :root { --active-border: var(--link); }
  .gemini-tag { background: var(--link); }
  :root.dark .gemini-tag { background: var(--gemini); }

  body:not(.scene-ready) .frame,
  body:not(.scene-ready) .mouse { visibility: hidden; }

  .cell-row { grid-template-columns: minmax(0, 1fr); }

  .cell-code { overflow-x: visible; }
  .line {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .line > .hl { background: transparent; }
  .cell-row.added .line > .hl { background: var(--highlight); }

  .hero,
  .chat-chips {
    max-height: 0;
    opacity: 0;
    margin-top: -16px;
    overflow: hidden;
    transition: max-height 0.45s cubic-bezier(0.32, 0.72, 0, 1),
                margin-top 0.45s cubic-bezier(0.32, 0.72, 0, 1),
                padding-bottom 0.45s cubic-bezier(0.32, 0.72, 0, 1),
                opacity 0.3s ease;
  }
  .hero.show,
  .chat-chips.show {
    opacity: 1;
    margin-top: 0;
  }
  .hero.show { max-height: 140px; }
  .chat-chips.show { max-height: 80px; }
  .hero.gone,
  .chat-chips.gone { display: none; }

  .hero {
    text-align: center;
  }
  .hero.show { padding-bottom: 4px; }
  .hero-title,
  .hero-sub {
    font-size: clamp(22px, 4.4vw, 33px);
    line-height: 1.35;
    font-weight: 400;
    transition: color 0.3s ease;
  }
  .hero-hi { color: var(--gemini); }
  .hero-name { color: var(--hero-name); }
  .hero-sub { color: var(--text-secondary); }

  .chat-chips {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  .chat-chips button {
    appearance: none;
    background: none;
    border: 1px solid var(--toolbar-border);
    border-radius: 999px;
    cursor: pointer;
    color: var(--link);
    font: 500 14px "Google Sans", "Helvetica Neue", Arial, sans-serif;
    padding: 8px 16px;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.3s ease,
                border-color 0.3s ease;
  }
  .chat-chips button:hover,
  .chat-chips button.hover { background: var(--action-hover); }
  .chat-chips button.pressed { background: var(--surface-pressed); }

  body.is-card .hero { display: none; }
  body.is-card .chat { position: relative; }
  body.is-card .chat-chips {
    position: absolute;
    top: calc(100% + 16px);
    left: 0;
    right: 0;
    margin-top: 0;
  }

  .sel {
    background: var(--sel-bg);
    border-bottom: 2px solid var(--sel-underline);
    border-radius: 2px 2px 0 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
  }

  .sel-actions {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--toolbar-border);
    border-radius: 10px;
    box-shadow: var(--toolbar-shadow);
    padding: 4px;
    opacity: 0;
    transform: translateY(4px) scale(0.96);
    transform-origin: 50% 100%;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease,
                background-color 0.3s ease, border-color 0.3s ease,
                box-shadow 0.3s ease;
  }
  .sel-actions.show {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  .sel-actions button {
    appearance: none;
    border: 0;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font: 400 14px "Google Sans", "Helvetica Neue", Arial, sans-serif;
    padding: 6px 12px;
    border-radius: 999px;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.3s ease;
  }
  .sel-actions button:hover,
  .sel-actions button.hover { background: var(--surface-hover); }
  .sel-actions button.pressed { background: var(--surface-pressed); }
  .sel-actions .msym {
    font-size: 18px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
  }

  .chat-ai .chat-spark,
  .chat-ai .chat-spinner { margin-top: 0; }

  .chat-ai-text code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.92em;
    background: var(--chip-bg);
    border-radius: 4px;
    padding: 1px 5px;
    transition: background-color 0.3s ease;
  }

  .chat-log {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: var(--chat-log-h);
    overflow-y: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0,
      #000 min(var(--chat-log-fade), var(--chat-log-clip, 0px)));
    mask-image: linear-gradient(to bottom, transparent 0,
      #000 min(var(--chat-log-fade), var(--chat-log-clip, 0px)));
  }
  .chat-log::-webkit-scrollbar { display: none; }
  .chat-log:empty { display: none; }

  .chat-log .chat-msg {
    max-height: none;
    margin-top: 0;
    overflow: visible;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .chat-chip {
    display: none;
    min-width: 0;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px 6px;
    background: var(--chip-bg);
    border-radius: 10px;
    padding: 8px 12px;
    transition: background-color 0.3s ease;
  }
  .chat-chip.show { display: inline-flex; }
  .chat-chip .msym { font-size: 18px; }

  .chat-user-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }
  .chat-chip--sent { margin: 8px 0 0; }
  .chat-user--with-chip { align-items: flex-start; }

  .chat-input.has-chip {
    border-radius: 24px;
    padding-top: 10px;
  }
  .chat-chip-icon {
    flex: none;
    color: var(--link);
    font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 20;
    transition: color 0.3s ease;
  }
  .chat-chip-close {
    flex: none;
    color: var(--text);
    cursor: pointer;
    transition: color 0.3s ease;
  }
  .chat-chip-label {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
  }
  .mouse.dragging {
    transition: transform 0.06s linear, opacity 0.3s ease;
  }

  .tok-num { color: var(--num); transition: color 0.3s ease; }

  @media (max-width: 50rem) {
    .sel-actions button {
      font-size: clamp(11px, 2.8vw, 14px);
      padding: 5px 8px;
    }
    .sel-actions .msym { font-size: 16px; }
    .chat-chip-label { font-size: clamp(10.5px, 2.6vw, 13px); }
    .chat-chips { gap: 6px; }
    .chat-chips button {
      font-size: clamp(11px, 2.8vw, 14px);
      padding: 6px 12px;
    }
  }

  @media (max-width: 25rem) {
    .sel-actions button { padding-inline: 6px; }
    .sel-actions button .msym { display: none; }
    .chat-chip-label { max-width: 60vw; }
    .chat-chips button:not(#datasetChip) { display: none; }
  }

  @media (prefers-reduced-motion: reduce) {
    .sel, .sel-actions, .sel-actions button, .sel-actions .msym,
    .chat-chip, .chat-chip-label, .chat-chip .msym, .chat-input,
    .hero, .chat-chips, .hero-title, .hero-sub, .chat-chips button {
      transition-duration: 0s !important;
    }
  }
