/* =========================================================================
   URUK AI — monochrome engineered interface
   Layers: tokens → base → background → topbar → workspace → left → right
           → modals → responsive → motion
   ========================================================================= */

/* ---------------------------------- tokens */
:root {
  --black: #000000;
  --near: #050505;
  --panel: #090909;
  --panel-2: #0d0d0d;
  --raise: #111111;
  --raise-2: #161616;
  --charcoal: #1c1c1c;
  --line: #1f1f1f;
  --line-soft: #171717;
  --line-strong: #2e2e2e;

  --white: #ffffff;
  --off: #ededed;
  --text: #e6e6e6;
  --text-2: #a3a3a3;
  --text-3: #6f6f6f;
  --text-4: #4a4a4a;

  --focus: rgba(255, 255, 255, 0.75);
  --sel: rgba(255, 255, 255, 0.14);

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --sans: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;

  --topbar-h: 52px;
  --mnav-h: 0px;
  --left-w: 40%;

  --t-fast: 120ms cubic-bezier(.2, .8, .3, 1);
  --t-med: 220ms cubic-bezier(.2, .8, .3, 1);
  --t-slow: 420ms cubic-bezier(.16, 1, .3, 1);
}

/* ---------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--black);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .02em; }
.dim { color: var(--text-3); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: -60px; inset-inline-start: 12px; z-index: 999;
  background: var(--white); color: var(--black);
  padding: 8px 14px; border-radius: var(--r-sm);
  font-weight: 600; text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 12px; }

:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: var(--sel); color: var(--white); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #232323; border: 3px solid transparent; background-clip: padding-box; border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: #333; background-clip: padding-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* ---------------------------------- background layers */
.bg-layers { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.bg-grid {
  position: absolute; inset: -2px;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.028) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 96px 96px;
}
.bg-dots {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: .5;
}
.bg-binary {
  position: absolute; inset: 0;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 15px;
  letter-spacing: .34em;
  color: #fff;
  opacity: .032;               /* stays far below 5% */
  white-space: pre;
  overflow: hidden;
  user-select: none;
  padding: 6px 10px;
}
.bg-scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.018) 0 1px, transparent 1px 3px);
  opacity: .55;
}
.bg-radial {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.05), transparent 62%),
    radial-gradient(80% 70% at 50% 110%, rgba(255,255,255,.03), transparent 60%),
    linear-gradient(180deg, #000000 0%, #060606 45%, #000000 100%);
}
.bg-marks .mk {
  position: absolute;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .18em;
  color: rgba(255,255,255,.14);
}
.mk-tl { top: 8px; left: 10px; } .mk-tr { top: 8px; right: 10px; }
.mk-bl { bottom: 8px; left: 10px; } .mk-br { bottom: 8px; right: 10px; }

/* ---------------------------------- app shell */
.app {
  position: relative; z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
}

/* ---------------------------------- topbar */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10,10,10,.92), rgba(6,6,6,.92));
  backdrop-filter: blur(12px);
  min-width: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-center { display: flex; align-items: center; gap: 8px; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 6px; justify-content: flex-end; min-width: 0; }

.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark { width: 22px; height: 22px; color: var(--white); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .16em; color: var(--white); }
.brand-desc { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; color: var(--text-3); }
.brand-sep { width: 1px; height: 22px; background: var(--line); flex: none; }

.project-title { display: flex; align-items: center; gap: 2px; min-width: 0; }
.project-name {
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 5px 8px;
  font-size: 13px; font-weight: 500;
  color: var(--off);
  min-width: 60px; max-width: 220px; width: 100%;
  text-overflow: ellipsis;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.project-name:hover { border-color: var(--line); }
.project-name:focus { border-color: var(--line-strong); background: var(--panel-2); outline: none; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.02);
}
.status-text { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; color: var(--text-2); white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); flex: none; }
.status-dot[data-state="idle"] { background: #3d3d3d; }
.status-dot[data-state="ok"] { background: #d6d6d6; }
.status-dot[data-state="busy"] { background: var(--white); animation: pulse 1.2s ease-in-out infinite; }
.status-dot[data-state="error"] { background: #6a6a6a; box-shadow: 0 0 0 2px rgba(255,255,255,.08); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

.meta-chip {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  color: var(--text-3);
  background: rgba(255,255,255,.015);
  white-space: nowrap;
}
.meta-chip[data-dirty="true"] { color: var(--off); border-color: var(--line-strong); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--white);
  background: var(--white); color: var(--black);
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
  transition: transform var(--t-fast), background var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: var(--off); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--raise); border-color: #3a3a3a; }
.btn.danger { background: transparent; color: var(--off); border-color: #4a4a4a; }
.btn.danger:hover { background: var(--raise-2); border-color: #6a6a6a; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--raise); color: var(--white); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.sm { width: 26px; height: 26px; } .icon-btn.sm svg { width: 14px; height: 14px; }
.icon-btn.xs { width: 24px; height: 24px; padding: 0 5px; width: auto; min-width: 24px; }
.icon-btn.xs svg { width: 13px; height: 13px; }
.icon-btn.round { border-radius: 50%; border-color: var(--line-strong); }
.icon-btn.round:hover { border-color: #4a4a4a; }
.icon-btn.is-active { background: var(--raise-2); color: var(--white); }

.device-group {
  display: inline-flex; gap: 2px;
  padding: 2px; margin-inline-start: 4px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(255,255,255,.015);
}
.device-btn { width: 26px; height: 24px; }
.device-btn.is-active { background: var(--raise-2); color: var(--white); }

.avatar {
  width: 28px; height: 28px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--raise);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: var(--text-2);
}

/* ---------------------------------- workspace */
.workspace {
  display: grid;
  grid-template-columns: var(--left-w) 5px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}
.panel {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(9,9,9,.72), rgba(4,4,4,.72));
}
.panel-left { border-inline-end: 1px solid var(--line-soft); }
.panel-right { background: linear-gradient(180deg, rgba(10,10,10,.8), rgba(6,6,6,.8)); }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  height: 40px; padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.panel-tabs { display: flex; gap: 2px; }
.ptab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: var(--r-xs);
  font-size: 12px; font-weight: 500;
  color: var(--text-3);
  transition: color var(--t-fast), background var(--t-fast);
}
.ptab:hover { color: var(--text); background: var(--raise); }
.ptab.is-active { color: var(--white); background: var(--raise-2); }
.ptab .count {
  padding: 1px 5px; border-radius: 999px;
  background: var(--charcoal); color: var(--text-3);
  font-size: 9.5px;
}
.head-tools { display: flex; align-items: center; gap: 4px; }

.splitter, .v-splitter {
  position: relative;
  background: transparent;
  cursor: col-resize;
  flex: none;
  display: grid; place-items: center;
  touch-action: none;
}
.splitter span, .v-splitter span {
  width: 1px; height: 100%;
  background: var(--line-soft);
  transition: background var(--t-fast), width var(--t-fast);
}
.splitter:hover span, .splitter:focus-visible span,
.v-splitter:hover span, .v-splitter:focus-visible span,
.splitter[data-dragging="true"] span, .v-splitter[data-dragging="true"] span {
  background: #3f3f3f; width: 2px;
}
.v-splitter { width: 5px; }

body[data-resizing="true"] { cursor: col-resize; user-select: none; }
body[data-resizing="true"] iframe { pointer-events: none; }

/* ---------------------------------- left panel */
.left-body { flex: 1; min-width: 0; min-height: 0; display: flex; overflow: hidden; }
.chat-view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; }

.chat-scroll {
  flex: 1 1 0; min-width: 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  padding: 16px 16px 4px;
  scroll-behavior: smooth;
}
/* Nothing scrolls while the empty state owns the panel. */
.chat-view[data-state="empty"] .chat-scroll { overflow: hidden; }

/**
 * Composer positioning.
 *
 * The composer sits in normal flow at all times — it is never absolutely
 * positioned, so it can never overlap the content above or below it. Vertical
 * centring comes from two flexible siblings (.chat-scroll and .chat-tail) that
 * share the leftover space equally. Docking animates `flex-grow` on .chat-tail
 * from 1 to 0, which drops the composer to the bottom smoothly and leaves the
 * transcript with all the room.
 */
.chat-tail {
  flex: 1 1 0;
  min-height: 0;
  padding: 0 16px 16px;
  overflow-y: auto;
  transition: flex-grow var(--t-slow), opacity var(--t-med), padding var(--t-slow);
}
.chat-view[data-state="docked"] .chat-tail {
  flex-grow: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}

/* empty state */
.empty-state {
  margin-top: auto;             /* hugs the composer from above */
  padding: 8px 4px 18px;
  text-align: center;
  animation: fadeUp var(--t-slow) both;
}
.chat-view[data-state="docked"] .empty-state { display: none; }
.empty-title {
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--white);
  margin-bottom: 8px;
}
.empty-sub { color: var(--text-3); font-size: 13.5px; max-width: 42ch; margin: 0 auto 22px; }
.examples { display: flex; flex-direction: column; gap: 6px; max-width: 760px; margin: 0 auto; padding-top: 4px; }
.example {
  text-align: start;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255,255,255,.014);
  color: var(--text-2);
  font-size: 12.5px;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.example:hover {
  border-color: var(--line-strong); color: var(--white);
  background: var(--raise); transform: translateX(2px);
}
[dir="rtl"] .example:hover { transform: translateX(-2px); }

/* messages */
.messages { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; min-width: 0; max-width: 100%; }

.msg { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; animation: fadeUp var(--t-med) both; }
.msg-user { align-items: flex-end; }
.msg-user .bubble {
  background: var(--raise-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg);
  padding: 9px 13px;
  max-width: min(84%, 680px);
  color: var(--off);
  font-size: 13.5px;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
[dir="rtl"] .msg-user .bubble { border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-xs); }

.msg-ai { align-items: stretch; }
.msg-ai .ai-head {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .12em; color: var(--text-4);
  text-transform: uppercase;
}
.msg-ai .ai-head::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.msg-text {
  color: var(--text-2); font-size: 13.5px;
  white-space: pre-wrap; word-break: break-word;
  padding: 2px 0;
}

.msg-attachments { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; max-width: 84%; }

/* activity cards */
.acts { display: flex; flex-direction: column; gap: 3px; }
.act {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.012);
  font-size: 12px;
  color: var(--text-2);
  animation: fadeUp var(--t-fast) both;
}
.act-ico { width: 13px; height: 13px; flex: none; color: var(--text-3); }
.act-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-path { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.act-state { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; color: var(--text-4); flex: none; }
.act[data-state="running"] { border-color: var(--line-strong); color: var(--white); }
.act[data-state="running"] .act-ico { color: var(--white); animation: spin 1.1s linear infinite; }
.act[data-state="done"] .act-state { color: var(--text-3); }
.act[data-state="error"] { border-color: #4a4a4a; }
@keyframes spin { to { transform: rotate(360deg); } }

.act-bar { height: 1px; background: var(--charcoal); overflow: hidden; border-radius: 1px; flex: none; width: 46px; }
.act-bar i { display: block; height: 100%; background: var(--white); width: 0; transition: width var(--t-fast); }

/* agent band */
.agent {
  display: flex; align-items: center; gap: 9px;
  margin-top: 4px; padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.03);
  animation: fadeUp var(--t-fast) both;
}
.agent-label { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--white); letter-spacing: .01em; }
.agent-step { color: var(--text-4); flex: none; }
.agent[data-state="running"] .act-ico { color: var(--white); animation: spin 1.1s linear infinite; }
.agent[data-state="done"] { border-color: var(--line); background: rgba(255,255,255,.014); }
.agent[data-state="done"] .agent-label { color: var(--text-2); font-weight: 500; }
.agent[data-state="error"] { border-color: #4a4a4a; }

/* design brief card */
.brief-body { padding: 9px 11px; display: flex; flex-direction: column; gap: 6px; }
.brief-row { display: flex; align-items: center; gap: 10px; }
.brief-k { color: var(--text-4); flex: none; width: 66px; letter-spacing: .1em; font-size: 9px; }
.brief-v { color: var(--text-2); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brief-sw { display: flex; gap: 4px; }
.sw {
  width: 15px; height: 15px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,.18);
  flex: none;
}
.brief-why {
  padding: 0 11px 9px;
  font-size: 12px; color: var(--text-3); font-style: italic;
}

/* live thinking feed */
.think {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.012);
  overflow: hidden;
  animation: fadeUp var(--t-fast) both;
}
.think-head {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 6px 10px;
  color: var(--text-2); font-size: 12px; text-align: start;
}
.think-head:hover { background: rgba(255,255,255,.02); }
.think-caret { width: 10px; height: 10px; flex: none; color: var(--text-4); transition: transform var(--t-fast); }
.think[data-open="false"] .think-caret { transform: rotate(-90deg); }
[dir="rtl"] .think[data-open="false"] .think-caret { transform: rotate(90deg); }
.think-label { flex: 1; min-width: 0; }
.think-clock { color: var(--text-4); flex: none; }
.think[data-state="running"] .act-ico { color: var(--white); animation: spin 1.1s linear infinite; }
.think[data-state="running"] .think-label { color: var(--white); }

.think-stream {
  max-height: 148px;
  overflow-y: auto;
  padding: 2px 10px 9px 29px;
  font-family: var(--mono);
  font-size: 10.5px; line-height: 1.65;
  color: var(--text-3);
  white-space: pre-wrap; word-break: break-word;
  transition: max-height var(--t-med), padding var(--t-med), opacity var(--t-fast);
}
.think[data-open="false"] .think-stream {
  max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0;
}
.think-stream .stream-cursor { height: 10px; width: 5px; }

/* "Typing the code" loading state — replaces the raw trace once the model
   starts drafting source, so code never leaks into the chat. */
.think-typing {
  display: none;
  flex-direction: column; gap: 6px;
  padding: 4px 10px 11px 29px;
}
.think[data-mode="typing"] .think-stream { display: none; }
.think[data-mode="typing"][data-open="true"] .think-typing { display: flex; }
.think[data-mode="typing"] .think-label { color: var(--white); }
.think-typing .skeleton { height: 7px; }
.think-typing .skeleton:nth-child(2) { animation-delay: .15s; }
.think-typing .skeleton:nth-child(3) { animation-delay: .3s; }

/* plan card */
.plan {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255,255,255,.016);
  overflow: hidden;
}
.plan-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .14em; color: var(--text-3);
}
.plan-body { padding: 10px 11px; font-size: 13px; color: var(--text-2); }
.plan-files { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 11px 10px; }
.plan-file {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 7px;
  border: 1px solid var(--line); border-radius: var(--r-xs);
  color: var(--text-3);
}

/* notes */
.note {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-inline-start: 2px solid var(--text-4);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.02);
  font-size: 12.5px; color: var(--text-2);
}
.note[data-kind="error"] { border-inline-start-color: var(--off); background: rgba(255,255,255,.035); color: var(--off); }
.note[data-kind="done"] { border-inline-start-color: var(--white); }
.note-title { font-weight: 600; color: var(--white); display: block; margin-bottom: 2px; font-size: 12.5px; }
.note-retry {
  margin-top: 7px; align-self: flex-start;
  border: 1px solid var(--line-strong); border-radius: var(--r-xs);
  padding: 3px 9px; font-size: 11px; color: var(--text);
}
.note-retry:hover { background: var(--raise); }

.changed-files { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }

.stream-cursor {
  display: inline-block; width: 6px; height: 13px;
  background: var(--white); margin-inline-start: 2px;
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.skeleton {
  height: 9px; border-radius: 3px;
  background: linear-gradient(90deg, #131313 25%, #1d1d1d 37%, #131313 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------------------------------- composer */
.composer-wrap {
  flex: none;
  padding: 10px 16px;
  position: relative;
  z-index: 3;
  transition: padding var(--t-slow), border-color var(--t-med), background var(--t-med);
  border-top: 1px solid transparent;
}
.chat-view[data-state="docked"] .composer-wrap {
  padding-bottom: 16px;
  border-top-color: var(--line-soft);
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(3,3,3,.92) 32%);
}

.composer {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, #0c0c0c, #080808);
  padding: 10px 12px 8px;
  transition: border-color var(--t-med), box-shadow var(--t-med);
  width: min(100%, 760px); max-width: 100%; margin: 0 auto;
}
.composer:focus-within {
  border-color: #454545;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 10px 40px -14px rgba(0,0,0,.9);
}

.prompt-input {
  display: block; width: 100%;
  background: transparent; border: 0; outline: none;
  resize: none;
  color: var(--off);
  font-size: 14px; line-height: 1.55;
  max-height: 220px; overflow-y: auto;
  padding: 2px 2px 6px;
}
.prompt-input::placeholder { color: var(--text-4); }

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-left { display: flex; align-items: center; gap: 7px; }
.composer-right { display: flex; align-items: center; gap: 9px; }
.hint { color: var(--text-4); white-space: nowrap; }

.send-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px;
  border-radius: 999px;
  background: var(--white); color: var(--black);
  font-size: 12px; font-weight: 600;
  transition: opacity var(--t-fast), transform var(--t-fast), background var(--t-fast);
}
.send-btn svg { width: 14px; height: 14px; }
.send-btn:hover:not(:disabled) { background: var(--off); }
.send-btn:active:not(:disabled) { transform: scale(.97); }
.send-btn:disabled { background: var(--charcoal); color: var(--text-4); cursor: not-allowed; }
.send-btn.stop { background: transparent; color: var(--off); border: 1px solid var(--line-strong); }
.send-btn.stop:hover { background: var(--raise); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; padding-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--raise);
  font-family: var(--mono); font-size: 10px;
  color: var(--text-2);
  max-width: 220px;
}
.chip img { width: 16px; height: 16px; border-radius: 3px; object-fit: cover; flex: none; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-kind { color: var(--text-4); flex: none; }
.chip-x {
  width: 15px; height: 15px; flex: none;
  border-radius: 50%; display: grid; place-items: center;
  color: var(--text-3); font-size: 11px; line-height: 1;
}
.chip-x:hover { background: var(--charcoal); color: var(--white); }

.attach-menu {
  position: absolute; bottom: 68px; inset-inline-start: 22px;
  min-width: 210px; padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--panel-2);
  box-shadow: 0 18px 50px -12px rgba(0,0,0,.95);
  z-index: 20;
  animation: fadeUp var(--t-fast) both;
}
.attach-menu button {
  display: block; width: 100%; text-align: start;
  padding: 7px 10px; border-radius: var(--r-xs);
  font-size: 12.5px; color: var(--text-2);
}
.attach-menu button:hover { background: var(--raise-2); color: var(--white); }

/* ---------------------------------- versions */
.versions-view { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.versions-list { display: flex; flex-direction: column; gap: 8px; }
.version {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255,255,255,.014);
  padding: 10px 12px;
  transition: border-color var(--t-fast);
}
.version:hover { border-color: var(--line-strong); }
.version-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.version-no { font-family: var(--mono); font-size: 11px; color: var(--white); letter-spacing: .06em; }
.version-time { font-family: var(--mono); font-size: 10px; color: var(--text-4); }
.version-summary { font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; word-break: break-word; }
.version-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.version-restore {
  border: 1px solid var(--line-strong); border-radius: var(--r-xs);
  padding: 3px 10px; font-size: 11px; color: var(--text);
}
.version-restore:hover { background: var(--raise); color: var(--white); }
.version.is-current { border-color: var(--line-strong); background: rgba(255,255,255,.03); }

.empty-list { padding: 28px 12px; text-align: center; color: var(--text-4); }

/* ---------------------------------- right panel */
.seg {
  display: inline-flex; gap: 2px; padding: 2px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(255,255,255,.015);
}
.seg-btn {
  height: 24px; padding: 0 12px;
  border-radius: var(--r-xs);
  font-size: 12px; font-weight: 500; color: var(--text-3);
  transition: background var(--t-fast), color var(--t-fast);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--raise-2); color: var(--white); }

.right-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.right-body[data-view="preview"] .code-side,
.right-body[data-view="preview"] .v-splitter { display: none; }
.right-body[data-view="preview"] .preview-side { flex: 1; }
.right-body[data-view="code"] .preview-side,
.right-body[data-view="code"] .v-splitter { display: none; }
.right-body[data-view="code"] .code-side { flex: 1; }
.right-body[data-view="split"] .code-side { flex: 0 0 var(--code-w, 50%); }
.right-body[data-view="split"] .preview-side { flex: 1; min-width: 0; }
.right-body[data-view="split"] .v-splitter { display: grid; }

/* explorer */
.code-side { display: flex; min-width: 0; min-height: 0; }
.explorer {
  flex: none; width: 220px;
  display: flex; flex-direction: column;
  border-inline-end: 1px solid var(--line-soft);
  background: rgba(255,255,255,.008);
  min-height: 0;
}
.explorer-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; padding: 0 6px 0 10px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.explorer-title { color: var(--text-4); letter-spacing: .16em; font-size: 9.5px; }
.explorer-actions { display: flex; gap: 1px; }
.tree { flex: 1; overflow: auto; padding: 5px 4px 12px; }
.explorer-empty { padding: 18px 12px; text-align: center; color: var(--text-4); font-size: 12px; }
.explorer-empty p { margin: 3px 0; }

.node {
  display: flex; align-items: center; gap: 6px;
  height: 25px; padding: 0 6px;
  border-radius: var(--r-xs);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.node:hover { background: var(--raise); color: var(--white); }
.node.is-selected { background: var(--raise-2); color: var(--white); }
.node:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.node-ico { width: 13px; height: 13px; flex: none; color: var(--text-3); }
.node.is-selected .node-ico { color: var(--white); }
.node-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.node-mark { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.node-mark[data-mark="dirty"] { background: var(--white); }
.node-mark[data-mark="new"] { background: var(--text-3); }
.node-caret { width: 10px; height: 10px; flex: none; color: var(--text-4); transition: transform var(--t-fast); }
.node[aria-expanded="false"] .node-caret { transform: rotate(-90deg); }
[dir="rtl"] .node[aria-expanded="false"] .node-caret { transform: rotate(90deg); }
.node-new { animation: nodeIn var(--t-med) both; }
@keyframes nodeIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* editor */
.editor-side { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.editor-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; height: 30px; padding: 0 6px 0 10px;
  border-bottom: 1px solid var(--line-soft); flex: none;
}
.crumbs { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-tools { display: flex; align-items: center; gap: 1px; }
.dirty-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--white); margin-inline-end: 5px; flex: none; }

.find-bar {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-2); flex: none;
}
.find-input {
  flex: 1; min-width: 0;
  background: var(--near); border: 1px solid var(--line);
  border-radius: var(--r-xs); padding: 4px 8px;
  color: var(--off); outline: none;
}
.find-input:focus { border-color: var(--line-strong); }
.find-count { color: var(--text-4); flex: none; min-width: 40px; text-align: center; }

.editor { flex: 1; min-height: 0; display: flex; position: relative; overflow: hidden; background: var(--near); }
.editor[data-empty="true"] .gutter, .editor[data-empty="true"] .code-area { display: none; }
.editor[data-empty="false"] .editor-empty { display: none; }
.editor-empty { flex: 1; display: grid; place-items: center; color: var(--text-4); }

.gutter {
  flex: none; width: 48px;
  padding: 10px 8px 10px 0;
  text-align: end;
  font-family: var(--mono); font-size: 12px; line-height: 19px;
  color: var(--text-4);
  background: rgba(255,255,255,.008);
  border-inline-end: 1px solid var(--line-soft);
  overflow: hidden;
  user-select: none;
  white-space: pre;
}
.gutter i { display: block; font-style: normal; }
.gutter i.cur { color: var(--off); }

.code-area { flex: 1; min-width: 0; position: relative; overflow: hidden; }
.highlight, .code-input {
  margin: 0;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 19px;
  tab-size: 2;
  white-space: pre;
  word-wrap: normal;
  border: 0;
}
.highlight {
  position: absolute; inset: 0;
  overflow: auto;
  pointer-events: none;
  color: var(--text-2);
}
.highlight code { font: inherit; }
.code-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: auto;
  resize: none; outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--white);
}
.code-input::selection { background: rgba(255,255,255,.2); }

/* monochrome syntax — weight & luminance only */
.t-com { color: #7d8590; font-style: italic; }
.t-str { color: #a5d6a7; }
.t-key { color: #ff7b72; font-weight: 600; }
.t-num { color: #79c0ff; }
.t-tag { color: #7ee787; font-weight: 600; }
.t-att { color: #d2a8ff; }
.t-fn  { color: #d2a8ff; }
.t-pun { color: #9ba3af; }
.t-sel { color: #ffa657; font-weight: 500; }
.t-prop { color: #79c0ff; }
.t-mark { background: rgba(255,255,255,.22); border-radius: 2px; }
.t-mark.cur { background: var(--white); color: var(--black); }

.editor-foot {
  display: flex; align-items: center; gap: 16px;
  height: 24px; padding: 0 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-4); flex: none;
  background: rgba(255,255,255,.008);
}

/* preview */
.preview-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.preview-bar {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 8px;
  border-bottom: 1px solid var(--line-soft); flex: none;
}
.url-bar {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  height: 22px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.015);
  color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.url-bar .lock { color: var(--text-4); font-size: 9px; }
.preview-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.mini-select {
  height: 22px; padding: 0 4px;
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  color: var(--text-2); outline: none;
}
.err-badge {
  min-width: 15px; padding: 0 4px;
  border-radius: 999px; background: var(--white); color: var(--black);
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  text-align: center; line-height: 14px;
}

.preview-stage {
  position: relative;          /* containing block for .preview-empty */
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  padding: 14px;
  overflow: auto;
  background:
    radial-gradient(70% 60% at 50% 40%, rgba(255,255,255,.03), transparent 70%),
    var(--black);
}
.preview-frame-wrap {
  position: relative;
  width: 100%; height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #fff;
  transition: width var(--t-med), height var(--t-med), max-width var(--t-med);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,1);
}
.preview-frame-wrap[data-device="tablet"] { width: 768px; max-width: 100%; height: min(1024px, 100%); }
.preview-frame-wrap[data-device="phone"] { width: 390px; max-width: 100%; height: min(844px, 100%); border-radius: var(--r-xl); }
.preview-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.preview-frame-wrap[data-empty="true"] { display: none; }

.preview-pulse {
  position: absolute; inset: 0; pointer-events: none;
  border: 1px solid rgba(255,255,255,0);
  border-radius: inherit;
}
.preview-pulse[data-pulse="true"] { animation: pulseBorder 500ms ease-out; }
@keyframes pulseBorder {
  0% { border-color: rgba(255,255,255,.85); box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
  100% { border-color: rgba(255,255,255,0); box-shadow: inset 0 0 0 1px rgba(255,255,255,0); }
}

.preview-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-4); }
.pe-inner { text-align: center; }
.pe-mark { width: 44px; height: 44px; margin: 0 auto 10px; display: block; color: var(--text-4); }
.pe-inner p { margin: 3px 0; font-size: 13px; }

.console {
  flex: none; height: 168px;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--near);
}
.console-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 26px; padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-4); flex: none;
}
.console-body { flex: 1; overflow: auto; padding: 6px 10px; font-size: 11px; line-height: 1.6; }
.cline { display: flex; gap: 8px; padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.03); word-break: break-word; }
.cline-kind { flex: none; width: 44px; color: var(--text-4); letter-spacing: .06em; }
.cline[data-kind="error"] .cline-kind { color: var(--white); }
.cline[data-kind="warn"] .cline-kind { color: var(--text-2); }
.cline-msg { flex: 1; min-width: 0; color: var(--text-2); white-space: pre-wrap; }
.cline-src { flex: none; color: var(--text-4); }

/* ---------------------------------- modals */
.modal-root { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(3px);
  animation: fade var(--t-fast) both;
}
.modal {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: min(84vh, 760px);
  display: flex; flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, #0d0d0d, #070707);
  box-shadow: 0 40px 100px -20px rgba(0,0,0,1);
  animation: modalIn var(--t-med) both;
}
.modal.sm { width: min(420px, calc(100vw - 32px)); }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid var(--line-soft); flex: none;
}
.modal-head h2 { font-size: 15px; font-weight: 600; color: var(--white); letter-spacing: -.01em; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line-soft); flex: none;
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 12.5px; font-weight: 500; color: var(--off); margin-bottom: 6px; }
.field.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.field.row > div { min-width: 0; }
.field.row > div > label { margin-bottom: 2px; display: block; font-size: 12.5px; font-weight: 500; color: var(--off); }
.fhint { font-size: 11.5px; color: var(--text-4); margin: 0; }
.fhint.err { color: var(--off); margin-top: 5px; }

.input {
  width: 100%; height: 32px; padding: 0 10px;
  background: var(--near);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--off); outline: none;
  font-size: 13px;
  transition: border-color var(--t-fast);
}
.input:focus { border-color: #454545; }
.input.ta { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; cursor: pointer; padding-inline-end: 26px;
  background-image: linear-gradient(45deg, transparent 50%, #777 50%), linear-gradient(135deg, #777 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
[dir="rtl"] select.input { background-position: 10px 14px, 15px 14px; }

.readonly {
  padding: 7px 10px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  color: var(--text-2); background: rgba(255,255,255,.012);
  word-break: break-all;
}

.range { width: 100%; height: 4px; appearance: none; background: var(--charcoal); border-radius: 2px; outline: none; }
.range::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--white); cursor: pointer; border: 0; }
.range::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--white); cursor: pointer; }

.switch { position: relative; width: 38px; height: 21px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--charcoal); border: 1px solid var(--line-strong);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.switch span::after {
  content: ""; position: absolute;
  top: 2px; inset-inline-start: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--text-3);
  transition: transform var(--t-fast), background var(--t-fast);
}
.switch input:checked + span { background: var(--white); border-color: var(--white); }
.switch input:checked + span::after { background: var(--black); transform: translateX(17px); }
[dir="rtl"] .switch input:checked + span::after { transform: translateX(-17px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.checkline { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.checkline label { font-size: 12.5px; color: var(--text-2); margin: 0; font-weight: 400; }
.checkline input[type="checkbox"] { accent-color: #fff; width: 14px; height: 14px; }

.danger-zone { border-top: 1px solid var(--line-soft); padding-top: 14px; }
.ask-msg { font-size: 13.5px; color: var(--text-2); word-break: break-word; }

.api-state {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(255,255,255,.015);
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
}

.projects-list { display: flex; flex-direction: column; gap: 6px; }
.proj {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: rgba(255,255,255,.012);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.proj:hover { border-color: var(--line-strong); background: var(--raise); }
.proj.is-current { border-color: var(--line-strong); background: rgba(255,255,255,.03); }
.proj-main { flex: 1; min-width: 0; cursor: pointer; text-align: start; }
.proj-name { font-size: 13px; color: var(--off); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta { font-family: var(--mono); font-size: 10px; color: var(--text-4); margin-top: 2px; }
.proj-actions { display: flex; gap: 2px; flex: none; }

/* context menu */
.ctx-menu {
  position: fixed; z-index: 300;
  min-width: 178px; padding: 4px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--panel-2);
  box-shadow: 0 18px 50px -12px rgba(0,0,0,.95);
  animation: fadeUp 100ms both;
}
.ctx-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: start;
  padding: 6px 9px; border-radius: var(--r-xs);
  font-size: 12.5px; color: var(--text-2);
}
.ctx-menu button:hover { background: var(--raise-2); color: var(--white); }
.ctx-menu button[data-danger="true"]:hover { background: var(--charcoal); color: var(--white); }
.ctx-menu button kbd { font-family: var(--mono); font-size: 9.5px; color: var(--text-4); }
.ctx-sep { height: 1px; background: var(--line-soft); margin: 4px 2px; }

/* toasts */
.toasts {
  position: fixed; z-index: 400;
  bottom: calc(16px + var(--mnav-h)); inset-inline-end: 16px;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  min-width: 200px; max-width: 340px;
  padding: 9px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--panel-2);
  box-shadow: 0 18px 44px -14px rgba(0,0,0,.95);
  font-size: 12.5px; color: var(--text);
  animation: toastIn var(--t-med) both;
  pointer-events: auto;
}
.toast[data-out="true"] { animation: toastOut var(--t-fast) both; }
.toast-ico { width: 14px; height: 14px; flex: none; color: var(--white); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------- mobile nav */
.mobile-nav { display: none; }

/* ---------------------------------- responsive */
@media (max-width: 1100px) {
  .brand-desc { display: none; }
  .topbar-center .meta-chip#modeChip { display: none; }
}

@media (max-width: 900px) {
  :root { --topbar-h: 48px; }
  .topbar { grid-template-columns: minmax(0,1fr) auto; }
  .topbar-center { display: none; }
  .btn#btnSave, .btn#btnNew { display: none; }
  .device-group { display: none; }
  .avatar { display: none; }
  .workspace { grid-template-columns: minmax(320px, 42%) 5px minmax(0, 1fr); }
  .explorer { width: 180px; }
}

@media (max-width: 760px) {
  :root { --mnav-h: 54px; }
  .app { grid-template-rows: var(--topbar-h) 1fr var(--mnav-h); }

  .workspace { display: block; position: relative; }
  .splitter, .v-splitter { display: none !important; }

  .panel-left, .panel-right {
    position: absolute; inset: 0;
    border: 0;
  }
  .panel-left { z-index: 2; }
  .panel-right { z-index: 1; }

  /* pane visibility driven by [data-mpane] on .app */
  .app[data-mpane="chat"] .panel-right { display: none; }
  .app[data-mpane="chat"] .panel-left { display: flex; }

  .app:not([data-mpane="chat"]) .panel-left { display: none; }
  .app:not([data-mpane="chat"]) .panel-right { display: flex; }

  .app[data-mpane="files"] .right-body { }
  .app[data-mpane="files"] .code-side { display: flex; flex: 1; }
  .app[data-mpane="files"] .editor-side { display: none; }
  .app[data-mpane="files"] .explorer { width: 100%; border-inline-end: 0; }
  .app[data-mpane="files"] .preview-side, .app[data-mpane="files"] .v-splitter { display: none; }

  .app[data-mpane="code"] .code-side { display: flex; flex: 1; }
  .app[data-mpane="code"] .explorer { display: none; }
  .app[data-mpane="code"] .editor-side { display: flex; }
  .app[data-mpane="code"] .preview-side, .app[data-mpane="code"] .v-splitter { display: none; }

  .app[data-mpane="preview"] .code-side, .app[data-mpane="preview"] .v-splitter { display: none; }
  .app[data-mpane="preview"] .preview-side { display: flex; flex: 1; }

  .app:not([data-mpane="chat"]) .panel-right .seg { display: none; }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line);
    background: rgba(6,6,6,.96);
    backdrop-filter: blur(12px);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mnav {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-4); font-size: 10px; letter-spacing: .02em;
    min-height: 44px;
    transition: color var(--t-fast);
  }
  .mnav svg { width: 17px; height: 17px; }
  .mnav.is-active { color: var(--white); }

  .composer-wrap[data-position="center"] { position: absolute; }
  .composer { padding: 9px 10px 7px; }
  .modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .modal.sm { width: 100vw; height: auto; max-height: 100dvh; }
  .empty-title { font-size: 21px; }
  .preview-stage { padding: 0; }
  .preview-frame-wrap { border-radius: 0; border: 0; }
  .preview-frame-wrap[data-device="tablet"], .preview-frame-wrap[data-device="phone"] { width: 100%; height: 100%; border-radius: 0; }
  .toasts { inset-inline: 12px; bottom: calc(12px + var(--mnav-h)); }
  .toast { max-width: none; }
  .hint#composerHint { display: none; }
}

@media (max-width: 420px) {
  .brand-text { display: none; }
  .project-name { max-width: 130px; }
}

/* ---------------------------------- RTL */
[dir="rtl"] .bg-binary { direction: ltr; }
[dir="rtl"] .attach-menu { animation: fadeUp var(--t-fast) both; }
[dir="rtl"] .gutter { text-align: end; }
/* code always reads LTR regardless of UI direction */
[dir="rtl"] .code-area, [dir="rtl"] .highlight, [dir="rtl"] .code-input,
[dir="rtl"] .gutter, [dir="rtl"] .console-body, [dir="rtl"] .url-bar { direction: ltr; }
[dir="rtl"] .crumbs { direction: ltr; text-align: end; }

/* ---------------------------------- reduced motion */
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
