/* GoPreview — app styles. Custom properties, BEM-ish, mobile-first. */

:root {
  --accent: #5b8cff;

  /* Admin dark theme (from design-tokens) */
  --bg-0: #0d0e11;
  --bg-1: #101215;
  --bg-2: #12141a;
  --bg-3: #14161a;
  --bg-4: #161920;
  --bg-input: #1a1d23;
  --border-1: #22262e;
  --border-2: #262b34;
  --border-3: #2c313a;
  --text-1: #f2f3f5;
  --text-2: #c3c7cf;
  --text-3: #9aa1ac;
  --text-4: #8a919c;
  --text-5: #6b7280;

  --radius-btn: 8px;
  --radius-card: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.admin { background: var(--bg-0); color: var(--text-1); }
body.viewer { background: #f5f6f8; color: #1a1d23; }

a { color: var(--accent); text-decoration: none; }
code { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-btn);
  padding: 11px 18px; font-size: 14px; font-weight: 700;
  font-family: inherit; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--accent); color: #0d0e11; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-block { width: 100%; }
.btn-ghost-light { background: #fff; border: 1px solid #e3e5ea; color: #6b7280; }
.link-btn {
  background: none; border: none; color: var(--text-4);
  font-size: 13px; padding: 6px 8px; cursor: pointer; text-align: left;
  font-family: inherit;
}
.link-btn:hover { color: var(--text-2); }
.back-link {
  display: inline-block; background: none; border: none; color: var(--text-4);
  font-size: 13px; cursor: pointer; margin-bottom: 14px;
}
.back-link:hover { color: var(--text-2); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-narrow { max-width: 560px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-3); }
.field input, .field textarea {
  background: var(--bg-4); border: 1px solid var(--border-2);
  border-radius: var(--radius-btn); padding: 11px 12px;
  color: var(--text-1); font-size: 14px; font-family: inherit; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text-5); }
.subform {
  border: 1px solid var(--border-2); border-radius: var(--radius-card);
  padding: 16px; display: flex; flex-direction: column; gap: 14px; margin: 0;
}
.subform legend { font-size: 12px; font-weight: 700; color: var(--text-3); padding: 0 6px; }
.slug-preview {
  background: var(--bg-1); border: 1px solid var(--border-1);
  border-radius: var(--radius-btn); padding: 11px 12px;
  color: var(--accent); font-family: ui-monospace, monospace; font-size: 13px;
}

/* ---------- Chips (client selection) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: #1d2129; border: 1px solid var(--border-3); color: #e5e7eb;
  border-radius: 20px; padding: 7px 12px 7px 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #0d0e11; }
.chip-avatar {
  width: 20px; height: 20px; border-radius: 50%; background: #2c313a;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; color: #e5e7eb;
}
.chip:has(input:checked) .chip-avatar { background: rgba(13,14,17,0.25); color: #0d0e11; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-btn); padding: 11px 14px; font-size: 13px; font-weight: 600; }
.alert-error { background: #2a1616; color: #f87171; border: 1px solid #442; }
.alert-warn { background: #2a2313; color: #fbbf24; border: 1px solid #4a3f1a; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at 30% 20%, #171a20 0%, #0d0e11 60%);
}
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 400px; max-width: 100%; background: var(--bg-4);
  border: 1px solid var(--border-2); border-radius: var(--radius-lg); padding: 40px;
}
.login-title { font-size: 22px; font-weight: 700; margin: 24px 0 6px; }
.login-sub { font-size: 14px; color: var(--text-4); margin-bottom: 24px; }
.login-card .alert { margin-bottom: 14px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #0d0e11; font-size: 14px;
}
.brand-mark.lg { width: 32px; height: 32px; border-radius: 8px; }
.brand-name { font-weight: 800; font-size: 16px; }
.brand-name.lg { font-size: 19px; }
.brand.light .brand-mark { color: #fff; }

/* ---------- Admin shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--bg-3);
  border-right: 1px solid var(--border-1);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar .brand { padding: 6px 8px 26px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-3); border-radius: var(--radius-btn);
  padding: 10px 12px; font-size: 14px; font-weight: 600;
}
.nav-item:hover { color: var(--text-1); }
.nav-item.is-active { background: #1d2129; color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.divider { height: 1px; background: var(--border-1); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #2c313a;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #e5e7eb; flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.user-role { font-size: 11px; color: var(--text-4); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; flex-shrink: 0; border-bottom: 1px solid var(--border-1);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
}
.topbar-title { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search {
  width: 260px; flex-shrink: 0; background: var(--bg-input);
  border: 1px solid var(--border-2); border-radius: var(--radius-btn);
  padding: 8px 12px; color: #e5e7eb; font-size: 13px; outline: none; margin-left: 20px;
  font-family: inherit;
}
.content { flex: 1; overflow: auto; padding: 28px; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 22px; font-weight: 800; margin: 0; }
.page-title.mb { margin-bottom: 24px; }

/* ---------- Table ---------- */
.table { border: 1px solid var(--border-1); border-radius: var(--radius-card); overflow: hidden; }
.thead, .trow { display: grid; grid-template-columns: 2.2fr 1.6fr 1fr 1fr 40px; align-items: center; }
.thead {
  padding: 12px 18px; background: var(--bg-4);
  font-size: 11px; font-weight: 700; color: var(--text-5);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.trow { padding: 16px 18px; border-top: 1px solid #1c2028; background: var(--bg-1); color: var(--text-1); }
.trow:hover { background: var(--bg-4); }
.cell-title { font-size: 14px; font-weight: 700; color: var(--text-1); }
.cell-sub { font-size: 12px; color: var(--text-5); margin-top: 2px; }
.cell-client { font-size: 13px; color: var(--text-2); }
.cell-date { font-size: 12px; color: var(--text-5); }
.cell-chevron { color: #5a616c; font-size: 18px; }

.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }

/* ---------- Cards / misc ---------- */
.card {
  border: 1px solid var(--border-1); border-radius: var(--radius-card);
  padding: 16px 18px; background: var(--bg-2); margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 12px; }
.note-card { color: var(--text-4); font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.user-line { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--text-4); font-size: 13px; }
.empty {
  border: 1px dashed var(--border-3); border-radius: var(--radius-card);
  padding: 40px; text-align: center; color: var(--text-4); font-size: 14px;
}
.mb { margin-bottom: 24px; }
.mt { margin-top: 16px; }

/* ---------- Success / credentials ---------- */
.success-hero { text-align: center; margin-bottom: 24px; }
.success-icon {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 14px;
  background: #132a22; color: #34d399; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
}
.creds { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.cred-row {
  border: 1px solid var(--border-1); border-radius: var(--radius-card);
  padding: 14px 16px; background: var(--bg-2);
}
.cred-name { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.cred-pair { display: flex; gap: 10px; align-items: center; font-size: 13px; margin-top: 4px; }
.cred-label { color: var(--text-4); width: 70px; }
.cred-pair code { background: var(--bg-0); padding: 3px 8px; border-radius: 6px; color: var(--text-1); }
.actions-row { margin-top: 20px; }

/* ---------- Center pages (errors / client home) ---------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.error-box { text-align: center; max-width: 420px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--accent); }
.error-title { font-size: 20px; font-weight: 700; margin: 8px 0; }
.error-body { color: var(--text-4); margin-bottom: 20px; }

/* ---------- Client home (light) ---------- */
.client-home { width: 480px; max-width: 100%; text-align: center; }
.client-home .brand { justify-content: center; margin-bottom: 20px; }
.client-hi { font-size: 24px; font-weight: 800; margin: 0 0 20px; }
.client-projects { display: flex; flex-direction: column; gap: 12px; }
.client-project {
  display: block; text-align: left; border: 1px solid #e3e5ea;
  border-radius: var(--radius-card); padding: 16px 18px; background: #fff; color: #1a1d23;
}
.client-project:hover { border-color: var(--accent); }
.client-project .cell-title { color: #1a1d23; }
.client-project .cell-sub { color: #6b7280; }
.viewer .muted { color: #6b7280; }

/* ---------- Buttons (secondary / small) ---------- */
.btn-secondary { background: #1d2129; border: 1px solid var(--border-3); color: #e5e7eb; }
.btn-secondary:hover { background: #22262e; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn-ghost-light.sm { padding: 8px 12px; font-size: 13px; }

/* ---------- Two-column layout ---------- */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.mt-lg { margin-top: 18px; }
.mono { font-family: ui-monospace, monospace; }
.link-inline { font-size: 13px; color: var(--accent); align-self: flex-start; }

.design-row {
  border: 1px solid var(--border-1); border-radius: var(--radius-card);
  padding: 14px 16px; background: var(--bg-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.activity { display: flex; flex-direction: column; gap: 2px; }
.activity-row { display: flex; gap: 10px; font-size: 13px; color: var(--text-3); padding: 5px 0; }
.activity-time { color: #4a515c; flex-shrink: 0; }

/* ---------- Upload ---------- */
.dropzone {
  border: 2px dashed var(--border-3); border-radius: 14px;
  padding: 36px; text-align: center; background: var(--bg-2);
}
.dz-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.dz-sub { font-size: 13px; color: var(--text-5); margin-bottom: 18px; }
.file-input { color: var(--text-2); font-size: 13px; }

/* ---------- Setup ---------- */
.setup-design { border: 1px solid var(--border-1); border-radius: var(--radius-card); overflow: hidden; }
.setup-design-head { background: var(--bg-4); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.tag { font-size: 11px; font-weight: 700; color: var(--accent); background: #161e2e; padding: 3px 8px; border-radius: 6px; flex-shrink: 0; }
.setup-input {
  flex: 1; background: var(--bg-0); border: 1px solid var(--border-2);
  border-radius: 6px; padding: 8px 10px; color: var(--text-1); font-size: 13px;
  font-family: inherit; outline: none;
}
.setup-input.strong { font-weight: 700; }
.setup-input:focus { border-color: var(--accent); }
.sort-field { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-4); flex-shrink: 0; }
.sort-input { width: 54px; background: var(--bg-0); border: 1px solid var(--border-2); border-radius: 6px; padding: 7px 8px; color: var(--text-1); font-size: 13px; }
.setup-screens { padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.setup-screen { display: flex; align-items: center; gap: 10px; }
.setup-screen .mono { width: 130px; flex-shrink: 0; font-size: 12px; }
.skipped { margin: 8px 0 0; padding-left: 18px; font-size: 12px; }
.skipped li { margin: 2px 0; }

/* ================= Client viewer ================= */
.vw { display: flex; flex-direction: column; height: 100vh; }
.vw-top {
  height: 60px; flex-shrink: 0; background: #fff; border-bottom: 1px solid #e3e5ea;
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.vw-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.vw-brand .brand-mark { color: #fff; }
.vw-proj { font-size: 14px; font-weight: 700; color: #1a1d23; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vw-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.vw-preview-tag { font-size: 11px; color: #9aa1ac; }
.device-toggle { display: flex; background: #f0f1f4; border-radius: 8px; padding: 3px; }
.device-toggle button {
  border: none; background: transparent; color: #6b7280;
  border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.device-toggle button.is-active { background: #fff; color: #1a1d23; }

.vw-body { display: flex; flex: 1; min-height: 0; }
.vw-side {
  width: 220px; flex-shrink: 0; border-right: 1px solid #e3e5ea; background: #fbfbfc;
  padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; overflow: auto;
}
.vw.side-collapsed .vw-side { display: none; }
.vw-side-label { font-size: 11px; font-weight: 700; color: #9aa1ac; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.vw-list { display: flex; flex-direction: column; gap: 3px; }
.vw-item {
  text-align: left; background: transparent; color: #374151; border: none;
  border-radius: 7px; padding: 9px 10px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.vw-item:hover { background: #eef0f3; }
.vw-item.is-active { background: var(--accent); color: #fff; }

.vw-canvas { flex: 1; overflow: auto; background: #eef0f3; display: flex; align-items: flex-start; justify-content: center; padding: 28px; position: relative; }
.vw-side-toggle {
  position: absolute; top: 12px; left: 12px; z-index: 5; background: #fff;
  border: 1px solid #e3e5ea; color: #374151; border-radius: 8px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(20,22,28,0.08);
}
.device-frame {
  width: 100%; max-width: 1180px; height: calc(100vh - 60px - 56px);
  background: #fff; border: 1px solid #e3e5ea; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(20,22,28,0.12); overflow: hidden;
}
.vw.is-mobile .device-frame {
  width: 390px; max-width: 390px; height: 844px; max-height: calc(100vh - 60px - 56px);
  border-radius: 32px; border: 8px solid #1a1d23;
}
.device-frame iframe { width: 100%; height: 100%; border: none; display: block; background: #fff; }

.vw-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: #6b7280; font-size: 15px; padding: 40px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .setup-screen .mono { width: 90px; }

  .sidebar { width: 64px; padding: 16px 8px; }
  .sidebar .brand-name, .nav-item span, .user-chip > div, .link-btn { display: none; }
  .nav-item { justify-content: center; }
  .search { display: none; }
  .content { padding: 18px; }
  .thead, .trow { grid-template-columns: 2fr 1fr 60px; }
  .thead > div:nth-child(3), .thead > div:nth-child(4),
  .trow > div:nth-child(3), .trow .cell-date { display: none; }
}

/* ================= Milestone 3: approval, comments, docs ================= */
[hidden] { display: none !important; }

/* Admin: ghost button + select + doc lines */
.btn-ghost { background: none; border: 1px solid var(--border-3); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-4); }
.select {
  background: var(--bg-4); border: 1px solid var(--border-2); border-radius: var(--radius-btn);
  padding: 10px 12px; color: var(--text-1); font-size: 14px; font-family: inherit; outline: none;
}
.doc-group-label { font-size: 11px; font-weight: 700; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.04em; margin: 10px 0 4px; }
.doc-line { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border-1); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.doc-type-tag { font-size: 10px; font-weight: 700; color: var(--text-4); background: var(--bg-4); padding: 2px 7px; border-radius: 10px; flex-shrink: 0; }
.doc-line-title { flex: 1; font-size: 13px; color: var(--text-2); }
.doc-del { background: none; border: none; color: var(--text-5); cursor: pointer; font-size: 14px; }
.doc-del:hover { color: #f87171; }
.doc-add { margin-top: 12px; }
.doc-add summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 600; }
.doc-form { margin-top: 12px; max-width: 100%; }
.doc-form textarea { resize: vertical; background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 8px; padding: 10px; color: var(--text-1); font-family: inherit; font-size: 14px; outline: none; }

/* Viewer: pill buttons in the top bar */
.pill-btn { background: #f0f1f4; border: none; color: #1a1d23; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit; }
.pill-btn:hover { background: #e7e9ee; }

/* Banner */
.vw-bnr { font-size: 13px; font-weight: 700; text-align: center; padding: 10px; }
.vw-bnr-ok { background: #e6f9f1; color: #0f7a4f; border-bottom: 1px solid #b7ecd6; }
.vw-bnr-no { background: #fdecec; color: #b42318; border-bottom: 1px solid #f5c2c2; }

/* Decide buttons */
.vw-decide { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
.btn-approve { background: #16a34a; color: #fff; }
.btn-approve:hover { filter: brightness(1.05); }
.btn-reject { background: #fff; color: #b42318; border: 1px solid #f5c2c2; }
.btn-reject:hover { background: #fdecec; }

/* Side panels (comments / docs) */
.vw-panel { width: 340px; flex-shrink: 0; border-left: 1px solid #e3e5ea; background: #fff; display: flex; flex-direction: column; min-height: 0; }
.vw-panel-head { padding: 14px 18px; border-bottom: 1px solid #e3e5ea; display: flex; align-items: center; justify-content: space-between; }
.vw-panel-title { font-size: 14px; font-weight: 800; color: #1a1d23; }
.panel-close { background: none; border: none; color: #9aa1ac; font-size: 16px; cursor: pointer; }
.vw-panel-body { flex: 1; overflow: auto; padding: 16px 18px; }
.vw-panel-foot { padding: 14px 18px; border-top: 1px solid #e3e5ea; display: flex; flex-direction: column; gap: 8px; }
.vw-panel-foot textarea { resize: none; border: 1px solid #e3e5ea; border-radius: 8px; padding: 9px 10px; font-size: 13px; font-family: inherit; outline: none; }
.vw-panel-foot .btn { align-self: flex-end; }
.vw-muted { color: #9aa1ac; font-size: 13px; }

/* Comments */
.cmt { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.cmt-head { display: flex; align-items: center; gap: 8px; }
.cmt-author { font-size: 13px; font-weight: 700; color: #1a1d23; }
.cmt-badge { font-size: 10px; font-weight: 700; color: #5b6472; background: #eef0f3; padding: 2px 7px; border-radius: 10px; }
.cmt-body { font-size: 13px; color: #374151; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.cmt-time { font-size: 11px; color: #9aa1ac; }

/* Docs */
.doc-section { margin-bottom: 20px; }
.doc-section-title { font-size: 11px; font-weight: 700; color: #9aa1ac; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }
.doc-card { border: 1px solid #e3e5ea; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.doc-card .doc-title { font-size: 13px; font-weight: 700; color: #1a1d23; margin-bottom: 6px; }
.doc-body { font-size: 13px; color: #4b5563; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.doc-link { font-size: 13px; font-weight: 600; color: var(--accent); }

/* Modal */
.vw-modal { position: fixed; inset: 0; background: rgba(15,17,21,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.vw-modal-card { width: 420px; max-width: calc(100% - 32px); background: #fff; border-radius: 14px; padding: 26px; }
.vw-modal-title { font-size: 17px; font-weight: 800; color: #1a1d23; margin-bottom: 10px; }
.vw-modal-body { font-size: 14px; color: #4b5563; line-height: 1.5; margin-bottom: 22px; }
.vw-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }


/* Per-screen "open in new tab" */
.vw-screen-row { display: flex; align-items: center; gap: 4px; }
.vw-screen-btn { flex: 1; min-width: 0; }
.vw-open {
  flex-shrink: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: #6b7280; font-size: 15px; text-decoration: none; line-height: 1;
}
.vw-open:hover { background: #eef0f3; color: #1a1d23; }

/* ===== Delight pack: nav, spinner, badges, guide, CTA, changes, toast ===== */
.device-frame { position: relative; }

/* Loading spinner */
.vw-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.7); z-index: 3; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #d7dbe2; border-top-color: var(--accent); animation: gp-spin 0.8s linear infinite; }
@keyframes gp-spin { to { transform: rotate(360deg); } }

/* Presentation nav */
.vw-nav { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #e3e5ea; border-radius: 999px; padding: 5px 8px; box-shadow: 0 4px 16px rgba(20,22,28,0.12); z-index: 4; }
.nav-arrow { width: 30px; height: 30px; border: none; background: #f0f1f4; color: #1a1d23; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; }
.nav-arrow:hover:not(:disabled) { background: #e3e5ea; }
.nav-arrow:disabled { opacity: 0.4; cursor: default; }
.nav-counter { font-size: 12px; font-weight: 700; color: #374151; min-width: 92px; text-align: center; }

/* Comment badge on a screen row */
.vw-cmt-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 8px; border-radius: 9px; background: #eef0f3; color: #5b6472; font-size: 11px; font-weight: 700; }
.vw-item.is-active .vw-cmt-badge { background: rgba(255,255,255,0.28); color: #fff; }

/* CTA bar */
.vw-cta-bar { background: #eef3ff; color: #2b4a8b; border-bottom: 1px solid #d5e0fb; font-size: 13px; font-weight: 600; text-align: center; padding: 9px 12px; }

/* Third decide button */
.btn-changes { background: #fff; color: #b45309; border: 1px solid #fcd9a6; }
.btn-changes:hover { background: #fff7ec; }

/* Modal textarea */
.vw-modal-textarea { width: 100%; resize: vertical; border: 1px solid #e3e5ea; border-radius: 8px; padding: 10px; font-size: 13px; font-family: inherit; outline: none; margin-bottom: 18px; }
.vw-modal-textarea:focus { border-color: var(--accent); }

/* Welcome guide */
.vw-guide { position: fixed; inset: 0; background: rgba(15,17,21,0.55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; animation: gp-fade 0.2s ease both; }
.vw-guide-card { width: 460px; max-width: 100%; background: #fff; border-radius: 18px; padding: 30px 28px 24px; box-shadow: 0 24px 60px rgba(15,17,21,0.28); animation: gp-pop 0.28s cubic-bezier(0.16,0.84,0.44,1) both; }
.vw-guide-badge { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; box-shadow: 0 6px 16px rgba(91,140,255,0.35); }
.vw-guide-title { font-size: 20px; font-weight: 800; color: #1a1d23; margin-bottom: 6px; letter-spacing: -0.01em; }
.vw-guide-sub { font-size: 13.5px; color: #6b7280; line-height: 1.5; margin-bottom: 22px; }
.vw-guide-steps { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.vw-guide-step { display: flex; gap: 13px; align-items: flex-start; }
.vw-guide-ico { flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; background: #f2f4f8; font-size: 19px; display: flex; align-items: center; justify-content: center; }
.vw-guide-txt { display: flex; flex-direction: column; gap: 3px; }
.vw-guide-txt strong { font-size: 14px; font-weight: 700; color: #1a1d23; }
.vw-guide-txt span { font-size: 13px; color: #6b7280; line-height: 1.5; }
.vw-guide-txt b { color: #374151; font-weight: 700; }
@keyframes gp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gp-pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Toast */
.vw-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1a1d23; color: #fff; font-size: 13px; font-weight: 600; padding: 11px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 70; }

/* Fullscreen: let the canvas fill the screen cleanly */
.vw-canvas:fullscreen { background: #eef0f3; padding: 24px; }
.vw-canvas:-webkit-full-screen { background: #eef0f3; padding: 24px; }

/* ===== Interactive tour ===== */
.pill-help { background: #eaf0ff; color: #2b4a8b; }
.pill-help:hover { background: #dde7ff; }
.tour-backdrop { position: fixed; inset: 0; z-index: 80; }
.tour-box { position: fixed; z-index: 81; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(15,17,21,0.55); pointer-events: none; transition: top .2s ease, left .2s ease, width .2s ease, height .2s ease; }
.tour-tip { position: fixed; z-index: 82; width: 300px; max-width: calc(100vw - 24px); background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 14px 34px rgba(0,0,0,0.28); }
.tour-tip-title { font-size: 15px; font-weight: 800; color: #1a1d23; margin-bottom: 5px; }
.tour-tip-text { font-size: 13px; color: #4b5563; line-height: 1.5; margin-bottom: 14px; }
.tour-tip-row { display: flex; align-items: center; gap: 10px; }
.tour-count { font-size: 12px; color: #9aa1ac; margin-right: auto; }
.tour-skip { background: none; border: none; color: #6b7280; font-size: 13px; cursor: pointer; font-family: inherit; }
.tour-next { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit; }

/* ===== Markdown rendering in doc panel ===== */
.doc-body.md h1, .doc-body.md h2, .doc-body.md h3, .doc-body.md h4 { color: #1a1d23; line-height: 1.3; margin: 12px 0 6px; }
.doc-body.md h1 { font-size: 18px; } .doc-body.md h2 { font-size: 16px; } .doc-body.md h3 { font-size: 14.5px; } .doc-body.md h4 { font-size: 13.5px; }
.doc-body.md p { margin: 0 0 10px; }
.doc-body.md ul, .doc-body.md ol { margin: 0 0 10px; padding-left: 20px; }
.doc-body.md li { margin: 2px 0; }
.doc-body.md a { color: var(--accent); }
.doc-body.md code { background: #f2f4f8; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.doc-body.md pre { background: #0d0e11; color: #e7e9f0; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }
.doc-body.md pre code { background: none; padding: 0; color: inherit; }
.doc-body.md blockquote { margin: 0 0 10px; padding: 4px 12px; border-left: 3px solid #d5dbe6; color: #6b7280; }
.doc-body.md hr { border: none; border-top: 1px solid #e3e5ea; margin: 12px 0; }

/* ===== Setup: screen kind + package docs ===== */
.kind-select { background: var(--bg-0); border: 1px solid var(--border-2); border-radius: 6px; padding: 7px 8px; color: var(--text-1); font-size: 12px; font-family: inherit; outline: none; flex-shrink: 0; }
.kind-select:focus { border-color: var(--accent); }
.pkg-doc { flex-wrap: wrap; }
.pkg-check { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; cursor: pointer; }
.pkg-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ===== Manage: inline design + document editing ===== */
.designs-edit { display: flex; flex-direction: column; gap: 12px; }
.designs-edit-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.del-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-4); cursor: pointer; flex-shrink: 0; user-select: none; }
.del-check input { width: 15px; height: 15px; accent-color: #f87171; }
.doc-edit { font-size: 12px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.doc-edit:hover { text-decoration: underline; }
.actions-row { display: flex; gap: 10px; align-items: center; }

/* ===================== Mobile viewer (modern) ===================== */
/* Elements that only appear on mobile are hidden by default. */
.vw-menu { display: none; }
.vw-drawer-actions { display: none; }
.vw-scrim { display: none; }
.vw-menu {
  background: none; border: none; color: #1a1d23; cursor: pointer;
  width: 38px; height: 38px; border-radius: 9px; align-items: center; justify-content: center; flex-shrink: 0;
}
.vw-menu:hover { background: #f0f1f4; }
.drawer-act {
  display: block; width: 100%; text-align: left; background: #f5f6f8; border: 1px solid #e8eaee;
  color: #1a1d23; border-radius: 10px; padding: 12px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; margin-bottom: 8px;
}
.drawer-act:hover { background: #eef0f3; }

@media (max-width: 820px) {
  /* No horizontal overflow — the whole UI fits the screen width. */
  html, body { overflow-x: hidden; }
  .vw { overflow-x: hidden; }

  /* Top bar: hamburger + brand + title only; the rest lives in the drawer. */
  .vw-top { height: 56px; padding: 0 10px; gap: 8px; }
  .vw-menu { display: flex; }
  .vw-actions { display: none; }
  .vw-proj { font-size: 13px; }
  .brand-mark { width: 26px; height: 26px; }

  /* Sidebar becomes an off-canvas drawer. */
  .vw-body { display: block; height: calc(100vh - 56px); position: relative; }
  .vw-side {
    position: fixed; top: 0; left: 0; height: 100vh; width: 84vw; max-width: 320px;
    transform: translateX(-100%); transition: transform .25s ease; z-index: 40;
    overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 14px 24px;
    box-shadow: 2px 0 24px rgba(15,17,21,0.18);
  }
  .vw.drawer-open .vw-side { transform: none; }
  .vw-drawer-actions { display: block; margin-top: 18px; border-top: 1px solid #e3e5ea; padding-top: 16px; }
  .vw-drawer-actions .device-toggle { width: 100%; margin-bottom: 10px; }
  .vw-drawer-actions .device-toggle button { flex: 1; }
  .vw-decide { margin-top: 16px; }

  /* Scrim behind drawer / panels. */
  .vw-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 38; background: rgba(15,17,21,0.45); }

  /* Canvas fills the screen; the desktop full-width toggle is not needed. */
  .vw-canvas { padding: 10px; height: 100%; }
  .vw-side-toggle { display: none; }

  /* Preview frame fills the width; content SCROLLS instead of being cut. */
  .device-frame {
    width: 100% !important; max-width: 100% !important; height: 100%;
    border-radius: 12px; overflow: auto !important; -webkit-overflow-scrolling: touch;
  }
  /* Mobile preview: the design fills the width, so responsive layouts render
     their phone version — nothing is cut. */
  .vw.is-mobile .device-frame {
    width: 100% !important; max-width: 100% !important; height: 100%;
    border-radius: 14px; border: 1px solid #e3e5ea;
  }
  .vw.is-mobile .device-frame iframe { width: 100%; height: 100%; }
  /* Desktop preview on a phone: render at a real desktop width and let the
     client pan by scrolling, so the full desktop layout is visible (not cut). */
  .vw:not(.is-mobile) .device-frame iframe { width: 1200px; height: 100%; }

  /* Comments / docs panels become full-screen sheets. */
  .vw-panel {
    position: fixed; left: 0; right: 0; top: 56px; bottom: 0; width: 100%; height: auto;
    z-index: 42; box-shadow: none; border-left: none;
  }

  /* Prev/next nav pinned above the thumb, always reachable. */
  .vw-nav { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); }

  /* Banners/CTA text a touch smaller. */
  .vw-cta-bar, .vw-bnr { font-size: 12px; }
}
