:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d7dce2;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --danger: #b42318;
  --screen: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--brand-dark);
  background: var(--brand);
  color: #fff;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: #fff;
  color: var(--brand-dark);
}

input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status {
  min-width: 92px;
  text-align: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.status.online {
  color: var(--brand-dark);
  border-color: #99d5cd;
  background: #e9fbf8;
}

.status.error {
  color: var(--danger);
  border-color: #f4aaa4;
  background: #fff1f0;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: calc(100vh - 70px);
}

.sidebar {
  padding: 14px;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}

.check input {
  width: 16px;
  height: 16px;
}

.agent-list {
  display: grid;
  gap: 8px;
}

.empty-list {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.agent {
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--text);
  border-color: var(--line);
  padding: 10px;
  min-height: 76px;
}

.agent:hover {
  border-color: var(--brand);
}

.agent strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.agent span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.screen-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  background: var(--screen);
  outline: none;
  overflow: hidden;
}

.screen-wrap:focus {
  box-shadow: inset 0 0 0 2px var(--brand);
}

#remoteScreen {
  display: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.empty {
  position: absolute;
  color: #cbd5e1;
  font-size: 16px;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(70vh, 1fr);
    height: auto;
    min-height: calc(100vh - 70px);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* 全螢幕（最大化）：手機把遠端畫面撐滿整個瀏覽器視窗 */
body.maximized .topbar,
body.maximized .sidebar {
  display: none;
}

body.maximized .layout {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

body.maximized .workspace {
  grid-template-rows: auto minmax(0, 1fr);
}
