/* Look of the playground: a chat assistant with a side panel. Applies inside the component only. */
.pg {
  --bg: #faf9f5; --nav: #f5f4ed; --bubble: #f0eee6; --white: #ffffff;
  --hover: rgba(20, 20, 19, .05); --active: rgba(20, 20, 19, .08);
  --line: rgba(31, 30, 29, .12); --line-strong: rgba(31, 30, 29, .22);
  --ink: #141413; --ink-2: #3d3d3a; --muted: #73726c; --faint: #a3a199;
  --clay: #c96442; --clay-hover: #b5573a;
  --sans: "BIC Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "BIC Serif", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  position: fixed; inset: 0; z-index: 100; display: flex; overflow: hidden;
  background: var(--bg); color: var(--ink); font: 400 14px/1.4 var(--sans); letter-spacing: -.003em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
.pg *, .pg *::before, .pg *::after { box-sizing: border-box; }
:where(.pg) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: left; }
:where(.pg) a { color: inherit; text-decoration: none; }
.pg svg { flex: none; display: block; }
.pg [hidden] { display: none !important; }
.pg :focus-visible { outline: 2px solid var(--clay); outline-offset: 1px; }
.pg ::selection { background: rgba(201, 100, 66, .22); }
.pg * { scrollbar-width: thin; scrollbar-color: rgba(31, 30, 29, .18) transparent; }

/* ---------------------------------------------------------------- shared pieces */
.pg-icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); transition: background .12s, color .12s; }
.pg-icon-btn:hover { background: var(--hover); color: var(--ink); }
.pg-icon-btn.small { width: 28px; height: 28px; border-radius: 6px; }
.pg-btn { height: 30px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; font-size: 13px; color: var(--ink-2); transition: background .12s; white-space: nowrap; }
.pg-btn:hover { background: var(--hover); }
.pg-btn svg { color: var(--muted); }

/* ---------------------------------------------------------------- sidebar */
.pg-nav { flex: none; width: 272px; display: flex; flex-direction: column; background: var(--nav); border-right: 1px solid var(--line); padding: 8px; transition: margin-left .2s ease; }
.pg[data-nav="closed"] .pg-nav { margin-left: -272px; }
.pg-nav-top { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 2px 0 8px; margin-bottom: 8px; }
.pg-brand { display: flex; align-items: center; gap: 9px; font: 500 19px/1 var(--serif); letter-spacing: -.01em; color: var(--ink); }
.pg-brand img { width: 22px; height: 22px; }
.pg-nav-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 34px; padding: 0 8px; border-radius: 8px; font-size: 14px; color: var(--ink); transition: background .12s; }
.pg-nav-item:hover { background: var(--hover); }
.pg-nav-item svg { color: var(--ink-2); }
.pg-nav-item .pg-ext { margin-left: auto; color: var(--faint); opacity: 0; transition: opacity .12s; }
.pg-nav-item:hover .pg-ext { opacity: 1; }
.pg-new { font-weight: 500; }
.pg-plus { width: 22px; height: 22px; margin: 0 -3px; display: grid; place-items: center; border-radius: 50%; background: var(--clay); color: #fff; transition: transform .15s, background .12s; }
.pg-plus svg { color: #fff; }
.pg-new:hover .pg-plus { background: var(--clay-hover); transform: rotate(90deg) scale(1.05); }
.pg-recents { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 14px -8px 0; padding: 0 8px 8px; }
.pg-label { position: sticky; top: 0; z-index: 1; background: var(--nav); padding: 6px 8px; font-size: 12px; color: var(--muted); }
.pg-recent { display: block; width: 100%; height: 32px; padding: 0 8px; border-radius: 8px; font-size: 13.5px; line-height: 32px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .12s; }
.pg-recent:hover { background: var(--hover); }
.pg-recent[aria-current="true"] { background: var(--active); color: var(--ink); }
.pg-account { position: relative; flex: none; margin: 0 -8px -8px; padding: 6px 8px; border-top: 1px solid var(--line); }
.pg-account-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 8px; transition: background .12s; }
.pg-account-btn:hover, .pg-account-btn[aria-expanded="true"] { background: var(--hover); }
.pg-avatar { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--ink-2); color: var(--bg); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.pg-account-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pg-account-text b { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-account-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-account-btn > svg { color: var(--muted); }

/* account menu */
.pg-menu { position: absolute; left: 8px; bottom: calc(100% - 2px); width: 300px; padding: 6px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(20, 20, 19, .12), 0 2px 6px rgba(20, 20, 19, .05); z-index: 20; }
.pg-menu-label { padding: 6px 8px 4px; font-size: 12px; color: var(--muted); }
.pg-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 8px; transition: background .12s; }
.pg-menu-item:hover { background: var(--hover); }
.pg-menu-item span { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pg-menu-item b { font-size: 13.5px; font-weight: 500; }
.pg-menu-item small { font-size: 12px; color: var(--muted); }
.pg-menu-item svg { color: var(--clay); visibility: hidden; }
.pg-menu-item[aria-checked="true"] svg { visibility: visible; }
.pg-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px -6px; }
.pg-menu-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; font-size: 13.5px; }
.pg-menu-note { padding: 4px 8px 6px; font-size: 12px; line-height: 1.45; color: var(--muted); }

/* segmented control (theme, views) */
.pg-seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--bubble); border-radius: 9px; }
.pg-seg button { height: 26px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: 7px; font-size: 13px; color: var(--muted); white-space: nowrap; transition: color .12s, background .12s; }
.pg-seg button:hover { color: var(--ink); }
.pg-seg button[aria-pressed="true"] { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 20, 19, .1), 0 0 0 .5px rgba(20, 20, 19, .06); }

/* ---------------------------------------------------------------- conversation */
.pg-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.pg-top { flex: none; height: 48px; display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.pg-open-nav { display: none; }
.pg[data-nav="closed"] .pg-open-nav { display: grid; }
.pg-title { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 6px; font-size: 14px; font-weight: 500; }
.pg-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-badge { flex: none; font-style: normal; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: .01em; }
.pg-top-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.pg-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.pg-thread { max-width: 46rem; margin: 0 auto; padding: 12px 24px 40px; display: flex; flex-direction: column; gap: 22px; }
.pg-user { align-self: flex-end; max-width: 85%; padding: 10px 16px; background: var(--bubble); border-radius: 16px; font-size: 15px; line-height: 1.5; color: var(--ink); overflow-wrap: anywhere; }
.pg-assistant { padding: 0 4px; }
.pg-assistant p { margin: 0 0 12px; font: 400 16px/1.62 var(--serif); color: var(--ink); letter-spacing: 0; }
.pg-card { display: flex; align-items: center; gap: 12px; width: min(100%, 26rem); margin-top: 14px; padding: 10px 14px 10px 10px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(20, 20, 19, .03); transition: border-color .15s, box-shadow .15s, background .15s; }
.pg-card:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px rgba(20, 20, 19, .07); }
.pg-card-icon { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; background: var(--bubble); border: 1px solid var(--line); color: var(--muted); }
.pg-card-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pg-card-text b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-card-text small { font-size: 12.5px; color: var(--muted); }
.pg-card-open { flex: none; font-size: 12px; color: var(--faint); opacity: 0; transition: opacity .15s; }
.pg-card:hover .pg-card-open { opacity: 1; }
.pg-card[aria-current="true"] { border-color: var(--line-strong); background: #fdfcfa; }
.pg-card[aria-current="true"] .pg-card-icon { background: rgba(201, 100, 66, .1); border-color: rgba(201, 100, 66, .25); color: var(--clay); }
.pg-actions { display: flex; gap: 2px; margin: 8px 0 0 -6px; }
.pg-actions .pg-icon-btn { color: var(--faint); }
.pg-actions .pg-icon-btn:hover { color: var(--ink-2); }

/* composer */
.pg-composer-wrap { position: relative; flex: none; width: 100%; max-width: 46rem; margin: 0 auto; padding: 0 24px 10px; }
.pg-composer-wrap::before { content: ""; position: absolute; left: 0; right: 12px; bottom: 100%; height: 28px; background: linear-gradient(to bottom, rgba(250, 249, 245, 0), var(--bg)); pointer-events: none; }
.pg-composer { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px 10px 16px; background: var(--white); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 4px 24px rgba(20, 20, 19, .05), 0 1px 2px rgba(20, 20, 19, .03); transition: border-color .15s, box-shadow .15s; }
.pg-composer:focus-within { border-color: var(--line-strong); box-shadow: 0 6px 28px rgba(20, 20, 19, .08), 0 1px 2px rgba(20, 20, 19, .04); }
.pg-composer textarea { width: 100%; min-height: 24px; max-height: 160px; padding: 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); font: 400 15.5px/1.5 var(--sans); }
.pg-composer textarea::placeholder { color: var(--faint); }
.pg-composer-bar { display: flex; align-items: center; gap: 8px; margin-left: -6px; }
.pg-composer-bar .pg-icon-btn { border: 1px solid var(--line); }
.pg-model { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; padding: 0 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.pg-model i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.pg-send { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--clay); color: #fff; transition: background .12s, opacity .12s; }
.pg-send:hover { background: var(--clay-hover); }
.pg-send:disabled { opacity: .45; cursor: default; }
.pg-note { margin: 8px 0 0; text-align: center; font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- panel: the dashboard written by the model */
.pg-panel { flex: 1.45 1 0; min-width: 0; display: flex; flex-direction: column; margin: 8px 8px 8px 0; background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 2px 14px rgba(20, 20, 19, .05); overflow: hidden; }
.pg[data-panel="closed"] .pg-panel { display: none; }
.pg[data-wide="true"] .pg-main { display: none; }
.pg[data-wide="true"] .pg-panel { margin-left: 8px; }
.pg[data-wide="true"] .pg-wide-on, .pg[data-wide="false"] .pg-wide-off { display: none; }
.pg-panel-head { flex: none; height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 8px 0 10px; border-bottom: 1px solid var(--line); }
.pg-panel-title { min-width: 0; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-versions { flex: none; display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pg-versions button:disabled { opacity: .3; cursor: default; background: none; }
.pg-panel-actions { flex: none; margin-left: auto; display: flex; align-items: center; gap: 2px; }
.pg-back, .pg-short { display: none; }
.pg-panel-body { position: relative; flex: 1 1 auto; min-height: 0; }
.pg-view { position: absolute; inset: 0; overflow: auto; }
.bic-host-root { overflow: hidden; background: var(--bg); }
.bic-host-root iframe { width: 100%; height: 100%; border: 0; display: block; }
.pg-code { margin: 0; padding: 18px 22px 28px; min-width: max-content; font: 400 12.5px/1.7 var(--mono); color: var(--ink-2); tab-size: 2; white-space: pre; }
.pg-code .t { font-weight: 400; color: #a0452b; }
.pg-code .a { font-style: normal; color: #6b5b1e; }
.pg-code .s { font-style: normal; color: #2f6f4f; }
.pg-code .c { font-style: italic; color: var(--faint); }
.pg-hint { margin: 0; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--bg); font-size: 13px; line-height: 1.5; color: var(--muted); position: sticky; left: 0; }
.pg-view.prompt .pg-code { white-space: pre-wrap; min-width: 0; }

/* ---------------------------------------------------------------- dialog */
.pg-modal { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(20, 20, 19, .38); backdrop-filter: blur(2px); animation: pg-fade .15s ease; }
.pg-dialog { position: relative; width: min(31rem, 100%); max-height: 100%; overflow: auto; padding: 26px 26px 22px; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 64px rgba(20, 20, 19, .24); animation: pg-rise .18s ease; }
.pg-dialog h2 { margin: 0 32px 14px 0; font: 500 23px/1.25 var(--serif); letter-spacing: -.01em; }
.pg-dialog p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.pg-dialog p b { font-weight: 600; color: var(--ink); }
.pg-dialog .pg-close { position: absolute; top: 16px; right: 16px; }
.pg-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.pg-primary, .pg-secondary { flex: 1 1 auto; height: 38px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.pg a.pg-primary { background: var(--ink); color: var(--bg); }
.pg a.pg-primary:hover { background: #2b2a27; }
.pg-secondary { border: 1px solid var(--line-strong); }
.pg-secondary:hover { background: var(--hover); }
.pg-toast { position: absolute; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); padding: 8px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 13px; box-shadow: 0 8px 24px rgba(20, 20, 19, .2); animation: pg-rise .18s ease; }
@keyframes pg-fade { from { opacity: 0; } }
@keyframes pg-rise { from { opacity: 0; transform: translateY(6px); } }
.pg-toast { animation-name: pg-fade; }

/* ---------------------------------------------------------------- narrow screens: one pane at a time */
@media (max-width: 920px) {
  .pg-nav { position: absolute; inset: 0 auto 0 0; z-index: 30; }
  .pg[data-nav="open"] .pg-nav { box-shadow: 0 0 0 100vmax rgba(20, 20, 19, .28); }
  .pg-panel { position: absolute; inset: 0; z-index: 25; margin: 0; border: 0; border-radius: 0; }
  .pg-thread, .pg-composer-wrap { padding-left: 16px; padding-right: 16px; }
  .pg-menu { width: min(300px, calc(100vw - 32px)); }
  .pg .pg-wide-on, .pg .pg-wide-off { display: none; }  /* the dashboard already takes the whole screen */
  /* The header must fit a phone: a way back to the conversation first, then the views and the version */
  .pg-panel-head { gap: 4px; padding: 0 4px 0 2px; }
  .pg-panel-actions .pg-btn { padding: 0 7px; }
  .pg-versions .pg-icon-btn.small { width: 24px; }
  .pg .pg-back { display: inline-flex; flex: none; padding: 0 6px 0 2px; gap: 0; font-weight: 500; color: var(--ink); }
  .pg-panel-title, .pg-long, .pg [data-action="close-panel"].pg-icon-btn { display: none; }
  .pg-short { display: inline; }
  .pg-seg button { padding: 0 7px; }
  .pg[data-wide="true"] .pg-main { display: flex; }
}
@media (min-width: 921px) {
  .pg[data-panel="open"] .pg-thread, .pg[data-panel="open"] .pg-composer-wrap { max-width: 42rem; }
}
@media (max-width: 370px) {
  .pg-back-label { display: none; }  /* very small phones: the arrow alone */
}
