:root {
  --studio-blue: #245be7;
  --studio-blue-dark: #1748c7;
  --studio-blue-soft: #eef4ff;
  --studio-ink: #11151d;
  --studio-text: #414b5c;
  --studio-muted: #70798b;
  --studio-bg: #f2f4f7;
  --studio-line: #dfe3e9;
  --studio-white: #fff;
  --cpw: 448px;
  --panel-width: 448px;
}

html,
body { word-break: keep-all; }

.apphdr,
.studio-header {
  height: 68px;
  padding: 0 28px;
  gap: 22px;
  border-bottom-color: var(--studio-line);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 0 rgba(17, 21, 29, .02);
}

.apphdr .lg img,
.studio-brand img { height: 23px; }

.apphdr .lg { gap: 10px; }

.studio-badge,
.studio-brand span {
  min-height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--studio-line);
  border-radius: 999px;
  color: var(--studio-muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .1em;
}

.poc-prod-switch,
.product-switch {
  height: 40px;
  margin-left: 4px;
  padding: 4px;
  border-radius: 11px;
  background: #eff1f4;
}

.poc-prod-switch a,
.product-switch a { min-width: 102px; border-radius: 8px; color: #657083; }

.apphdr .acts,
.header-actions { gap: 7px; }

.hbtn,
.header-button,
.header-link {
  min-height: 38px;
  height: 38px;
  padding: 0 13px;
  border-radius: 9px;
  font-size: 12px;
}

.hbtn:not(.ghost),
.header-button.primary { box-shadow: 0 5px 14px rgba(36, 91, 231, .18); }

.cpanel,
.editor-panel {
  border-color: var(--studio-line);
  box-shadow: -18px 0 50px rgba(17, 21, 29, .055);
}

.cpanel { top: 68px; height: calc(100vh - 68px); padding: 28px 28px 116px; }
.card-workspace { height: calc(100vh - 68px); }

.cpanel h2,
.panel-heading h1 {
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: -.045em;
}

.poc-panel-label,
.panel-heading > p { margin-bottom: 14px; }

.cpanel .sub,
.panel-heading > span { color: var(--studio-muted); font-size: 13px; }

.poc-tabs,
.editor-tabs {
  padding: 4px;
  gap: 4px;
  border: 1px solid #e7eaf0;
  border-radius: 12px;
  background: #f0f2f5;
}

.poc-tabs { top: -28px; margin: 0 -4px 30px; }
.editor-tabs { margin: 0 24px; }

.poc-tab,
.editor-tabs button { min-height: 46px; border-radius: 9px; }

.poc-tab.active,
.editor-tabs button.active {
  background: #fff;
  color: var(--studio-blue);
  box-shadow: 0 2px 7px rgba(17, 21, 29, .09);
}

.cpanel .grp { margin-bottom: 34px; }
.cpanel .gh { margin-bottom: 12px; font-size: 15px; }
.cpanel .opt { min-height: 46px; border-radius: 11px; }
.cpanel .opt.active { border-color: var(--studio-blue); background: var(--studio-blue-soft); color: var(--studio-blue); }
.cpanel .samples { gap: 9px; }
.cpanel .sample-card { border-radius: 11px; }
.cpanel .overlay-card { padding: 18px; border-radius: 15px; background: #f8f9fb; }

.panel-heading { padding: 28px 28px 18px; }
.panel-scroll { padding: 26px 28px 116px; }
.step-heading h2 { margin-top: 6px; font-size: 21px; }
.step-heading p { font-size: 12px; }
.picker { gap: 11px; }
.picker .p { border-radius: 11px; }
.sec { padding: 18px; border-radius: 14px; background: #fafbfc; }

.poc-wizard-nav,
.wizard-actions {
  min-height: 92px;
  padding: 18px 28px;
  border-top-color: var(--studio-line);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 -10px 32px rgba(17, 21, 29, .04);
}

.poc-wizard-nav { width: var(--cpw); }
.poc-nav-button,
.wizard-button { min-height: 50px; border-radius: 11px; }

.sheet,
.canvas-shell { background: var(--studio-bg); }

.poc-canvasbar,
.canvas-toolbar {
  min-height: 62px;
  border-bottom-color: var(--studio-line);
  background: rgba(255, 255, 255, .96);
}

.poc-canvasbar { padding: 0 24px; }
.canvas-toolbar { padding: 0 28px; }

body:not(.thumb) .sheet .stage,
.card-stage {
  background-color: #f1f3f6;
  background-image:
    linear-gradient(rgba(255,255,255,.34), rgba(255,255,255,.34)),
    radial-gradient(#ccd2dc .9px, transparent .9px);
  background-size: auto, 22px 22px;
}

body:not(.thumb) .sheet .vshape {
  border-color: rgba(213, 219, 228, .9);
  background: rgba(255,255,255,.76);
  box-shadow: 0 18px 45px rgba(17,21,29,.075);
}

.cardwrap { box-shadow: 0 28px 60px rgba(17,21,29,.22); }
.face-label { border-color: #d8dde5; box-shadow: 0 4px 14px rgba(17,21,29,.06); }

.poc-view-tabs,
.view-switch { border: 1px solid #e5e8ed; background: #eff1f4; }
.poc-view-tabs button,
.view-switch button { min-height: 34px; }

.canvas-status {
  min-height: 50px;
  border-top-color: var(--studio-line);
  background: rgba(255,255,255,.96);
}

.live-dot { animation: studio-pulse 2.2s ease-in-out infinite; }

@keyframes studio-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(19,148,95,.1); }
  50% { box-shadow: 0 0 0 7px rgba(19,148,95,.04); }
}

@media (min-width: 941px) {
  .sheet { height: calc(100vh - 68px); }
  .apphdr { flex: 0 0 68px; }
  body:not(.thumb) .sheet .stage { padding: 34px 58px; }
  body:not(.thumb) .sheet .vshape > svg { height: min(65vh, 700px) !important; max-height: calc(100vh - 268px); }
}

@media (max-width: 1320px) and (min-width: 941px) {
  :root { --cpw: 420px; --panel-width: 420px; }
  .cpanel { width: var(--cpw); padding-right: 24px; padding-left: 24px; }
  .panel-heading { padding-right: 24px; padding-left: 24px; }
  .panel-scroll { padding-right: 24px; padding-left: 24px; }
  .editor-tabs { margin-right: 20px; margin-left: 20px; }
  .poc-wizard-nav,
  .wizard-actions { padding-right: 24px; padding-left: 24px; }
  body:not(.thumb) .sheet .stage { padding: 26px; gap: 20px; }
  .card-stage { padding: 28px; gap: 28px; }
}

/* Mobile keeps the preview and controls in one viewport. */
@media (max-width: 940px) {
  .apphdr,
  .studio-header { height: 56px; padding: 0 14px; gap: 8px; }
  .apphdr .lg img,
  .studio-brand img { height: 20px; }
  .studio-brand img { width: 108px; height: auto; }
  .studio-badge,
  .studio-brand span { display: none; }
  .poc-prod-switch,
  .product-switch { height: 34px; margin: 0; padding: 2px; }
  .poc-prod-switch a,
  .product-switch a { min-width: 66px; height: 30px; padding: 0 7px; font-size: 11px; }

  html:has(.card-workspace),
  body:has(.card-workspace) { height: 100svh; min-height: 0; overflow: hidden; }
  body:has(.card-workspace) { padding-bottom: 0; }
  .studio-header { position: relative; top: auto; }
  .mobile-menu { width: 38px; height: 38px; }
  .header-actions { top: 56px; padding: 10px 14px; }
  .card-workspace {
    height: calc(100svh - 56px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(250px, 43%) minmax(0, 57%);
    overflow: hidden;
  }
  .canvas-shell { min-height: 0; height: 100%; overflow: hidden; }
  .canvas-toolbar { min-height: 44px; flex-basis: 44px; padding: 0 10px; }
  .canvas-title strong { font-size: 12px; }
  .canvas-title span { display: none; }
  .view-switch { padding: 2px; }
  .view-switch button { min-width: 42px; min-height: 30px; padding: 0 6px; font-size: 11px; }
  .card-stage { min-height: 0; flex: 1; padding: 10px 8px; gap: 8px; overflow: hidden; }
  .card-side { min-width: 0; gap: 6px; }
  .face-label { min-height: 24px; padding: 0 8px; font-size: 10px; }
  .cardwrap { width: min(34vw, 150px); border-radius: 10px; }
  body.card-front-only .cardwrap,
  body.card-back-only .cardwrap { width: min(56vw, 226px); }
  .canvas-status { min-height: 34px; flex-basis: 34px; padding: 0 12px; font-size: 10px; }
  .canvas-status > span:last-child { display: none; }
  .editor-panel { min-height: 0; height: 100%; overflow: hidden; border-top: 1px solid var(--studio-line); }
  .panel-heading { padding: 12px 16px 8px; }
  .panel-heading > p { display: none; }
  .panel-heading h1 { font-size: 20px; }
  .panel-heading > span { display: none; }
  .editor-tabs { position: relative; top: auto; margin: 0 12px; padding: 3px; border-radius: 10px; }
  .editor-tabs button { min-height: 38px; font-size: 11px; }
  .panel-scroll { min-height: 0; flex: 1; padding: 16px 16px 84px; overflow-y: auto; }
  .step-heading { margin-bottom: 16px; }
  .step-heading h2 { font-size: 18px; }
  .step-heading p { font-size: 11px; }
  .picker { grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .wizard-actions { position: relative; inset: auto; z-index: 6; min-height: 72px; flex-basis: 72px; padding: 10px 14px; grid-template-columns: 82px 1fr; }
  .wizard-button { min-height: 48px; }

  html:has(.apphdr),
  body:has(.apphdr) { width: 100%; height: 100svh; min-height: 0; overflow: hidden; }
  body:has(.apphdr):not(.embed):not(.thumb) {
    padding: 0;
    display: grid;
    grid-template-rows: 56px minmax(240px, 42svh) minmax(0, 1fr);
  }
  body:has(.apphdr) .apphdr { grid-row: 1; margin: 0; }
  body:has(.apphdr) .sheet {
    grid-row: 2;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 0;
    border-radius: 0;
  }
  body:has(.apphdr) .sheet .main { min-height: 0; flex: 1; display: flex; flex-direction: column; }
  body:has(.apphdr) .poc-canvasbar { min-height: 44px; flex: 0 0 44px; padding: 0 10px; }
  body:has(.apphdr) .poc-canvas-title strong { font-size: 12px; }
  body:has(.apphdr) .poc-canvas-title span { display: none; }
  body:has(.apphdr) .poc-view-tabs { padding: 2px; }
  body:has(.apphdr) .poc-view-tabs button { min-height: 30px; padding: 0 8px; font-size: 10px; }
  body:has(.apphdr):not(.thumb) .sheet .stage {
    min-height: 0 !important;
    flex: 1;
    padding: 8px 6px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    overflow: hidden;
  }
  body:has(.apphdr):not(.thumb) .sheet .vshape { min-height: 0; padding: 16px 2px 4px; border-radius: 9px; }
  body:has(.apphdr):not(.thumb) .sheet .vshape > svg { width: 100% !important; height: auto !important; max-height: calc(42svh - 92px); margin-top: 16px; }
  body:has(.apphdr) .notice { display: none; }
  body:has(.apphdr) .cpanel {
    grid-row: 3;
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 14px 16px 92px;
    overflow-y: auto !important;
    border-top: 1px solid var(--studio-line);
  }
  body:has(.apphdr) .poc-panel-label { display: none; }
  body:has(.apphdr) .cpanel h2 { margin-bottom: 2px; font-size: 20px; }
  body:has(.apphdr) .cpanel .sub { display: none; }
  body:has(.apphdr) .poc-tabs { position: sticky; top: -14px; z-index: 8; margin: 10px -4px 18px; padding: 3px; }
  body:has(.apphdr) .poc-tab { min-height: 38px; font-size: 11px; }
  body:has(.apphdr) .poc-tab span { display: none; }
  body:has(.apphdr) .cpanel .grp { margin-bottom: 24px; }
  body:has(.apphdr) .cpanel .samples { grid-template-columns: repeat(5, 1fr); }
  body:has(.apphdr) .poc-wizard-nav { width: 100%; min-height: 72px; padding: 10px 14px; grid-template-columns: 82px 1fr; }
  body:has(.apphdr) .appftr { display: none; }
}

@media (max-width: 560px) {
  .studio-brand img { width: 98px; }
  .picker { grid-template-columns: repeat(4, 1fr); }
  .editor-tabs button span { display: none; }
  .cardwrap { width: min(33.5vw, 138px); }
}

@media (max-width: 390px) {
  .apphdr .lg img,
  .studio-brand img { width: 92px; height: auto; }
  .poc-prod-switch a,
  .product-switch a { min-width: 58px; padding: 0 5px; }
  body:has(.apphdr) .cpanel .samples { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}
