/* BASURATTI Studio experience layer — shared polish for workspace, library and AI. */
/* Search keeps its input and result viewport mounted in both editor modes. */
body.studio-shell #editorOverlay .pack-picker-filters{grid-template-columns:minmax(0,1fr) repeat(3,40px);gap:6px}
body.studio-shell #editorOverlay .pack-icon-filter{padding:0;min-height:40px;border-radius:12px}
body.studio-shell #editorOverlay .pack-icon-filter svg{width:18px;height:18px;flex:none}
body.studio-shell #editorOverlay .pack-scope-toggle:focus-visible{outline:2px solid var(--gold);outline-offset:2px}
body.studio-shell #editorOverlay .pack-search-field{display:flex;align-items:center;gap:8px;min-width:0;height:42px;flex:none;margin:0;border:1px solid rgba(255,255,255,.12);border-radius:12px;background:rgba(0,0,0,.17);transition:border-color .25s ease,box-shadow .25s ease}
body.studio-shell #editorOverlay .pack-search-field:focus-within{border-color:rgba(211,167,82,.6);box-shadow:0 0 0 3px rgba(211,167,82,.07)}
body.studio-shell #editorOverlay .pack-search-field>svg{width:16px;height:16px;flex:none;margin-left:11px;color:#99938a}
body.studio-shell #editorOverlay #edPackSearch{width:100%;min-width:0;height:40px;margin:0;padding:0;border:0;outline:0;background:transparent;box-shadow:none;color:#ece8df;font-size:16px;line-height:normal;-webkit-appearance:none;scroll-margin-block:20px}
body.studio-shell #editorOverlay #edPackSearch::placeholder{font-size:12px;color:#88858a}
body.studio-shell #editorOverlay #edPackSearch::-webkit-search-cancel-button{-webkit-appearance:none}
body.studio-shell #editorOverlay #edPackSearchClear{width:38px;height:40px;flex:none;border:0;background:transparent;color:#b4ada1;font-size:22px;cursor:pointer;transition:opacity .2s ease}
body.studio-shell #editorOverlay #edPackSearchClear:disabled{opacity:0;pointer-events:none}
body.studio-shell #editorOverlay .settings-block-handwriting #edPacks{height:220px;min-height:220px;max-height:220px;flex:none;overflow-anchor:none;scrollbar-gutter:stable}
body.studio-shell #editorOverlay #edPacks>.pack-opt{flex-shrink:0}
body.studio-shell #editorOverlay .po-id{font:9px/1.3 ui-monospace,Consolas,monospace;color:#8b8580;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.pack-search-status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
@media(max-width:767px){
  body.studio-shell #editorOverlay .settings-block-handwriting #edPacks{height:248px;min-height:248px;max-height:248px}
}
@media(prefers-reduced-motion:reduce){body.studio-shell #editorOverlay .pack-search-field,body.studio-shell #editorOverlay #edPackSearchClear{transition:none}}
:root{
  --hws-gold:#d6aa57;
  --hws-gold-strong:#eccb82;
  --hws-surface:rgba(18,19,23,.88);
  --hws-line:rgba(255,255,255,.085);
  --hws-ease:cubic-bezier(.22,.82,.24,1);
}

/* Settings architecture: visual grouping only. Controls keep their original
   ids, values and event bindings; these wrappers establish hierarchy. */
body.studio-shell #editorOverlay .editor-side{
  --settings-card-bg:linear-gradient(155deg,rgba(255,255,255,.035),rgba(255,255,255,.014));
  --settings-card-border:rgba(255,255,255,.085);
}
body.studio-shell #editorOverlay .settings-block{
  position:relative;isolation:isolate;display:flex;flex-direction:column;gap:12px;
  margin:0;padding:14px;border:1px solid var(--settings-card-border);border-radius:17px;
  background:var(--settings-card-bg);box-shadow:0 12px 32px rgba(0,0,0,.1),inset 0 1px rgba(255,255,255,.025);
}
body.studio-shell #editorOverlay .settings-block::before{
  content:"";position:absolute;z-index:-1;left:-1px;top:15px;bottom:15px;width:2px;
  border-radius:0 2px 2px 0;background:linear-gradient(180deg,rgba(227,189,112,.9),rgba(211,167,82,.12));
}
body.studio-shell #editorOverlay .settings-block-head{
  display:grid;grid-template-columns:30px minmax(0,1fr);align-items:center;gap:10px;min-width:0;
}
body.studio-shell #editorOverlay .settings-block-index{
  display:grid;place-items:center;width:30px;height:30px;border:1px solid rgba(211,167,82,.27);
  border-radius:10px;background:rgba(211,167,82,.085);color:#ddb970;
  font:700 9px/1 var(--font-mono,monospace);letter-spacing:.04em;
}
body.studio-shell #editorOverlay .settings-block-copy{display:grid;gap:2px;min-width:0}
body.studio-shell #editorOverlay .settings-block-copy b{
  color:#eeeae2;font-size:13px;font-weight:670;line-height:1.25;letter-spacing:.005em;
}
body.studio-shell #editorOverlay .settings-block-copy small{
  color:#777b83;font-size:10.5px;line-height:1.3;
}
body.studio-shell #editorOverlay .settings-block-body{display:grid;gap:9px;min-width:0}
body.studio-shell #editorOverlay .settings-subsection{
  display:flex;flex-direction:column;gap:10px;min-width:0;padding-top:12px;border-top:1px solid rgba(255,255,255,.065);
}
body.studio-shell #editorOverlay .settings-subsection-head{
  display:flex;align-items:baseline;justify-content:space-between;gap:10px;min-width:0;
}
body.studio-shell #editorOverlay .settings-subsection-head b{
  color:#d5d2cc;font-size:10px;font-weight:720;letter-spacing:.075em;text-transform:uppercase;
}
body.studio-shell #editorOverlay .settings-subsection-head span{
  overflow:hidden;color:#656970;font-size:9.5px;line-height:1.2;text-align:right;text-overflow:ellipsis;white-space:nowrap;
}
body.studio-shell #editorOverlay .settings-block-content textarea{min-height:142px}
body.studio-shell #editorOverlay .settings-block-handwriting .pack-picker-head{display:block}
body.studio-shell #editorOverlay .settings-block-handwriting .pack-pick{max-height:220px}
body.studio-shell #editorOverlay .settings-block-presets{background:linear-gradient(150deg,rgba(211,167,82,.055),rgba(255,255,255,.014))}
body.studio-shell #editorOverlay .preset-field{display:grid;gap:8px;min-width:0}
body.studio-shell #editorOverlay .preset-field-label{
  color:#686c74;font-size:9.5px;font-weight:650;letter-spacing:.07em;text-transform:uppercase;
}
body.studio-shell #editorOverlay .preset-row{gap:8px}
body.studio-shell #editorOverlay .preset-primary-actions{grid-template-columns:repeat(2,36px);justify-content:start}
body.studio-shell #editorOverlay .preset-row select{
  width:100%;height:38px;padding:0 32px 0 11px;border:1px solid var(--border-medium);border-radius:10px;
  background-color:#111216;color:var(--text-main);font-size:12.5px;
}
body.studio-shell #editorOverlay .settings-block-page>.fld-row,
body.studio-shell #editorOverlay .settings-block-page>#orientationField{margin:0}
body.studio-shell #editorOverlay .settings-block-page .custom-paper-fields{margin:0}
body.studio-shell #editorOverlay .settings-block-page .page-start-selects{align-items:end}
body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:0;padding:11px;
  border:1px solid rgba(211,167,82,.18);border-radius:12px;background:rgba(211,167,82,.045);
  animation:firstPageStartReveal .24s cubic-bezier(.2,.7,.2,1) both;
}
body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls .fld{
  min-width:0;margin:0;
}
body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls .fld>label{
  display:flex;align-items:end;height:38px;min-height:38px;margin:0;
}
body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls .fld>select,
body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls .fld>input{
  width:100%;height:42px;min-width:0;box-sizing:border-box;
}
body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls[hidden],
body.studio-shell #editorOverlay .settings-block-page:has(#edFirstPageStartMode option[value="standard"]:checked) .first-page-start-controls,
body.studio-shell #editorOverlay .settings-block-page #firstPageStartSideField[hidden]{display:none!important}
@keyframes firstPageStartReveal{
  from{opacity:0;transform:translateY(-5px)}
  to{opacity:1;transform:translateY(0)}
}
@media (prefers-reduced-motion:reduce){
  body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls{animation:none}
}
body.studio-shell #editorOverlay .settings-block-page .first-page-start-hint{
  grid-column:1/-1;margin:0;color:#777b83;font-size:10.5px;line-height:1.45;
}
body.studio-shell #editorOverlay .settings-block-page .page-geometry-settings{
  padding-top:11px;border-top:1px solid rgba(255,255,255,.065);
}
body.studio-shell #editorOverlay .editor-adv.settings-block{
  overflow:visible;padding:0;border:1px solid var(--settings-card-border);background:var(--settings-card-bg);
}
body.studio-shell #editorOverlay .editor-adv.settings-block>summary{
  display:grid;grid-template-columns:30px minmax(0,1fr) 28px;align-items:center;gap:10px;
  min-height:58px;padding:13px 14px;color:var(--text-main);list-style:none;
}
body.studio-shell #editorOverlay .editor-adv.settings-block>summary::before{display:none;content:none}
body.studio-shell #editorOverlay .settings-block-disclosure{
  position:relative;width:28px;height:28px;border:1px solid rgba(255,255,255,.08);border-radius:9px;background:rgba(255,255,255,.025);
}
body.studio-shell #editorOverlay .settings-block-disclosure::before,
body.studio-shell #editorOverlay .settings-block-disclosure::after{
  content:"";position:absolute;left:8px;right:8px;top:13px;height:1px;background:#a58b58;transition:transform .18s ease;
}
body.studio-shell #editorOverlay .settings-block-disclosure::after{transform:rotate(90deg)}
body.studio-shell #editorOverlay .editor-adv.settings-block[open] .settings-block-disclosure::after{transform:rotate(0)}
body.studio-shell #editorOverlay .editor-adv.settings-block>.editor-disclosure-clip>.adv-controls{
  gap:12px;margin:0;padding:0 14px 14px;
}
body.studio-shell #editorOverlay .settings-block .natural-feature-card{margin-top:0}
body.studio-shell #editorOverlay .settings-block-footnote{
  margin:0;padding:10px 11px;border:1px dashed rgba(255,255,255,.075);border-radius:11px;background:rgba(0,0,0,.12);
}
/* Narrow editor columns exist on desktop too. Text-block sliders therefore use
   a stable two-row layout instead of letting the third grid item wrap at random. */
body.studio-shell #editorOverlay .settings-block-typography .settings-subsection-head{
  display:grid;justify-content:stretch;gap:3px;
}
body.studio-shell #editorOverlay .settings-block-typography .settings-subsection-head span{
  overflow:visible;text-align:left;text-overflow:clip;white-space:normal;
}
body.studio-shell #editorOverlay .settings-block-typography .settings-subsection>.range-row{
  grid-template-columns:minmax(0,1fr) minmax(70px,auto)!important;gap:8px 10px!important;min-width:0;
}
body.studio-shell #editorOverlay .settings-block-typography .settings-subsection>.range-row>span:not(.range-num){
  grid-column:1;grid-row:1;min-width:0;line-height:1.3;overflow-wrap:anywhere;
}
body.studio-shell #editorOverlay .settings-block-typography .settings-subsection>.range-row>input[type=range]{
  grid-column:1/-1;grid-row:2;width:100%;min-width:0;margin:0;
}
body.studio-shell #editorOverlay .settings-block-typography .settings-subsection>.range-row>.range-num{
  grid-column:2;grid-row:1;justify-self:end;box-sizing:border-box;min-width:70px;max-width:82px;
}
body.studio-shell #editorOverlay .settings-block-typography .nb-card{
  grid-template-columns:34px minmax(0,1fr) auto;grid-template-rows:auto auto auto;
  align-items:center;gap:5px 9px;padding:12px;
}
body.studio-shell #editorOverlay .settings-block-typography .nb-card .nb-ico{
  grid-column:1;grid-row:1/3;
}
body.studio-shell #editorOverlay .settings-block-typography .nb-card .nb-title{
  grid-column:2;grid-row:1;min-width:0;line-height:1.3;overflow-wrap:anywhere;
}
body.studio-shell #editorOverlay .settings-block-typography .nb-card .nb-switch{
  grid-column:3;grid-row:1;
}
body.studio-shell #editorOverlay .settings-block-typography .nb-card .nb-badge{
  grid-column:2;grid-row:2;justify-self:start;
}
body.studio-shell #editorOverlay .settings-block-typography .nb-card .nb-desc{
  grid-column:1/-1;grid-row:3;margin-top:3px;line-height:1.4;
}
/* The old 52px value column clipped physical units in the ordinary editor. */
body.studio-shell #editorOverlay .editor-adv.settings-block .range-num{
  box-sizing:border-box;justify-self:end;min-width:70px;max-width:82px;
}
body.studio-shell #editorOverlay .editor.tb-mode .tb-settings:not(.settings-block-typography){
  padding:13px;border:1px solid var(--settings-card-border);border-radius:15px;background:var(--settings-card-bg);
}
body.studio-shell #editorOverlay .editor.tb-mode .tb-bg-head>span{
  color:#d5d2cc;font-size:10px;font-weight:720;letter-spacing:.07em;text-transform:uppercase;
}
body.studio-shell #editorOverlay .ed-mode-switch{
  position:sticky;z-index:5;top:-18px;margin:0 -2px 2px;padding:4px;border-color:rgba(255,255,255,.08);
  background:rgba(11,12,15,.94);box-shadow:0 8px 24px rgba(0,0,0,.18);backdrop-filter:blur(14px);
}

@media (max-width:767px){
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side{
    box-sizing:border-box!important;width:100%!important;max-width:100%!important;min-width:0!important;
    overflow-x:hidden!important;overscroll-behavior-x:none!important;
  }
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side>.ed-mode-switch,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side>.settings-block,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side>.editor-export-settings{
    box-sizing:border-box!important;width:100%!important;max-width:100%!important;min-width:0!important;
    margin-left:0!important;margin-right:0!important;
  }
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side>.ed-mode-switch{
    position:static!important;margin-top:0!important;
  }
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .settings-block-body,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .settings-subsection,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .fld,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .fld-row,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .pack-picker-head,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .pack-picker-filters,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .pack-pick,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .preset-field,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .preset-row,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .preset-actions,
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .adv-controls{
    box-sizing:border-box;max-width:100%;min-width:0;
  }
  body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side>.ed-mode-switch,
  body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side>.settings-block,
  body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side>.editor-export-settings{margin-bottom:12px}
  body.studio-shell #editorOverlay .settings-block{padding:13px;border-radius:16px}
  body.studio-shell #editorOverlay .settings-block-head{grid-template-columns:28px minmax(0,1fr);gap:9px}
  body.studio-shell #editorOverlay .settings-block-index{width:28px;height:28px;border-radius:9px}
  body.studio-shell #editorOverlay .settings-block-copy b{font-size:13.5px}
  body.studio-shell #editorOverlay .settings-block-copy small{font-size:10.5px}
  body.studio-shell #editorOverlay .settings-subsection{gap:11px;padding-top:13px}
  body.studio-shell #editorOverlay .settings-subsection-head{display:grid;gap:3px}
  body.studio-shell #editorOverlay .settings-subsection-head span{text-align:left;white-space:normal}
  body.studio-shell #editorOverlay .settings-block-content textarea{min-height:180px}
  body.studio-shell #editorOverlay .editor-adv.settings-block .range-row{
    grid-template-columns:minmax(0,1fr) minmax(70px,auto)!important;
  }
  body.studio-shell #editorOverlay .settings-block-handwriting .pack-pick{max-height:248px}
  body.studio-shell #editorOverlay .settings-block-handwriting .pack-opt{
    box-sizing:border-box;min-height:68px;padding:10px 12px 11px;align-items:center;overflow:hidden;
  }
  body.studio-shell #editorOverlay .settings-block-handwriting .pack-opt .po-main{
    align-content:center;gap:5px;min-height:42px;overflow:hidden;
  }
  body.studio-shell #editorOverlay .settings-block-handwriting .pack-opt .po-title{line-height:1.22}
  body.studio-shell #editorOverlay .settings-block-handwriting .pack-opt .po-author{
    display:block;padding-bottom:1px;font-size:11px;line-height:1.35;
  }
  body.studio-shell #editorOverlay .settings-block-handwriting .pack-opt .po-side{align-content:center}
  body.studio-shell #editorOverlay .preset-primary-actions{grid-template-columns:repeat(2,44px)!important}
  body.studio-shell #editorOverlay .preset-actions{
    display:flex!important;grid-template-columns:none!important;align-items:center!important;
    justify-content:flex-start!important;gap:8px!important;flex-wrap:wrap!important;
  }
  body.studio-shell #editorOverlay .preset-actions .btn-mini.icon-only{
    flex:0 0 44px;width:44px!important;height:44px!important;padding:0!important;
  }
  body.studio-shell #editorOverlay .preset-actions .btn-mini.system{
    grid-column:auto!important;flex:0 1 auto;width:auto!important;min-width:132px;height:44px!important;margin:0!important;
  }
  body.studio-shell #editorOverlay .settings-block-page .fld-row{grid-template-columns:1fr 1fr!important}
  body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls{grid-template-columns:1fr}
  body.studio-shell #editorOverlay .editor-adv.settings-block>summary{min-height:62px;padding:14px 13px}
  body.studio-shell #editorOverlay .editor-adv.settings-block>.editor-disclosure-clip>.adv-controls{padding:0 13px 13px}
  body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-text .settings-block-typography{
    display:flex!important;margin-bottom:2px!important;padding:13px!important;
  }
  body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-text .editor-pack-field{margin-bottom:12px!important}
  body.studio-shell #editorOverlay .editor.tb-mode .ed-mode-switch{position:static;margin:0 0 12px;box-shadow:none}
}

@media (min-width:768px){
  body.studio-shell #editorOverlay .editor-adv.settings-block .range-row{
    grid-template-columns:minmax(76px,auto) minmax(80px,1fr) minmax(70px,auto)!important;
  }
}

@media (max-width:380px){
  body.studio-shell #editorOverlay .settings-block{padding:11px}
  body.studio-shell #editorOverlay .settings-block-page .fld-row{grid-template-columns:1fr!important}
  body.studio-shell #editorOverlay .settings-block-page .first-page-start-controls{grid-template-columns:1fr}
  body.studio-shell #editorOverlay .preset-actions .btn-mini.system{
    flex:1 1 100%;width:100%!important;
  }
}

/* Mobile saved-documents toolbar: compact hierarchy instead of a loose
   two-column control wall. Dynamic controls keep their existing ids/events. */
@media (max-width:767px){
  html body.studio-shell .docs .docs-head{
    display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;
    align-items:center!important;gap:9px!important;min-height:0!important;padding:14px!important;
  }
  html body.studio-shell .docs .docs-title-wrap{
    grid-column:1/-1!important;display:flex!important;align-items:center!important;
    width:100%!important;min-width:0!important;min-height:32px!important;gap:9px!important;
  }
  html body.studio-shell .docs .docs-title{
    width:auto!important;flex:0 1 auto!important;font-size:18px!important;font-weight:620!important;line-height:1.2!important;
  }
  html body.studio-shell .docs .docs-count{
    min-width:26px!important;height:24px!important;padding:0 7px!important;font-size:10.5px!important;
  }
  html body.studio-shell .docs .view-toggle{display:none!important}
  html body.studio-shell .docs .docs-head #statusFilter,
  html body.studio-shell .docs .docs-head #sortFilter{
    box-sizing:border-box!important;width:100%!important;min-width:0!important;max-width:100%!important;
    height:42px!important;margin:0!important;padding:0 32px 0 12px!important;border-radius:12px!important;
    overflow:hidden!important;text-overflow:ellipsis!important;font-size:12.5px!important;
  }
  html body.studio-shell .docs .docs-head .docs-bulk-actions{
    grid-column:1/-1!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;
    align-items:center!important;width:100%!important;min-width:0!important;margin:2px 0 0!important;gap:8px!important;
  }
  html body.studio-shell .docs .docs-head .docs-bulk-actions .btn{
    box-sizing:border-box!important;width:100%!important;min-width:0!important;height:40px!important;
    padding:0 9px!important;border-radius:11px!important;gap:6px!important;font-size:11px!important;white-space:nowrap!important;
  }
  html body.studio-shell .docs .docs-head .docs-bulk-actions .btn svg{
    width:16px!important;height:16px!important;flex:none!important;
  }
  html body.studio-shell .docs .docs-head .docs-retention{
    grid-column:1/-1!important;margin:1px 0 0!important;padding-top:2px!important;
    color:#666a72!important;font-size:10.5px!important;line-height:1.25!important;text-align:center!important;white-space:normal!important;
  }
  html body.studio-shell .docs .empty-row{
    min-height:142px!important;padding:30px 18px!important;display:grid;place-content:center;gap:5px;
    font-size:12.5px!important;line-height:1.45!important;
  }
  html body.studio-shell .docs .empty-row b{
    margin:0!important;font-size:15px!important;font-weight:620!important;line-height:1.3!important;
  }
}

@media (max-width:360px){
  html body.studio-shell .docs .docs-head{grid-template-columns:1fr!important;padding:12px!important}
  html body.studio-shell .docs .docs-title-wrap,
  html body.studio-shell .docs .docs-head .docs-bulk-actions{grid-column:1!important}
  html body.studio-shell .docs .docs-head .docs-bulk-actions{grid-template-columns:1fr!important}
  html body.studio-shell .docs .docs-head .docs-retention{grid-column:1!important}
}

.studio-shell .main{
  background:
    radial-gradient(900px 520px at 72% -180px,rgba(211,167,82,.065),transparent 66%),
    radial-gradient(650px 420px at 10% 105%,rgba(106,83,42,.035),transparent 68%),
    #0c0d0f;
}
.studio-shell .screen.active{animation:hwsViewIn .48s var(--hws-ease) both}
@keyframes hwsViewIn{from{opacity:0;transform:translateY(10px);filter:blur(2px)}to{opacity:1;transform:none;filter:none}}

/* Desktop navigation: quieter chrome, stronger active context. */
@media(min-width:768px){
  .studio-shell .app{grid-template-columns:244px minmax(0,1fr)}
  .studio-shell .sidebar{
    padding:22px 17px 18px;border-right-color:rgba(255,255,255,.075);
    background:linear-gradient(180deg,#111216 0%,#0e0f12 100%);
    box-shadow:18px 0 60px -48px #000;
  }
  .studio-shell .logo{margin-bottom:25px;padding:0 4px}
  .studio-shell .logo-mark{width:40px;height:40px;border-radius:12px;box-shadow:0 8px 22px -14px rgba(211,167,82,.7)}
  .studio-shell .logo-text{font-size:15px;line-height:1.2;letter-spacing:-.01em}
  .studio-shell .logo-text small{margin-top:4px;color:#676b72;font-size:9px;letter-spacing:.16em}
  .studio-shell .nav{gap:5px}
  .studio-shell .nav-item{
    height:46px;padding:0 13px;border-radius:11px;color:#888c94;font-size:13px;
    transition:color .2s ease,background .2s ease,border-color .2s ease,transform .2s var(--hws-ease);
  }
  .studio-shell .nav-item:hover{transform:translateX(2px);background:rgba(255,255,255,.032);color:#d7d8da}
  .studio-shell .nav-item.active{
    color:#f2eee6;border-color:rgba(211,167,82,.19);
    background:linear-gradient(90deg,rgba(211,167,82,.12),rgba(211,167,82,.035));
    box-shadow:inset 0 1px 0 rgba(255,255,255,.025);
  }
  .studio-shell .nav-item.active::before{top:11px;bottom:11px;width:2px;box-shadow:0 0 12px rgba(211,167,82,.7)}
  .studio-shell .ws-wrap,.studio-shell .lib-wrap{width:100%;max-width:1500px;margin-inline:auto}

  /* Keep portrait previews inside their own saved-work row. */
  body.studio-shell .docs:not(.docs-grid) tbody tr,
  body.studio-shell .docs:not(.docs-grid) tbody td{height:136px!important}
  body.studio-shell .docs:not(.docs-grid) .file-cell{min-height:116px!important}
  body.studio-shell .docs:not(.docs-grid) .doc-preview-thumb{
    --thumb-inset:0px!important;
    width:88px!important;height:116px!important;min-width:88px!important;
    overflow:hidden!important;display:grid!important;place-items:center!important;
  }
  body.studio-shell .docs:not(.docs-grid) .document-sheet{
    max-width:100%!important;max-height:100%!important;
  }
}

/* Workspace: controlled density on large screens. */
.studio-shell .ws-wrap{padding:24px clamp(20px,3vw,44px) 42px}
.studio-shell .ws-content{padding-right:0}
.studio-shell .workspace-head{
  border-color:var(--hws-line);background:
    radial-gradient(540px 230px at 92% -8%,rgba(211,167,82,.14),transparent 68%),
    linear-gradient(145deg,rgba(22,23,27,.97),rgba(14,15,18,.98));
}
.studio-shell .workspace-head::before{
  content:"";position:absolute;left:28px;right:28px;bottom:0;height:1px;
  background:linear-gradient(90deg,transparent,rgba(211,167,82,.25),transparent);opacity:.65;
}
.studio-shell .workspace-title{font-weight:620}
.studio-shell .last-card,.studio-shell .docs{transition:border-color .25s ease,box-shadow .25s ease,transform .25s var(--hws-ease)}
.studio-shell .last-card:hover{border-color:rgba(211,167,82,.18);box-shadow:0 24px 60px -44px rgba(0,0,0,.96)}
.studio-shell .docs-head{backdrop-filter:blur(14px)}
.studio-shell .btn,.studio-shell .act-btn,.studio-shell .vt-btn{transition-duration:.2s}

/* Handwriting library: product-like discovery instead of a plain card dump. */
.studio-shell .lib-wrap{padding:30px clamp(20px,3vw,44px) 52px}
.studio-shell .lib-title{font-size:clamp(29px,3.4vw,43px);font-weight:630;line-height:1.05;letter-spacing:-.045em}
.studio-shell .lib-title::before{
  content:"BASURATTI COLLECTION";display:block;margin-bottom:9px;color:var(--hws-gold);
  font-size:10px;font-weight:750;letter-spacing:.16em;
}
.studio-shell .notice{
  max-width:850px;margin-top:13px;padding:13px 15px;border:1px solid rgba(211,167,82,.12);
  border-radius:13px;background:rgba(211,167,82,.035);
}
.studio-shell .notice-ico{margin-top:0;background:rgba(211,167,82,.08)}
.studio-shell .notice-text{color:#8f939a;line-height:1.55}
.studio-shell .filters{
  position:sticky;z-index:15;top:12px;display:grid;grid-template-columns:minmax(260px,1fr) auto auto auto;
  margin-top:20px;padding:9px;border:1px solid var(--hws-line);border-radius:16px;
  background:rgba(14,15,18,.82);box-shadow:0 18px 46px -35px #000;
  -webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);
}
.studio-shell .lib-search{width:100%;height:44px;border:0;border-radius:11px;background:rgba(255,255,255,.035)}
.studio-shell .select-lg,.studio-shell .btn-filter{height:44px;border-radius:11px;background:rgba(255,255,255,.025)}
.studio-shell .lib-native-select{
  min-width:148px;padding:0 36px 0 13px;appearance:none;color-scheme:dark;
  color:#e8e4dc;background-color:#15161a;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a9a39a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 12px center;
}
.studio-shell .lib-native-select option,.studio-shell .lib-native-select optgroup{background:#15161a;color:#f4f0e6}
.studio-shell .font-grid{grid-template-columns:repeat(auto-fill,minmax(min(285px,100%),1fr));gap:20px;margin-top:22px}
.studio-shell .font-card{
  border-color:var(--hws-line);border-radius:19px;background:linear-gradient(155deg,#15161a,#0f1013);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.025),0 22px 44px -36px rgba(0,0,0,.95);
  transition:transform .32s var(--hws-ease),border-color .25s ease,box-shadow .32s var(--hws-ease);
}
.studio-shell .font-card::after{border-radius:19px}
.studio-shell .font-card:hover{transform:translateY(-4px);border-color:rgba(211,167,82,.35);box-shadow:0 28px 55px -35px rgba(0,0,0,.95),0 0 0 1px rgba(211,167,82,.04)}
.studio-shell .fc-preview{aspect-ratio:16/10}
.studio-shell .fc-preview::before{background:repeating-linear-gradient(180deg,rgba(154,124,72,.065) 0 1px,transparent 1px 24px),radial-gradient(140% 90% at 50% -10%,rgba(255,255,255,.2),transparent 60%)}
.studio-shell .fc-body{padding:17px;gap:12px}
.studio-shell .fc-name{font-size:17px;letter-spacing:-.02em}
.studio-shell .progress{height:5px}
.studio-shell .progress-quality{background:#31343a}
.studio-shell .progress-quality>i{background:linear-gradient(90deg,#bf9450,#e7c071)}
.studio-shell .progress-quality.is-zero{background:#363940}
.studio-shell .progress-quality.is-zero>i{width:0!important;box-shadow:none}
.studio-shell .fc-quality-label.is-zero b{color:#858991}
.studio-shell .system-pack-folder{grid-column:1/-1;min-width:0;border:1px solid var(--hws-line);border-radius:18px;background:linear-gradient(145deg,rgba(255,255,255,.025),rgba(255,255,255,.012));overflow:hidden}
.studio-shell .system-pack-folder>summary{display:flex;align-items:center;gap:13px;min-height:74px;padding:14px 17px;cursor:pointer;list-style:none;user-select:none}
.studio-shell .system-pack-folder>summary::-webkit-details-marker{display:none}
.studio-shell .system-pack-folder-icon{display:grid;place-items:center;width:43px;height:43px;flex:none;border:1px solid rgba(211,167,82,.22);border-radius:12px;background:rgba(211,167,82,.075);color:var(--hws-gold);font:700 15px/1 Georgia,serif}
.studio-shell .system-pack-folder-copy{display:grid;gap:4px;min-width:0;margin-right:auto}
.studio-shell .system-pack-folder-copy b{color:#eeeae2;font-size:15px;font-weight:650}
.studio-shell .system-pack-folder-copy small{color:#858991;font-size:11.5px}
.studio-shell .system-pack-folder-count{display:grid;place-items:center;min-width:28px;height:28px;padding:0 8px;border-radius:999px;background:rgba(255,255,255,.055);color:#b7b9bd;font-size:11px;font-weight:700}
.studio-shell .system-pack-folder-chevron{color:#8f939a;font-size:20px;transition:transform .24s var(--hws-ease)}
.studio-shell .system-pack-folder[open] .system-pack-folder-chevron{transform:rotate(180deg)}
.studio-shell .system-pack-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(285px,100%),1fr));gap:20px;padding:4px 17px 17px}
.studio-shell .lib-foot{gap:18px;padding-top:22px}
.studio-shell .lib-auto-status{display:flex;align-items:center;justify-content:center;gap:9px;margin-left:auto;color:#7f838a;font-size:11.5px}
.studio-shell .lib-auto-status[hidden]{display:none}
.studio-shell .lib-auto-status>i{width:7px;height:7px;border-radius:50%;background:#73777e;box-shadow:0 0 0 5px rgba(115,119,126,.08)}
.studio-shell .lib-auto-status.is-loading>i{background:var(--hws-gold);animation:packLoadPulse 1s ease-in-out infinite}
@keyframes packLoadPulse{50%{transform:scale(1.45);box-shadow:0 0 0 8px rgba(211,167,82,0)}}

@media(max-width:980px) and (min-width:768px){
  .studio-shell .app{grid-template-columns:86px minmax(0,1fr)}
  .studio-shell .sidebar{padding-inline:12px}
  .studio-shell .logo{justify-content:center}.studio-shell .logo-text{display:none}
  .studio-shell .btn-new{justify-content:center;padding:0}.studio-shell .btn-new span,.studio-shell .btn-new::after{display:none}
  .studio-shell .nav-item{justify-content:center;padding:0}.studio-shell .nav-item .nav-label,.studio-shell .nav-item>span:not(.assistant-nav-badge):not(.machine-update-dot):not(.machine-update-alert){display:none}
}

@media(max-width:767px){
  .studio-shell .main{background:radial-gradient(520px 260px at 75% -80px,rgba(211,167,82,.06),transparent 70%),#0c0d0f}
  .studio-shell .ws-wrap,.studio-shell .lib-wrap{padding:14px 12px 32px!important}
  .studio-shell .workspace-head::before{left:15px;right:15px}
  .studio-shell .lib-title{font-size:30px}.studio-shell .lib-title::before{font-size:8px;margin-bottom:7px}
  .studio-shell .notice{margin-top:11px;padding:11px 12px;border-radius:12px}
  .studio-shell .filters{
    position:static;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:14px;padding:0;border:0;background:transparent;box-shadow:none;
  }
  .studio-shell .lib-search{grid-column:1/-1;height:46px;border:1px solid var(--hws-line)}
  .studio-shell .select-lg{grid-column:1/-1;width:100%!important;min-width:0;overflow:hidden;text-overflow:ellipsis}
  .studio-shell .btn-filter{width:100%;min-width:0;padding:0 12px;justify-content:center;font-size:11.5px;white-space:nowrap}.studio-shell .btn-filter svg{width:17px;height:17px}
  .studio-shell .pack-mine-filter{grid-column:auto!important}
  .studio-shell #btnOpenGlyphEditor{grid-column:1/-1}
  .studio-shell .font-grid{grid-template-columns:1fr;gap:13px;margin-top:16px}
  .studio-shell .system-pack-grid{grid-template-columns:1fr;gap:13px;padding:4px 10px 10px}
  .studio-shell .system-pack-folder>summary{min-height:68px;padding:12px}
  .studio-shell .system-pack-folder-copy small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .studio-shell .font-card{border-radius:17px}.studio-shell .font-card::after{border-radius:17px}
  .studio-shell .fc-preview{aspect-ratio:16/9}.studio-shell .fc-body{padding:15px}
  .studio-shell .lib-foot{align-items:center}.studio-shell .lib-auto-status{margin:0;text-align:center;line-height:1.45}

}

@media(prefers-reduced-motion:reduce){
  .studio-shell .screen.active{animation:none!important}
  .studio-shell .nav-item,.studio-shell .font-card{transition:none!important}
  .studio-shell .lib-auto-status.is-loading>i{animation:none!important}
}

/* Mobile foundation: one safe viewport contract for browsers and Telegram. */
:root{
  --hws-safe-top:max(env(safe-area-inset-top,0px),var(--hws-tg-safe-top,0px));
  --hws-safe-right:max(env(safe-area-inset-right,0px),var(--hws-tg-safe-right,0px));
  --hws-safe-bottom:max(env(safe-area-inset-bottom,0px),var(--hws-tg-safe-bottom,0px));
  --hws-safe-left:max(env(safe-area-inset-left,0px),var(--hws-tg-safe-left,0px));
}
.editor-mobile-view-toggle,.tb-mobile-settings-head,
.tb-mobile-insert-panel,.tb-mobile-settings-scrim{display:none}

@media(max-width:767px){
  html,body{height:var(--hws-vvh,100dvh);min-height:0}
  body.studio-shell .app{
    height:var(--hws-vvh,100dvh)!important;
    padding-top:var(--hws-safe-top)!important;
    padding-right:var(--hws-safe-right)!important;
    padding-left:var(--hws-safe-left)!important;
  }
  body.studio-shell .main{scroll-padding-top:14px!important}

  /* Every document editor occupies only the safe content rectangle. */
  html body.studio-shell #editorOverlay.modal-overlay{
    display:block!important;box-sizing:border-box!important;
    padding:var(--hws-safe-top) var(--hws-safe-right) var(--hws-safe-bottom) var(--hws-safe-left)!important;
  }
  html body.studio-shell #editorOverlay .editor{
    position:relative;width:100%!important;height:100%!important;min-height:0!important;
    display:grid!important;grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto minmax(0,1fr) auto!important;overflow:hidden!important;
  }
  html body.studio-shell #editorOverlay .editor-head{
    grid-column:1!important;grid-row:1!important;min-width:0!important;
    padding:10px 10px!important;gap:8px!important;
    background:rgba(15,16,19,.98)!important;
  }
  html body.studio-shell #editorOverlay #edBack{
    display:grid!important;place-items:center!important;flex:0 0 auto!important;
  }
  html body.studio-shell #editorOverlay #edClose{display:none!important}
  html body.studio-shell #editorOverlay .editor-mobile-view-toggle{
    display:grid!important;place-items:center!important;flex:0 0 auto!important;
    color:#d8d8d8!important;
  }
  html body.studio-shell #editorOverlay .editor-mobile-view-toggle.is-preview{
    color:var(--gold)!important;border-color:rgba(211,167,82,.45)!important;
    background:rgba(211,167,82,.1)!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .editor-mobile-view-toggle{display:none!important}
  html body.studio-shell #editorOverlay .editor-head .e-title input{font-size:16px!important}

  /* The settings and the sheet are two views of one editor, not stacked panes. */
  html body.studio-shell #editorOverlay .editor-stage{display:contents!important}
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .editor-side{
    position:static!important;grid-column:1!important;grid-row:2!important;
    display:block!important;min-height:0!important;max-height:none!important;
    overflow-y:auto!important;padding:14px 12px 22px!important;border:0!important;
  }
  html body.studio-shell #editorOverlay .editor:not(.tb-mode):not(.mobile-preview-mode) .stage-canvas{display:none!important}
  html body.studio-shell #editorOverlay .editor:not(.tb-mode).mobile-preview-mode .editor-side{display:none!important}
  html body.studio-shell #editorOverlay .editor:not(.tb-mode).mobile-preview-mode .stage-canvas{
    grid-column:1!important;grid-row:2!important;display:flex!important;min-height:0!important;
    padding:10px!important;overflow:auto!important;
  }
  html body.studio-shell #editorOverlay .stage-bar{
    grid-column:1!important;grid-row:3!important;min-width:0!important;
    min-height:58px!important;padding:7px 10px!important;gap:8px!important;
    border-top:1px solid rgba(255,255,255,.09)!important;background:#101115!important;
  }
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .stage-bar #edPreview{
    flex:1 1 auto!important;aspect-ratio:auto!important;padding:0 15px!important;
  }
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .stage-bar #edPreview .btn-label,
  html body.studio-shell #editorOverlay .editor.tb-mode .stage-bar #edExport .btn-label{display:inline!important}
  html body.studio-shell #editorOverlay .stage-bar .btn{width:44px!important;height:44px!important;flex:0 0 auto!important}
  html body.studio-shell #editorOverlay .editor:not(.tb-mode) .stage-bar #edPreview,
  html body.studio-shell #editorOverlay .editor.tb-mode .stage-bar #edExport{width:auto!important}

  /* Text blocks: canvas stays primary; settings are explicit bottom sheets. */
  html body.studio-shell #editorOverlay .editor.tb-mode .editor-side{
    display:none!important;position:absolute!important;z-index:82!important;
    left:8px!important;right:8px!important;bottom:0!important;top:auto!important;
    width:auto!important;max-height:min(74%,620px)!important;overflow-y:auto!important;
    padding:0 14px calc(18px + var(--hws-safe-bottom))!important;
    border:1px solid rgba(255,255,255,.11)!important;border-bottom:0!important;
    border-radius:24px 24px 0 0!important;background:#111216!important;
    box-shadow:0 -24px 70px rgba(0,0,0,.62)!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-open .editor-side{display:block!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .editor-side>*{display:none!important}
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-open .tb-mobile-settings-head{
    position:sticky;z-index:3;top:0;display:flex!important;align-items:center;justify-content:space-between;
    gap:12px;margin:0 -14px 14px;padding:14px 14px 11px;border-bottom:1px solid rgba(255,255,255,.08);
    background:rgba(17,18,22,.96);backdrop-filter:blur(18px);
  }
  .tb-mobile-settings-head>div{display:grid;gap:2px}.tb-mobile-settings-head span{color:var(--gold);font-size:9px;font-weight:750;letter-spacing:.12em;text-transform:uppercase}.tb-mobile-settings-head b{font-size:17px;font-weight:620}
  .tb-mobile-settings-close{display:grid;place-items:center;width:42px;height:42px;flex:none;border:1px solid rgba(255,255,255,.1);border-radius:14px;background:#191a1f;color:#eee;font-size:25px}
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-text .ed-mode-switch,
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-text .editor-pack-field,
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-text .tb-settings:not(.tb-pages-panel):not(.tb-execution-panel):not(.tb-guide-panel):not(.tb-bg-panel){display:flex!important}
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-background .tb-bg-import-panel{display:flex!important}
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-background .tb-bg-panel{display:flex!important}
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-objects .tb-mobile-insert-panel{display:grid!important}
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-open .tb-mobile-settings-scrim,
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-mobile-sheet-open + .tb-mobile-settings-scrim{display:block!important}
  html body.studio-shell #editorOverlay .tb-mobile-settings-scrim{
    position:absolute;z-index:78;inset:0;width:100%;height:100%;border:0;background:rgba(0,0,0,.58);backdrop-filter:blur(3px);
  }
  .tb-mobile-insert-panel{grid-template-columns:1fr;gap:9px}
  .tb-mobile-command{width:100%;min-height:68px;display:grid;grid-template-columns:44px minmax(0,1fr);grid-template-rows:auto auto;align-items:center;gap:2px 11px;padding:10px 12px;text-align:left;border:1px solid rgba(255,255,255,.08);border-radius:17px;background:#17181d}
  .tb-mobile-command>span{grid-row:1/3;display:grid;place-items:center;width:44px;height:44px;border-radius:14px;background:rgba(211,167,82,.11);color:var(--gold);font-size:18px;font-weight:700}
  .tb-mobile-command b{align-self:end;font-size:14px}.tb-mobile-command small{align-self:start;color:var(--text-muted);font-size:10.5px}

  html body.studio-shell #editorOverlay .editor.tb-mode .tb-stage{grid-column:1!important;grid-row:2!important;min-height:0!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-toolbar{
    order:0!important;position:relative!important;display:flex!important;justify-content:space-between!important;
    gap:6px!important;min-height:52px!important;padding:5px 7px!important;overflow:hidden!important;
    border-top:0!important;border-bottom:1px solid rgba(255,255,255,.08)!important;box-shadow:none!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-page-nav{display:none!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-toolbar{justify-content:flex-end!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-toolbar .tb-tbtn{min-height:40px!important;height:40px!important;padding:6px 9px!important;border-radius:12px!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-toolbar .tb-icon-btn{width:38px!important;padding:0!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-create-tools #tbBgUpload,
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-create-tools #tbAddDrawing{display:none!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-create-tools #tbAddBlock span{font-size:0!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-create-tools #tbAddBlock span::after{content:"Текст";font-size:11px}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-scene-wrap{order:2!important;min-height:0!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-overflow-card{order:1!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav{
    order:3!important;display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr))!important;
    gap:5px!important;padding:6px 7px!important;border-top:1px solid rgba(255,255,255,.08)!important;background:#101115!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button{
    min-width:0!important;min-height:49px!important;display:grid!important;place-items:center!important;align-content:center!important;
    gap:2px!important;padding:4px 2px!important;border-radius:13px!important;font-size:9.5px!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button::before{color:#b8bac0;font-size:16px;font-weight:650;line-height:1}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button[data-tb-mobile="text"]::before{content:"T"}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button[data-tb-mobile="background"]::before{content:"▧"}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button[data-tb-mobile="objects"]::before{content:"＋"}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button[data-tb-mobile="pages"]::before{content:"▤"}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button[data-tb-mobile="export"]::before{content:"↓"}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button.active{border-color:rgba(211,167,82,.48)!important;background:rgba(211,167,82,.13)!important;color:var(--gold)!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-mobile-nav button.active::before{color:var(--gold)!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .stage-bar #edExport{flex:1 1 auto!important;aspect-ratio:auto!important;padding:0 14px!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .stage-bar #tbClearDraft{display:none!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-context-tools:not([hidden]){
    display:flex!important;right:8px!important;top:48px!important;bottom:auto!important;transform:none!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-block-editor{
    left:8px!important;right:8px!important;top:auto!important;bottom:8px!important;width:auto!important;
    max-height:min(76%,560px)!important;border-radius:20px!important;padding:12px!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-block-editor textarea{min-height:112px!important;font-size:16px!important}

  /* Saved works use a real paper-shaped thumbnail instead of a landscape crop. */
  body.studio-shell .docs tbody tr{grid-template-columns:minmax(0,1fr) auto!important;padding:14px!important}
  body.studio-shell .docs tbody td:first-child{grid-column:1/-1!important;grid-row:1!important}
  body.studio-shell .docs tbody td:nth-child(2){grid-column:1!important;grid-row:2!important}
  body.studio-shell .docs tbody td:nth-child(3){grid-column:1!important;grid-row:3!important}
  body.studio-shell .docs tbody td:nth-child(4){grid-column:1!important;grid-row:4!important}
  body.studio-shell .docs tbody td:last-child{grid-column:2!important;grid-row:2/5!important}
  body.studio-shell .docs .file-cell{display:grid!important;grid-template-columns:auto 88px minmax(0,1fr)!important;align-items:center!important;gap:11px!important}
  body.studio-shell .docs .doc-preview-thumb{width:88px!important;height:116px!important;min-width:88px!important;border-radius:12px!important;background:#0b0c0f!important;overflow:hidden!important}
  body.studio-shell .docs .document-sheet{max-width:calc(100% - 8px)!important;max-height:calc(100% - 8px)!important}

  /* Other fullscreen surfaces obey the same top and bottom contract. */
  html body.studio-shell .account-dropdown{padding:calc(var(--hws-safe-top) + 10px) calc(var(--hws-safe-right) + 12px) calc(var(--hws-safe-bottom) + 12px) calc(var(--hws-safe-left) + 12px)!important}
  html body.studio-shell .profile-content-island{max-height:none!important;min-height:0!important}
  html body.studio-shell .export-drawer{
    top:calc(var(--hws-safe-top) + 8px)!important;right:calc(var(--hws-safe-right) + 8px)!important;
    bottom:calc(var(--hws-safe-bottom) + 8px)!important;left:calc(var(--hws-safe-left) + 8px)!important;
    width:auto!important;max-height:none!important;border-radius:20px!important;transform:translateY(10px) scale(.99)!important;
  }
  html body.studio-shell .export-drawer.open{transform:none!important}
  html body.studio-shell .docs-panel-content{height:calc(var(--hws-vvh,100dvh) - var(--hws-safe-top))!important}
  html body.studio-shell .docs-panel-head{padding-top:14px!important}
  html body.studio-shell .work-save-overlay{padding:calc(var(--hws-safe-top) + 12px) calc(var(--hws-safe-right) + 12px) calc(var(--hws-safe-bottom) + 12px) calc(var(--hws-safe-left) + 12px)!important}
  html body.studio-shell .work-save-dialog{max-height:100%!important;overflow:auto!important}
  html body.studio-shell .full-access-required-overlay{padding:calc(var(--hws-safe-top) + 12px) calc(var(--hws-safe-right) + 12px) calc(var(--hws-safe-bottom) + 12px) calc(var(--hws-safe-left) + 12px)!important}
  html body.studio-shell .drawing-modal-overlay{padding:calc(var(--hws-safe-top) + 8px) calc(var(--hws-safe-right) + 8px) calc(var(--hws-safe-bottom) + 8px) calc(var(--hws-safe-left) + 8px)!important}
  html body.studio-shell .drawing-modal{max-height:100%!important}
}

@media(max-width:380px){
  body.studio-shell .docs .file-cell{grid-template-columns:auto 76px minmax(0,1fr)!important;gap:8px!important}
  body.studio-shell .docs .doc-preview-thumb{width:76px!important;height:102px!important;min-width:76px!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-page-nav #tbPageAddToolbar{display:none!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-toolbar .tb-tbtn{padding-inline:7px!important}
}

/* Mobile follow-up: make the remaining actions explicit and thumb-safe. */
.docs-panel-foot{display:none}
.studio-shell .work-select-control{display:inline-flex;align-items:center;gap:6px;flex:none;color:#8f9299;font-size:10.5px;line-height:1;cursor:pointer}
.studio-shell .work-select-control>span{display:none}

@keyframes mobileAvatarLoading{
  0%{transform:translateX(-125%)}
  100%{transform:translateX(125%)}
}

@media(max-width:767px){
  /* The dock opens the account directly and previews the actual account. */
  .studio-shell .mobile-account-avatar{
    position:relative;display:grid;place-items:center;width:28px;height:28px;flex:none;overflow:hidden;
    border:1px solid rgba(211,167,82,.34);border-radius:50%;background:#292a2f;color:#e7c36f;
    font-size:10px;font-weight:750;letter-spacing:.02em;box-shadow:0 0 0 3px rgba(211,167,82,.055);
  }
  .studio-shell .mobile-account-avatar img{display:block;width:100%;height:100%;object-fit:cover}
  .studio-shell .mobile-account-avatar.profile-loading{color:transparent;background:linear-gradient(135deg,#24262b,#34363d)}
  .studio-shell .mobile-account-avatar.profile-loading::after{
    content:"";position:absolute;inset:0;background:linear-gradient(100deg,transparent,rgba(255,255,255,.18),transparent);
    animation:mobileAvatarLoading 1.15s ease-in-out infinite;
  }
  .studio-shell .btn-mobile-menu.active .mobile-account-avatar{border-color:var(--gold);box-shadow:0 0 0 3px rgba(211,167,82,.13)}

  /* The documentation panel owns the safe rectangle, including Telegram's header. */
  html body.studio-shell .docs-panel{
    box-sizing:border-box!important;align-items:stretch!important;justify-content:stretch!important;
    padding:var(--hws-safe-top) var(--hws-safe-right) var(--hws-safe-bottom) var(--hws-safe-left)!important;
  }
  html body.studio-shell .docs-panel-content{
    width:100%!important;max-width:none!important;height:100%!important;max-height:none!important;min-height:0!important;
    border-radius:0!important;overflow:hidden!important;
  }
  html body.studio-shell .docs-panel-head{
    position:relative!important;z-index:2!important;flex:0 0 auto!important;min-height:64px!important;
    padding:10px 10px 10px 16px!important;background:rgba(17,18,22,.98)!important;
  }
  html body.studio-shell .docs-panel-head h3{min-width:0!important;padding-right:4px!important;font-size:17px!important;line-height:1.25!important}
  html body.studio-shell .docs-panel-close{
    display:grid!important;place-items:center!important;width:46px!important;height:46px!important;min-width:46px!important;
    border:1px solid rgba(255,255,255,.13)!important;border-radius:14px!important;background:#24252a!important;color:#fff!important;
  }
  html body.studio-shell .docs-panel-body{flex:1 1 auto!important;min-height:0!important;padding:14px!important;overflow-y:auto!important}
  html body.studio-shell .docs-panel-foot{
    display:flex!important;flex:0 0 auto!important;padding:9px 12px!important;border-top:1px solid rgba(255,255,255,.08)!important;background:#111216!important;
  }
  html body.studio-shell .docs-panel-close-bottom{
    width:100%!important;min-height:46px!important;border:1px solid rgba(211,167,82,.34)!important;border-radius:14px!important;
    background:rgba(211,167,82,.11)!important;color:var(--gold)!important;font-size:13px!important;font-weight:700!important;
  }

  /* The page ellipsis opens this sheet; its actions are never clipped by the toolbar. */
  html body.studio-shell #editorOverlay .tb-mobile-pages-sheet{z-index:96!important}
  html body.studio-shell #editorOverlay .tb-mobile-pages-content{
    gap:11px!important;max-height:min(72%,620px)!important;
    padding:14px 14px calc(14px + var(--hws-safe-bottom))!important;border-radius:22px 22px 0 0!important;
  }
  html body.studio-shell #editorOverlay .tb-mobile-page-actions{display:grid!important;grid-template-columns:1fr!important;gap:8px!important;padding-top:2px!important}
  html body.studio-shell #editorOverlay .tb-mobile-page-actions .tb-tbtn{width:100%!important;justify-content:center!important;min-height:44px!important}

  /* Selected block width is a labeled, readable control rather than a stray slider. */
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-block-width{
    left:8px!important;right:auto!important;bottom:8px!important;transform:none!important;
    display:grid!important;grid-template-columns:1fr!important;gap:7px!important;width:min(232px,calc(100% - 126px))!important;min-width:0!important;
    padding:10px 11px!important;border-radius:15px!important;background:rgba(18,19,23,.97)!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-block-width[hidden]{display:none!important}
  html body.studio-shell #editorOverlay .tb-block-width>span::before{display:none!important}
  html body.studio-shell #editorOverlay .tb-block-width-label{display:flex!important;align-items:baseline!important;justify-content:space-between!important;gap:8px!important}
  html body.studio-shell #editorOverlay .tb-block-width-label b{color:#e8e8e8!important;font-size:11.5px!important;font-weight:650!important}
  html body.studio-shell #editorOverlay .tb-block-width-label small{color:var(--gold)!important;font-size:10.5px!important;font-variant-numeric:tabular-nums!important}
  html body.studio-shell #editorOverlay .tb-block-width input[type=range]{width:100%!important;min-width:0!important;margin:0!important}

  /* Keep destructive cleanup visible in blocks mode, but compact. */
  html body.studio-shell #editorOverlay .editor.tb-mode .stage-bar #tbClearDraft{
    display:grid!important;place-items:center!important;width:44px!important;height:44px!important;flex:0 0 44px!important;
    color:#dfa08e!important;border-color:rgba(223,126,98,.27)!important;background:rgba(223,126,98,.07)!important;
  }
  html body.studio-shell #editorOverlay .editor.tb-mode .stage-bar #tbClearDraft .btn-label{display:none!important}

  /* Last work: compact thumbnail column, protected text column, full-width actions. */
  body.studio-shell .last-card{
    grid-template-columns:96px minmax(0,1fr)!important;grid-template-rows:auto auto auto auto auto auto!important;
    align-items:start!important;gap:5px 13px!important;min-height:0!important;padding:12px!important;
  }
  body.studio-shell .last-card .preview{
    grid-column:1!important;grid-row:1/6!important;width:96px!important;height:132px!important;min-width:96px!important;
    align-self:start!important;border-radius:12px!important;
  }
  body.studio-shell .last-card .last-info{display:contents!important}
  body.studio-shell .last-card .last-label{grid-column:2!important;grid-row:1!important;min-width:0!important;margin:1px 0 0!important}
  body.studio-shell .last-card .last-title{
    grid-column:2!important;grid-row:2!important;min-width:0!important;max-width:100%!important;margin:0!important;
    font-size:19px!important;line-height:1.15!important;overflow-wrap:anywhere!important;
  }
  body.studio-shell .last-card .last-badge{
    position:static!important;grid-column:2!important;grid-row:3!important;justify-self:start!important;
    width:max-content!important;max-width:100%!important;margin:2px 0!important;
  }
  body.studio-shell .last-card .meta{grid-column:2!important;grid-row:4!important;min-width:0!important;gap:5px!important;margin:2px 0 0!important}
  body.studio-shell .last-card .meta-row{grid-template-columns:58px minmax(0,1fr)!important;gap:5px!important;min-width:0!important;font-size:11.5px!important;line-height:1.35!important}
  body.studio-shell .last-card .m-value{min-width:0!important;overflow-wrap:anywhere!important}
  body.studio-shell .last-card .card-sep{display:none!important}
  body.studio-shell .last-card .card-actions{
    grid-column:1/-1!important;grid-row:6!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;width:100%!important;margin-top:7px!important;
  }
  body.studio-shell .last-card .card-actions .btn{min-width:0!important;width:100%!important;min-height:43px!important;padding:0 9px!important;font-size:11px!important}
  body.studio-shell .last-card #lastEdit{grid-column:1/-1!important}

  /* Saved works are one grid, not five cells overflowing over each other. */
  body.studio-shell .docs:not(.docs-grid) tbody tr{
    grid-template-columns:88px minmax(0,1fr)!important;grid-template-rows:auto auto auto auto auto!important;
    align-items:start!important;gap:7px 12px!important;padding:13px!important;
  }
  body.studio-shell .docs:not(.docs-grid) tbody td{height:auto!important;min-height:0!important;padding:0!important}
  body.studio-shell .docs:not(.docs-grid) tbody td:first-child,
  body.studio-shell .docs:not(.docs-grid) .file-cell{display:contents!important}
  body.studio-shell .docs:not(.docs-grid) .doc-preview-thumb{
    grid-column:1!important;grid-row:1/5!important;position:relative!important;z-index:1!important;
    width:88px!important;height:116px!important;min-width:88px!important;align-self:start!important;
  }
  body.studio-shell .docs:not(.docs-grid) .file-main{
    grid-column:2!important;grid-row:1!important;align-self:start!important;min-width:0!important;position:relative!important;z-index:2!important;
    display:flex!important;flex-wrap:wrap!important;align-items:flex-start!important;gap:7px!important;padding-top:1px!important;
  }
  body.studio-shell .docs:not(.docs-grid) .file-main .file-name{
    width:100%!important;min-width:0!important;white-space:normal!important;overflow-wrap:anywhere!important;font-size:15px!important;line-height:1.25!important;
  }
  body.studio-shell .docs:not(.docs-grid) tbody td:nth-child(2){grid-column:2!important;grid-row:2!important;min-width:0!important;overflow-wrap:anywhere!important}
  body.studio-shell .docs:not(.docs-grid) tbody td:nth-child(2)::before{content:"Почерк: ";color:#676a71!important}
  body.studio-shell .docs:not(.docs-grid) tbody td:nth-child(3){grid-column:2!important;grid-row:3!important;justify-self:start!important}
  body.studio-shell .docs:not(.docs-grid) tbody td:nth-child(4){grid-column:2!important;grid-row:4!important;min-width:0!important}
  body.studio-shell .docs:not(.docs-grid) tbody td:nth-child(4)::before{content:"Изменён: ";color:#676a71!important}
  body.studio-shell .docs:not(.docs-grid) tbody td:last-child{
    grid-column:2!important;grid-row:5!important;align-self:center!important;position:static!important;width:100%!important;min-width:0!important;
  }
  body.studio-shell .docs:not(.docs-grid) .act-cell{display:grid!important;grid-template-columns:repeat(5,42px)!important;justify-content:start!important;gap:6px!important;width:100%!important}
  body.studio-shell .docs:not(.docs-grid) .act-btn{width:42px!important;height:42px!important}
  body.studio-shell .docs:not(.docs-grid) .work-select-control{
    grid-column:1!important;grid-row:5!important;display:flex!important;align-items:center!important;justify-content:center!important;
    width:88px!important;min-height:42px!important;padding:5px 4px!important;border:1px solid rgba(255,255,255,.09)!important;
    border-radius:11px!important;background:rgba(255,255,255,.025)!important;color:#b5b7bc!important;
  }
  body.studio-shell .docs .work-select-control>span{display:inline!important;white-space:nowrap!important}
  body.studio-shell .docs .work-check{position:static!important;margin:0!important;flex:0 0 auto!important}

  body.studio-shell .docs.docs-grid .file-cell{
    display:grid!important;grid-template-columns:1fr!important;grid-template-rows:170px auto auto!important;row-gap:9px!important;
  }
  body.studio-shell .docs.docs-grid .doc-preview-thumb{grid-column:1!important;grid-row:1!important;width:100%!important;height:170px!important;order:initial!important}
  body.studio-shell .docs.docs-grid .work-select-control{grid-column:1!important;grid-row:2!important;justify-content:flex-start!important;width:max-content!important;padding-inline:9px!important;order:initial!important}
  body.studio-shell .docs.docs-grid .file-main{grid-column:1!important;grid-row:3!important;width:100%!important;margin:0!important;padding:0!important;order:initial!important}

  html body.studio-shell .docs-panel,
  html body.studio-shell .docs-panel-content{overflow:hidden!important;overscroll-behavior:none!important}
  html body.studio-shell .docs-panel-body{overflow-anchor:none!important;scroll-behavior:auto!important}
}

@media(max-width:380px){
  body.studio-shell .last-card{grid-template-columns:82px minmax(0,1fr)!important;column-gap:10px!important}
  body.studio-shell .last-card .preview{width:82px!important;height:116px!important;min-width:82px!important}
  body.studio-shell .last-card .last-title{font-size:17px!important}
  body.studio-shell .last-card .meta-row{grid-template-columns:52px minmax(0,1fr)!important;font-size:10.8px!important}
  html body.studio-shell #editorOverlay .editor.tb-mode .tb-page-nav #tbPageAddToolbar{display:grid!important}
  body.studio-shell .docs:not(.docs-grid) tbody tr{grid-template-columns:76px minmax(0,1fr)!important;column-gap:9px!important}
  body.studio-shell .docs:not(.docs-grid) .doc-preview-thumb{width:76px!important;height:102px!important;min-width:76px!important}
  body.studio-shell .docs:not(.docs-grid) .work-select-control{width:76px!important;font-size:9.5px!important}
  body.studio-shell .docs:not(.docs-grid) .act-cell{grid-template-columns:repeat(5,40px)!important;gap:5px!important}
  body.studio-shell .docs:not(.docs-grid) .act-btn{width:40px!important;height:40px!important}
}

@media(prefers-reduced-motion:reduce){
  .studio-shell .mobile-account-avatar.profile-loading::after{animation:none!important}
}

/* Notebook proofing belongs to the preview, including the phone's preview tab. */
.preview-page-frame.machine-execution-frame,.pv-image-wrap.machine-execution-frame{aspect-ratio:var(--machine-preview-ratio);background:#111416;overflow:hidden;border-radius:8px}
.pv-image-wrap.machine-execution-frame{width:min(92vw,1000px,calc(76vh * var(--machine-preview-ratio)));height:auto}
.preview-page-frame.machine-execution-frame>img,.pv-image-wrap.machine-execution-frame>img{display:block;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;border:0!important;background:transparent!important;box-shadow:none!important;object-fit:contain}
.machine-execution-frame>.preview-bounds-box{display:none!important}
.machine-preview-status{position:absolute;inset:auto 8px 8px;padding:8px 12px;border-radius:8px;background:rgba(17,20,22,.92);color:#e7c071;font-size:12px;line-height:1.4;pointer-events:none}
.preview-viewer-overlay.open:has(.machine-execution-frame){display:grid;grid-template-rows:auto minmax(0,1fr) auto auto;gap:8px}
.preview-viewer-overlay:has(.machine-execution-frame)>.preview-viewer-top{position:relative;grid-row:1}
.preview-viewer-overlay:has(.machine-execution-frame)>.preview-viewer-stage{position:relative;inset:auto;grid-row:2;min-height:0;container-type:size}
.preview-viewer-overlay:has(.machine-execution-frame)>.pv-metrics{position:relative;inset:auto;grid-row:3;margin:0 12px}
.preview-viewer-overlay:has(.machine-execution-frame)>.pv-counter{position:relative;inset:auto;transform:none;grid-row:4;justify-self:center;margin-bottom:18px}
.preview-viewer-overlay .pv-image-wrap.machine-execution-frame{width:min(92vw,1000px,calc(98cqh * var(--machine-preview-ratio)))}
.page-geometry-grid>label[hidden]{display:none!important}
.preview-page-frame.notebook-workarea-frame,.pv-image-wrap.notebook-workarea-frame{aspect-ratio:var(--notebook-ratio);background:#fff;overflow:hidden;border-radius:var(--radius-sm);isolation:isolate}
.pv-image-wrap.notebook-workarea-frame{width:min(94vw,1200px,calc(88vh * var(--notebook-ratio)));height:auto}
.preview-page-frame.notebook-workarea-frame>img,.pv-image-wrap.notebook-workarea-frame>img{position:absolute!important;left:var(--notebook-image-left)!important;top:var(--notebook-image-top)!important;width:var(--notebook-image-width)!important;height:var(--notebook-image-height)!important;max-width:none!important;max-height:none!important;border:0!important;border-radius:0!important;box-shadow:none!important}
.preview-page-frame.notebook-workarea-frame>.notebook-paper-overlay{inset:0;width:100%;height:100%}
.paper-preview-controls{overflow:hidden;box-sizing:border-box;position:relative;z-index:6;min-width:0;background:#121317;border-bottom:1px solid var(--border-medium);color:var(--text-main)}
.paper-preview-controls[hidden],.editor.tb-mode .paper-preview-controls{display:none!important}
.paper-preview-controls>summary{display:flex;align-items:center;justify-content:flex-end;gap:10px;min-height:44px;padding:8px 16px;cursor:pointer;list-style:none;font-size:12px}
.paper-preview-controls>summary::-webkit-details-marker{display:none}
.paper-preview-controls>summary>b{color:var(--gold);font-weight:600}
.paper-preview-controls:focus-within{border-color:rgba(211,167,82,.45)}
.paper-preview-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:4px 16px 16px;max-height:48vh;overflow-y:auto;overscroll-behavior:contain}
.paper-preview-settings [hidden]{display:none!important}
.paper-preview-controls>summary>span:last-child{transition:transform .24s ease}
.paper-preview-controls>summary[aria-expanded="true"]>span:last-child{transform:rotate(180deg)}
@media(prefers-reduced-motion:reduce){.paper-preview-controls>summary>span:last-child{transition:none}}
.paper-preview-settings label{display:flex;flex-direction:column;gap:6px;min-width:0;font-size:11px;color:var(--text-secondary)}
.paper-preview-settings select,.paper-preview-settings input[type=number]{width:100%;min-width:0;min-height:40px;padding:6px 9px;border:1px solid var(--border-medium);border-radius:8px;background:#1b1c21;color:var(--text-main);font:inherit;font-size:13px}
.paper-preview-settings input:disabled{opacity:.4}
.paper-preview-settings .paper-preview-check{flex-direction:row;align-items:center;gap:8px;min-height:40px}
.paper-preview-check input{width:18px;height:18px;accent-color:var(--gold)}
.paper-preview-hint{grid-column:1/-1;margin:0;color:var(--text-muted);font-size:11px;line-height:1.5}
.paper-preview-reset{grid-column:1/-1;justify-self:start;min-height:40px;padding:8px 12px;border:1px solid var(--border-medium);border-radius:8px;background:#1b1c21;color:var(--gold);font-size:12px}
.editor:not(.tb-mode) .editor-stage:has(>.paper-preview-controls:not([hidden])){grid-template-rows:auto minmax(0,1fr) auto}
.preview-page-frame:has(.notebook-paper-overlay),.pv-image-wrap:has(.notebook-paper-overlay){isolation:isolate}
.notebook-paper-overlay{position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none;mix-blend-mode:multiply;border-radius:var(--radius-sm);overflow:hidden}
.preview-page-frame>.notebook-paper-overlay{inset:1px;width:calc(100% - 2px);height:calc(100% - 2px)}
.preview-page-frame>.preview-mode-badge,.preview-page-frame>.preview-bounds-box,.pv-image-wrap>.preview-bounds-box{z-index:2}
@media(max-width:767px){
  html body.studio-shell #editorOverlay .editor:not(.tb-mode):not(.mobile-preview-mode) .paper-preview-controls{display:none!important}
  html body.studio-shell #editorOverlay .editor:not(.tb-mode).mobile-preview-mode:has(.paper-preview-controls:not([hidden])){grid-template-rows:auto auto minmax(0,1fr) auto!important}
  html body.studio-shell #editorOverlay .paper-preview-controls{grid-column:1!important;grid-row:2!important}
  html body.studio-shell #editorOverlay .editor:not(.tb-mode).mobile-preview-mode:has(.paper-preview-controls:not([hidden])) .stage-canvas{grid-row:3!important}
  html body.studio-shell #editorOverlay .editor:not(.tb-mode).mobile-preview-mode:has(.paper-preview-controls:not([hidden])) .stage-bar{grid-row:4!important}
  .paper-preview-controls>summary{min-height:46px;padding:8px 12px}
  .paper-preview-settings{grid-template-columns:repeat(2,minmax(0,1fr));padding:4px 12px 12px;gap:10px;max-height:42dvh}
  .paper-preview-settings input[type=number],.paper-preview-settings select{min-height:44px;font-size:16px}
}

/* Editor motion: short, reversible transitions; layout stays measurable while hidden. */
html body.studio-shell #editorOverlay.modal-overlay{
  display:flex!important;opacity:0;visibility:hidden;pointer-events:none;animation:none!important;
  transition:opacity .24s ease,visibility 0s linear .24s;
}
html body.studio-shell #editorOverlay.modal-overlay.open{
  opacity:1;visibility:visible;pointer-events:auto;transition-delay:0s;
}
html body.studio-shell #editorOverlay>.editor{
  transform:translateY(10px);transition:transform .26s cubic-bezier(.22,.75,.2,1),width .26s ease,height .26s ease;
}
html body.studio-shell #editorOverlay.open>.editor{transform:translateY(0)}
#editorOverlay details{overflow-anchor:none}
#editorOverlay details>div{animation:none!important}
#editorOverlay .editor-disclosure-clip{min-height:0;overflow:hidden}
#editorOverlay .editor-disclosure-clip .adv-controls,
#editorOverlay .editor-disclosure-clip .inline-machine-config,
#editorOverlay .editor-disclosure-clip .editor-export-grid{animation:none!important}
#editorOverlay .sheet-alignment-settings{margin-top:12px;border-top:1px solid var(--border-soft);padding-top:6px}
#editorOverlay .sheet-alignment-settings>summary{display:flex;align-items:center;gap:10px;cursor:pointer;list-style:none;padding:10px 0;font-size:12px;color:var(--text-muted)}
#editorOverlay .sheet-alignment-settings>summary::-webkit-details-marker{display:none}
#editorOverlay .sheet-alignment-settings>summary::after{content:"";width:6px;height:6px;border-right:1px solid var(--gold);border-bottom:1px solid var(--gold);transform:rotate(45deg);margin-left:auto;transition:transform .25s ease}
#editorOverlay .sheet-alignment-settings[open]>summary::after{transform:rotate(225deg)}
#editorOverlay .sheet-alignment-content{padding-top:6px}
.studio-shell .workspace-top-row{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:18px}
.studio-shell .workspace-top-row .crumbs{order:0;margin:0}
.studio-shell .workspace-top-row #exportRail{order:1;position:static;flex-shrink:0;transform:none;box-shadow:none;z-index:auto}
.studio-shell .workspace-top-row #exportRail:hover{transform:none}
@media(min-width:768px){
  html body.studio-shell #editorOverlay>.editor.tb-mode{transition:transform .26s ease,width .26s ease,height .26s ease,grid-template-columns .28s cubic-bezier(.22,.75,.2,1)}
  html body.studio-shell #editorOverlay .editor.tb-mode .editor-side{min-width:0;transition:opacity .22s ease,visibility 0s}
  html body.studio-shell #editorOverlay .editor.tb-mode.tb-side-hidden .editor-side{display:block!important;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .18s ease,visibility 0s .28s}
}
@media(max-width:767px){
  .studio-shell .workspace-top-row{gap:10px;flex-wrap:wrap;margin-bottom:12px}
  .studio-shell .workspace-top-row #exportRail{margin-left:auto;height:36px;padding:0 10px}
}
@media(prefers-reduced-motion:reduce){
  html body.studio-shell #editorOverlay.modal-overlay,
  html body.studio-shell #editorOverlay>.editor,
  html body.studio-shell #editorOverlay>.editor.tb-mode,
  html body.studio-shell #editorOverlay .editor.tb-mode .editor-side{transition:none!important}
}

/* Compact-height desktop mode.
   Short notebook viewports need denser spacing and local scrolling, while
   controls must keep a usable hit area instead of becoming flexbox stripes.
   Width gating keeps the established phone layout completely separate. */
@media (min-width:768px) and (max-height:700px){
  :root{
    --hws-compact-control-h:36px;
    --hws-compact-edge:12px;
  }

  html,body{height:100%;min-height:0}
  body.studio-shell .app,
  body.studio-shell .sidebar,
  body.studio-shell .main{
    height:100vh;
    height:100dvh;
    min-height:0;
  }

  /* Navigation may scroll when optional machine/admin entries are present,
     but its actions never surrender their height to flexbox. */
  body.studio-shell .sidebar{padding:12px 14px 10px}
  body.studio-shell .sb-top{
    min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:2px;
    scrollbar-width:none;overscroll-behavior:contain;
  }
  body.studio-shell .sb-top::-webkit-scrollbar{display:none}
  body.studio-shell .sidebar .logo,
  body.studio-shell .sidebar .btn-new,
  body.studio-shell .sidebar .nav,
  body.studio-shell .sidebar .nav-item,
  body.studio-shell .sidebar .sb-bottom,
  body.studio-shell .sidebar .account,
  body.studio-shell .sidebar .plotter{flex-shrink:0}
  body.studio-shell .logo{margin-bottom:12px}
  body.studio-shell .btn-new{
    height:38px;min-height:38px;margin-bottom:12px;border-radius:10px;
  }
  body.studio-shell .nav{gap:2px}
  body.studio-shell .nav-item{height:38px;min-height:38px}
  body.studio-shell .nav-item.active::before{top:8px;bottom:8px}
  body.studio-shell .nav-about{margin-top:4px}
  body.studio-shell .sb-bottom{margin-top:7px}
  body.studio-shell .account,
  body.studio-shell .plotter{padding-top:8px;padding-bottom:8px;min-height:50px}
  body.studio-shell .avatar{width:34px;height:34px}
  body.studio-shell .plotter-ico{width:36px;height:36px}

  /* Main scrolling screens retain their normal composition with a denser
     first viewport; content below it remains available through .main. */
  body.studio-shell .ws-wrap{padding:12px 24px 24px}
  body.studio-shell .lib-wrap{padding:16px 24px 28px}
  body.studio-shell .workspace-head{
    margin-bottom:12px;padding:16px 20px 15px;border-radius:16px;
  }
  body.studio-shell .workspace-head .crumbs{margin-bottom:9px}
  body.studio-shell .workspace-title-row{margin-bottom:12px}
  body.studio-shell .workspace-title{font-size:clamp(25px,2.7vw,33px)}
  body.studio-shell .workspace-description{margin-top:6px;line-height:1.4}
  body.studio-shell .workspace-stat{padding-block:7px}
  body.studio-shell .workspace-head .search-bar{height:42px;min-height:42px}
  body.studio-shell .saved-time-card{margin-bottom:12px;padding:11px 16px}
  body.studio-shell .saved-time-card .stc-headline b{font-size:32px}
  body.studio-shell .last-card{min-height:224px;padding:13px}
  body.studio-shell .last-card .preview{height:196px}
  body.studio-shell .last-info{padding-top:0}
  body.studio-shell .docs-head{min-height:60px;padding:11px 15px}
  body.studio-shell .lib-title{font-size:clamp(27px,3vw,37px)}
  body.studio-shell .notice{padding:10px 13px}
  body.studio-shell .filters{top:8px;margin-top:12px;padding:7px}
  body.studio-shell .lib-search,
  body.studio-shell .select-lg,
  body.studio-shell .btn-filter{height:40px;min-height:40px}
  body.studio-shell .font-grid{margin-top:15px;gap:15px}
  body.studio-shell .system-pack-folder>summary{min-height:62px;padding:10px 14px}

  /* Every vertically constrained flex panel scrolls its content instead of
     shrinking fields and actions. */
  body.studio-shell .editor-side>*,
  body.studio-shell .account-dropdown>*,
  body.studio-shell .docs-panel-head,
  body.studio-shell .docs-panel-body>*,
  body.studio-shell .assistant-empty>*,
  body.studio-shell .assistant-header,
  body.studio-shell .assistant-composer-wrap,
  body.studio-shell .tb-toolbar,
  body.studio-shell .tb-overflow-card,
  body.studio-shell .stage-bar{flex-shrink:0}

  /* Normal editor: side-by-side is substantially more useful on a short
     notebook, including narrow laptop/tablet widths above the phone cutoff. */
  body.studio-shell .modal-overlay{padding:var(--hws-compact-edge)}
  body.studio-shell .modal-overlay>.editor{
    width:min(1240px,100%);height:calc(100vh - 24px);height:calc(100dvh - 24px);
    min-height:0;flex:none;grid-template-columns:minmax(300px,35vw) minmax(0,1fr);
    grid-template-rows:auto minmax(0,1fr);
  }
  body.studio-shell .editor-head{grid-column:1/3;padding:10px 15px}
  body.studio-shell .editor-head .icon-btn{width:36px;height:36px;min-height:36px;flex:none}
  body.studio-shell .editor-side{
    grid-column:1;grid-row:2;display:flex;min-height:0;max-height:none;
    padding:12px 15px;gap:11px;overflow-y:auto;border-right:1px solid var(--border-soft);
    border-bottom:0;
  }
  body.studio-shell .editor-stage{grid-column:2;grid-row:2;min-height:0}
  body.studio-shell .fld textarea{min-height:112px}
  body.studio-shell .pack-pick{max-height:190px}
  body.studio-shell .stage-canvas{padding:14px}
  body.studio-shell .stage-bar{padding:9px 14px}
  body.studio-shell .stage-bar .btn{height:36px;min-height:36px}

  /* Blocks mode keeps its desktop canvas and side settings at short heights;
     the phone-only command dock stays out of this width range. */
  body.studio-shell .modal-overlay:has(.editor.tb-mode){padding:0}
  body.studio-shell .modal-overlay>.editor.tb-mode{
    width:100vw;max-width:100vw;height:100vh;height:100dvh;
    grid-template-columns:280px minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);
  }
  body.studio-shell .editor.tb-mode .editor-side{
    grid-column:1;grid-row:2;display:flex;max-height:none;padding:10px 12px;
    border-top:0;border-right:1px solid var(--border-soft);
  }
  body.studio-shell .editor.tb-mode .editor-stage{grid-column:2;grid-row:2}
  body.studio-shell .editor.tb-mode .tb-mobile-nav{display:none}
  body.studio-shell .editor.tb-mode .tb-toolbar{
    position:relative;z-index:2;min-height:46px;padding:5px 9px;gap:7px;
    overflow-x:auto;flex-wrap:nowrap;
  }
  body.studio-shell .editor.tb-mode .tb-tbtn{min-height:34px;padding:6px 10px}
  body.studio-shell .editor.tb-mode .tb-pages-panel{display:block}
  body.studio-shell .editor.tb-mode .stage-bar{min-height:48px;padding:6px 10px}

  /* AI has no artificial minimum taller than the viewport. */
  body.studio-shell .assistant-screen{height:100%;min-height:0}
  body.studio-shell .assistant-shell{
    width:min(1180px,calc(100% - 24px));height:calc(100vh - 24px);height:calc(100dvh - 24px);
    min-height:0;margin:12px auto;border-radius:18px;
  }
  body.studio-shell .assistant-header{min-height:62px;padding:9px 16px}
  body.studio-shell .assistant-brand{gap:10px}
  body.studio-shell .assistant-brand-mark{width:36px;height:36px;border-radius:11px}
  body.studio-shell .assistant-header h1{font-size:18px}
  body.studio-shell .assistant-header p{display:none}
  body.studio-shell .assistant-messages{padding:16px max(20px,calc((100% - 860px)/2))}
  body.studio-shell .assistant-empty{min-height:0;padding:12px}
  body.studio-shell .assistant-empty h2{font-size:clamp(24px,2.7vw,32px)}
  body.studio-shell .assistant-empty p{margin:7px auto 12px}
  body.studio-shell .assistant-topic{min-height:80px;padding:12px 30px 11px 12px}
  body.studio-shell .assistant-topic b{margin-bottom:4px}
  body.studio-shell .assistant-quick-row{margin-top:8px}
  body.studio-shell .assistant-quick-row button{min-height:32px}
  body.studio-shell .assistant-composer-wrap{padding:0 16px 8px}
  body.studio-shell .assistant-composer{min-height:50px;padding-block:5px}
  body.studio-shell .assistant-send,
  body.studio-shell .assistant-stop{flex:0 0 38px;width:38px;height:38px;min-height:38px}
  body.studio-shell .assistant-jump{bottom:80px}

  /* Full-screen profile, help and generated dialogs get a bounded inner
     scroller. Header/close/actions remain reachable and keep their height. */
  body.studio-shell .account-dropdown{padding:10px 16px;gap:10px}
  body.studio-shell .profile-menu-head{padding:13px 15px}
  body.studio-shell .profile-menu-avatar{width:48px;height:48px}
  body.studio-shell .profile-content-island{padding:14px}
  body.studio-shell .profile-overview-grid{margin-bottom:10px}
  body.studio-shell .profile-overview-card{min-height:80px;padding:11px}
  body.studio-shell .account-dropdown-section{padding:12px;margin-bottom:8px}
  body.studio-shell .docs-panel{padding:10px}
  body.studio-shell .docs-panel-content{
    height:calc(100vh - 20px);height:calc(100dvh - 20px);max-height:none;
  }
  body.studio-shell .docs-panel-head{padding:11px 16px}
  body.studio-shell .docs-panel-close{width:36px;height:36px;min-height:36px;flex:none}
  body.studio-shell .docs-panel-body{padding:15px;gap:12px}
  body.studio-shell .docs-section{padding:14px}
  body.studio-shell .locked-overlay{
    align-items:flex-start;padding:10px;overflow-y:auto;overscroll-behavior:contain;
  }
  body.studio-shell .locked-card{width:min(440px,100%);margin:auto;padding:22px 26px}
  body.studio-shell .locked-icon{margin-bottom:8px}
  body.studio-shell .locked-icon svg{width:42px;height:42px}
  body.studio-shell .locked-card>p,
  body.studio-shell .locked-status{margin-bottom:10px}
  body.studio-shell .locked-tariffs{gap:6px;margin-bottom:12px}
  body.studio-shell .locked-tariff-option{padding:8px 12px;min-height:42px}
  body.studio-shell .locked-btn,
  body.studio-shell .locked-tariff-option .lt-pay-btn{min-height:36px;flex-shrink:0}
  body.studio-shell .locked-footer-note{margin-top:12px}
  body.studio-shell .work-save-overlay{padding:10px!important;overflow-y:auto!important}
  body.studio-shell .work-save-dialog{
    max-height:calc(100vh - 20px)!important;max-height:calc(100dvh - 20px)!important;
    overflow-y:auto!important;padding:18px!important;
  }
  body.studio-shell .work-save-actions .btn{min-height:36px;flex-shrink:0}
  body.studio-shell .drawing-modal-overlay{padding:10px!important}
  body.studio-shell .drawing-modal{
    max-height:calc(100vh - 20px)!important;max-height:calc(100dvh - 20px)!important;
    padding:18px!important;
  }
  body.studio-shell .drawing-modal-close{width:36px;height:36px;min-height:36px}
  body.studio-shell .export-drawer{max-height:calc(100vh - 20px);max-height:calc(100dvh - 20px)}
  body.studio-shell .export-modal-head{padding:14px 17px 12px}
  body.studio-shell .export-modal-body{padding:14px 17px 17px}
}
