:root{
  --bg:#0b1022;
  --surface:#11193a;
  --surface-2:#0e1530;
  --text:#dbe2ff;
  --muted:#9db0e2;
  --border:#32406b;
  --accent:#4f7cff;
  --accent-2:#7aa0ff;
  --danger:#e86c6c;
  --ok:#35cba0;
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --radius:12px;
  --pad:12px;
  --pad-lg:16px;
  --gap:10px;
  --font:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,"Helvetica Neue",Arial,"Noto Sans",sans-serif;
  --mono:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font:14px/1.5 var(--font);
  color:var(--text);
  background:radial-gradient(1200px 800px at 30% -20%,#16224b 0%,var(--bg) 60%) fixed;
}
a{color:var(--accent-2);text-decoration:none;}
a:hover{text-decoration:underline;}
.muted{color:var(--muted);}
.mono{font-family:var(--mono);}
.small{font-size:.9rem;}
.container{
  height:100vh;
  max-width:1100px;
  margin:0 auto;
  padding:8px 12px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.row{display:flex;gap:var(--gap);align-items:center;flex-wrap:wrap;}
.toolbar{display:flex;gap:var(--gap);align-items:center;flex-wrap:wrap;margin-bottom:var(--pad);}
.card{
  background:linear-gradient(180deg,var(--surface) 0%,var(--surface-2) 100%);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:var(--pad-lg);
}
h1,h2,h3{margin:0 0 8px;font-weight:600;}
h2{font-size:1.3rem;}
h3{font-size:1.1rem;color:var(--muted);}
.input,
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"]{
  height:34px;
  padding:0 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:#0b1330;
  color:var(--text);
  outline:none;
}
.input:focus,input:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(79,124,255,.25);
}
input[type="number"]{width:6rem;}
label span{display:block;margin-bottom:.25rem;color:var(--muted);}
button,.btn{
  height:34px;
  padding:0 12px;
  border:1px solid var(--accent);
  background:rgba(79,124,255,.15);
  color:var(--text);
  border-radius:8px;
  cursor:pointer;
}
button:hover,.btn:hover{background:rgba(79,124,255,.25);}
button:active,.btn:active{transform:translateY(1px);}
button.secondary,.secondary{border-color:var(--border);background:#0c1330;}
button.secondary:hover,.secondary:hover{background:#0f1738;}
button.danger{border-color:var(--danger);background:rgba(232,108,108,.12);}
button.danger:hover{background:rgba(232,108,108,.2);}
button[disabled],.btn[disabled],input[disabled]{opacity:.55;cursor:default;pointer-events:none;}
.badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:.8rem;
  border:1px solid var(--border);
  background:#0b1330;
  color:var(--muted);
}
.table{
  width:100%;
  border-collapse:collapse;
  overflow:hidden;
  border-radius:10px;
  border:1px solid var(--border);
}
.table th,.table td{
  text-align:left;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
}
.table th{
  background:#0f1838;
  color:var(--muted);
  font-weight:600;
}
.table tr:hover td{background:rgba(79,124,255,.07);}
details.dropdown{position:relative;}
details.dropdown>summary{
  list-style:none;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  height:34px;
  padding:0 12px;
  border:1px solid var(--border);
  border-radius:8px;
  background:#0c1330;
}
details.dropdown>summary::-webkit-details-marker{display:none;}
details.dropdown[open]>summary{
  border-bottom-left-radius:0;
  border-bottom-right-radius:0;
}
details.dropdown .menu{
  position:absolute;
  right:0;
  top:calc(100% + .4rem);
  z-index:50;
  min-width:340px;
  max-width:min(92vw,560px);
  max-height:60vh;
  overflow:auto;
  padding:12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface);
  box-shadow:var(--shadow);
}
.rowv{display:flex;flex-direction:column;gap:10px;}
.rowh{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.auth-card{max-width:420px;margin:12vh auto;padding:20px;}
.auth-form{display:grid;gap:12px;}
.auth-form .field{display:grid;gap:6px;}
.auth-form label{color:var(--muted);font-size:.95rem;}
.input-row{position:relative;}
.input-row .prefix{
  position:absolute;
  left:10px;
  top:50%;
  transform:translateY(-50%);
  padding:0 6px;
  height:22px;
  display:inline-flex;
  align-items:center;
  border:1px solid var(--border);
  border-radius:6px;
  background:#0b1330;
  color:var(--muted);
  font-size:.85rem;
  pointer-events:none;
}
.input-row input{width:100%;padding-left:52px;}
.form-hint{color:var(--muted);font-size:.9rem;}
.form-error{color:var(--danger);font-size:.9rem;}
.input-error{border-color:var(--danger)!important;box-shadow:0 0 0 3px rgba(232,108,108,.18);}
.auth-actions{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  margin-top:6px;
}
.auth-links a{color:var(--muted);}
.auth-links a:hover{color:var(--text);}
.container:has(#graphCanvas){
  max-width:100%;
  width:100%;
  height:100vh;
  padding:12px;
  gap:12px;
}
.card:has(#graphCanvas){
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
  padding:12px;
}
.card:has(#graphCanvas) .toolbar{flex:0 0 auto;margin-bottom:10px;}
#graphCanvas{
  flex:1 1 auto;
  width:100%;
  height:auto!important;
  min-height:0;
  display:block;
  background:#000;
  border-radius:14px;
  touch-action:none;
  cursor:grab;
}
.notice{
  padding:10px 12px;
  border-radius:8px;
  border:1px solid var(--border);
  background:#0c1330;
  color:var(--text);
}
.notice.ok{border-color:var(--ok);}
.notice.warn{border-color:var(--danger);}
#shareRoleDlg{
  border:none;
  border-radius:var(--radius);
  padding:18px 20px;
  max-width:360px;
  width:92%;
  color:var(--text);
  background:linear-gradient(180deg,var(--surface) 0%,var(--surface-2) 100%);
  border:1px solid var(--border);
  box-shadow:var(--shadow);
}
#shareRoleDlg::backdrop{background:rgba(0,0,0,.45);}
#shareRoleDlg h3{margin:0 0 10px;font-size:16px;font-weight:600;color:var(--muted);}
#shareRoleDlg form{display:grid;gap:12px;}
#shareRoleDlg input[name="username"]{
  width:100%;
  height:36px;
  padding:0 12px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#0b1330;
  color:var(--text);
  outline:none;
}
#shareRoleDlg input[name="username"]::placeholder{color:var(--muted);}
#shareRoleDlg input[name="username"]:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(79,124,255,.25);
}
#shareRoleDlg .row{
  display:flex;
  gap:16px;
  align-items:center;
  flex-wrap:wrap;
}
#shareRoleDlg label{color:var(--text);}
#shareRoleDlg input[type="radio"]{accent-color:var(--accent);}
#shareRoleDlg .row:last-child{justify-content:flex-end;gap:8px;}
#shareRoleDlg button[value="ok"]{
  border:1px solid var(--accent);
  background:rgba(79,124,255,.15);
  color:var(--text);
  border-radius:8px;
  height:34px;
  padding:0 12px;
}
#shareRoleDlg button[value="ok"]:hover{background:rgba(79,124,255,.25);}
.section-title{
  margin:0 0 6px;
  font-size:1rem;
  font-weight:600;
  color:var(--muted);
}
.form-section{
  border-top:1px solid var(--border);
  padding-top:12px;
  margin-top:8px;
}
.form-section:first-of-type{
  border-top:0;
  padding-top:0;
  margin-top:0;
}
.rowh.wrap{flex-wrap:wrap;gap:10px;}
.rowh.end{justify-content:flex-end;gap:10px;}
.grow{flex:1 1 auto;}
details .menu input,
details .menu textarea{
  border:1px solid var(--border);
  background:#0b1330;
  color:var(--text);
  border-radius:8px;
  outline:none;
}
details .menu input{height:34px;padding:0 10px;}
details .menu textarea{padding:8px 10px;resize:vertical;}
details .menu input:focus,
details .menu textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(79,124,255,.25);
}
details .menu label span{
  display:block;
  margin-bottom:.25rem;
  color:var(--muted);
}
@media (max-width:640px){
  .container{padding:8px;}
  .toolbar{gap:8px;}
  details.dropdown .menu{min-width:280px;}
  .card:has(#graphCanvas){padding:10px;}
  .auth-card{margin:8vh 12px;}
  .input-row input{padding-left:48px;}
}
