/* Studio — violet glass workspace in the language of the landing design. */
html, body { height: 100%; }
body { overflow: hidden; background: var(--bg); }
.mark { width: 26px; height: 26px; filter: drop-shadow(0 0 6px rgba(180, 107, 255, 0.55)); }

/* ---------- gate wall ---------- */
.gatewall {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; overflow: hidden;
  background: radial-gradient(60% 45% at 50% 0%, rgba(110, 40, 220, 0.32), transparent 70%), radial-gradient(40% 38% at 50% 70%, rgba(120, 40, 255, 0.18), transparent 70%), var(--bg);
}
.gatewall::before {
  content: ""; position: absolute; left: 50%; top: -560px; width: 1100px; height: 720px; transform: translateX(-50%); border-radius: 50%;
  border: 1px solid rgba(170, 110, 255, 0.35); box-shadow: 0 0 60px rgba(140, 60, 255, 0.25), inset 0 -40px 80px rgba(120, 40, 255, 0.18);
}
.gate-card {
  position: relative; text-align: center; max-width: 420px; padding: 34px 30px 30px; border-radius: 16px;
  background: linear-gradient(170deg, rgba(110, 50, 200, 0.36), rgba(30, 10, 64, 0.6)); border: 1px solid var(--line-2);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 30px 90px rgba(60, 10, 140, 0.45);
}
.gate-card .mark { width: 64px; height: 64px; margin: 0 auto 20px; filter: drop-shadow(0 0 14px rgba(190, 120, 255, 0.75)); }
.gate-card h1 { font: 500 28px/1.15 var(--display); letter-spacing: -0.005em; margin: 0 0 10px; }
.gate-card p { color: var(--ink-2); font-size: 14px; margin: 0 0 22px; }
.gate-card .btn { padding: 10px 18px; }

/* ---------- app shell ---------- */
.app { height: 100%; display: grid; grid-template-rows: 60px 1fr; }
.bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  margin: 10px 10px 0; padding: 0 8px 0 10px; border-radius: 14px; position: relative; z-index: 10;
  background: linear-gradient(180deg, rgba(60, 22, 110, 0.55), rgba(24, 8, 48, 0.55)); border: 1px solid var(--line-2);
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.bar-start, .bar-end { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-end { justify-self: end; }
.home { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none; }
.home:hover { background: rgba(255, 255, 255, 0.06); }

.project { position: relative; display: flex; align-items: center; min-width: 0; }
.project-name {
  width: clamp(110px, 18vw, 240px); min-width: 0; border: 1px solid transparent; background: transparent; padding: 6px 8px; border-radius: 8px;
  font: 400 14.5px/1 var(--display); letter-spacing: 0.005em; text-overflow: ellipsis;
}
.project-name:hover { background: rgba(255, 255, 255, 0.04); }
.project-name:focus { outline: none; background: var(--field); border-color: var(--line-2); }
.save-state { font-size: 11px; color: var(--muted); white-space: nowrap; }
.save-state.edited { color: #f6c87a; }

.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink-2); flex: none; transition: 0.2s; }
.icon-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); border-color: var(--line); }

.popover {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 30; width: 290px; padding: 6px; border-radius: 12px;
  background: rgba(18, 6, 38, 0.96); border: 1px solid var(--line-2);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(110, 40, 220, 0.2);
  transform-origin: top left; animation: pop 160ms var(--ease-out);
}
.popover.right { left: auto; right: 0; transform-origin: top right; width: 220px; }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.popover button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 13.5px; color: var(--ink-2); }
.popover button:hover { background: rgba(120, 50, 220, 0.22); color: var(--ink); }
.pop-new { color: #e0c8ff !important; font-weight: 500; }
.pop-new span { font-size: 18px; line-height: 1; color: var(--violet-2); }
.pop-list { max-height: 320px; overflow: auto; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.pop-item { display: flex; align-items: center; border-radius: 8px; }
.pop-item:hover, .pop-item.on { background: rgba(120, 50, 220, 0.22); }
.pop-item.on { box-shadow: inset 0 0 0 1px rgba(190, 140, 255, 0.45); }
.pop-item > button:first-child { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; gap: 2px; background: none !important; color: var(--ink); }
.pop-item b { font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-item small { font: 11px var(--mono); color: var(--muted); }
.pop-item .del { width: 32px; height: 32px; justify-content: center; padding: 0; color: var(--muted); opacity: 0; }
.pop-item:hover .del, .pop-item .del:focus-visible { opacity: 1; }
.pop-item .del:hover { color: var(--bad); background: rgba(255, 120, 160, 0.1) !important; }
.pop-head { padding: 9px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.pop-head small { display: block; color: var(--muted); font-size: 11.5px; }
.pop-head b { font-weight: 500; font-size: 12.5px; }

.seg { display: inline-flex; gap: 6px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 8px; font-size: 12.5px;
  color: var(--ink-2); background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.1); transition: 0.2s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { color: var(--ink); background: rgba(120, 50, 220, 0.28); border-color: rgba(190, 140, 255, 0.75); box-shadow: 0 0 18px rgba(150, 70, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12); }

.quota { font-size: 11px; color: var(--ink-2); padding: 4px 9px; border-radius: 6px; background: var(--field); border: 1px solid rgba(255, 255, 255, 0.07); white-space: nowrap; }
.quota.low { color: #f6c87a; border-color: rgba(246, 200, 122, 0.35); }
#codeToggle[aria-pressed="true"] { color: var(--ink); background: rgba(120, 50, 220, 0.28); border-color: rgba(190, 140, 255, 0.75); box-shadow: 0 0 18px rgba(150, 70, 255, 0.35); }
#exportBtn { background: linear-gradient(180deg, rgba(140, 70, 255, 0.55), rgba(70, 20, 150, 0.7)); border-color: rgba(210, 170, 255, 0.6); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 20px rgba(150, 70, 255, 0.35); }
.account { position: relative; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 35% 30%, #fff 0 6%, transparent 18%), conic-gradient(from 40deg, #ff6ae6, #7c4dff, #4fd8ff, #c13cff, #ff6ae6);
  box-shadow: 0 0 14px rgba(230, 100, 255, 0.55), inset -4px -6px 10px rgba(30, 0, 60, 0.55);
}

/* ---------- workspace ---------- */
.work { display: grid; grid-template-columns: minmax(320px, 380px) 1fr; gap: 10px; padding: 10px; min-height: 0; position: relative; }

/* chat */
.chat {
  display: flex; flex-direction: column; min-height: 0; position: relative; border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, rgba(28, 10, 52, 0.62), rgba(6, 2, 14, 0.82)); border: 1px solid var(--line);
  box-shadow: 0 -1px 0 rgba(200, 150, 255, 0.2), 0 0 60px rgba(110, 40, 220, 0.12);
}
.thread { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { max-width: 94%; font-size: 14px; line-height: 1.55; animation: msg-in 260ms var(--ease-out); white-space: pre-wrap; overflow-wrap: anywhere; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg.user {
  align-self: flex-end; padding: 10px 14px; border-radius: 12px 12px 4px 12px;
  background: linear-gradient(160deg, rgba(150, 80, 255, 0.55), rgba(80, 24, 170, 0.65)); border: 1px solid rgba(210, 170, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 24px rgba(140, 60, 255, 0.25);
}
.msg.agent { align-self: flex-start; padding: 12px 14px; border-radius: 12px 12px 12px 4px; background: rgba(30, 12, 60, 0.55); border: 1px solid rgba(255, 255, 255, 0.08); color: var(--ink-2); }
.msg.agent.error { background: rgba(90, 14, 40, 0.45); border-color: rgba(255, 120, 160, 0.35); color: #ffc4d3; }
.msg .typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.msg .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--violet-2); animation: dot 1.2s infinite ease-in-out; }
.msg .typing i:nth-child(2) { animation-delay: 0.15s; } .msg .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.progress { margin-top: 10px; font: 11.5px/1 var(--mono); color: var(--muted); }
.progress .track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); margin-top: 8px; overflow: hidden; }
.progress .track span { display: block; height: 100%; width: 35%; border-radius: 3px; background: linear-gradient(90deg, #9d4dff, #c56bff, #5fe6ff); box-shadow: 0 0 10px rgba(200, 110, 255, 0.9); animation: indet 1.3s var(--ease-out) infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.ver-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; white-space: normal; flex-wrap: wrap; }
.ver {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--ink-2); font: 500 11px/1 var(--mono);
}
button.ver:hover { color: var(--ink); border-color: var(--line-2); background: rgba(90, 36, 170, 0.35); }
.ver.current { color: var(--good); border-color: rgba(126, 240, 192, 0.35); background: rgba(126, 240, 192, 0.06); }
.ver .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.note { font-size: 12px; color: var(--muted); }

.empty { flex: 1; min-height: 0; overflow-y: auto; padding: 34px 18px 12px; }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--violet-2); margin: 0; }
.empty h2 { font: 500 30px/1.1 var(--display); letter-spacing: -0.005em; margin: 14px 0 10px; }
.empty-sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 20px; }
.starters { display: grid; gap: 8px; }
.starters button {
  display: block; width: 100%; text-align: left; padding: 11px 13px; border-radius: 10px; font-size: 12.5px; color: var(--muted);
  background: rgba(30, 12, 60, 0.45); border: 1px solid rgba(255, 255, 255, 0.08); transition: 0.25s;
}
.starters button b { display: block; color: var(--ink); font-weight: 500; font-size: 13.5px; margin-bottom: 2px; }
.starters button:hover { border-color: var(--line-2); background: rgba(90, 36, 170, 0.35); color: var(--ink-2); box-shadow: 0 0 24px rgba(140, 60, 255, 0.25); }
.starters button:active { transform: scale(0.98); }

.composer {
  margin: 8px 12px 12px; padding: 10px 10px 8px 14px; border-radius: 12px; background: var(--field); border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within { border-color: rgba(200, 160, 255, 0.75); box-shadow: 0 0 0 3px rgba(150, 70, 255, 0.18), 0 0 30px rgba(150, 70, 255, 0.25); }
.composer textarea { width: 100%; min-height: 24px; max-height: 200px; resize: none; border: 0; background: transparent; padding: 4px 0; font-size: 14.5px; line-height: 1.5; outline: none; }
.composer textarea::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { font-size: 10.5px; color: var(--muted); }
.send { margin-left: auto;
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none; color: #fff;
  background: linear-gradient(180deg, rgba(160, 90, 255, 0.9), rgba(90, 30, 190, 0.95)); border: 1px solid rgba(220, 180, 255, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 18px rgba(160, 80, 255, 0.55); transition: transform 0.15s var(--ease-out), box-shadow 0.2s, opacity 0.2s;
}
.send:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 28px rgba(180, 100, 255, 0.8); }
.send:active { transform: scale(0.92); }
.send:disabled { opacity: 0.4; cursor: not-allowed; }
.send .i-stop { display: none; }
.busy .send { background: #050208; border-color: rgba(255, 255, 255, 0.22); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.busy .send .i-send { display: none; }
.busy .send .i-stop { display: block; }

/* stage */
.stage {
  position: relative; min-width: 0; min-height: 0; display: grid; border-radius: 14px; overflow: hidden; isolation: isolate;
  background: radial-gradient(50% 50% at 50% 55%, rgba(130, 50, 240, 0.28), transparent 72%), #04010a; border: 1px solid var(--line);
}
.stage::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(170, 110, 255, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(170, 110, 255, 0.07) 1px, transparent 1px);
  background-size: 14px 14px;
  -webkit-mask: radial-gradient(60% 55% at 50% 50%, #000 30%, transparent 80%); mask: radial-gradient(60% 55% at 50% 50%, #000 30%, transparent 80%);
}
.stage-inner { grid-area: 1 / 1; display: grid; place-items: center; padding: 16px; min-height: 0; transition: padding 300ms var(--ease-out); }
.frame-wrap {
  position: relative; width: 100%; height: 100%; border-radius: 10px; overflow: hidden; background: #fff;
  border: 1px solid var(--line-2); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 80px rgba(110, 40, 220, 0.2);
  transition: width 380ms var(--ease-out), height 380ms var(--ease-out), border-radius 380ms;
}
.stage-inner[data-device="tablet"] .frame-wrap { width: min(100%, 820px); height: min(100%, 1100px); border-radius: 18px; }
.stage-inner[data-device="phone"] .frame-wrap { width: 390px; max-width: 100%; height: min(100%, 820px); border-radius: 34px; border: 8px solid #0d0518; box-shadow: 0 0 0 1px var(--line-2), 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 80px rgba(110, 40, 220, 0.3); }
#preview { width: 100%; height: 100%; border: 0; background: #fff; }
.building {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px; border-radius: 9px; font: 11.5px/1 var(--mono); color: var(--ink);
  background: rgba(18, 6, 38, 0.9); border: 1px solid var(--line-2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(150, 70, 255, 0.35); animation: msg-in 220ms var(--ease-out);
}
.spark { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 12%, #e2a8ff 25%, #9b3dff 65%, #5a14b8); box-shadow: 0 0 10px rgba(200, 110, 255, 0.9); animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.35); } }
.stage-empty { grid-area: 1 / 1; display: grid; place-content: center; justify-items: center; gap: 18px; color: var(--muted); font-size: 13.5px; pointer-events: none; }
.stage-empty p { margin: 0; }
.has-code .stage-empty { display: none; }
.stage:not(.has-code) .stage-inner { visibility: hidden; }
.kiln-art {
  width: 110px; height: 110px; border-radius: 22px; display: grid; place-items: center;
  background: linear-gradient(160deg, rgba(150, 90, 255, 0.28), rgba(40, 14, 80, 0.55)); border: 1px solid rgba(200, 160, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 60px rgba(120, 40, 255, 0.45);
}
.kiln-art span {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 6%, transparent 18%), conic-gradient(from 40deg, #ff6ae6, #7c4dff, #4fd8ff, #c13cff, #ff6ae6);
  box-shadow: 0 0 24px rgba(230, 100, 255, 0.8), inset -6px -8px 12px rgba(30, 0, 60, 0.6); animation: hue 8s linear infinite;
}
@keyframes hue { to { filter: hue-rotate(360deg); } }
.reload { position: absolute; top: 24px; right: 24px; background: rgba(18, 6, 38, 0.9); border-color: var(--line-2); opacity: 0; transition: opacity 160ms; }
.stage.has-code:hover .reload, .reload:focus-visible { opacity: 1; }

/* code drawer */
.code {
  position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(50%, 720px); z-index: 5; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, rgba(28, 10, 52, 0.94), rgba(6, 2, 14, 0.97)); border: 1px solid var(--line-2); color: #e7e1fb;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: -30px 0 80px rgba(0, 0, 0, 0.6), 0 0 80px rgba(110, 40, 220, 0.2);
  transform: translateX(104%); visibility: hidden; transition: transform 340ms var(--ease-out), visibility 0s 340ms;
}
.code-open .code { transform: none; visibility: visible; transition: transform 340ms var(--ease-out); }
.code-head { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); font-size: 12px; }
.code-head > .mono:first-child { padding: 5px 11px; border-radius: 7px; background: rgba(120, 50, 220, 0.28); border: 1px solid rgba(190, 140, 255, 0.75); box-shadow: 0 0 14px rgba(150, 70, 255, 0.3); }
.code-meta { flex: 1; color: #8f84ad; font-size: 11px; }
.editor { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.gutter { margin: 0; padding: 14px 10px 14px 14px; min-width: 52px; text-align: right; color: #5d5277; font-size: 12.5px; line-height: 1.62; overflow: hidden; user-select: none; }
#code { flex: 1; border: 0; outline: none; resize: none; background: transparent; color: inherit; padding: 14px 16px 14px 6px; font-size: 12.5px; line-height: 1.62; tab-size: 2; white-space: pre; overflow: auto; caret-color: var(--violet-2); }
#code::selection { background: rgba(163, 91, 255, 0.45); }

/* scrollbars */
.thread, .empty, #code, .pop-list { scrollbar-width: thin; scrollbar-color: rgba(176, 120, 255, 0.35) transparent; }

/* mobile tabs */
.tabs { display: none; }

@media (max-width: 1100px) {
  .seg button span, #codeToggle span, #exportBtn span { display: none; }
  .seg button, .bar-end .btn.sm { padding: 0 9px; height: 30px; }
}
@media (max-width: 860px) {
  .app { grid-template-rows: 56px 1fr auto; }
  .bar { grid-template-columns: 1fr auto; margin: 8px 8px 0; }
  .seg, #codeToggle, .save-state, .hint { display: none; }
  .work { grid-template-columns: 1fr; padding: 8px; }
  .work > * { grid-area: 1 / 1; }
  .chat, .stage, .code { display: none; }
  .work[data-view="chat"] .chat { display: flex; }
  .work[data-view="preview"] .stage { display: grid; }
  .work[data-view="code"] .code { display: flex; position: static; width: auto; transform: none; visibility: visible; }
  .stage-inner { padding: 10px; }
  .tabs {
    display: flex; gap: 6px; margin: 0 8px calc(8px + env(safe-area-inset-bottom)); padding: 6px; border-radius: 12px;
    background: linear-gradient(180deg, rgba(60, 22, 110, 0.55), rgba(24, 8, 48, 0.55)); border: 1px solid var(--line-2);
  }
  .tabs button { flex: 1; height: 38px; border-radius: 8px; border: 1px solid transparent; background: none; font-size: 13px; color: var(--ink-2); }
  .tabs button[aria-current="true"] { color: var(--ink); background: rgba(120, 50, 220, 0.28); border-color: rgba(190, 140, 255, 0.75); box-shadow: 0 0 18px rgba(150, 70, 255, 0.35); }
  .reload { opacity: 1; top: 18px; right: 18px; }
}

/* Clash Display runs tight at small sizes: open it up a touch */
.project-name { letter-spacing: 0.01em; }
.kiln-art svg { width: 56px; height: auto; overflow: visible; filter: drop-shadow(0 0 10px rgba(190, 120, 255, 0.8)) drop-shadow(0 0 24px rgba(95, 230, 255, 0.35)); animation: nexa-float 6s ease-in-out infinite; }
@keyframes nexa-float { 50% { transform: translateY(-5px); } }
