:root {
  color-scheme: light;
  --ink: #141712;
  --muted: #617066;
  --line: #d7ddd5;
  --paper: #f6f7f2;
  --surface: #ffffff;
  --green: #1e7a4d;
  --green-dark: #145c39;
  --blue: #2357a4;
  --red: #b4233c;
  --amber: #b7791f;
  --shadow: 0 18px 50px rgba(24, 30, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(35, 87, 164, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(30, 122, 77, 0.12), transparent 38%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

a {
  text-decoration: none;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--amber);
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(24, 30, 24, 0.08);
  white-space: nowrap;
}

.status-pill.connected {
  color: var(--green);
}

.status-pill.revoked {
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: stretch;
}

.panel,
.viewer {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-header > svg {
  flex: 0 0 auto;
  color: var(--blue);
}

.panel-header p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.code-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf8;
}

.code-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.code-card strong {
  grid-column: 1;
  font-size: 2rem;
  letter-spacing: 0;
}

.icon-button {
  grid-row: 1 / span 2;
  grid-column: 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue);
}

.permission-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.permission-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 700;
}

.permission-list input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.agent-actions,
.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.agent-download {
  margin-top: 14px;
  margin-bottom: 14px;
}

.agent-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.agent-actions .danger {
  grid-column: 1 / -1;
}

.primary,
.ghost,
.danger,
.tool,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  min-width: 0;
  text-align: center;
  line-height: 1.25;
  white-space: normal;
}

.primary {
  background: var(--green);
  color: white;
}

.primary:hover {
  background: var(--green-dark);
}

.danger {
  background: white;
  border-color: rgba(180, 35, 60, 0.28);
  color: var(--red);
}

.ghost {
  background: white;
  border-color: var(--line);
  color: var(--blue);
}

.download-link {
  width: 100%;
  min-height: 50px;
  color: var(--blue);
}

.viewer {
  min-width: 0;
  overflow: hidden;
}

.viewer-toolbar {
  align-items: end;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.session-input {
  display: grid;
  gap: 6px;
  min-width: min(300px, 100%);
}

.session-input label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.session-input input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 800;
}

.remote-screen {
  position: relative;
  margin: 14px;
  min-height: 520px;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1814;
  border: 1px solid #24352f;
}

.remote-video,
.remote-frame {
  position: absolute;
  inset: 38px 0 0;
  z-index: 3;
  width: 100%;
  height: calc(100% - 38px);
  display: none;
  background: #050807;
  object-fit: contain;
}

.remote-screen.live .remote-video,
.remote-screen.frame-live .remote-frame {
  display: block;
}

.remote-screen.live .screen-content,
.remote-screen.frame-live .screen-content {
  opacity: 0;
}

.screen-top {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 38px;
  padding: 0 14px;
  background: #16251f;
}

.screen-top span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #789485;
}

.screen-content {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  min-height: 482px;
}

.desktop-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  background: #20332b;
}

.desktop-sidebar div {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #8fb7a4;
}

.desktop-window {
  margin: 28px;
  border-radius: 8px;
  background: #eef4ef;
  overflow: hidden;
}

.window-bar {
  height: 48px;
  background: #d4e0d8;
}

.window-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.window-grid span {
  min-height: 110px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #c7d9df);
  border: 1px solid #c7d5cd;
}

.consent-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: rgba(13, 24, 20, 0.84);
  color: white;
}

.consent-overlay p {
  max-width: 360px;
  color: #d9e5dd;
  line-height: 1.45;
}

.remote-screen.connected .consent-overlay {
  display: none;
}

.control-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.tool {
  min-width: 0;
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.tool:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tool.allowed {
  color: var(--green);
  border-color: rgba(30, 122, 77, 0.35);
}

.mobile-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 10px;
  padding: 0 14px 14px;
}

.touchpad,
.virtual-keyboard,
.ai-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf8;
}

.touchpad {
  min-height: 116px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  touch-action: none;
  user-select: none;
}

.touchpad.active {
  color: var(--green);
  border-color: rgba(30, 122, 77, 0.45);
  background: #eef8f1;
}

.virtual-keyboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.virtual-keyboard button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.virtual-keyboard button:disabled,
.ai-box button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ai-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.ai-box label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-box textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}

.audit-log {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-log li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf8;
  color: var(--muted);
  line-height: 1.35;
}

.audit-log strong {
  display: block;
  color: var(--ink);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .remote-screen {
    min-height: 420px;
  }

  .screen-content {
    min-height: 382px;
  }

  .agent-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    justify-content: center;
  }

  .agent-actions {
    grid-template-columns: 1fr;
  }

  .remote-screen {
    margin: 10px;
    min-height: 360px;
  }

  .screen-content {
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 322px;
  }

  .desktop-sidebar {
    padding: 12px;
  }

  .desktop-window {
    margin: 16px;
  }

  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 10px 10px;
  }

  .mobile-controls {
    grid-template-columns: 1fr;
    padding: 0 10px 10px;
  }
}
