:root {
  --bg: #0f1115;
  --panel: #181b22;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #e5484d;
  --accent-hover: #f2555a;
  --ok: #3dd68c;
  --error: #ff6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
}

[hidden] { display: none !important; }

.muted { color: var(--muted); }

.center {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card h1 { margin: 0; font-size: 22px; }
.card p { margin: 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input, select, button {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
}

#remote-id { font-size: 20px; letter-spacing: 1px; }

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button { cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); }

.card h2 { margin: 0; font-size: 17px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

#connect-view { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.topbar button { padding: 5px 12px; }

.home {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px;
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.home .card { max-width: none; }
@media (max-width: 760px) {
  .home { grid-template-columns: 1fr; }
}

.book-head { display: flex; align-items: center; gap: 12px; }
.book-head h2 { flex: 1; }
.book-head input { width: 160px; padding: 6px 10px; }

#book-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.host {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.host-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); flex: none; }
.host-dot.online { background: var(--ok); }
.host-main { flex: 1; min-width: 0; }
.host-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.host-meta { color: var(--muted); font-size: 12px; }
.host-actions { display: flex; gap: 6px; flex: none; }
.host-actions button { padding: 5px 10px; }
.host-actions .connect { border-color: var(--accent); color: var(--accent); }
.host-actions .connect:hover { background: var(--accent); color: #fff; }
.icon-btn { width: 32px; padding: 5px 0 !important; }

dialog {
  width: min(380px, calc(100vw - 32px));
  padding: 24px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-size: 17px; }
dialog p { margin: 0; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }

.status { min-height: 1.4em; color: var(--muted); }
.status.error { color: var(--error); }

#session-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.toolbar label { flex-direction: row; align-items: center; }
.toolbar select, .toolbar button { padding: 5px 10px; }
.toolbar .spacer { flex: 1; }
.toolbar .danger { border-color: var(--accent); color: var(--accent); }
.toolbar .danger:hover { background: var(--accent); color: #fff; }

#session-title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ok);
}

#screen-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

.badge {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}
.badge:empty { display: none; }

#screen, #video {
  max-width: 100%;
  max-height: 100%;
  outline: none;
  cursor: default;
}

:fullscreen .toolbar { display: none; }

#screen-wrap.dragover { outline: 3px dashed var(--accent); outline-offset: -12px; }

#toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  z-index: 10;
}
#toast.error { border-left-color: var(--error); }
