:root {
  --bg: #0e1116;
  --bg-soft: #141922;
  --card: #171d28;
  --card-2: #1c2330;
  --border: #263043;
  --text: #e8ecf3;
  --muted: #8b96ab;
  --accent: #4f7cff;
  --accent-2: #3f66d8;
  --green: #3ecf8e;
  --red: #f2555a;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#app { min-height: 100vh; }

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

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: rgba(14, 17, 22, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.logo svg { width: 24px; height: 24px; }
.topbar .spacer { flex: 1; }
.key-chip { color: var(--muted); font-size: 13px; }
.key-chip code { color: var(--text); background: var(--card-2); padding: 2px 8px; border-radius: 6px; }

/* ---------- layout ---------- */
.wrap { max-width: 1060px; margin: 0 auto; padding: 26px 22px 80px; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .spacer { flex: 1; }

/* ---------- login ---------- */
.login-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 420px; padding: 34px 30px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.login-card .logo { justify-content: center; margin-bottom: 8px; font-size: 20px; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 24px; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  user-select: none; white-space: nowrap;
}
.btn:hover { background: #232c3d; border-color: #33405c; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: rgba(242,85,90,.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.input, input[type=text], input[type=password] {
  width: 100%; padding: 10px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--text); font: inherit; outline: none;
}
.input:focus, input:focus { border-color: var(--accent); }
label.field { display: block; }
label.field span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }

/* ---------- cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.proj-card { display: flex; flex-direction: column; gap: 10px; }
.proj-card .name { font-weight: 700; font-size: 16px; word-break: break-word; }
.proj-card .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.proj-card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }
.chip.on { color: var(--green); border-color: rgba(62,207,142,.35); }
.chip.off { color: var(--red); border-color: rgba(242,85,90,.35); }
.chip.model-ok { color: var(--accent); border-color: rgba(79,124,255,.35); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 10px; }

/* ---------- project detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }

.share-box .url-row {
  display: flex; gap: 8px; margin: 10px 0;
}
.share-box .url-row .input { font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.share-box .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 26px 18px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .15s, background .15s;
  position: relative;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(79,124,255,.06); color: var(--text); }
.dropzone svg { width: 30px; height: 30px; margin-bottom: 8px; opacity: .75; }
.dropzone .dz-title { font-weight: 600; color: var(--text); }
.dropzone .dz-sub { font-size: 13px; }
.dropzone input[type=file] { display: none; }
.dropzone .progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: rgba(79,124,255,.15); border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden; opacity: 0; transition: opacity .2s;
}
.dropzone .progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.dropzone.uploading .progress { opacity: 1; }
.dropzone.uploading { pointer-events: none; }

/* ---------- file lists ---------- */
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px;
}
.file-row .ico { width: 34px; height: 34px; border-radius: 8px; background: rgba(79,124,255,.12); display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; font-size: 10px; font-weight: 700; }
.file-row .fname { flex: 1; min-width: 0; }
.file-row .fname b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .fname span { font-size: 12px; color: var(--muted); }
.file-row .acts { display: flex; gap: 4px; flex-shrink: 0; }
.iconbtn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:hover { background: var(--card); color: var(--text); border-color: var(--border); }
.iconbtn.danger:hover { color: var(--red); }
.iconbtn svg { width: 15px; height: 15px; }

.bind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.bind-item { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 4/3; background: var(--card-2); }
.bind-item img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.bind-item .del {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 7px;
  background: rgba(10,12,16,.75); border: none; color: #fff; cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.bind-item:hover .del { display: inline-flex; }
.bind-item .del svg { width: 14px; height: 14px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(5,7,10,.92);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 90vh; border-radius: 10px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 90; background: rgba(5,7,10,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 460px; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal h3 { margin: 0 0 14px; }
.modal .modal-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 11px 16px; border-radius: 9px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: toast-in .2s ease;
  max-width: 360px;
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
