:root {
  --bg: #f4f7fb;
  --bg-sidebar: #ffffff;
  --bg-card: #f8fafc;
  --bg-hover: #eef3f9;
  --border: #e3e9f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --danger: #ef4444;
  --ok: #10b981;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

.layout {
  display: flex;
  height: 100vh;
}

/* ---------- sidebar ---------- */
.sidebar {
  width: 360px;
  min-width: 360px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.sidebar-header .sub {
  color: var(--text-dim);
  font-size: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.slot-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color .15s, box-shadow .15s;
}
.slot:hover { box-shadow: 0 2px 6px rgba(15, 23, 42, .08); }
.slot.active { border-color: var(--accent); }

.slot-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.slot .num {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.slot .name {
  font-weight: 600;
  font-size: 12px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot .name.empty { color: var(--text-dim); font-weight: 400; }
.slot .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.slot .dot.has-cookies { background: var(--accent); }
.slot .dot.has-proxy { background: #d97706; }
.slot .url {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.slot-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.slot-actions button {
  padding: 6px 0;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--bg-sidebar);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.slot-actions button:hover { background: var(--bg-hover); }
.slot-actions .btn-open {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.slot-actions .btn-open:hover { background: var(--accent); color: #fff; }

/* ---------- viewer ---------- */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  font-size: 13px;
  color: var(--text-dim);
}

.viewer-toolbar #active-label { color: var(--text); font-weight: 600; }

.viewer-body {
  flex: 1;
  position: relative;
  background: #eef2f7;
}

.viewer-body iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 15px;
}
.placeholder.hidden { display: none; }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .4);
  display: grid;
  place-items: center;
  z-index: 10;
}

.modal {
  width: 480px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, .15);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal h2 { margin: 0 0 4px; font-size: 16px; }

.modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.modal input, .modal textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.modal input:focus, .modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.modal button {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.modal button:hover { background: var(--bg-hover); }
.modal button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.modal button.ghost { background: transparent; }
.modal button:disabled { opacity: .5; cursor: not-allowed; }

.modal-status {
  font-size: 12px;
  color: var(--text-dim);
  min-height: 16px;
}
.modal-status.err { color: var(--danger); }
.modal-status.ok { color: var(--ok); }
