:root{
  --bg:#f3f5f8;
  --panel:#ffffff;
  --panel2:#eef2f6;
  --border:#d8dee8;
  --text:#1f2d3d;
  --muted:#6b7a8c;
  --term:#f5f7fa;
  --green:#1f9d55;
  --red:#c94b55;
  --blue:#2f6fb3;
  --font:14px;
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",sans-serif;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;background:var(--bg);color:var(--text);height:100%;overflow:hidden}
button,textarea,input{font:inherit}
button{touch-action:manipulation;cursor:pointer}
#app{
  height:100dvh;
  display:flex;
  flex-direction:column;
  padding-top:env(safe-area-inset-top);
  padding-bottom:env(safe-area-inset-bottom);
  background:var(--bg);
}
.topbar{
  height:56px;
  flex:none;
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 14px;
  border-bottom:1px solid var(--border);
  background:#ffffff;
}
.brand{
  font-weight:800;
  letter-spacing:.2px;
  flex:1;
  color:#162334;
}
.status{
  font-size:12px;
  color:var(--muted);
  display:flex;
  align-items:center;
  gap:6px;
}
.dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:#9aa6b2;
}
.dot.online{
  background:var(--green);
  box-shadow:0 0 0 3px rgba(31,157,85,.15);
}
.iconBtn,.fontBtns button,.drawerHead button{
  border:1px solid var(--border);
  background:#ffffff;
  color:var(--text);
  border-radius:9px;
  padding:7px 10px;
}
.workspace{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:12px;
  background:var(--bg);
}
.terminalCard{
  flex:1;
  min-height:0;
  border:1px solid var(--border);
  border-radius:12px;
  background:#ffffff;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  box-shadow:0 2px 10px rgba(20,32,50,.05);
}
.terminalHead{
  height:38px;
  flex:none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 10px;
  background:#ffffff;
  border-bottom:1px solid var(--border);
  color:#556476;
  font-size:12px;
}
.fontBtns{display:flex;gap:6px}
.fontBtns button{
  padding:4px 10px;
  background:#f8fafc;
}
.screen{
  flex:1;
  min-height:0;
  margin:0;
  padding:14px 14px 20px;
  overflow:auto;
  overscroll-behavior:contain;
  background:#000000;
  color:var(--term);
  font:var(--font)/1.45 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  white-space:pre-wrap;
  word-break:break-word;
  -webkit-user-select:text;
  user-select:text;
}
.composer{
  flex:none;
  display:flex;
  flex-direction:column;
  gap:8px;
  background:var(--bg);
}
textarea{
  width:100%;
  height:96px;
  max-height:28vh;
  resize:vertical;
  border:1px solid var(--border);
  background:#ffffff;
  color:var(--text);
  border-radius:12px;
  padding:12px;
  font:14px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace;
  outline:none;
}
textarea:focus{
  border-color:#90a7c4;
  box-shadow:0 0 0 2px rgba(47,111,179,.12);
}
.primaryGrid,.copyGrid{
  display:grid;
  grid-template-columns:1.4fr .8fr;
  gap:8px;
}
.copyGrid{grid-template-columns:1fr 1fr}
.btn{
  min-height:46px;
  border:1px solid transparent;
  border-radius:11px;
  color:#fff;
  font-weight:700;
}
.btnPaste{background:#356fb3}
.btnRun{background:#1f8f4d}
.secondary{
  background:#f3f6fa;
  border:1px solid var(--border);
  color:#243447;
}
.btn:disabled{opacity:.5}
.keys{
  display:grid;
  grid-template-columns:repeat(6,1fr);
  gap:7px;
}
.keys button{
  height:40px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#ffffff;
  color:#1f2d3d;
  font-weight:700;
}
.keys .dangerKey{
  border-color:#e5b8bd;
  color:#a93841;
  background:#fff5f6;
}
.toast{
  position:fixed;
  left:50%;
  bottom:calc(18px + env(safe-area-inset-bottom));
  transform:translateX(-50%);
  z-index:30;
  background:#1f2d3d;
  color:#ffffff;
  padding:9px 13px;
  border-radius:10px;
  font-size:13px;
  box-shadow:0 8px 30px rgba(0,0,0,.18);
  max-width:88vw;
  text-align:center;
}
.hidden{display:none!important}
.backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.22);
  z-index:20;
}
.drawer{
  position:fixed;
  z-index:21;
  right:0;
  top:0;
  bottom:0;
  width:min(88vw,460px);
  background:#ffffff;
  border-left:1px solid var(--border);
  padding-top:env(safe-area-inset-top);
  padding-bottom:env(safe-area-inset-bottom);
  display:flex;
  flex-direction:column;
}
.drawerHead{
  height:54px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 12px;
  border-bottom:1px solid var(--border);
  background:#ffffff;
}
.historyList{
  overflow:auto;
  padding:8px;
  background:#f7f9fc;
}
.historyItem{
  width:100%;
  text-align:left;
  border:1px solid var(--border);
  background:#ffffff;
  color:var(--text);
  border-radius:10px;
  padding:10px;
  margin-bottom:8px;
}
.historyTime{
  display:block;
  color:var(--muted);
  font-size:11px;
  margin-bottom:5px;
}
.historyCmd{
  display:block;
  white-space:pre-wrap;
  word-break:break-word;
  font:12px/1.35 ui-monospace,SFMono-Regular,Menlo,monospace;
  max-height:84px;
  overflow:hidden;
}
.loginBody{
  min-height:100dvh;
  overflow:auto;
  display:grid;
  place-items:center;
  padding:calc(20px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
  background:linear-gradient(180deg,#f5f7fa 0%,#eef3f8 100%);
}
.loginCard{
  width:min(100%,390px);
  border:1px solid var(--border);
  background:#ffffff;
  border-radius:18px;
  padding:24px;
  box-shadow:0 20px 60px rgba(20,32,50,.08);
}
.loginIcon{
  width:64px;
  height:64px;
  border-radius:14px;
}
.loginCard h1{
  font-size:24px;
  margin:14px 0 3px;
  color:#162334;
}
.loginCard p{
  margin:0 0 20px;
  color:var(--muted);
}
.loginCard label{
  display:block;
  color:#4b5a6b;
  font-size:13px;
  margin-bottom:12px;
}
.loginCard input{
  display:block;
  margin-top:6px;
  width:100%;
  height:46px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#ffffff;
  color:#162334;
  padding:0 11px;
  outline:none;
}
.loginCard .btn{width:100%;margin-top:4px}
.loginError{
  height:22px;
  color:#c94b55;
  font-size:12px;
  padding-top:7px;
}
.loginCard small{
  display:block;
  margin-top:15px;
  color:#6f7e90;
  line-height:1.45;
}
@media (min-width:760px){
  :root{--font:15px}
  .workspace{padding:12px;gap:12px}
  .topbar{height:58px;padding:0 16px}
  .screen{padding:14px 16px 24px}
  .composer{
    display:grid;
    grid-template-columns:minmax(0,1fr) 380px;
    grid-template-areas:
      "input primary"
      "input copy"
      "keys keys";
    gap:8px
  }
  .composer textarea{grid-area:input;height:104px;max-height:none}
  .primaryGrid{grid-area:primary}
  .copyGrid{grid-area:copy}
  .keys{grid-area:keys}
  .btn{min-height:48px}
  .keys button{height:42px}
}
@media (min-width:1180px){
  .workspace{max-width:1500px;width:100%;margin:0 auto}
  .composer{grid-template-columns:minmax(0,1fr) 430px}
}
