/* HTML Lab visual refinement — typography + help dialog */
:root{
  --ui-font:15px;
  --ui-small:13px;
  --ui-tiny:12px;
}
body{font-size:var(--ui-font)}
.topbar{min-height:72px;padding-top:12px;padding-bottom:12px}
.brand-mark{width:46px;height:46px;border-radius:14px;font-size:21px}
.brand strong{font-size:18px}
.brand small{font-size:13px;margin-top:5px}
.topbar-title{font-size:16px}
.eyebrow{font-size:11px;padding:6px 10px}
.privacy-chip{font-size:13px;padding:8px 11px}
.btn{min-height:44px;padding:9px 15px;font-size:14px;border-radius:13px}
.icon-btn{width:44px;font-size:20px}

.modebar{min-height:82px;padding-top:11px;padding-bottom:11px}
.mode-tab{padding:10px 14px;border-radius:16px;gap:11px}
.mode-icon{min-width:44px;height:44px;border-radius:12px;font-size:13px}
.mode-icon.zip{font-size:12px}
.mode-tab strong{font-size:15px}
.mode-tab small{font-size:12px;margin-top:3px}
.mode-description{font-size:14px;line-height:1.55;padding:10px 14px}
.status{font-size:13px}

.toolbar{min-height:62px;padding-top:9px;padding-bottom:9px}
.control-label,.mobile-view-switch>span{font-size:12px}
.device-switch button,.segmented-view button{min-height:35px;padding:6px 12px;font-size:13px}
.device-switch,.segmented-view{border-radius:12px}

.guide-strip{min-height:58px;padding-top:8px;padding-bottom:8px;gap:12px}
.guide-label{font-size:12px}
.guide-step>b{width:28px;height:28px;border-radius:9px;font-size:12px}
.guide-step strong{font-size:13px}
.guide-step small{font-size:11px;margin-top:2px}
.guide-arrow{font-size:15px}
.guide-help{font-size:13px}

.workspace{padding:14px}
.file-head,.panel-head{min-height:70px;padding:11px 15px}
.panel-kicker{font-size:10px;margin-bottom:4px}
.file-head strong,.panel-head strong{font-size:16px}
.file-head small,.panel-head small{font-size:13px;margin-top:3px}
.pill{font-size:11px;padding:5px 8px}
.mini-btn{width:38px;height:38px;border-radius:11px;font-size:18px}

.project-panel{grid-template-columns:270px minmax(0,1fr)}
.zip-drop{margin:13px;padding:18px 12px;border-radius:16px;gap:5px}
.zip-drop-icon{width:48px;height:40px;border-radius:12px;font-size:12px}
.zip-drop strong{font-size:14px}
.zip-drop span{font-size:12px}
.zip-drop small{font-size:11px;line-height:1.45}
.tree-dir-title,.tree-file{font-size:13px;padding:7px 9px}
textarea{font-size:14px;line-height:1.65;padding:20px 20px 52px}
.editor-stats{font-size:11px;padding:6px 9px}
.binary-notice strong{font-size:16px}
.binary-notice span:last-child{font-size:13px}

.live-badge{font-size:11px;padding:6px 9px}
.browser-chrome{height:36px}
.browser-address{font-size:10px}
#preview{height:calc(100% - 36px)}
.preview-flash{inset:36px 0 0}
.preview-note{font-size:12px;padding:10px 14px;line-height:1.55}

.privacy-footer{min-height:68px;padding-top:10px;padding-bottom:10px}
.privacy-icon{width:36px;height:36px;border-radius:11px;font-size:17px}
.privacy-footer strong{display:block;font-size:14px;margin-bottom:3px}
.privacy-footer span{display:block;font-size:12px;line-height:1.55;color:#5d6a63}
.footer-help-btn{
  min-height:42px;padding:9px 14px;border:1px solid var(--line-strong);border-radius:13px;
  background:#fff;color:var(--ink);font-size:13px;font-weight:800;cursor:pointer;
  transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease
}
.footer-help-btn:hover{transform:translateY(-1px);border-color:#aec3b4;box-shadow:0 8px 20px rgba(18,32,25,.07)}

/* Help dialog: same visual language as the app */
dialog{
  width:min(900px,calc(100vw - 32px));
  max-height:min(88vh,860px);
  padding:0;border:0;border-radius:24px;overflow:hidden;
  background:#fff;
  box-shadow:0 30px 90px rgba(11,24,16,.28);
}
dialog::backdrop{background:rgba(8,15,10,.52);backdrop-filter:blur(7px)}
.dialog-head{
  padding:22px 24px 18px;
  display:flex;align-items:flex-start;justify-content:space-between;gap:18px;
  border-bottom:1px solid var(--line);
  background:
    radial-gradient(circle at 12% 0,rgba(169,237,187,.28),transparent 34%),
    linear-gradient(180deg,#fbfefc,#f4faf6);
}
.dialog-title-wrap{display:grid;gap:6px;min-width:0}
.dialog-kicker{
  display:inline-flex;width:max-content;align-items:center;
  padding:5px 9px;border-radius:999px;background:#eaf7ee;border:1px solid #d3e9d9;
  color:#397449;font-size:11px;font-weight:900;letter-spacing:.09em
}
.dialog-head strong{font-size:24px;line-height:1.25}
.dialog-head small{font-size:14px;color:#607067;line-height:1.55}
.dialog-close-btn{
  min-width:88px;min-height:43px;padding:9px 14px;border:1px solid var(--line-strong);
  border-radius:13px;background:#fff;color:var(--ink);font-size:14px;font-weight:800;cursor:pointer;
  transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease
}
.dialog-close-btn:hover{transform:translateY(-1px);border-color:#a9c0b0;box-shadow:0 9px 22px rgba(18,32,25,.08)}
.dialog-body{
  max-height:calc(88vh - 112px);
  padding:22px 24px 26px;
  display:grid;gap:16px;overflow:auto;background:#fff
}
.dialog-body::-webkit-scrollbar{width:10px}
.dialog-body::-webkit-scrollbar-thumb{background:#d7e0da;border-radius:999px}
.help-intro{
  display:grid;grid-template-columns:66px 1fr;gap:16px;align-items:center;
  padding:18px;border:1px solid #dbe7de;border-radius:19px;
  background:linear-gradient(135deg,#f7fcf8,#eff8f2)
}
.help-intro-mark{
  width:66px;height:66px;border-radius:18px;display:grid;place-items:center;
  background:linear-gradient(135deg,#dbf5e2,#aeeabd);
  color:#183f27;font:900 17px/1 ui-monospace,SFMono-Regular,Menlo,monospace
}
.help-intro strong{display:block;font-size:18px;margin-bottom:7px}
.help-intro p{margin:0;font-size:14px;line-height:1.7;color:#5e6b64}
.help-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.help-card{
  padding:18px;border:1px solid var(--line);border-radius:18px;background:#fbfdfb;
  box-shadow:0 5px 16px rgba(16,27,20,.035)
}
.help-number{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:40px;height:28px;padding:0 9px;margin-bottom:10px;border-radius:999px;
  background:#e5f6ea;color:#24713a;font-size:12px;font-weight:900
}
.help-card strong{display:block;font-size:16px;margin-bottom:7px}
.help-card p{margin:0;font-size:14px;line-height:1.7;color:#5e6b64}
.support-box{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.support-box>div,.privacy-box{
  padding:18px;border:1px solid var(--line);border-radius:18px;background:#fbfdfb
}
.support-box>div:last-child{background:#fffaf3;border-color:#eee3ca}
.support-box strong,.privacy-box strong{display:block;font-size:16px;margin-bottom:7px}
.support-box p,.privacy-box p{margin:0;font-size:14px;line-height:1.72;color:#5e6b64}
.privacy-box{background:linear-gradient(135deg,#f6fbf7,#eff8f2)}
.privacy-box p+p{margin-top:9px}
dialog code{padding:2px 5px;border-radius:6px;background:#edf3ef;color:#2e4937;font-size:.93em}

@media(max-width:980px){
  .project-panel{grid-template-columns:220px minmax(0,1fr)}
  .help-grid,.support-box{grid-template-columns:1fr}
}
@media(max-width:760px){
  .topbar-title{font-size:14px}
  .modebar{min-height:auto}
  .mode-tab strong{font-size:14px}
  .mode-tab small{font-size:11px}
  .mode-description{font-size:13px}
  .guide-strip{min-height:54px}
  .file-head strong,.panel-head strong{font-size:15px}
  .file-head small,.panel-head small{font-size:12px}
  dialog{width:min(96vw,900px);max-height:90vh}
  .dialog-head{padding:18px;gap:12px}
  .dialog-head strong{font-size:21px}
  .dialog-head small{font-size:13px}
  .dialog-body{padding:18px;gap:13px}
  .help-intro{grid-template-columns:1fr}
}
@media(max-width:560px){
  .btn{font-size:13px;padding:8px 11px}
  .mode-icon{min-width:40px;height:40px}
  .mode-tab{padding:9px}
  .guide-step strong{font-size:12px}
  .guide-step small{font-size:10px}
  .privacy-footer strong{font-size:13px}
  .privacy-footer span{font-size:11px}
  .dialog-head{flex-direction:column}
  .dialog-close-btn{width:100%}
}


/* Workspace fullscreen / focus mode */
.workspace-focus-toggle{
  min-width:82px;
  padding-inline:13px;
  gap:7px;
}
.workspace-focus-toggle .focus-icon{
  font-size:18px;
  line-height:1;
}
.workspace-focus-toggle.active{
  background:linear-gradient(135deg,#dff7e5,#b7edc4);
  border-color:#9edcaf;
  color:#183d25;
}
.app.workspace-focus,
.app:fullscreen{
  width:100%;
  height:100vh;
  height:100dvh;
  background:var(--bg);
  grid-template-rows:auto 1fr;
}
.app.workspace-focus .topbar,
.app.workspace-focus .modebar,
.app.workspace-focus .guide-strip,
.app.workspace-focus .privacy-footer,
.app:fullscreen .topbar,
.app:fullscreen .modebar,
.app:fullscreen .guide-strip,
.app:fullscreen .privacy-footer{
  display:none!important;
}
.app.workspace-focus .toolbar,
.app:fullscreen .toolbar{
  min-height:60px;
  padding:8px 12px;
  position:relative;
  z-index:20;
  background:rgba(251,253,251,.98);
  box-shadow:0 8px 24px rgba(18,32,25,.08);
}
.app.workspace-focus .workspace,
.app:fullscreen .workspace{
  height:100%;
  min-height:0;
  padding:8px;
  grid-template-columns:minmax(360px,.98fr) 7px minmax(400px,1.02fr);
}
.app.workspace-focus .left-pane,
.app:fullscreen .left-pane{
  border-radius:18px 0 0 18px;
}
.app.workspace-focus .preview-pane,
.app:fullscreen .preview-pane{
  border-radius:0 18px 18px 0;
}
.app.workspace-focus .file-head,
.app.workspace-focus .panel-head,
.app:fullscreen .file-head,
.app:fullscreen .panel-head{
  min-height:62px;
}
.app.workspace-focus .preview-stage,
.app:fullscreen .preview-stage{
  padding:10px;
}
.app.workspace-focus .device-shell,
.app:fullscreen .device-shell{
  min-height:0;
  height:100%;
}
.app.workspace-focus #preview,
.app:fullscreen #preview{
  min-height:0;
}
.app.workspace-focus .editor-wrap,
.app:fullscreen .editor-wrap{
  min-height:0;
}
.app.workspace-focus .workspace,
.app:fullscreen .workspace,
.app.workspace-focus .left-pane,
.app.workspace-focus .preview-pane,
.app:fullscreen .left-pane,
.app:fullscreen .preview-pane{
  overflow:hidden;
}

@media(max-width:980px){
  .app.workspace-focus .workspace,
  .app:fullscreen .workspace{
    display:block;
    padding:8px;
  }
  .app.workspace-focus .left-pane,
  .app.workspace-focus .preview-pane,
  .app:fullscreen .left-pane,
  .app:fullscreen .preview-pane{
    height:100%;
    border-radius:18px;
  }
}
@media(max-width:640px){
  .workspace-focus-toggle{
    min-width:44px;
    width:44px;
    padding:0;
  }
  .workspace-focus-toggle .focus-label{
    display:none;
  }
}


/* Compact header + scroll workspace flow */
/*
 * 桌機操作邏輯：
 * 1. 將模式切換合併進工具列，減少「頭重腳輕」。
 * 2. 頁面可自然往下捲；工具列固定在頂端。
 * 3. 捲到工作區後，編輯器＋即時預覽直接佔滿剩餘視窗高度。
 */
body{
  overflow-x:hidden!important;
  overflow-y:auto!important;
}
.app:not(.workspace-focus){
  height:auto!important;
  min-height:100dvh;
  display:block!important;
  overflow:visible!important;
}
.modebar.merged-into-toolbar{
  display:none!important;
}
.app:not(.workspace-focus) .toolbar{
  position:sticky;
  top:0;
  z-index:45;
  min-height:64px;
  padding:9px clamp(16px,2.6vw,30px);
  background:rgba(251,253,251,.96);
  border-bottom:1px solid var(--line);
  box-shadow:0 8px 24px rgba(18,32,25,.06);
  backdrop-filter:blur(14px);
}
.toolbar>.toolbar-mode-tabs{
  display:flex;
  align-items:center;
  gap:6px;
  flex:0 0 auto;
  margin-right:4px;
  padding-right:12px;
  border-right:1px solid #dfe7e1;
}
.toolbar>.toolbar-mode-tabs .mode-tab{
  min-height:44px;
  padding:6px 10px;
  border-radius:13px;
  gap:8px;
}
.toolbar>.toolbar-mode-tabs .mode-tab::after{
  left:10px;
  right:10px;
}
.toolbar>.toolbar-mode-tabs .mode-icon{
  min-width:34px;
  width:34px;
  height:34px;
  border-radius:10px;
  font-size:11px;
}
.toolbar>.toolbar-mode-tabs .mode-icon.zip{
  font-size:10px;
}
.toolbar>.toolbar-mode-tabs .mode-tab strong{
  font-size:13px;
}
.toolbar>.toolbar-mode-tabs .mode-tab small{
  display:none;
}
.app:not(.workspace-focus) .guide-strip{
  position:relative;
  z-index:2;
}
.app:not(.workspace-focus) .workspace{
  height:calc(100dvh - 64px);
  min-height:640px;
  padding:10px 14px 14px;
  scroll-margin-top:64px;
}
.app:not(.workspace-focus) .left-pane,
.app:not(.workspace-focus) .preview-pane{
  height:100%;
}
.app:not(.workspace-focus) .single-panel,
.app:not(.workspace-focus) .project-panel{
  height:100%;
}
.app:not(.workspace-focus) .preview-stage{
  min-height:0;
}
.app:not(.workspace-focus) .device-shell{
  min-height:0;
  height:100%;
}
.app:not(.workspace-focus) #preview{
  min-height:0;
}
.app:not(.workspace-focus) .privacy-footer{
  position:relative;
  z-index:2;
}

/* 捲到工作區時，畫面會像編輯器工作台，而不是一般內容頁。 */
@media(min-width:981px){
  .app:not(.workspace-focus) .workspace{
    grid-template-columns:minmax(380px,.98fr) 7px minmax(420px,1.02fr);
  }
}

/* 中小尺寸保留橫向可滑工具列，模式切換仍與操作按鈕同列。 */
@media(max-width:980px){
  .app:not(.workspace-focus) .toolbar{
    min-height:60px;
    top:0;
  }
  .app:not(.workspace-focus) .workspace{
    height:calc(100dvh - 60px);
    min-height:560px;
    scroll-margin-top:60px;
  }
  .toolbar>.toolbar-mode-tabs{
    padding-right:8px;
  }
}
@media(max-width:640px){
  .toolbar>.toolbar-mode-tabs .mode-tab{
    padding:5px 7px;
  }
  .toolbar>.toolbar-mode-tabs .mode-icon{
    min-width:32px;
    width:32px;
    height:32px;
  }
  .toolbar>.toolbar-mode-tabs .mode-tab strong{
    font-size:12px;
  }
}


/* RWD mobile hardening v2 */
html,body{
  width:100%;
  max-width:100%;
}
.app,
.topbar,
.toolbar,
.guide-strip,
.workspace,
.privacy-footer{
  width:100%;
  max-width:100vw;
}
.topbar>*,
.toolbar>*,
.workspace>*{
  min-width:0;
}

@media(max-width:980px){
  html,body{
    overflow-x:hidden!important;
  }

  .topbar{
    width:100%;
    grid-template-columns:minmax(0,1fr) auto!important;
    gap:10px!important;
    padding:10px 12px!important;
  }
  .brand{
    min-width:0!important;
    max-width:100%;
  }
  .brand-copy{
    min-width:0;
  }
  .brand strong,
  .brand small{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .topbar-center{
    display:none!important;
  }
  .top-actions{
    min-width:0;
    justify-self:end;
    gap:6px!important;
  }
  .top-actions .privacy-chip{
    display:none!important;
  }

  .app:not(.workspace-focus) .toolbar{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto auto auto!important;
    grid-auto-flow:row;
    align-items:center;
    gap:8px!important;
    overflow:visible!important;
    padding:8px 10px!important;
  }

  .toolbar>.toolbar-mode-tabs{
    grid-column:1 / -1;
    width:100%;
    max-width:100%;
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:7px!important;
    margin:0!important;
    padding:0!important;
    border-right:0!important;
  }
  .toolbar>.toolbar-mode-tabs .mode-tab{
    width:100%;
    min-width:0!important;
    justify-content:flex-start;
    padding:7px 9px!important;
  }
  .toolbar>.toolbar-mode-tabs .mode-tab>span:last-child{
    min-width:0;
  }
  .toolbar>.toolbar-mode-tabs .mode-tab strong{
    display:block;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  .toolbar-group.single-actions,
  .toolbar-group.project-actions{
    grid-column:1 / -1;
    width:100%;
    max-width:100%;
    display:flex;
    gap:7px!important;
    overflow-x:auto;
    overflow-y:hidden;
    padding:0 0 2px;
    scrollbar-width:none;
  }
  .toolbar-group.single-actions::-webkit-scrollbar,
  .toolbar-group.project-actions::-webkit-scrollbar{
    display:none;
  }
  .toolbar-group.single-actions .btn,
  .toolbar-group.project-actions .btn{
    flex:0 0 auto;
  }

  .toolbar-spacer{
    display:none!important;
  }

  .mobile-view-switch{
    grid-column:1 / 2;
    display:flex!important;
    min-width:0;
  }
  .mobile-view-switch>span{
    display:none!important;
  }
  .segmented-view{
    width:100%;
    min-width:0;
  }
  .segmented-view button{
    flex:1 1 0;
    min-width:0;
  }

  .device-control{
    grid-column:2 / 3;
    min-width:0;
  }
  .device-control .control-label{
    display:none!important;
  }

  .workspace-focus-toggle{
    grid-column:3 / 4;
  }
  #refreshBtn{
    grid-column:4 / 5;
  }
  #openPreviewBtn{
    grid-column:5 / 6;
  }

  .app:not(.workspace-focus) .workspace{
    display:block!important;
    width:100%!important;
    max-width:100%!important;
    height:calc(100dvh - 154px)!important;
    min-height:520px!important;
    padding:8px!important;
    overflow:hidden!important;
  }
  .app:not(.workspace-focus) .left-pane,
  .app:not(.workspace-focus) .preview-pane{
    width:100%!important;
    max-width:100%!important;
    height:100%!important;
    min-width:0!important;
    border-radius:16px!important;
    overflow:hidden!important;
  }
  .app:not(.workspace-focus) .preview-pane{
    display:none!important;
  }
  .app:not(.workspace-focus) .workspace.mobile-preview .left-pane{
    display:none!important;
  }
  .app:not(.workspace-focus) .workspace.mobile-preview .preview-pane{
    display:grid!important;
  }

  .single-panel,
  .project-panel,
  .project-editor,
  .editor-wrap,
  .preview-stage,
  .device-shell{
    min-width:0!important;
    max-width:100%!important;
  }

  textarea{
    white-space:pre!important;
    overflow:auto!important;
    word-break:normal!important;
  }

  .privacy-footer{
    padding:9px 12px!important;
  }
}

@media(max-width:640px){
  .topbar{
    min-height:62px!important;
  }
  .brand-mark{
    width:40px!important;
    height:40px!important;
    border-radius:12px!important;
    font-size:18px!important;
  }
  .brand strong{
    font-size:16px!important;
  }
  .brand small{
    font-size:12px!important;
  }
  .top-actions .btn.primary{
    display:none!important;
  }
  .top-actions .btn.ghost{
    min-height:40px!important;
    padding:8px 11px!important;
    font-size:13px!important;
  }

  .app:not(.workspace-focus) .toolbar{
    grid-template-columns:minmax(0,1fr) auto auto auto!important;
    gap:7px!important;
    padding:7px 8px!important;
  }
  .toolbar>.toolbar-mode-tabs .mode-tab{
    min-height:42px!important;
    padding:6px 8px!important;
  }
  .toolbar>.toolbar-mode-tabs .mode-icon{
    min-width:34px!important;
    width:34px!important;
    height:34px!important;
  }
  .toolbar>.toolbar-mode-tabs .mode-tab strong{
    font-size:13px!important;
  }

  .toolbar-group.single-actions .btn,
  .toolbar-group.project-actions .btn{
    min-height:40px!important;
    padding:8px 11px!important;
    font-size:13px!important;
  }

  .device-control{
    display:none!important;
  }
  .mobile-view-switch{
    grid-column:1 / 2!important;
  }
  .workspace-focus-toggle{
    grid-column:2 / 3!important;
  }
  #refreshBtn{
    grid-column:3 / 4!important;
  }
  #openPreviewBtn{
    grid-column:4 / 5!important;
  }

  .guide-strip{
    display:none!important;
  }

  .app:not(.workspace-focus) .workspace{
    height:calc(100dvh - 146px)!important;
    min-height:480px!important;
    padding:6px!important;
    scroll-margin-top:146px!important;
  }

  .file-head,.panel-head{
    min-height:64px!important;
    padding:10px 12px!important;
  }
  .file-head strong,.panel-head strong{
    font-size:15px!important;
  }
  .file-head small,.panel-head small{
    font-size:12px!important;
  }
  textarea{
    padding:16px 14px 48px!important;
    font-size:13px!important;
    line-height:1.62!important;
  }

  .project-panel{
    grid-template-columns:1fr!important;
    grid-template-rows:auto minmax(0,1fr)!important;
  }
  .file-sidebar{
    width:100%!important;
    max-height:190px;
    border-right:0!important;
    border-bottom:1px solid var(--line);
  }
  .zip-drop{
    margin:8px!important;
    padding:11px 8px!important;
  }
  .zip-drop small{
    display:none;
  }

  .preview-stage{
    padding:7px!important;
  }
  .device-shell{
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    border-radius:14px!important;
  }
  #preview{
    min-height:0!important;
  }

  .privacy-footer{
    grid-template-columns:auto 1fr!important;
    gap:8px!important;
  }
  .privacy-footer span{
    display:-webkit-box!important;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden;
  }
  .privacy-footer .footer-help-btn{
    grid-column:1 / -1;
    width:100%;
  }

  dialog{
    width:calc(100vw - 16px)!important;
    max-height:92dvh!important;
    border-radius:18px!important;
  }
  .dialog-head{
    padding:15px!important;
  }
  .dialog-head strong{
    font-size:19px!important;
  }
  .dialog-body{
    padding:14px!important;
  }
}


/* Mobile workspace stabilization v3 */
html.workspace-focus-active,
html.workspace-focus-active body{
  overflow:hidden!important;
  overscroll-behavior:none;
}

@media(max-width:980px){
  /* 641–980px 原本會因 openPreviewBtn 被放進不存在的第 5 欄而產生隱性欄位。 */
  .app:not(.workspace-focus) .toolbar{
    grid-template-columns:minmax(0,1fr) auto auto auto auto!important;
  }

  /* 手機 / 平板滿版採站內固定工作區，不依賴 Fullscreen API。 */
  .app.workspace-focus{
    position:fixed!important;
    inset:0!important;
    z-index:9999!important;
    width:100vw!important;
    max-width:100vw!important;
    height:100dvh!important;
    min-height:0!important;
    display:grid!important;
    grid-template-rows:auto minmax(0,1fr)!important;
    overflow:hidden!important;
    background:var(--bg)!important;
    padding:
      env(safe-area-inset-top,0)
      env(safe-area-inset-right,0)
      env(safe-area-inset-bottom,0)
      env(safe-area-inset-left,0);
  }

  .app.workspace-focus .toolbar{
    position:relative!important;
    top:auto!important;
    z-index:50!important;
    width:100%!important;
    max-width:100%!important;
    min-height:56px!important;
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto auto auto!important;
    align-items:center!important;
    gap:7px!important;
    padding:7px 8px!important;
    overflow:hidden!important;
    background:rgba(251,253,251,.98)!important;
    border-bottom:1px solid var(--line)!important;
    box-shadow:0 8px 22px rgba(18,32,25,.08)!important;
  }

  /* 滿版只保留真正需要的控制：編輯/預覽、退出滿版、重新整理、另開預覽。 */
  .app.workspace-focus .toolbar>.toolbar-mode-tabs,
  .app.workspace-focus .toolbar-group.single-actions,
  .app.workspace-focus .toolbar-group.project-actions,
  .app.workspace-focus .toolbar-spacer,
  .app.workspace-focus .device-control{
    display:none!important;
  }

  .app.workspace-focus .mobile-view-switch{
    display:flex!important;
    grid-column:1 / 2!important;
    width:100%!important;
    min-width:0!important;
  }
  .app.workspace-focus .mobile-view-switch>span{
    display:none!important;
  }
  .app.workspace-focus .segmented-view{
    width:100%!important;
    min-width:0!important;
  }
  .app.workspace-focus .segmented-view button{
    flex:1 1 0!important;
    min-width:0!important;
    min-height:38px!important;
    padding:6px 9px!important;
    font-size:13px!important;
  }

  .app.workspace-focus .workspace-focus-toggle{
    grid-column:2 / 3!important;
    min-width:44px!important;
    width:44px!important;
    height:42px!important;
    padding:0!important;
  }
  .app.workspace-focus .workspace-focus-toggle .focus-label{
    display:none!important;
  }
  .app.workspace-focus #refreshBtn{
    grid-column:3 / 4!important;
    width:42px!important;
    min-width:42px!important;
    height:42px!important;
  }
  .app.workspace-focus #openPreviewBtn{
    grid-column:4 / 5!important;
    width:42px!important;
    min-width:42px!important;
    height:42px!important;
  }

  .app.workspace-focus .workspace{
    width:100%!important;
    max-width:100%!important;
    height:auto!important;
    min-height:0!important;
    display:block!important;
    padding:6px!important;
    overflow:hidden!important;
  }

  .app.workspace-focus .left-pane,
  .app.workspace-focus .preview-pane{
    width:100%!important;
    max-width:100%!important;
    height:100%!important;
    min-width:0!important;
    min-height:0!important;
    border-radius:16px!important;
    overflow:hidden!important;
  }

  .app.workspace-focus .preview-pane{
    display:none!important;
  }
  .app.workspace-focus .workspace.mobile-preview .left-pane{
    display:none!important;
  }
  .app.workspace-focus .workspace.mobile-preview .preview-pane{
    display:grid!important;
  }

  .app.workspace-focus .single-panel,
  .app.workspace-focus .project-panel,
  .app.workspace-focus .project-editor,
  .app.workspace-focus .editor-wrap,
  .app.workspace-focus .preview-stage,
  .app.workspace-focus .device-shell{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:0!important;
  }

  .app.workspace-focus .single-panel,
  .app.workspace-focus .project-panel{
    height:100%!important;
  }

  .app.workspace-focus .preview-stage{
    height:100%!important;
    padding:6px!important;
  }
  .app.workspace-focus .device-shell{
    height:100%!important;
    min-height:0!important;
    border-radius:14px!important;
  }
  .app.workspace-focus #preview{
    height:calc(100% - 36px)!important;
    min-height:0!important;
  }

  /* 避免手機工具列或程式碼讓整頁被撐寬。 */
  .toolbar,
  .toolbar>*,
  .toolbar-mode-tabs,
  .toolbar-group,
  .workspace,
  .left-pane,
  .preview-pane,
  .project-panel,
  .project-editor{
    min-width:0!important;
  }
}

@media(max-width:640px){
  .app:not(.workspace-focus) .toolbar{
    grid-template-columns:minmax(0,1fr) auto auto auto!important;
  }

  .app.workspace-focus .toolbar{
    grid-template-columns:minmax(0,1fr) 42px 42px 42px!important;
  }

  .app.workspace-focus .panel-head,
  .app.workspace-focus .file-head{
    min-height:58px!important;
    padding:8px 10px!important;
  }

  .app.workspace-focus textarea{
    padding:14px 12px 44px!important;
    font-size:13px!important;
    line-height:1.58!important;
  }

  .app.workspace-focus .project-panel{
    grid-template-columns:1fr!important;
    grid-template-rows:auto minmax(0,1fr)!important;
  }

  .app.workspace-focus .file-sidebar{
    max-height:170px!important;
  }
}

@media(max-width:390px){
  .app.workspace-focus .toolbar{
    grid-template-columns:minmax(0,1fr) 40px 40px 40px!important;
    gap:5px!important;
    padding:6px!important;
  }
  .app.workspace-focus .workspace-focus-toggle,
  .app.workspace-focus #refreshBtn,
  .app.workspace-focus #openPreviewBtn{
    width:40px!important;
    min-width:40px!important;
    height:40px!important;
  }
  .app.workspace-focus .segmented-view button{
    font-size:12px!important;
    padding-inline:6px!important;
  }
}
