/* kev-browser-use demo. The console uses the site's tokens; the store inside the
   frame has its own small palette, like any real shop would. */

.kbu { --kbu-accent: var(--accent); --kbu-bar: color-mix(in srgb, var(--fg) 16%, transparent); container-type: inline-size; margin: 1.8rem 0 2.2rem; font-size: 0.95rem; line-height: 1.45; }
.kbu button, .kbu input, .kbu select { font: inherit; color: inherit; }
.kbu code, .kbu pre { font-family: var(--mono); }

/* ---------- stats ---------- */
.kbu-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 2px solid var(--fg); border-bottom: 1px solid var(--line); }
.kbu-hero { padding: 0.75rem 0.4rem 0.65rem 0; }
.kbu-hero + .kbu-hero { padding-left: 0.8rem; border-left: 1px solid var(--line); }
.kbu-hero b { display: block; font-family: var(--mono); font-weight: 400; font-size: clamp(1.55rem, 1rem + 2.4cqi, 2.35rem); letter-spacing: -0.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kbu-hero span { display: block; color: var(--soft); font-size: 0.8rem; margin-top: 0.2rem; }
.kbu-facts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.25rem 1.3rem; padding: 0.55rem 0 0.6rem; border-top: 1px solid var(--line); margin: 0; font-size: 0.8rem; }
.kbu-facts div { display: flex; gap: 0.4rem; }
.kbu-facts dt { color: var(--soft); }
.kbu-facts dd { margin: 0; font-family: var(--mono); font-size: 0.76rem; font-variant-numeric: tabular-nums; }

/* ---------- console ---------- */
.kbu-console { padding: 0.9rem 0 0.8rem; }
.kbu-path { margin: 0.9rem 0 0.4rem; }
.kbu-path-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.5rem; }
.kbu-path-head b { font-size: 0.9rem; }
.kbu-path-head span { color: var(--soft); font-size: 0.8rem; flex: 1; }
.kbu-chips { list-style: none; padding: 0 !important; margin: 0 !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.45rem; }
.kbu-chips li { margin: 0 !important; padding: 0 !important; }
.kbu-chips li::before, .kbu-chips li::marker { content: none; }
.kbu-chip { width: 100%; text-align: left; display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font-size: 0.82rem; background: none; cursor: pointer; }
.kbu-chip span { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); min-width: 1.1rem; }
.kbu-chip { flex-wrap: wrap; align-items: baseline; padding: 0.55rem 0.7rem; }
.kbu-chip b { font-size: 0.9rem; }
.kbu-chip-steps { flex: 1 1 100%; padding-left: 1.6rem; color: var(--soft); font-size: 0.74rem; line-height: 1.35; }
.kbu-chip:hover { border-color: color-mix(in srgb, var(--fg) 35%, transparent); }
.kbu-chip.next { border-color: var(--kbu-accent); }
.kbu-chip.next span { color: var(--kbu-accent); }
.kbu-chip.done { color: var(--soft); background: color-mix(in srgb, var(--fg) 5%, transparent); }
.kbu-chip.done span::after { content: " ✓"; }
.kbu-chip:disabled { opacity: 0.5; cursor: default; }
.kbu-goal-row { display: flex; align-items: center; gap: 0.7rem; }
.kbu-goal-label { color: var(--soft); font-size: 0.85rem; }
.kbu-goal { flex: 1; min-width: 0; padding: 0.55rem 0.8rem; border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent); border-radius: 6px; background: var(--bg); font-size: 1rem; }
.kbu-goal:focus { outline: 2px solid color-mix(in srgb, var(--kbu-accent) 55%, transparent); outline-offset: 1px; }
.kbu-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.kbu-btn { padding: 0.42rem 0.9rem; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent); background: var(--bg); font-size: 0.88rem; transition: background 160ms var(--ease), opacity 160ms var(--ease); }
.kbu-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.kbu-btn:disabled { opacity: 0.45; cursor: default; }
.kbu-primary { background: var(--fg); color: var(--bg) !important; border-color: var(--fg); min-width: 5.2rem; }
.kbu-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--fg) 85%, var(--bg)); }
.kbu-quiet { border-color: var(--line); color: var(--soft) !important; }
.kbu-select { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--soft); font-size: 0.82rem; margin-left: 0.3rem; }
.kbu-select select { padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); font-size: 0.82rem; }
.kbu-load { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin-top: 0.55rem; }
.kbu-load-btn { margin-left: auto; border-color: var(--kbu-accent); color: var(--kbu-accent) !important; }
.kbu-progress { flex: 1 1 10rem; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.kbu-progress-bar { height: 100%; width: 0; background: var(--kbu-accent); transition: width 200ms var(--ease); }
.kbu-status { color: var(--soft); font-size: 0.84rem; flex: 1 1 100%; }
.kbu-nogpu { border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1rem; background: var(--code-bg); }
.kbu-nogpu p { color: var(--soft); margin-top: 0.3rem; font-size: 0.88rem; }

/* ---------- stage ---------- */
.kbu-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.8rem; }
.kbu-panel { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); column-gap: 1.4rem; align-content: start; }
.kbu-panel > .kbu-panel-head { grid-column: 1 / -1; }
.kbu-panel > .kbu-said { grid-column: 1 / -1; }
@container (max-width: 560px) { .kbu-panel { grid-template-columns: minmax(0, 1fr); } }
.kbu-frame { border: 1px solid color-mix(in srgb, var(--fg) 16%, transparent); border-radius: 10px; overflow: hidden; background: var(--code-bg); box-shadow: 0 1px 2px oklch(0 0 0 / 0.04), 0 12px 32px -18px oklch(0 0 0 / 0.25); }
.kbu-chrome { display: flex; align-items: center; gap: 0.6rem; height: 2.2rem; padding: 0 0.55rem 0 0.75rem; border-bottom: 1px solid var(--line); }
.kbu-dots { display: flex; gap: 5px; }
.kbu-dots i { width: 9px; height: 9px; border-radius: 50%; background: color-mix(in srgb, var(--fg) 16%, transparent); }
.kbu-url { flex: 1; min-width: 0; font-family: var(--mono); font-size: 0.72rem; color: var(--soft); background: var(--bg); border-radius: 5px; padding: 0.18rem 0.55rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbu-url span { color: var(--fg); }
.kbu-inspect { font-size: 0.75rem !important; padding: 0.16rem 0.55rem; border-radius: 5px; border: 1px solid var(--line); color: var(--soft) !important; }
.kbu-inspect[aria-pressed="true"] { border-color: var(--kbu-accent); color: var(--kbu-accent) !important; }
.kbu-viewport { position: relative; overflow: hidden; background: #fff; }
.kbu-scaler { width: 920px; transform-origin: 0 0; }
.kbu-game { display: block; border: 0; background: #fff; }
.kbu-says { margin: 0.2rem 0 0.7rem !important; font-size: 0.85rem; font-style: italic; color: var(--fg); min-height: 1.3em; }
.kbu-t-kind { font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--kbu-accent); min-width: 4.6rem; }
.kbu-t-said { color: var(--soft); font-style: italic; }

/* ---------- overlay ---------- */
.kbu-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.kbu-ring { position: absolute; left: 0; top: 0; border: 2px solid var(--kbu-accent); border-radius: 8px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--kbu-accent) 18%, transparent); opacity: 0; transition: opacity 160ms var(--ease); }
.kbu-ring.show { opacity: 1; }
.kbu-tag { position: absolute; left: -2px; bottom: calc(100% + 4px); font-family: var(--mono); font-size: 0.7rem; line-height: 1; padding: 0.28rem 0.42rem; border-radius: 4px; background: var(--kbu-accent); color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kbu-cursor { position: absolute; left: 0; top: 0; width: 22px; height: 22px; opacity: 0; transition-property: transform, opacity; transition-timing-function: var(--ease); }
.kbu-cursor.show { opacity: 1; }
.kbu-cursor svg { width: 22px; height: 22px; fill: #111; stroke: #fff; stroke-width: 1.4; filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.35)); transition: transform 90ms var(--ease); transform-origin: 4px 2px; }
.kbu-cursor.press svg { transform: scale(0.82); }
.kbu-tip { position: absolute; left: 0; top: 0; max-width: 18rem; padding: 0.45rem 0.6rem; border-radius: 6px; background: #17181a; color: #ececea; font-size: 0.72rem; opacity: 0; transition: opacity 120ms var(--ease); box-shadow: 0 6px 20px rgb(0 0 0 / 0.25); }
.kbu-tip.show { opacity: 1; }
.kbu-tip code { display: block; font-size: 0.72rem; word-break: break-word; background: none !important; padding: 0 !important; color: inherit; }
.kbu-tip span { display: block; color: #a2a7ab; margin-top: 0.25rem; }
.kbu-inspecting .kbu-store [data-store] :is(a, button, input, select):hover { outline: 1.5px dashed var(--kbu-accent); outline-offset: 2px; }
.kbu-banner { position: absolute; left: 50%; top: 0.8rem; transform: translateX(-50%); width: min(92%, 30rem); pointer-events: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; padding: 0.7rem 0.9rem; border-radius: 10px; background: #17181a; color: #ececea; font-size: 0.88rem; box-shadow: 0 10px 30px rgb(0 0 0 / 0.3); }
.kbu-banner .kbu-btn { background: transparent; color: #ececea !important; border-color: #4a4d52; font-size: 0.8rem; padding: 0.25rem 0.6rem; }
.kbu-banner[hidden] { display: none; }
.kbu-timer { font-family: var(--mono); margin-left: auto; font-variant-numeric: tabular-nums; }
.kbu-race { display: flex; gap: 1.4rem; flex: 1 1 100%; font-size: 0.85rem; color: #a2a7ab; }
.kbu-race b { font-family: var(--mono); color: #fff; font-weight: 400; font-size: 1.05rem; }

/* ---------- panel ---------- */
.kbu-panel { border-top: 2px solid var(--fg); padding-top: 0.55rem; min-width: 0; }
.kbu-panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.kbu-phase { font-family: var(--mono); font-size: 0.74rem; color: var(--soft); }
.kbu-busy .kbu-phase::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--kbu-accent); animation: kbu-pulse 900ms ease-in-out infinite; vertical-align: 1px; }
@keyframes kbu-pulse { 50% { opacity: 0.25; } }
.kbu-sub { color: var(--soft); font-size: 0.76rem; margin: 0.7rem 0 0.3rem; }
.kbu-cand-note { color: var(--faint); }
.kbu-row { display: grid; grid-template-columns: minmax(0, 1fr) 3.4rem 2.2rem; align-items: center; gap: 0.45rem; padding: 0.2rem 0.3rem; border-radius: 4px; font-size: 0.74rem; }
.kbu-ops .kbu-row { grid-template-columns: 3.6rem minmax(0, 1fr) 2.2rem; }
.kbu-cand { grid-template-columns: minmax(0, 1fr) 2.2rem; row-gap: 0.15rem; padding: 0.22rem 0.35rem; }
.kbu-cand .kbu-name { grid-column: 1 / -1; }
.kbu-cand .kbu-name i { font-style: normal; color: var(--faint); }
.kbu-name { font-family: var(--mono); font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbu-track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.kbu-fill { display: block; height: 100%; width: 0; background: var(--kbu-bar); border-radius: 3px; transition: width 420ms var(--ease); }
.kbu-val { font-family: var(--mono); font-size: 0.7rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--soft); }
.kbu-row.on { background: color-mix(in srgb, var(--kbu-accent) 10%, transparent); }
.kbu-row.on .kbu-fill { background: var(--kbu-accent); }
.kbu-row.on .kbu-val, .kbu-row.on .kbu-name { color: var(--fg); }
.kbu-empty { color: var(--faint); font-size: 0.8rem; }
.kbu-sees { margin-top: 0.7rem; font-size: 0.78rem; }
.kbu-sees summary { cursor: pointer; color: var(--soft); }
.kbu-state { margin-top: 0.4rem; max-height: 16rem; overflow: auto; padding: 0.6rem; border-radius: 6px; background: var(--code-bg); border: 1px solid var(--line); font-size: 0.66rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

/* ---------- trail ---------- */
.kbu-trail { list-style: none; padding: 0 !important; margin: 0.9rem 0 0 !important; font-size: 0.82rem; max-height: 17rem; overflow-y: auto; overscroll-behavior: contain; }
.kbu-trail li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.5rem; padding: 0.35rem 0; border-top: 1px solid var(--line); margin: 0 !important; }
.kbu-trail code { font-size: 0.74rem; background: none !important; padding: 0 !important; }
.kbu-t-n { font-family: var(--mono); color: var(--faint); min-width: 1.1rem; }
.kbu-t-p { font-family: var(--mono); font-size: 0.72rem; color: var(--soft); }
.kbu-t-note { color: var(--soft); flex: 1 1 100%; padding-left: 1.6rem; font-size: 0.78rem; }
.kbu-end { color: var(--soft); }
.kbu-end.ok b { color: var(--kbu-accent); }

@container (max-width: 560px) {
  .kbu-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kbu-hero:nth-child(4) { padding-left: 0; border-left: 0; }
  .kbu-hero:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .kbu-select { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .kbu-fill, .kbu-cursor { transition: none !important; animation: none !important; }
}

/* ---------- one view: wide screens get the whole demo side by side ---------- */
.kbu-log-head { margin-top: 0.9rem !important; }
@media (min-width: 1180px) {
  .kbu { width: min(1320px, calc(100vw - 64px)); position: relative; left: 50%; transform: translateX(-50%); }
}
@container (min-width: 1000px) {
  .kbu-stats { grid-template-columns: repeat(5, auto) minmax(0, 1fr); column-gap: 0; }
  .kbu-hero { padding: 0.45rem 1.1rem 0.4rem 0; }
  .kbu-hero b { font-size: 1.55rem; }
  .kbu-hero span { font-size: 0.72rem; }
  .kbu-facts { grid-column: auto; border-top: 0; border-left: 1px solid var(--line); padding: 0.45rem 0 0.4rem 1rem; align-content: center; font-size: 0.74rem; gap: 0.1rem 1rem; }
  .kbu-console { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 0.8rem; row-gap: 0.45rem; padding: 0.7rem 0 0.6rem; }
  .kbu-console > .kbu-path, .kbu-console > .kbu-load { grid-column: 1 / -1; }
  .kbu-path { margin: 0; }
  .kbu-path-head { margin-bottom: 0.35rem; }
  .kbu-chips { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kbu-chip { padding: 0.4rem 0.55rem; }
  .kbu-chip-steps { padding-left: 0; }
  .kbu-load { min-height: 0; }
  .kbu-stage { grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); align-items: stretch; gap: 1rem; }
  /* the panel takes the game's height; the log scrolls inside it */
  .kbu-panel { display: flex; flex-direction: column; contain: size; overflow: hidden; }
  .kbu-trail { margin-top: 0.3rem !important; max-height: none; flex: 1 1 0; min-height: 4rem; }
}
