*{box-sizing:border-box}
:root{
  --bg:#f4f7f4;--panel:#fff;--ink:#111814;--muted:#6c756f;--line:#dfe6e1;
  --line-strong:#c9d3cc;--soft:#f8faf8;--brand:#bdf3cb;--brand-strong:#7cdf98;
  --brand-dark:#173b22;--danger:#b42318;--danger-bg:#fff1f0;--dark:#101713;
  --shadow:0 16px 45px rgba(16,23,19,.08);--radius:18px
}
html,body{height:100%;margin:0}
body{
  background:var(--bg);color:var(--ink);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans TC","PingFang TC","Microsoft JhengHei",sans-serif;
  -webkit-font-smoothing:antialiased
}
button,textarea{font:inherit}button{color:inherit}
.hidden{display:none!important}
.app{height:100dvh;display:grid;grid-template-rows:auto auto auto 1fr;overflow:hidden}
.topbar{
  min-height:62px;padding:10px clamp(14px,2.8vw,28px);background:rgba(255,255,255,.94);
  border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;
  gap:20px;backdrop-filter:blur(14px)
}
.brand{display:flex;align-items:center;gap:10px;color:inherit;text-decoration:none}
.brand-mark{
  width:38px;height:38px;border-radius:11px;display:grid;place-items:center;font-weight:900;
  background:linear-gradient(135deg,#d8ffe2,#82e79e);border:1px solid #91e7aa;color:#173c24
}
.brand span:last-child{display:grid;line-height:1.05}
.brand strong{font-size:15px;letter-spacing:.03em}
.brand small{margin-top:4px;color:var(--muted);font-size:11px;font-weight:700}
.top-actions,.toolbar-group{display:flex;align-items:center;gap:8px}
.btn{
  min-height:37px;border:1px solid var(--line-strong);border-radius:10px;background:#fff;padding:8px 12px;
  display:inline-flex;align-items:center;justify-content:center;gap:7px;text-decoration:none;font-size:12px;
  font-weight:800;cursor:pointer;transition:.15s ease;white-space:nowrap
}
.btn:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 5px 16px rgba(16,23,19,.08)}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn.primary{background:var(--brand);border-color:#91e8aa;color:#173a22}
.btn.ghost{background:var(--soft)}
.btn.danger{background:var(--danger-bg);border-color:#ffd0cd;color:var(--danger)}
.icon-btn{width:37px;padding:0;font-size:17px}
.modebar{
  min-height:68px;padding:8px clamp(14px,2.8vw,28px);display:flex;align-items:center;gap:18px;
  background:#fff;border-bottom:1px solid var(--line)
}
.mode-tabs{display:flex;gap:6px;min-width:0}
.mode-tab{
  border:1px solid transparent;background:transparent;border-radius:12px;padding:7px 12px;display:flex;
  align-items:center;gap:9px;cursor:pointer;color:#68716c;text-align:left
}
.mode-tab:hover{background:#f5f8f5}
.mode-tab.active{background:#eff9f2;border-color:#cfead7;color:var(--ink)}
.mode-icon{
  min-width:34px;height:34px;padding:0 6px;border-radius:8px;background:#eef3ef;display:grid;place-items:center;
  font:900 10px/1 ui-monospace,SFMono-Regular,Menlo,monospace;color:#3d4c43
}
.mode-tab.active .mode-icon{background:var(--brand);color:#173a22}
.mode-tab>span:last-child{display:grid}
.mode-tab strong{font-size:12px}
.mode-tab small{font-size:10px;color:var(--muted);margin-top:2px}
.status{margin-left:auto;display:flex;align-items:center;gap:8px;color:var(--muted);font-size:11px;font-weight:800;white-space:nowrap}
.status-dot{width:7px;height:7px;border-radius:99px;background:#39b860;box-shadow:0 0 0 4px rgba(57,184,96,.12)}
.toolbar{
  min-height:54px;padding:8px clamp(14px,2.8vw,28px);display:flex;align-items:center;gap:8px;
  background:#fbfcfb;border-bottom:1px solid var(--line);overflow:auto hidden;scrollbar-width:none
}
.toolbar::-webkit-scrollbar{display:none}.toolbar-spacer{flex:1}
.device-switch{display:flex;padding:3px;border:1px solid var(--line);border-radius:10px;background:#eff3f0}
.device-switch button{
  min-height:29px;border:0;border-radius:7px;padding:5px 9px;background:transparent;color:#69736c;
  font-size:11px;font-weight:800;cursor:pointer
}
.device-switch button.active{background:#fff;color:var(--ink);box-shadow:0 1px 5px rgba(16,23,19,.09)}
.workspace{
  min-height:0;padding:12px;display:grid;grid-template-columns:minmax(360px,.95fr) 7px minmax(400px,1.05fr);
  overflow:hidden
}
.left-pane,.preview-pane{
  min-width:0;min-height:0;background:#fff;border:1px solid var(--line);box-shadow:var(--shadow);overflow:hidden
}
.left-pane{border-radius:var(--radius) 0 0 var(--radius)}
.preview-pane{border-radius:0 var(--radius) var(--radius) 0;display:grid;grid-template-rows:auto 1fr auto}
.single-panel{height:100%;display:grid;grid-template-rows:auto 1fr}
.project-panel{height:100%;min-height:0;display:grid;grid-template-columns:235px minmax(0,1fr)}
.file-sidebar{min-width:0;min-height:0;border-right:1px solid var(--line);background:#f8faf8;display:grid;grid-template-rows:auto auto 1fr}
.file-sidebar.collapsed{width:0;overflow:hidden;border:0}
.file-head,.panel-head{
  min-height:49px;padding:9px 12px;display:flex;align-items:center;justify-content:space-between;gap:10px;
  border-bottom:1px solid var(--line);background:#fbfcfb
}
.file-head>div,.panel-head>div{display:grid;min-width:0}
.file-head strong,.panel-head strong{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.file-head small,.panel-head small{margin-top:2px;color:var(--muted);font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mini-btn{
  width:28px;height:28px;border:1px solid var(--line);background:#fff;border-radius:8px;cursor:pointer;font-weight:900
}
.pill{
  flex:0 0 auto;padding:4px 7px;border-radius:7px;background:#eef3ef;color:#526058;
  font:800 9px/1 ui-monospace,SFMono-Regular,Menlo,monospace
}
.zip-drop{
  margin:10px;border:1px dashed #bdc9c1;background:#fff;border-radius:11px;padding:13px 10px;text-align:center;
  display:grid;gap:3px;color:#566158;transition:.15s ease
}
.zip-drop strong{font-size:11px}.zip-drop span{font-size:9px;color:var(--muted)}
.zip-drop.dragging{border-color:#6bd989;background:#effcf2;transform:scale(.99)}
.file-tree{min-height:0;overflow:auto;padding:3px 6px 10px}
.tree-dir{margin-top:2px}
.tree-dir-title,.tree-file{
  width:100%;border:0;background:transparent;border-radius:7px;padding:5px 7px;display:flex;align-items:center;
  gap:6px;text-align:left;font-size:10px;color:#566058
}
.tree-dir-title{font-weight:800;color:#3d4741}
.tree-file{cursor:pointer}
.tree-file:hover{background:#edf2ee}.tree-file.active{background:#dff5e6;color:#163d23;font-weight:800}
.tree-icon{width:14px;flex:0 0 14px;text-align:center;color:#7b857f}
.tree-children{padding-left:12px}
.project-editor{min-width:0;min-height:0;display:grid;grid-template-rows:auto 1fr}
.editor-wrap{min-height:0;position:relative;background:var(--dark)}
textarea{
  position:absolute;inset:0;width:100%;height:100%;resize:none;border:0;outline:0;padding:17px 17px 46px;
  background:var(--dark);color:#ddf2e3;caret-color:#bdf3cb;
  font:500 12px/1.68 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;tab-size:2
}
textarea::selection{background:rgba(189,243,203,.2)}
textarea:disabled{opacity:.62}
.editor-stats{
  position:absolute;right:11px;bottom:10px;padding:5px 7px;border-radius:6px;background:rgba(31,44,36,.9);
  border:1px solid rgba(255,255,255,.07);color:#abb9af;font:700 9px/1 ui-monospace,monospace;pointer-events:none
}
.binary-notice{
  position:absolute;inset:0;display:grid;place-content:center;text-align:center;gap:6px;padding:30px;
  background:#121a15;color:#dceae0
}
.binary-notice strong{font-size:15px}.binary-notice span{max-width:380px;color:#8e9d94;font-size:11px;line-height:1.7}
.splitter{position:relative;cursor:col-resize;z-index:5}
.splitter::before{content:"";position:absolute;inset:0 2px;background:#d7dfda}
.splitter:hover::before,.splitter.dragging::before{background:#82dc9a}
.preview-head{background:#fbfcfb}
.mobile-tabs{display:none}
.preview-stage{
  min-height:0;overflow:auto;padding:16px;display:flex;justify-content:center;align-items:flex-start;
  background:
    linear-gradient(45deg,#eef2ef 25%,transparent 25%),
    linear-gradient(-45deg,#eef2ef 25%,transparent 25%),
    linear-gradient(45deg,transparent 75%,#eef2ef 75%),
    linear-gradient(-45deg,transparent 75%,#eef2ef 75%),#e6ebe7;
  background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0
}
.device-shell{
  width:100%;height:100%;min-height:410px;border:1px solid #cad5cd;border-radius:8px;background:#fff;
  overflow:hidden;box-shadow:0 12px 34px rgba(16,23,19,.13);transition:.2s ease
}
.device-shell.tablet{width:min(768px,100%);border-radius:15px}
.device-shell.mobile{width:min(390px,100%);border-radius:22px}
#preview{width:100%;height:100%;min-height:inherit;border:0;display:block;background:#fff}
.preview-note{
  padding:8px 12px;border-top:1px solid var(--line);background:#fffdf4;color:#6e6138;font-size:9px;line-height:1.5
}
.toast{
  position:fixed;right:18px;bottom:18px;z-index:90;max-width:min(360px,calc(100vw - 36px));
  padding:11px 13px;border:1px solid #cde8d4;background:#f0fff4;color:#184d29;border-radius:11px;
  box-shadow:0 12px 32px rgba(16,23,19,.16);font-size:11px;font-weight:800;opacity:0;transform:translateY(9px);
  pointer-events:none;transition:.18s ease
}
.toast.show{opacity:1;transform:none}
dialog{
  width:min(600px,calc(100vw - 30px));padding:0;border:0;border-radius:17px;overflow:hidden;
  box-shadow:0 24px 70px rgba(16,23,19,.26)
}
dialog::backdrop{background:rgba(8,13,10,.5);backdrop-filter:blur(4px)}
.dialog-head{padding:15px 17px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center}
.dialog-head>div{display:grid}.dialog-head strong{font-size:14px}.dialog-head small{margin-top:3px;color:var(--muted);font-size:10px}
.dialog-body{padding:16px;display:grid;gap:10px}
.help-card{padding:13px;border:1px solid var(--line);border-radius:11px;background:#fbfcfb}
.help-card.warning{background:#fffdf4;border-color:#eee2b9}
.help-card strong{font-size:12px}.help-card p,.privacy{margin:5px 0 0;color:#606b64;font-size:10px;line-height:1.65}
code{padding:1px 4px;border-radius:4px;background:#edf2ee;color:#2e4435;font-family:ui-monospace,monospace}

@media(max-width:900px){
  .app{grid-template-rows:auto auto auto 1fr}
  .workspace{display:block;padding:9px;overflow:hidden}
  .left-pane,.preview-pane{height:100%;border-radius:15px}
  .preview-pane{display:none}
  .workspace.mobile-preview .left-pane{display:none}
  .workspace.mobile-preview .preview-pane{display:grid}
  .splitter{display:none}
  .mobile-tabs{display:flex;gap:3px;padding:3px;border:1px solid var(--line);border-radius:9px;background:#eff3f0}
  .mobile-tabs button{border:0;background:transparent;border-radius:6px;padding:5px 8px;color:var(--muted);font-size:10px;font-weight:800}
  .mobile-tabs button.active{background:#fff;color:var(--ink);box-shadow:0 1px 4px rgba(16,23,19,.08)}
  .project-panel{grid-template-columns:210px minmax(0,1fr)}
}
@media(max-width:620px){
  .topbar{min-height:56px;padding:9px 12px}.brand small,.top-actions .ghost{display:none}
  .modebar{padding:7px 10px;overflow:auto hidden}.mode-tab{padding:6px 8px}.mode-tab small{display:none}
  .mode-icon{min-width:30px;height:30px}.status{display:none}
  .toolbar{padding:7px 10px}.toolbar-spacer{display:none}.device-switch{margin-left:auto}
  .btn{padding:7px 9px;font-size:10px}
  .project-panel{grid-template-columns:170px minmax(0,1fr)}
  .file-head{padding:7px}.zip-drop{margin:7px;padding:10px 6px}
}
@media(prefers-reduced-motion:reduce){*{transition:none!important;scroll-behavior:auto!important}}
