:root {
  --bg: #12131a;
  --surface: #1e1f28;
  --surface-2: #2c2e3c;
  --surface-hover: #3a3c4b;
  --border: #2c2e3c;
  --border-strong: #3a3c4b;
  --text: #ededf0;
  --muted: #9296a1;
  --primary: #145ce3;
  --primary-press: #1049b8;
  --green: #36c46a;
  --red: #f06067;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--red); font-size: 13px; min-height: 16px; margin: 4px 0 0; }

.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--surface-2); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.btn:hover { background: var(--surface-hover); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-press); }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface); }
.btn--danger { background: transparent; border-color: rgba(240,96,103,.5); color: var(--red); }
.btn--danger:hover { background: rgba(240,96,103,.12); }
.btn--block { width: 100%; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }

input[type="text"], input[type="password"], .url {
  width: 100%; background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 10px; color: var(--text); padding: 11px 13px; font-size: 14px;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20,92,227,.18); }

/* ---- Login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 26px;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-card h1, .brand { font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.login-card h1 span, .brand span { color: var(--primary); }
.login-card input, .login-card .btn { text-align: center; }
.login-card .btn { text-align: center; }

/* ---- App layout ---- */
.app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.sidebar-actions { padding: 12px 16px; }
.site-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.empty { padding: 0 16px; }
.site-item {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent; transition: background .12s var(--ease);
}
.site-item:hover { background: var(--surface-2); }
.site-item.active { background: rgba(20,92,227,.14); border-color: rgba(20,92,227,.35); }
.si-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.si-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Live thumbnails ---- */
.thumb {
  position: relative; overflow: hidden; flex-shrink: 0;
  border-radius: 6px; background: #fff; border: 1px solid var(--border);
}
.thumb iframe {
  position: absolute; top: 0; left: 0; width: 1280px; height: 800px; border: 0;
  transform-origin: top left; pointer-events: none; background: #fff;
}
.site-item .thumb { width: 104px; height: 65px; }   /* 1280×800 → same ratio, no crop */
.thumb--lg { width: 168px; height: 105px; }

/* detail: thumbnail left of the URL field */
.detail-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 8px; }
.detail-top-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.main { padding: 28px; overflow-y: auto; }

/* ---- Dropzone ---- */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 18px;
  min-height: 60vh; display: grid; place-items: center; text-align: center;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.dropzone.drag { border-color: var(--primary); background: rgba(20,92,227,.08); }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px; }
.dz-icon { font-size: 34px; color: var(--primary); }
.dz-title { font-size: 17px; font-weight: 600; margin: 0; }

/* ---- Progress ---- */
.progress { max-width: 520px; margin: 40px auto; }
.progress-label { text-align: center; margin: 0 0 10px; color: var(--muted); }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s var(--ease); }

/* ---- Detail ---- */
.detail { max-width: 640px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.detail-head h2 { margin: 0; font-size: 1.4rem; }
.url-row { display: flex; gap: 8px; margin-bottom: 8px; }
.url { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.re-dz {
  margin-top: 18px; border: 2px dashed var(--border-strong); border-radius: 14px;
  padding: 22px; text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.re-dz.drag { border-color: var(--primary); background: rgba(20,92,227,.08); }
.re-title { font-weight: 600; }
.detail-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* ---- Visitors ---- */
.visitors { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 18px; }
.vtitle { margin: 0 0 12px; font-size: 1.05rem; }
.vcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 10px;
}
.vhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.vip { font-family: ui-monospace, Menlo, monospace; font-weight: 600; font-size: 14px; }
.vchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text);
}
.chip--warn { background: rgba(244,180,0,.14); border-color: rgba(244,180,0,.5); color: #f4b400; }
.vpages { margin-top: 12px; }
.vpages summary { cursor: pointer; color: var(--primary); font-size: 13px; }
.vpages ul { list-style: none; margin: 8px 0 0; padding: 0; }
.vpages li { padding: 5px 0; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.vpath { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.modal-title { margin: 0; font-size: 16px; font-weight: 650; }
.modal-card .row { margin-top: 6px; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 11px 16px; border-radius: 10px; font-weight: 600; font-size: 13px;
  box-shadow: 0 10px 28px rgba(0,0,0,.5); z-index: 60;
}
.toast--ok { background: var(--green); color: #052012; }
.toast--err { background: var(--red); color: #2a0608; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .site-list { max-height: 30vh; }
}
