:root{
  --bg:#0f172a;
  --panel:#111827;
  --panel-2:#0b1220;
  --border:#1f2937;
  --text:#e5e7eb;
  --muted:#9ca3af;
  --accent:#60a5fa;
  --ok:#6ee7a1;
  --warn:#fde68a;
  --err:#fca5a5;
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  min-height:100vh;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background:radial-gradient(circle at top,#1e293b 0%,var(--bg) 60%);
  overscroll-behavior-y:none;
  scrollbar-color:#1f2937 #0f172a;
  scrollbar-width:thin;
}

html{
  overflow-y:scroll;
}

body.auth-page{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:32px 16px;
}

a{
  color:var(--accent);
  text-decoration:none;
}

a:hover{
  text-decoration:underline;
}

.wrap{
  width:min(950px, calc(100% - 32px));
  margin:0 auto 32px;
  padding-top:16px;
}

.header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:24px;
  padding:18px 20px;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:0 10px 40px rgba(0,0,0,.35);
}

.header-main{
  min-width:0;
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.header-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  flex-shrink:0;
}

.title{
  font-size:22px;
  font-weight:800;
  line-height:1.25;
}

.meta{
  margin-top:4px;
  font-size:13px;
  line-height:1.45;
  color:var(--muted);
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:36px;
  padding:8px 12px;
  border:1px solid rgba(148,163,184,.22);
  border-radius:10px;
  background:rgba(148,163,184,.08);
  color:#cbd5f5;
  font-size:13px;
  text-decoration:none;
  cursor:pointer;
  transition:background .15s ease,border-color .15s ease,color .15s ease;
}

.btn:hover{
  text-decoration:none;
  border-color:rgba(148,163,184,.45);
  background:rgba(148,163,184,.14);
}

.btn_create{
  border-color:rgba(34,197,94,.18);
  background:rgba(34,197,94,.10);
  color:#a7f3d0;
}

.btn_create:hover{
  border-color:rgba(34,197,94,.45);
  background:rgba(34,197,94,.16);
}

.btn_cfg{
  border-color:rgba(14,165,233,.22);
  background:rgba(14,165,233,.10);
  color:#bae6fd;
}

.btn_cfg:hover{
  border-color:rgba(14,165,233,.45);
  background:rgba(14,165,233,.18);
}

.btn_delete{
  border-color:rgba(239,68,68,.18);
  background:rgba(239,68,68,.10);
  color:#fecaca;
}

.btn_delete:hover{
  border-color:rgba(239,68,68,.45);
  background:rgba(239,68,68,.16);
}

.btn_users{
  border-color:rgba(139,92,246,.20);
  background:rgba(139,92,246,.10);
  color:#c4b5fd;
}

.btn_users:hover{
  border-color:rgba(139,92,246,.45);
  background:rgba(139,92,246,.18);
}

.btn_logout{
  border-color:rgba(239,68,68,.18);
  background:rgba(239,68,68,.10);
  color:#fecaca;
}

.btn_logout:hover{
  border-color:rgba(239,68,68,.45);
  background:rgba(239,68,68,.16);
}

.tool-wrap{
  width:100%;
  margin:0;
}

.tool-wrap.editor-grid{
  display:block;
}

.tool-wrap.editor-grid > .editor-block{
  margin-bottom:24px;
}

.tool-wrap.editor-grid > .editor-block:last-child{
  margin-bottom:0;
}

.editor-block{
  padding:20px 18px;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:0 10px 40px rgba(0,0,0,.35);
}

.editor-head{
  margin-bottom:18px;
}

.editor-title{
  margin:0;
  font-size:18px;
  font-weight:800;
  line-height:1.3;
}

.editor-subtitle{
  margin:8px 0 10px;
  color:var(--muted);
  font-size:13px;
  line-height:1.45;
}

.editor-path{
  margin-top:10px;
  color:var(--muted);
  font-size:12px;
  line-height:1.5;
  word-break:break-word;
}

.list-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto;
  gap:12px;
  align-items:end;
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:16px;
}

.tool-field{
  min-width:0;
}

.tool-field label{
  display:block;
  margin:0 0 8px;
  color:var(--muted);
  font-size:13px;
}

.tool-input,
.tool-select,
.tool-textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--panel-2);
  color:var(--text);
  outline:none;
  font-size:14px;
}

.tool-input,
.tool-select{
  height:40px;
  padding:0 12px;
}

.tool-textarea{
  min-height:180px;
  padding:12px 14px;
  line-height:1.6;
  resize:none;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  scrollbar-color:#1f2937 #0b1220;
  scrollbar-width:thin;
}

.code-area{
  min-height:540px;
  margin-top:8px;
}

.tool-input:focus,
.tool-select:focus,
.tool-textarea:focus,
.auth-input:focus{
  border-color:rgba(96,165,250,.55);
  box-shadow:0 0 0 3px rgba(96,165,250,.10);
}

.editor-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:18px;
}

.notice{
  margin:10px 0 14px;
  padding:10px 12px;
  border:1px solid rgba(148,163,184,.18);
  border-radius:10px;
  background:rgba(148,163,184,.08);
  color:var(--text);
  font-size:13px;
  line-height:1.45;
  word-break:break-word;
  white-space:normal;
  opacity:1;
  transform:translateY(0);
  transition:opacity .25s ease, transform .25s ease;
}

.notice.hide{
  opacity:0;
  transform:translateY(-6px);
}

.notice.ok{
  border-color:rgba(34,197,94,.25);
  background:rgba(34,197,94,.08);
  color:#d1fae5;
}

.notice.warn{
  border-color:rgba(245,158,11,.25);
  background:rgba(245,158,11,.08);
  color:#fde68a;
}

.notice.err{
  border-color:rgba(239,68,68,.25);
  background:rgba(239,68,68,.08);
  color:#fecaca;
}

.notice.delete{
  border-color:rgba(239,68,68,.35);
  background:rgba(239,68,68,.12);
  color:#fecaca;
}

.editor-head + .notice{
  margin-top:0;
}

.editor-block .notice{
  margin-bottom:14px;
}

#globalNotice.notice{
  margin:12px 0 0;
}

#createError.notice,
#previewError.notice,
#editActionNotice.notice,
#logsNotice.notice{
  margin:0 0 14px;
}

.term{
  margin-top:18px;
  overflow:hidden;
  border:1px solid #1b2a44;
  border-radius:14px;
  background:#08111f;
}

.term-head{
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  border-bottom:1px solid #162235;
  background:linear-gradient(180deg,#0c1729 0%,#0a1323 100%);
  color:#9fb3c8;
  font-size:12px;
}

.term-dot{
  display:inline-block;
  width:10px;
  height:10px;
  border-radius:50%;
}

.term-dot.red{background:#fb7185;}
.term-dot.yellow{background:#fbbf24;}
.term-dot.green{background:#22c55e;}

.term-title{
  margin-left:4px;
  font-weight:600;
  letter-spacing:.02em;
}

.term-body{
  min-height:220px;
  max-height:520px;
  margin:0;
  overflow:auto;
  padding:14px 16px;
  background:#08111f;
  color:#d7e3f4;
  white-space:pre-wrap;
  font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  scrollbar-color:#1b2a44 #08111f;
  scrollbar-width:thin;
}

.auth-card{
  width:min(420px,100%);
  padding:24px;
  border:1px solid var(--border);
  border-radius:16px;
  background:var(--panel);
  box-shadow:0 10px 40px rgba(0,0,0,.35);
}

.auth-title{
  margin:0 0 8px;
  font-size:22px;
  font-weight:800;
}

.auth-meta{
  margin-bottom:18px;
  font-size:13px;
  line-height:1.5;
  color:var(--muted);
}

.auth-label{
  display:block;
  margin:12px 0 6px;
  font-size:13px;
  color:var(--muted);
}

.auth-input{
  width:100%;
  height:40px;
  padding:0 12px;
  border:1px solid var(--border);
  border-radius:10px;
  outline:none;
  background:#0b1220;
  color:var(--text);
}

.auth-btn{
  width:100%;
  margin-top:18px;
  padding:10px 12px;
  border:1px solid rgba(96,165,250,.35);
  border-radius:10px;
  background:rgba(96,165,250,.10);
  color:var(--text);
  font-size:14px;
  cursor:pointer;
}

.auth-btn:hover{
  background:rgba(96,165,250,.16);
}

.auth-err{
  margin:10px 0 14px;
  padding:10px 12px;
  border:1px solid rgba(251,113,133,.25);
  border-radius:10px;
  background:rgba(251,113,133,.08);
  color:var(--text);
  font-size:13px;
  line-height:1.45;
}

.auth-card .notice,
.auth-card .auth-err{
  max-width:100%;
}

.auth-card .notice{
  margin:0 0 14px;
}

.hidden{
  display:none !important;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.tool-textarea::-webkit-scrollbar,
.term-body::-webkit-scrollbar{
  width:8px;
  height:8px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track{
  background:#0f172a;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb{
  background:#1f2937;
  border:2px solid #0f172a;
  border-radius:8px;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover{
  background:#374151;
}

.tool-textarea::-webkit-scrollbar-track{
  background:#0b1220;
}

.tool-textarea::-webkit-scrollbar-thumb{
  background:#1f2937;
  border:2px solid #0b1220;
  border-radius:8px;
}

.tool-textarea::-webkit-scrollbar-thumb:hover{
  background:#374151;
}

.term-body::-webkit-scrollbar-track{
  background:#08111f;
}

.term-body::-webkit-scrollbar-thumb{
  background:#1b2a44;
  border:2px solid #08111f;
  border-radius:8px;
}

.term-body::-webkit-scrollbar-thumb:hover{
  background:#2b4267;
}

@media (max-width:860px){
  body.auth-page{
    padding:20px 14px;
  }

  .wrap{
    width:min(1100px, calc(100% - 24px));
    margin:0 auto 20px;
    padding-top:12px;
  }

  .header{
    flex-direction:column;
    align-items:stretch;
  }

  .header-actions{
    width:100%;
    flex-direction:column;
  }

  .header-actions .btn{
    width:100%;
  }

  .list-row,
  .form-grid{
    grid-template-columns:1fr;
  }

  .editor-actions .btn{
    width:100%;
  }

  .code-area{
    min-height:420px;
  }
}

#globalNotice.hidden{
  display:none !important;
}

.header-actions .is-active{
  border-color:rgba(34,197,94,.45);
  background:rgba(34,197,94,.18);
  color:#dcfce7;
}

.dashboard-topbar{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:12px;
  margin-bottom:14px;
}

.table-wrap{
  overflow:auto;
  border:1px solid var(--border);
  border-radius:14px;
}

.dash-table{
  width:100%;
  border-collapse:collapse;
  min-width:900px;
}

.dash-table thead th{
  text-align:left;
  font-size:12px;
  color:var(--muted);
  letter-spacing:.08em;
  text-transform:uppercase;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  background:rgba(0,0,0,.15);
}

.dash-table tbody td{
  padding:12px 14px;
  border-bottom:1px solid rgba(34,53,44,.6);
  vertical-align:top;
  font-size:14px;
}

.dash-table tbody tr:hover{
  background:rgba(158,255,198,.04);
}

.pill{
  display:inline-block;
  padding:4px 8px;
  border:1px solid rgba(158,255,198,.22);
  background:rgba(158,255,198,.06);
  border-radius:999px;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  font-size:12px;
  margin:2px 6px 2px 0;
  color:var(--text);
  white-space:nowrap;
}

.flag{
  display:inline-block;
  padding:4px 8px;
  border:1px solid rgba(251,191,36,.28);
  background:rgba(251,191,36,.08);
  border-radius:999px;
  font-size:12px;
  margin:2px 6px 2px 0;
  color:#fbbf24;
  white-space:nowrap;
}

.file{
  display:inline-block;
  padding:4px 8px;
  border:1px solid rgba(143,168,156,.25);
  background:rgba(143,168,156,.06);
  border-radius:10px;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  font-size:12px;
  margin:2px 6px 2px 0;
  color:var(--muted);
  white-space:nowrap;
}

.code-shell{
  margin-top:8px;
  border:1px solid #1b2a44;
  border-radius:14px;
  overflow:hidden;
  background:#0b1220;
}

.code-shell .tool-textarea{
  margin:0;
  border:0;
  border-radius:0;
  display:block;
  width:100%;
  min-height:540px;
  background:#0b1220;
}

.preview-shell{
  margin-top:8px;
  border:1px solid #1b2a44;
  border-radius:14px;
  overflow:hidden;
  background:#08111f;
}

.preview-shell .term-body{
  margin:0;
  border:0;
  border-radius:0;
  max-height:520px;
  min-height:220px;
}

.site-footer{
  margin:20px auto 28px;
  width:min(350px, calc(100% - 32px));
  padding:10px 14px;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(17,24,39,.55);
}

.site-footer__inner{
  text-align:center;
  font-size:12px;
  color:var(--muted);
  opacity:.75;
}

.footer-link{
  color:var(--muted);
  text-decoration:none;
  border-bottom:1px dashed rgba(156,163,175,.35);
  transition:all .15s ease;
}

.footer-link:hover{
  color:var(--accent);
  border-bottom-color:rgba(96,165,250,.6);
}