/* UI-26 coding space (#/code), public/code-space.js. Codex and Muse on the
   iPhone are the reference: big type, few words, rounded groups, a floating
   composer. One design for phone and desktop (rule zero). */

[data-page="code"] .content > .inner.code-space-view { max-width: 720px; margin: 0 auto; }
.code-space { display: flex; flex-direction: column; gap: var(--space-5); min-height: calc(100dvh - 150px); font-size: 17px; }
.code-muted { color: var(--ink-3); font-size: 16px; margin: var(--space-2) 0; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* Title switcher ("Code ⌄") */
[data-page="code"] .topbar h1 { position: relative; overflow: visible; }
.code-title { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap-min); padding: 0 10px; margin-left: -10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.code-title:hover { background: var(--hover-2, var(--panel-2)); }
.code-title-caret svg { width: 16px; height: 16px; color: var(--ink-3); }
.code-switcher { position: absolute; top: calc(100% + 6px); left: -10px; z-index: 60; min-width: 260px; max-width: calc(100vw - 32px); padding: 6px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); box-shadow: 0 18px 48px rgba(0,0,0,.28); font-size: 17px; font-weight: 400; }
.code-switcher-label { padding: 8px 12px 4px; color: var(--ink-3); font-size: 14px; }
.code-switcher :is(button, a) { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.code-switcher :is(button, a):is(:hover, :focus-visible) { background: var(--panel-2); outline: none; }
.code-switcher :is(button, a) > svg { width: 20px; height: 20px; flex: none; color: var(--ink-2); }
.code-switcher button > svg:last-child { margin-left: auto; color: var(--ink); }
.code-switcher-avatar { width: 28px; height: 28px; flex: none; display: grid; place-items: center; }
.code-switcher-avatar svg, .code-switcher-avatar img { width: 28px; height: 28px; }
.code-switcher-sep { height: 1px; margin: 6px 8px; background: var(--line); }

.code-search-btn { width: var(--tap-min); height: var(--tap-min); display: grid; place-items: center; border-radius: 999px; color: var(--ink); }
.code-search-btn svg { width: 22px; height: 22px; }
@media (max-width: 760px) { .code-search-btn { background: var(--panel-2); } :root:not([data-theme="light"]) .code-search-btn { background: #1c1c1c; } }
.code-search { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px; border-radius: 999px; background: var(--panel-2); color: var(--ink-3); }
.code-search[hidden] { display: none; }
.code-search svg { width: 20px; height: 20px; flex: none; }
.code-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font-size: 17px; outline: none; }

/* Cloud | Your computer */
.code-tabs { display: flex; gap: var(--space-2); }
.code-tabs button { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-3); font: inherit; font-size: 17px; cursor: pointer; }
.code-tabs button svg { width: 20px; height: 20px; }
.code-tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--ink); font-weight: 600; }
:root:not([data-theme="light"]) .code-tabs button[aria-selected="true"] { background: #2a2a2a; }
.code-tabs button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Rounded groups (Muse settings) */
.code-group { border-radius: 18px; background: var(--panel-2); overflow: hidden; }
:root:not([data-theme="light"]) .code-group { background: #1c1c1c; }
.code-env-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 8px 16px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; text-decoration: none; }
.code-env-row + .code-env-row { border-top: 1px solid var(--line); }
.code-env-row.is-link { cursor: pointer; }
.code-env-row.is-link:is(:hover, :focus-visible) { background: var(--hover-2, rgba(127,127,127,.08)); outline: none; }
.code-env-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; color: var(--ink-2); }
.code-env-icon > svg { width: 24px; height: 24px; }
.code-env-icon .integration-logo { width: 32px; height: 32px; }
.code-env-title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-env-chev { color: var(--ink-3); display: grid; }
.code-env-chev svg { width: 20px; height: 20px; }
.code-pill { flex: none; min-height: 40px; padding: 0 18px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-size: 16px; font-weight: 500; cursor: pointer; }
.code-pill:hover { background: var(--panel); }
.code-pill.is-solid { border-color: transparent; background: var(--ink); color: var(--bg); }
.code-pill:disabled { opacity: .5; cursor: default; }
@media (pointer: coarse) { .code-pill { min-height: var(--tap-min); } }
.code-status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 16px; white-space: nowrap; }
.code-status.is-on { color: var(--ink-2); }
.code-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--ink-3); }
.code-status.is-on .code-dot, .code-dot.is-on { background: var(--green); }

/* Recents */
.code-recents-head { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap-min); }
.code-recents-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.code-new { width: var(--tap-min); height: var(--tap-min); display: grid; place-items: center; color: var(--ink-2); }
.code-new svg { width: 22px; height: 22px; }
.code-list { list-style: none; margin: 0; padding: 0; }
.code-list li { display: flex; align-items: center; border-radius: 14px; }
.code-list li.is-selected { background: var(--panel-2); }
:root:not([data-theme="light"]) .code-list li.is-selected { background: #1c1c1c; }
.code-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 12px; border: 0; border-radius: 14px; background: transparent; color: var(--ink); font: inherit; font-size: 17px; text-align: left; cursor: pointer; }
.code-row:is(:hover, :focus-visible) { background: var(--panel-2); outline: none; }
.code-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-row-time { flex: none; color: var(--ink-3); font-size: 15px; }
.code-row-check svg { width: 20px; height: 20px; }
.code-row-open { width: var(--tap-min); height: var(--tap-min); flex: none; display: grid; place-items: center; border-radius: 12px; color: var(--ink-3); }
.code-row-open:hover { color: var(--ink); background: var(--panel-2); }
.code-row-open svg { width: 20px; height: 20px; }

/* "Ask …": a floating rounded composer */
.code-composer-dock { position: sticky; bottom: 0; z-index: 20; margin-top: auto; padding: var(--space-4) 0 calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--bg) 32%); }
.code-composer { display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 8px 20px; border: 1px solid var(--line-2); border-radius: 28px; background: var(--panel-2); box-shadow: 0 8px 28px rgba(0,0,0,.12); }
:root:not([data-theme="light"]) .code-composer { background: #1c1c1c; }
.code-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.code-composer textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 200px; padding: 8px 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 17px; line-height: 1.4; resize: none; outline: none; }
.code-composer textarea::placeholder { color: var(--ink-3); }
.code-send { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--ink); color: var(--bg); cursor: pointer; }
.code-send svg { width: 20px; height: 20px; }
.code-send:disabled { background: var(--line-2); color: var(--ink-3); cursor: default; }
@media (pointer: coarse) { .code-send { width: var(--tap-min); height: var(--tap-min); } }
.code-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 36px; margin-left: -8px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--panel); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; }
.code-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-chip svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }

/* "Set up your Mac" sheet, like Codex's "Set up Codex" */
.modal.dialog:has(.code-mac-sheet) { max-width: 440px; }
.code-mac-sheet { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); font-size: 17px; }
.code-mac-hero { display: grid; place-items: center; width: 72px; height: 72px; color: var(--ink); }
.code-mac-hero svg { width: 64px; height: 64px; stroke-width: 1.6; }
.code-mac-sheet h2 { margin: 0; font-size: 22px; font-weight: 600; }
.code-mac-lede { margin: 0; color: var(--ink-2); font-size: 17px; }
.code-mac-points { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); text-align: left; color: var(--ink-2); }
.code-mac-points li { display: flex; gap: 14px; align-items: flex-start; line-height: 1.4; }
.code-mac-points svg { width: 26px; height: 26px; flex: none; color: var(--ink); }
.code-mac-status { min-height: 1.4em; margin: 0; color: var(--ink-2); font-size: 16px; }
.code-mac-status:empty { display: none; }
.code-mac-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: var(--space-4); }
:root .modal .code-mac-actions .btn { width: 100%; height: 52px; min-height: 52px; border-radius: 999px; font-size: 17px; font-weight: 600; justify-content: center; }
.modal.dialog:has(.code-mac-sheet) .modal-head { border-bottom: 0; min-height: 0; padding-bottom: 0; }
.modal .code-mac-actions .btn:not(.primary) { background: transparent; border: 1px solid var(--line-3); }

@media (max-width: 760px) {
  .code-space { min-height: calc(100dvh - 120px - env(safe-area-inset-top, 0px)); }
  /* The title sits in the middle, like Codex. */
  [data-page="code"] > .main > .topbar h1 { flex: 1; display: flex; justify-content: center; font-size: 17px; }
  [data-page="code"] > .main > .topbar > .spacer { display: none; }
  .code-switcher { left: 50%; transform: translateX(-50%); }
  .code-tabs button { padding: 0 16px; }
  /* The Mac sheet rises from the bottom and fills the phone. */
  .modal-scrim:has(.code-mac-sheet) { align-items: flex-end; padding: 0; }
  .modal.dialog:has(.code-mac-sheet) { width: 100%; max-width: none; min-height: 88vh; border-radius: 24px 24px 0 0; display: flex; flex-direction: column; }
  .modal.dialog:has(.code-mac-sheet) .modal-head { border-bottom: 0; }
  .modal.dialog .dialog-body.code-mac-sheet { flex: 1; padding-bottom: calc(var(--dialog-pad) + env(safe-area-inset-bottom, 0px)); }
  .code-mac-actions { margin-top: auto; }
}

/* The chat header's "Cloud" / "Your Mac" for a code chat (runOnChip). */
.thread-run-on { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: var(--ink-3); font-size: 14px; line-height: 22px; white-space: nowrap; }
.thread-run-on svg { width: 15px; height: 15px; }
