/* Interfaces and Kreator, the setup wizard and Program (linked right after styles.css in
   index.html). */

/* Interfaces (ADR 0025): the page in its sandboxed frame, button runs over it. */
.interface-page { position: relative; height: 100%; }
.interface-box { height: 100%; }
.interface-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--paper); }
/* What an agent just changed on the page, said over it (ADR 0053); it never moves the page. */
.change-note-layer.is-fixed { position: fixed; top: 64px; left: calc(50% + 112px); }
@media (max-width: 760px) { .change-note-layer.is-fixed { left: 50%; } }
.change-note-layer.is-sticky { position: sticky; top: 0; left: auto; transform: none; height: 0; width: 100%; max-width: none; display: flex; justify-content: center; overflow: visible; }
.change-note-layer { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6; width: max-content; max-width: calc(100% - 32px); pointer-events: none; }
.change-note { pointer-events: auto; display: flex; align-items: center; gap: 9px; padding: 8px 8px 8px 13px; border-radius: 999px; background: #333b2a; color: #edf2e1; border: 1px solid #566445; box-shadow: 0 8px 30px #2b39272b; font-size: 12px; transition: opacity 200ms ease, transform 200ms ease; }
/* Idle, it is out of sight but in the page (its live region keeps being heard). */
.change-note.is-idle { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.change-note.is-leaving { opacity: 0; transform: translateY(-4px); }
.change-note-text { overflow-wrap: anywhere; }
.change-note-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #c9d6b3; }
.change-note-close { flex: none; width: 22px; height: 22px; color: inherit; font-size: 15px; line-height: 1; border-radius: 50%; }
.change-note-close:hover { background: #ffffff1f; }
@media (prefers-reduced-motion: reduce) { .change-note { transition: none; } }
.run-layer { position: absolute; right: 22px; bottom: 22px; display: grid; gap: 10px; width: min(360px, calc(100% - 44px)); z-index: 5; }
.run-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; box-shadow: 0 8px 24px #292b2718; font-size: 12px; animation: q-enter 180ms ease-out both; }
.run-card.waiting { border-top: 2px solid var(--olive); }
.run-card.failed { border-top: 2px solid var(--danger); }
.run-card-head { display: flex; align-items: center; gap: 8px; }
.run-card-head strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.run-card-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.run-card-dot.going { background: var(--olive); animation: run-card-pulse 1.4s ease-in-out infinite; }
@keyframes run-card-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.run-card .run-card-line { color: var(--ink); }
.run-card-steps { list-style: none; margin: 6px 0 0; padding: 0; color: var(--muted); display: grid; gap: 2px; }
.run-card-steps li::before { content: "✓ " / ""; color: var(--olive); }
/* Its parts come and go with the run (the `hidden` attribute wins over their own display). */
.run-card [hidden] { display: none; }
.run-card .run-card-still { margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.run-card-hide { flex: none; width: 22px; height: 22px; font-size: 15px; line-height: 1; color: var(--muted); border-radius: 50%; }
.run-card-links a { color: var(--olive); }
@media (prefers-reduced-motion: reduce) { .run-card, .run-card-dot.going { animation: none; } }
.run-card p { margin-top: 6px; color: #5d6052; }
.run-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.run-card .args { margin-top: 6px; color: var(--muted); }
.run-card pre { white-space: pre-wrap; word-break: break-word; font-size: 11.5px; background: var(--paper); border-radius: 6px; padding: 6px 9px; margin: 4px 0 0; max-height: 160px; overflow: auto; }

/* Kreator (ADR 0025): the list, and one interface with its chat beside its live preview. */
.page-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.kr-new textarea, .kr-new input, .kr textarea, .kr input, .kr select { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; }
.kr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.kr-card { position: relative; color: inherit; }
.kr-card:hover { border-color: #b9c2a6; }
/* The whole card opens the interface; the move buttons sit above that link. */
.kr-card-link { color: inherit; }
.kr-card-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.kr-moves { position: relative; z-index: 1; display: inline-flex; gap: 2px; }
.kr-move:disabled { opacity: .35; cursor: default; background: none; }
.kr-tabs-title { margin: 28px 0 4px; font-size: 1.05rem; }
.kr-tabs-title + .muted { margin-bottom: 14px; }
.kr-card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; flex-wrap: wrap; }
.kr-card-head .muted { margin-left: auto; }
.kr-missing { color: var(--danger); }
.kr { height: 100%; display: flex; flex-direction: column; min-height: 0; padding: 18px 26px 0; }
.kr-head { flex-shrink: 0; margin-bottom: 12px; }
.kr-title-row { display: flex; align-items: baseline; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.kr-title { font: 30px var(--serif); letter-spacing: -.4px; }
.kr-screens { margin: 14px 0 0; }
.kr-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.kr-screen { flex: 1; min-height: 0; }
/* Prototyp (ADR 0038): the chat beside the stage, where the page renders at a device's width. */
.kr-prototype { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 18px; }
.kr-chat { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); padding-right: 18px; }
.kr-log { flex: 1; overflow: auto; padding: 4px 4px 14px 0; scrollbar-width: thin; }
.kr-log .chat-message.user { max-width: 100%; }
.kr-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 18px; border-top: 1px solid var(--line); }
.kr-compose textarea { flex: 1; resize: vertical; min-height: 60px; }
.kr-asked { display: flex; align-items: center; gap: 8px; padding: 8px 0 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.kr-asked q { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.kr-stage-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding-bottom: 18px; }
.kr-pane { overflow: auto; padding-bottom: 18px; }
.kr-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.kr-spacer { flex: 1; }
.kr-toolbar .btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.kr-intro { font-size: 12px; line-height: 1.6; padding: 6px 2px; max-width: 34ch; }
.kr-choice { display: inline-flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.kr-choice-btn { padding: 5px 10px; border-radius: 6px; font-size: 11.5px; color: var(--muted); }
.kr-choice-btn:hover { color: var(--ink); }
.kr-choice-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.kr-widgets { position: relative; }
.kr-widgets > summary { list-style: none; }
.kr-widgets > summary::-webkit-details-marker { display: none; }
.kr-widgets-menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 320px; display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px #292b271f; animation: q-pop 160ms var(--ease) both; }
.kr-widget { display: grid; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 7px; font-size: 12px; }
.kr-widget:hover, .kr-widget:focus-visible { background: var(--paper); }
.kr-widget .muted { font-size: 11px; }
.kr-samples-tag { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kr-live { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; }
.kr-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--olive); }
.kr-live-dot.pulse { animation: kr-pulse 900ms var(--ease); }
@keyframes kr-pulse { from { transform: scale(1.5); box-shadow: 0 0 0 0 #666e4e88; } to { transform: none; box-shadow: 0 0 0 9px #666e4e00; } }
.kr-stage { flex: 1; min-height: 0; display: flex; justify-content: center; padding: 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--paper) radial-gradient(circle, #d6d5cb 1px, transparent 1.2px) 0 0 / 18px 18px; }
.kr-device { width: 100%; max-width: 100%; flex-shrink: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper);
  box-shadow: 0 10px 30px #292b2712; transition: width 240ms var(--ease), border-radius 240ms var(--ease); }
.kr-device[data-device="tablet"] { width: 820px; border-radius: 16px; }
.kr-device[data-device="phone"] { width: 390px; border-radius: 26px; }
.kr-frame { height: 100%; }
.kr.kr-full { padding-top: 12px; }
.kr.kr-full .kr-head, .kr.kr-full .kr-chat { display: none; }
.kr.kr-full .kr-prototype { grid-template-columns: minmax(0, 1fr); }
@media (prefers-reduced-motion: reduce) { .kr-device { transition: none; } .kr-live-dot.pulse, .kr-widgets-menu { animation: none; } }
.kr-dataset .tiny, .kr-version .tiny { margin-top: 5px; }
.kr-missing-row { display: flex; gap: 10px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.kr-json { white-space: pre-wrap; word-break: break-word; font-size: 11px; background: var(--surface); border-radius: 6px; padding: 8px 10px; max-height: 320px; overflow: auto; margin-top: 8px; }
.kr-row { display: flex; gap: 10px; align-items: center; }
.kr-row input { flex: 1; }
.kr-check { border-color: var(--danger); }
.kr-check-list { margin: 8px 0 12px; padding-left: 18px; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
@media (max-width: 1100px) { .kr-prototype { grid-template-columns: 1fr; grid-template-rows: auto minmax(520px, 1fr); overflow: auto; } .kr-chat { border-right: 0; padding-right: 0; max-height: 50vh; } }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; border-radius: 4px; line-height: 1.5; padding: 2px 7px; background: #e3e6da; color: #5a5e50; white-space: nowrap; }
.tag.ok { background: #dbe5cf; color: #505f3e; }
.tag.warn { background: #e9e1d1; color: #6b583b; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.kr-new .field { margin-bottom: 10px; }

/* The setup wizard (ADR 0027): full screen, one step per screen, the auth card's look, wider. */
.lang-switch { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 14px; }
.wizard { min-height: 100dvh; display: grid; place-items: start center; padding: 40px 16px; }
.wizard-card { width: 100%; max-width: 720px; background: var(--surface); border: 1px solid #cbcdbd; border-radius: 12px; padding: 30px 32px; box-shadow: 0 4px 18px #393b2910; display: grid; gap: 16px; }
.wizard-card .wordmark { padding: 0; }
.wizard-dots { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.wizard-dots li { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.wizard-dots li.on { background: var(--olive); }
.wizard-step { display: grid; gap: 14px; }
.wizard-step h1 { font-size: 30px; }
.wizard-step h2 { font-size: 20px; }
.wizard-step .lead { color: var(--muted); }
.wizard-nav { display: flex; gap: 10px; justify-content: space-between; }
.wizard-nav [hidden] { display: none; }
.wizard-nav .btn.dark { margin-left: auto; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choice { flex: 1 1 200px; padding: 16px; border: 1px solid #cbcdbd; border-radius: 8px; background: var(--paper); font-size: 15px; text-align: left; }
.choice.active { border-color: var(--olive); background: var(--sage); box-shadow: 0 0 0 1px var(--olive); }
.choice-list { display: grid; gap: 10px; }
.choice-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 14px; border: 1px solid #cbcdbd; border-radius: 8px; background: var(--paper); cursor: pointer; }
.choice-card:has(input:checked) { border-color: var(--olive); background: var(--sage); }
.choice-card > span { display: grid; gap: 4px; }
.custom-fields { display: grid; gap: 8px; margin-top: 6px; }
.recovery-key { white-space: pre-wrap; word-break: break-all; background: var(--paper); border: 1px dashed #b9c0a6; border-radius: 6px; padding: 12px; font-size: 13px; }
.wizard-step .actions, .onboarding .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-top: 4px; }
@media (max-width: 640px) { .wizard-card { padding: 22px 16px; } }
.program-page textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.program-page .buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.program-page .buttons input { flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; }
.program-page h3 { font-size: 13px; margin: 18px 0 6px; }
