/* ZulfiEra Code workspace. Colours, fonts and dark mode come from /theme.css (shared with the chat app);
   this file only lays out the workspace. Same rules as the chat: white / charcoal, one blue accent, hairline rules,
   small radii, almost no motion. */
:root { --danger: #B42318; --ok: #157A3F; color-scheme: light; }
:root[data-theme="dark"] { --danger: #F97066; --ok: #47CD89; color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --danger: #F97066; --ok: #47CD89; color-scheme: dark; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.55 var(--sans); color: var(--text); background: var(--bg); display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--tint-soft); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
:is(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none; white-space: nowrap; }
/* The </> product mark keeps its own colours (brand marks change only with the owner's approval). */
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: #7C3AED; color: #FFFFFF; font: 600 11px var(--mono); }
.badge { padding: 1px 7px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--tint) 45%, transparent); color: var(--tint);
  font: 500 10.5px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Buttons ---------- */
.primary, .ghost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 14px; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; font: 500 13.5px var(--sans); }
.primary { background: var(--accent); color: var(--accent-text); }
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.ghost:hover:not(:disabled) { background: var(--hover); border-color: var(--rule-strong); }
.ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.danger { color: var(--danger); }

/* ---------- Sign-in / not available ---------- */
.gate { flex: 1; display: grid; place-items: center; padding: 24px; }
.gate-card { max-width: 440px; text-align: center; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 32px 28px; }
.gate-card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.gate-card p { margin: 0 0 20px; color: var(--muted); }

/* ---------- Workspace: build steps on the left, the site on the right ---------- */
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); }
.tabs { display: none; }
.pane { min-height: 0; overflow: auto; }
.build-pane { padding: 16px 16px 24px; border-right: 1px solid var(--border); background: var(--side); display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
.project-head { display: flex; align-items: center; gap: 8px; }
.project-name { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 8px; }
.project-name:hover, .project-name:focus { border-color: var(--border); background: var(--panel); }
.saved { font: 400 11px var(--mono); color: var(--faint); white-space: nowrap; }
.credits-line { margin: -6px 0 0; padding: 0 8px; font: 400 11.5px var(--mono); color: var(--muted); white-space: pre-line; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; flex-wrap: wrap; }
.step > span { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 4px; border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--tint) 45%, transparent); color: var(--tint); font: 500 11px var(--mono); }
.step small { font-weight: 400; font-size: 12.5px; }
textarea, input[type="text"], select { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; background: var(--bg); resize: vertical; line-height: 1.5; }
/* Fields show focus with a solid blue border and ring (clearly visible, no layout shift). */
textarea:focus, input[type="text"]:focus, select:focus, .project-name:focus { border-color: var(--tint); outline: none; box-shadow: 0 0 0 1px var(--tint); }
textarea::placeholder, input::placeholder { color: var(--faint); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { font: 400 11px var(--mono); color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 4px; padding: 3px 9px; font-size: 12.5px; cursor: pointer; }
.chips button:hover { border-color: var(--rule-strong); background: var(--hover); }
.questions { background: var(--tint-soft); border: 1px solid color-mix(in srgb, var(--tint) 25%, transparent); border-radius: 6px; padding: 10px 12px; font-size: 13.5px; }
.questions p { margin: 0 0 4px; }
.questions ul { margin: 0; padding-left: 18px; }

/* Kind of website (Pro multi-page or Lite one-page) and the page tabs above the preview */
.modes { display: flex; width: 100%; }
.modes button { flex: 1; display: grid; gap: 1px; padding: 6px 10px; text-align: left; }
.modes button small { font: 400 11px var(--sans); color: inherit; opacity: 0.8; }
.modes button[aria-checked="true"] { background: var(--accent); color: var(--accent-text); }
.modes button:disabled { cursor: default; }
.modes button:disabled:not([aria-checked="true"]) { opacity: 0.5; }
.mode-hint { margin: -2px 0 0; }
.pages { max-width: 100%; overflow-x: auto; }
.pages button { white-space: nowrap; }
.busy-detail { margin-left: 8px; font: 400 11.5px var(--mono); color: var(--faint); }

/* Plan editor (built by code.js) */
#plan-editor { display: grid; gap: 12px; }
.colours .field small { font-size: 11.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: grid; gap: 4px; font-size: 13px; }
.field > span { font: 500 10.5px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.colours { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.colours input[type="color"] { width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; background: var(--bg); cursor: pointer; }
.sections { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sec-row { border: 1px solid var(--border); border-radius: 6px; padding: 8px; display: grid; gap: 6px; background: var(--bg); }
.sec-top { display: grid; grid-template-columns: 130px 1fr auto; gap: 6px; align-items: center; }
.sec-top select, .sec-top input { padding: 6px 8px; }
.sec-row textarea { padding: 6px 8px; font-size: 13px; }
.icon-btns { display: flex; gap: 2px; }
.icon-btns button { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 5px; cursor: pointer; line-height: 1; }
.icon-btns button:hover:not(:disabled) { background: var(--hover); }
.icon-btns button:disabled { opacity: 0.35; cursor: default; }
.add-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }

.upgrade-card { border-color: color-mix(in srgb, var(--tint) 40%, var(--border)); box-shadow: inset 3px 0 0 var(--tint); }
.upgrade-card p { margin: 0; }

/* Versions */
.versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.versions li { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; display: grid; gap: 4px; background: var(--bg); }
.versions li.current { box-shadow: inset 2px 0 0 var(--tint); border-color: var(--rule-strong); }
.v-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.v-head strong { font-weight: 600; }
.v-head .muted { font: 400 11px var(--mono); color: var(--faint); }
.v-note { font-size: 13px; margin: 0; overflow-wrap: anywhere; color: var(--muted); }
.v-actions { display: flex; gap: 6px; }
.v-actions button { min-height: 28px; font-size: 12.5px; padding: 3px 10px; }

/* ---------- Preview ---------- */
.preview-pane { display: flex; flex-direction: column; background: var(--bg); }
.preview-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg); }
.preview-bar #zip-btn { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; padding: 2px; gap: 2px; background: var(--panel); }
.seg button { border: 0; background: none; color: var(--muted); border-radius: 5px; padding: 4px 10px; cursor: pointer; font: 500 12.5px var(--sans); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.viewing { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px; background: var(--tint-soft); border-bottom: 1px solid var(--border); font-size: 13.5px; }
.status { padding: 6px 14px; font: 400 12px var(--mono); color: var(--muted); min-height: 30px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); font-family: var(--sans); font-size: 13px; }
.status details { color: var(--text); }
.status ul { margin: 4px 0 0; padding-left: 18px; }
.stage { flex: 1; min-height: 0; display: flex; justify-content: center; padding: 0 14px 14px; overflow: auto; }
/* The site keeps its own white page; a hairline frame and a soft edge separate it from the workspace. */
#frame { width: 100%; height: 100%; min-height: 480px; border: 1px solid var(--rule-strong); border-radius: 8px; background: #fff;
  box-shadow: 0 10px 30px -22px rgba(17, 24, 39, 0.45); transition: width 0.2s ease; }
.stage[data-device="tablet"] #frame { width: 820px; max-width: 100%; }
.stage[data-device="mobile"] #frame { width: 390px; max-width: 100%; }
.empty { align-self: center; max-width: 440px; padding: 28px 24px; text-align: center; border: 1px dashed var(--rule-strong); border-radius: 10px; }
.empty p { margin: 0 0 6px; }
.empty p:last-child { margin: 0; font-size: 13.5px; }
.files { width: 100%; display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 10px; min-height: 0; }
.files ul { list-style: none; margin: 0; padding: 0; display: grid; align-content: start; gap: 2px; }
.files li button { width: 100%; text-align: left; border: 1px solid transparent; background: none; color: var(--text); border-radius: 5px; padding: 6px 10px; cursor: pointer;
  font: 12.5px var(--mono); display: flex; justify-content: space-between; gap: 8px; }
.files li button:hover { background: var(--hover); }
.files li button[aria-pressed="true"] { background: var(--panel); border-color: var(--border); box-shadow: inset 2px 0 0 var(--tint); }
.files pre { margin: 0; overflow: auto; background: var(--code-bg); color: #E2E8F0; border-radius: 8px; padding: 14px 16px; font: 12.5px/1.6 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border); }

/* ---------- Projects drawer, upgrade dialog, toast ---------- */
.drawer { position: fixed; inset: 0; background: rgba(15, 17, 21, 0.45); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-card { width: min(420px, 100%); height: 100%; background: var(--panel); border-left: 1px solid var(--border); padding: 18px; overflow: auto; box-shadow: var(--shadow); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.project-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.project-list li { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; background: var(--bg); }
.project-list li.current { box-shadow: inset 2px 0 0 var(--tint); border-color: var(--rule-strong); }
.project-list li > .muted { font: 400 11px var(--mono); color: var(--faint); }
.project-list .row button { min-height: 28px; font-size: 12.5px; padding: 3px 10px; }
.modal { position: fixed; inset: 0; background: rgba(15, 17, 21, 0.45); display: grid; place-items: center; padding: 16px; z-index: 25; }
.modal-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 22px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 8px; font-size: 19px; font-weight: 600; }
.modal-card p { margin: 0 0 16px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 6px;
  font-size: 13.5px; z-index: 30; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.busy { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.busy::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--tint); border-right-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .busy::before { animation: none; border-right-color: var(--tint); } #frame { transition: none; } }

/* ---------- Narrower screens ---------- */
@media (max-width: 1180px) { .workspace { grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); } }
@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .tabs { display: flex; gap: 4px; padding: 0 12px; background: var(--bg); border-bottom: 1px solid var(--border); }
  .tabs button { flex: 1; border: 0; background: none; color: var(--muted); padding: 11px 10px 9px; border-bottom: 2px solid transparent; font-weight: 500; cursor: pointer; }
  .tabs button[aria-pressed="true"] { border-bottom-color: var(--tint); color: var(--text); }
  .build-pane { border-right: 0; }
  .workspace[data-tab="build"] .preview-pane, .workspace[data-tab="preview"] .build-pane { display: none; }
  .badge { display: none; }
  .files { grid-template-columns: minmax(0, 1fr); }
  .preview-bar .devices { display: none; } /* a phone shows the phone layout anyway */
  .stage #frame { width: 100%; }
}
.narrow { display: none; }
@media (max-width: 600px) {
  .topbar { padding: 6px 12px; min-height: 48px; }
  .top-actions .ghost { padding: 5px 10px; min-height: 32px; }
  .wide { display: none; }
  .narrow { display: inline; }
  .build-pane { padding: 12px 12px 20px; }
  .stage { padding: 0 8px 8px; }
  textarea, input[type="text"], select { font-size: 16px; } /* below 16px, iOS Safari zooms in on focus */
}
@media (max-width: 420px) {
  .grid2, .colours { grid-template-columns: 1fr 1fr; }
  .sec-top { grid-template-columns: 1fr auto; }
  .sec-top select { grid-column: 1 / -1; }
  .logo { font-size: 14px; }
}
