*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273449;
  --border: #334155;
  --accent: #f97316;
  --accent2: #fb923c;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }

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

/* ── Screens ── */
.screen { display: none; flex-direction: column; height: 100%; }
.screen.active { display: flex; }

/* ── Auth ── */
.auth-card {
  margin: auto;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  width: min(90vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.logo { font-size: 2rem; text-align: center; font-weight: 700; letter-spacing: -0.5px; }
.logo-sm { font-size: 1.1rem; font-weight: 700; }

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-actions { display: flex; gap: .5rem; }

/* ── Tabs ── */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  padding: .65rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: .9rem;
  font-family: var(--font);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tab content ── */
.tab-content { display: none; flex-direction: column; flex: 1; overflow-y: auto; padding: 1rem; gap: 1rem; }
.tab-content.active { display: flex; }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

/* ── Sessions ── */
.session-list { display: flex; flex-direction: column; gap: .5rem; }
.session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.session-card:active { background: var(--surface2); }
.session-card.selected { border-color: var(--accent); }
.session-id { font-size: .75rem; color: var(--muted); font-family: monospace; }
.session-path { font-size: .9rem; font-weight: 500; word-break: break-all; }
.session-preview { font-size: .8rem; color: var(--muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta { display: flex; gap: .5rem; align-items: center; }
.badge {
  font-size: .65rem;
  padding: .15rem .45rem;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--muted);
}
.badge.active { background: #14532d; color: var(--success); }
.session-actions { display: flex; gap: .5rem; margin-top: .25rem; }

/* ── Screenshot ── */
#screenshot-container {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 180px;
  flex-shrink: 0;
}
#screenshot-img { width: 100%; display: block; }
#annotation-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.annotation-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: all;
}
.legend { background: var(--surface); border-radius: var(--radius); padding: .75rem; font-size: .8rem; }
.legend-item { padding: .2rem 0; border-bottom: 1px solid var(--border); }
.legend-item:last-child { border-bottom: none; }
.stream-controls { display: flex; gap: .5rem; align-items: center; }
.toggle-label { display: flex; gap: .3rem; align-items: center; font-size: .85rem; cursor: pointer; }

/* ── Input tab ── */
.input-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.input-section h3 { font-size: .85rem; color: var(--muted); font-weight: 600; }
.coord-row { display: flex; gap: .5rem; }
.coord-row input { flex: 1; }

/* ── Form elements ── */
input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .65rem .75rem;
  font-size: 1rem;
  font-family: var(--font);
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { appearance: none; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  width: 100%;
  transition: background .15s;
}
.btn-primary:active { background: var(--accent2); }
.btn-sm {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .75rem;
  font-size: .85rem;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color .15s;
}
.btn-sm.accent { border-color: var(--accent); color: var(--accent); }
.btn-sm:active { border-color: var(--accent); }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: .25rem;
  border-radius: 6px;
  transition: color .15s;
}
.icon-btn:active { color: var(--accent); }

/* ── Send message bar ── */
.send-bar { display: flex; gap: .5rem; margin-top: .5rem; }
.send-bar input { flex: 1; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: .6rem 1.25rem;
  border-radius: 99px;
  font-size: .875rem;
  white-space: nowrap;
  z-index: 100;
  transition: opacity .3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* ── Misc ── */
/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: min(92vw, 380px);
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600;
}
.modal-body {
  padding: 1rem; display: flex; flex-direction: column; gap: .75rem;
}
.modal-body h3 { font-size: .85rem; color: var(--muted); font-weight: 600; }
.modal-user { font-size: .9rem; color: var(--muted); }
.modal-user strong { color: var(--text); }
.success { color: var(--success); font-size: .875rem; text-align: center; }

.setup-hint { text-align: center; color: var(--muted); font-size: .85rem; margin-top: -.25rem; }
.muted-note { font-size: .75rem; color: var(--muted); text-align: center; line-height: 1.4; }
.divider { font-size: .75rem; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .05em; padding: .25rem 0; }

.placeholder { color: var(--muted); font-size: .9rem; text-align: center; padding: 2rem; }
.error { color: var(--danger); font-size: .875rem; text-align: center; }
.hidden { display: none !important; }
