/* ORION Build: laid out like the Caffeine builder (sidebar · chat · stage), ORION's dark palette. */
:root {
  --bg: #0b0b0c; --side: #131314; --panel: #161618; --raise: #1f1f22; --raise-2: #2a2a2e;
  --line: #26262a; --text: #ececee; --muted: #9a9aa2; --faint: #6c6c74;
  --blue: #3b82f6; --blue-hi: #5b9bff; --cyan: #5fd4ff; --ok: #3ddc97; --warn: #f5b454; --bad: #ff6b7a;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
input, textarea, select { font: inherit; color: var(--text); }
.spacer { flex: 1; }
.orb { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--cyan); box-shadow: 0 0 12px rgba(95, 212, 255, .6), inset 0 0 0 3px transparent; position: relative; }
.orb::after { content: ""; position: absolute; inset: 2.5px; border-radius: 50%; background: var(--cyan); }
.orb.big { width: 44px; height: 44px; border-width: 3px; }
.orb.big::after { inset: 11px; }

.btn-blue { background: var(--blue); color: #fff; border-radius: 12px; padding: 11px 16px; font-weight: 600; }
.btn-blue:hover { background: var(--blue-hi); }
.btn-quiet { background: var(--raise); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; }
.btn-quiet.small { padding: 5px 12px; font-size: 13px; border-radius: 999px; }
.wide { width: 100%; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--muted); }
.icon-btn:hover { background: var(--raise); color: var(--text); }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--raise); border: 1px solid var(--line); font-weight: 500; }
.pill:hover:not(:disabled) { background: var(--raise-2); }
.pill.live { color: var(--ok); border-color: rgba(61, 220, 151, .35); }

/* ---------- film + door ---------- */
.film { position: fixed; inset: 0; background: #000; z-index: 20; }
.film video, .door-bg { display: block; width: 100%; height: 100%; object-fit: cover; }
.film-skip { position: absolute; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); color: rgba(255, 255, 255, .75); border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; padding: 7px 16px; font-size: 13px; backdrop-filter: blur(8px); }
.door { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(900px 600px at 50% 30%, rgba(20, 60, 100, .35), transparent 70%), rgba(0, 0, 0, .55); z-index: 10; }
.door-card { width: min(430px, 100%); background: rgba(19, 19, 20, .86); border: 1px solid var(--line); border-radius: 22px; padding: 30px 28px; display: grid; gap: 14px; backdrop-filter: blur(22px); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.door-mark { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; font-size: 17px; }
.door-mark b { font-weight: 500; color: var(--muted); }
.door-card h1 { margin: 6px 0 0; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
.door-sub { margin: 0; color: var(--muted); }
.door-note { margin: 0; color: var(--faint); font-size: 13px; }
.door-field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.door-field input { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.door-msg { margin: 0; min-height: 1.2em; color: var(--warn); font-size: 13px; }

/* ---------- builder layout ---------- */
.app { display: grid; grid-template-columns: 290px minmax(340px, 1fr) minmax(380px, 1.45fr); height: 100vh; height: 100dvh; }
.app.collapsed { grid-template-columns: 0 minmax(340px, 1fr) minmax(380px, 1.45fr); }
.app.collapsed .side { visibility: hidden; }
.only-collapsed { display: none; }
.app.collapsed .only-collapsed { display: grid; }
.app.nochat { grid-template-columns: 290px 0 1fr; }
.app.collapsed.nochat { grid-template-columns: 0 0 1fr; }
.app.nochat .chat { visibility: hidden; }
.app.market-open { grid-template-columns: 290px 1fr; }
.app.collapsed.market-open { grid-template-columns: 0 1fr; }
.app.market-open .chat, .app.market-open .stage { display: none; }

.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px; gap: 10px; min-height: 0; overflow: hidden; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 8px; }
.side-title { font-size: 19px; font-weight: 600; }
.side-workspace { display: flex; align-items: center; padding: 10px 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.side-nav { display: grid; gap: 2px; }
.side-item { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 12px; text-align: left; }
.side-item:hover, .side-item.active { background: var(--raise); }
.side-item svg { color: var(--muted); }
.side-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; color: var(--muted); margin: 6px 0; }
.side-search input { flex: 1; background: none; border: 0; outline: 0; padding: 10px 0; }
.side-lists { flex: 1; overflow: auto; min-height: 0; }
.side-lists summary { list-style: none; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13.5px; padding: 12px 12px 6px; cursor: pointer; }
.side-lists summary::-webkit-details-marker { display: none; }
.side-lists summary::after { content: ""; width: 7px; height: 7px; border-left: 1.6px solid var(--muted); border-top: 1.6px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
.side-lists details:not([open]) summary::after { transform: rotate(225deg); }
.app-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px; border-radius: 12px; text-align: left; }
.app-row:hover { background: var(--raise); }
.app-row.active { background: var(--raise-2); }
.app-row .tile { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #b8e35f, #72c14a); display: grid; place-items: center; }
.app-row .tile::after { content: ""; width: 10px; height: 10px; background: linear-gradient(#1b3d0e 0 0) 0 0 / 4px 4px no-repeat, linear-gradient(#1b3d0e 0 0) 6px 0 / 4px 4px no-repeat, linear-gradient(#1b3d0e 0 0) 0 6px / 4px 4px no-repeat, linear-gradient(#1b3d0e 0 0) 6px 6px / 4px 4px no-repeat; }
.app-row svg { color: var(--muted); }
.app-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-empty { color: var(--faint); font-size: 13px; padding: 4px 12px 8px; }
.side-foot { display: grid; gap: 10px; position: relative; }
.quota-pill { background: var(--blue); color: #fff; text-align: center; border-radius: 999px; padding: 10px; font-weight: 500; }
.quota-pill.out { background: var(--raise-2); color: var(--warn); }
.account { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 12px; text-align: left; }
.account:hover { background: var(--raise); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #6f7c8a 40%, #1a1d22 75%); }
.account-text { flex: 1; display: grid; line-height: 1.25; }
.account-text small { color: var(--muted); }
.menu { position: absolute; bottom: 56px; left: 0; right: 0; background: var(--raise); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.menu button { width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; }
.menu button:hover { background: var(--raise-2); }

/* ---------- chat column ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.chat-bar, .stage-bar { height: 64px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px 0 22px; }
.title-btn { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; padding: 6px 8px; border-radius: 10px; min-width: 0; }
.chat-bar > .drop:first-of-type { min-width: 0; flex: 0 1 auto; }
.title-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-btn:hover { background: var(--raise); }
.version { background: none; border: 0; font-size: 17px; padding: 6px; border-radius: 10px; cursor: pointer; -webkit-appearance: none; appearance: none; text-align: center; }
.version:hover { background: var(--raise); }
.bar-icon { display: grid; place-items: center; color: var(--muted); padding: 0 4px; }
.thread { flex: 1; overflow: auto; padding: 12px 22px 24px; display: flex; flex-direction: column; gap: 18px; }
.hello { color: var(--muted); margin-top: 18vh; text-align: center; padding: 0 16px; }
.hello h2 { color: var(--text); font-size: 24px; margin: 0 0 8px; letter-spacing: -.01em; }
.date-chip { align-self: center; background: var(--raise); color: var(--muted); font-size: 13px; padding: 3px 12px; border-radius: 999px; }
.u-msg { align-self: flex-end; max-width: 80%; background: var(--raise-2); padding: 11px 18px; border-radius: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.o-msg { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.o-msg.working { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.o-msg.working::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 1.2s ease-in-out infinite; }
.o-msg.failed { color: var(--warn); }
.o-msg + .u-msg { margin-top: 10px; }
.o-divider { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
@keyframes pulse { 50% { opacity: .3; } }
.composer { margin: 0 22px 20px; background: var(--raise); border: 1px solid var(--line); border-radius: 22px; padding: 14px 14px 10px 20px; }
.composer textarea { width: 100%; background: none; border: 0; outline: 0; resize: none; max-height: 220px; font-size: 16px; line-height: 1.45; }
.composer textarea::placeholder { color: var(--faint); }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.dev-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.dev-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dev-state.ok::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dev-state.off::before { background: var(--warn); }
.ask-msg { color: var(--warn); font-size: 13px; }
.send { width: 42px; height: 42px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; }
.send:hover:not(:disabled) { background: var(--blue-hi); }
.send svg { stroke-width: 2.2; }

/* ---------- stage (preview / ORION Dev 1 / code) ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar { padding-left: 12px; }
.seg { display: inline-flex; background: var(--raise); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 9px; color: var(--muted); }
.seg button[aria-selected=true] { background: var(--raise-2); color: var(--text); }
.seg button:not([aria-selected=true]) .seg-label { display: none; }
.seg button.busy { color: var(--cyan); }
.eye { width: 44px; height: 44px; border-radius: 50%; background: #1d3a78; color: #9dc0ff; display: grid; place-items: center; }
.eye[aria-disabled=true] { opacity: .4; pointer-events: none; }
.stage-body { flex: 1; min-height: 0; padding: 0 16px 16px 12px; }
.view { height: 100%; position: relative; }
.frame { height: 100%; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.empty { position: absolute; inset: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); text-align: center; padding: 20px; }
.empty p { margin: 0; }
.feed { height: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: #0d0e10; padding: 14px 16px; font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, monospace; }
.line { white-space: pre-wrap; overflow-wrap: anywhere; padding: 1px 0; color: #c9ccd3; }
.line.orion { color: var(--cyan); font-weight: 600; margin-top: 8px; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; }
.line.command { color: #c6a4ff; }
.line.output, .line.verify { color: var(--faint); }
.line.error { color: var(--bad); }
.feed-empty { color: var(--faint); font-family: -apple-system, system-ui, sans-serif; }
.code { display: grid; grid-template-columns: 220px 1fr; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #0d0e10; }
.files { border-right: 1px solid var(--line); overflow: auto; padding: 8px; font-size: 13px; }
.files button { display: block; width: 100%; text-align: left; padding: 5px 8px; border-radius: 7px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files button:hover { background: var(--raise); color: var(--text); }
.files button.active { background: var(--raise-2); color: var(--text); }
.file-body { margin: 0; overflow: auto; padding: 14px 16px; font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, monospace; color: #d6d8de; white-space: pre; tab-size: 2; }

.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(380px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0, 0, 0, .6); }
.dlg h3 { margin: 0 0 12px; }
.dlg input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.dlg-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- menus, composer controls ---------- */
.drop { position: relative; }
.menu.down { top: calc(100% + 6px); bottom: auto; left: 0; right: auto; min-width: 190px; z-index: 30; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); }
.menu.down.right { left: auto; right: 0; }
.menu.up { bottom: calc(100% + 8px); top: auto; left: 0; right: auto; min-width: 260px; z-index: 30; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); }
.menu button b { display: block; font-weight: 500; }
.menu button small, .switch-row small, .danger small { display: block; color: var(--muted); font-size: 12.5px; }
.menu button.on { background: var(--raise-2); }
.menu-note { margin: 4px 8px 8px; color: var(--muted); font-size: 13px; }
.menu-link { display: block; margin: 0 8px 8px; color: var(--blue-hi); font-size: 13px; overflow-wrap: anywhere; }
.live-menu { min-width: 280px; }
.versions { max-height: 60vh; overflow: auto; min-width: 280px; }
.versions button { display: flex; gap: 10px; align-items: baseline; }
.versions button b { flex: none; min-width: 34px; }
.versions button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.versions .v-actions { display: flex; gap: 6px; padding: 6px 8px 4px; border-top: 1px solid var(--line); margin-top: 4px; }
.mode-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); padding: 6px 8px; border-radius: 10px; font-size: 14.5px; }
.mode-btn:hover { background: var(--raise-2); color: var(--text); }
.mode-btn svg { width: 16px; height: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:not(:empty) { margin-bottom: 8px; }
.chip-x { display: inline-flex; align-items: center; gap: 6px; background: var(--raise-2); border-radius: 10px; padding: 4px 6px 4px 4px; font-size: 12.5px; color: var(--muted); max-width: 100%; }
.chip-x img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.chip-x span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.chip-x button { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.chip-x button:hover { background: var(--line); color: var(--text); }
.chat > .dev-state { margin: -10px 26px 12px; }
.msg-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; color: var(--faint); font-size: 12px; }
.msg-actions button { color: var(--faint); padding: 0; display: grid; place-items: center; }
.msg-actions button:hover, .msg-actions button.on { color: var(--text); }
.msg-actions svg { width: 15px; height: 15px; }
.o-msg .ver { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.o-msg.answer { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; }

/* ---------- preview extras ---------- */
.frame.phone { width: 390px; max-width: 100%; margin: 0 auto; border-radius: 34px; border: 8px solid #26262a; }
.loading { position: absolute; inset: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); display: grid; place-content: center; justify-items: center; gap: 18px; color: var(--muted); }
.loading p { margin: 0; font-size: 14px; }
.dots { display: flex; align-items: center; gap: 14px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #d7d9df; opacity: .8; animation: dot 1.4s ease-in-out infinite; }
.dots i:nth-child(1) { width: 22px; height: 22px; } .dots i:nth-child(2) { width: 14px; height: 14px; }
.dots i:nth-child(2) { animation-delay: .1s; } .dots i:nth-child(3) { animation-delay: .2s; } .dots i:nth-child(4) { animation-delay: .3s; }
.dots i:nth-child(5) { animation-delay: .4s; } .dots i:nth-child(6) { animation-delay: .5s; } .dots i:nth-child(7) { animation-delay: .6s; }
@keyframes dot { 0%, 100% { transform: scale(1); opacity: .85; } 50% { transform: scale(.5); opacity: .35; } }
.toolbar { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; background: rgba(22, 22, 24, .92); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; backdrop-filter: blur(10px); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); z-index: 4; }
.toolbar button { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #d9dbe0; }
.toolbar button:hover, .toolbar button.on { background: var(--raise-2); }
.toolbar button.on { color: var(--blue-hi); }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.tb-handle { color: var(--faint); cursor: grab; display: grid; place-items: center; width: 22px; touch-action: none; }
.spec { height: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 22px 26px; line-height: 1.65; }
.spec h1, .spec h2, .spec h3 { line-height: 1.25; margin: 1.2em 0 .5em; }
.spec h1:first-child { margin-top: 0; }
.spec code { background: var(--raise-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.spec .muted { color: var(--muted); }
.code-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.code-main .feed { flex: 1; border: 0; border-radius: 0; }
.code-main .file-body { flex: 1; }
.feed-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--cyan); font-size: 13px; font-weight: 600; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 1.2s ease-in-out infinite; }
.files .dir { color: var(--faint); font-size: 12px; padding: 8px 8px 2px; }

/* ---------- market ---------- */
.market { overflow: auto; padding-bottom: 30px; }
.market-title { font-size: 19px; font-weight: 600; }
.market-sub { color: var(--muted); margin: 0 22px 18px; }
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; padding: 0 22px; }
.market-card { display: grid; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; color: var(--text); text-decoration: none; }
.market-card:hover { border-color: #3a3a40; background: var(--raise); }
.market-card small { color: var(--muted); }

/* ---------- dialogs ---------- */
.switch-row, .danger { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.switch-row input { width: 20px; height: 20px; accent-color: var(--blue); }
.btn-danger { background: rgba(255, 107, 122, .12); color: var(--bad); border: 1px solid rgba(255, 107, 122, .35); border-radius: 10px; padding: 7px 14px; }
.share-row { display: grid; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; min-width: 0; }

/* ---------- narrow screens: sidebar becomes a drawer, chat above the stage ---------- */
@media (max-width: 980px) {
  .app, .app.collapsed { grid-template-columns: 1fr; grid-template-rows: minmax(420px, 58dvh) minmax(420px, 70dvh); height: auto; min-height: 100dvh; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 5; box-shadow: 20px 0 60px rgba(0, 0, 0, .6); }
  .app.collapsed .side { visibility: hidden; }
  .only-collapsed { display: grid; }
  .app.nochat, .app.collapsed.nochat { grid-template-rows: 0 minmax(480px, 88dvh); }
  .app.market-open, .app.collapsed.market-open { grid-template-rows: auto; }
  .chat { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-bar { padding-left: 10px; }
  .thread { padding: 10px 16px 18px; }
  .composer { margin: 0 12px 14px; }
  .stage-body { padding: 0 12px 12px; }
  .stage-bar { padding: 0 12px; gap: 6px; }
  .pill-label { display: none; }
  #share { padding: 0 12px; }
  .code { grid-template-columns: 1fr; grid-template-rows: 140px 1fr; }
  .files { border-right: 0; border-bottom: 1px solid var(--line); }
}
