/* Remote Control – host & viewer */
:root {
  --bg: #0f0f12;
  --bg-elevated: #18181c;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --border: #27272a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --input-bg: #18181c;
  --radius: 8px;
}

html.theme-light,
html[data-theme="light"] {
  --bg: #f0f0f4;
  --bg-elevated: #fff;
  --text: #18181b;
  --text-muted: #52525b;
  --border: #e4e4e7;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --input-bg: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.host-page .app,
.viewer-page .app,
.index-page .app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Index / home */
.index-app {
  padding-top: 2rem;
}

.index-header {
  text-align: center;
  margin-bottom: 2rem;
}

.index-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 600;
}

.index-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.index-by {
  margin: 0.5rem 0 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.index-by strong {
  color: var(--accent);
  font-weight: 600;
}

.index-info {
  text-align: left;
  max-width: 480px;
  margin: 0 auto 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.index-info-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.index-features {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.index-features li {
  margin-bottom: 0.35rem;
}

.index-features li:last-child {
  margin-bottom: 0;
}

.index-main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.index-card {
  display: block;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.index-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.index-card:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.index-card-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.index-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.index-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.index-footer {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.index-footer-sep {
  margin: 0 0.5rem;
  color: var(--text-muted);
}

.index-credit {
  color: var(--text-muted);
}

.index-credit strong {
  color: var(--accent);
}

.index-link {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
}

.index-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Controller page */
.controller-page .app {
  max-width: 480px;
}

.controller-tagline {
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.controller-version {
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.controller-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.controller-actions .btn {
  width: 100%;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--border);
}

.controller-hint {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.5em;
}

/* Downloads page */
.downloads-page .app {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.downloads-header {
  text-align: center;
  margin-bottom: 2rem;
}

.downloads-back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.downloads-back:hover {
  color: var(--accent);
}

.downloads-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 600;
}

.downloads-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.downloads-by {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.downloads-by strong {
  color: var(--accent);
}

.downloads-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.downloads-section {
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.downloads-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.downloads-section p {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.downloads-install {
  margin-top: 0.5rem;
}

.downloads-install a {
  color: var(--accent);
  text-decoration: none;
}

.downloads-install a:hover {
  text-decoration: underline;
}

.downloads-options {
  margin: 0.5rem 0 1rem;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.downloads-options li {
  margin-bottom: 0.35rem;
}

.downloads-hint,
.downloads-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.downloads-section code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.btn-download {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

.btn-download:hover {
  background: var(--accent-hover);
}

.downloads-summary ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.downloads-summary a {
  color: var(--accent);
  text-decoration: none;
}

.downloads-summary a:hover {
  text-decoration: underline;
}

/* Saved contacts (viewer join page) */
.saved-contacts {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.saved-contacts-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.saved-contacts-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.saved-contact-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.saved-contact-item:last-child {
  border-bottom: none;
}

.saved-contact-name {
  font-weight: 500;
  min-width: 6em;
}

.saved-contact-room {
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Top utility buttons */
.top-buttons {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 100;
  display: flex;
  gap: 0.5rem;
}

.fullscreen-toggle,
.theme-toggle {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.fullscreen-toggle:hover,
.theme-toggle:hover {
  background: var(--border);
}

.fullscreen-icon-exit,
.theme-icon-light {
  display: none;
}

.fullscreen-toggle.is-fullscreen .fullscreen-icon-enter {
  display: none;
}

.fullscreen-toggle.is-fullscreen .fullscreen-icon-exit {
  display: inline;
}

html.theme-light .theme-icon-dark,
html[data-theme="light"] .theme-icon-dark {
  display: none;
}

html.theme-light .theme-icon-light,
html[data-theme="light"] .theme-icon-light {
  display: inline;
}

/* Headers */
.host-header,
.viewer-header {
  margin-bottom: 1rem;
}

.host-header h1,
.viewer-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.back {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.back:hover {
  text-decoration: underline;
}

.room-code,
.status,
.join-hint {
  margin: 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.join-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}

.password-wrap {
  margin-top: 0.75rem;
}

.password-wrap label,
.room-password-wrap label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.invite-wrap {
  position: relative;
  display: inline-block;
  margin-left: 0.5rem;
  z-index: 100;
}

.invite-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem;
  min-width: 160px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.host-header .room-code {
  overflow: visible;
}

.invite-dropdown-open {
  display: block;
}

.invite-option {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.invite-option:hover {
  background: var(--border);
}

/* Inputs & buttons */
.input-room,
.chat-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
  min-width: 160px;
}

.input-room:focus,
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

/* Preview area */
.host-main,
.viewer-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-area {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-placeholder {
  margin: 0;
  padding: 1rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
}

.preview-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Viewer: video area is the control surface (mouse + keyboard) */
.viewer-page .preview-area.control-surface {
  cursor: crosshair;
  outline: none;
}

.viewer-page .preview-area.control-surface:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.fullscreen-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.35rem 0.65rem;
  border: none;
  border-radius: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.875rem;
  cursor: pointer;
}

.fullscreen-btn:hover {
  background: rgba(0,0,0,0.8);
}

.play-video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
}

.play-video-overlay:hover {
  background: rgba(0,0,0,0.85);
}

.capture-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.record-status {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.record-status.recording {
  color: #ef4444;
}

.camera-fallback-wrap {
  margin-top: 0.5rem;
}

/* Chat panel */
.chat-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.chat-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.chat-messages {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.msg {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

.msg.remote {
  color: var(--text-muted);
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.chat-input {
  flex: 1;
  min-width: 0;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.file-input {
  font-size: 0.875rem;
  color: var(--text);
}

.viewer-actions {
  margin: 0.25rem 0 0;
}

.request-control-wrap {
  margin-right: 0.5rem;
}

/* Host: control request approval */
.control-request-wrap {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.control-request-msg {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.control-request-actions {
  display: flex;
  gap: 0.5rem;
}

.control-status-wrap {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.control-status-wrap #controlStatusText {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.viewer-voice-wrap {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.file-status {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-messages a {
  color: var(--accent);
  text-decoration: none;
}

.chat-messages a:hover {
  text-decoration: underline;
}

/* Accessibility widget */
.a11y-widget {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 90;
}

.a11y-toggle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
}

.a11y-panel {
  display: none;
  position: absolute;
  bottom: 3rem;
  right: 0;
  min-width: 220px;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.a11y-panel-open {
  display: block;
}

.a11y-panel-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.a11y-option {
  margin-bottom: 0.75rem;
}

.a11y-option-label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.a11y-buttons button {
  padding: 0.25rem 0.5rem;
  margin-right: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
}

.a11y-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.a11y-reset {
  margin-top: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

/* Accessibility state classes */
html.a11y-larger-text {
  font-size: 18px;
}

html[data-a11y-font-level="2"] {
  font-size: 20px;
}

html[data-a11y-font-level="3"] {
  font-size: 22px;
}

html.a11y-high-contrast {
  --text: #fff;
  --text-muted: #d4d4d8;
  --border: #3f3f46;
}

html.theme-light.a11y-high-contrast,
html[data-theme="light"].a11y-high-contrast {
  --text: #000;
  --text-muted: #374151;
  --border: #1f2937;
}

html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
