:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #617083;
  --line: #cfd8e1;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --danger-strong: #8f1b12;
  --focus: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

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

button.danger {
  background: var(--danger);
}

button.danger:hover:not(:disabled) {
  background: var(--danger-strong);
}

button.install-button {
  flex: 0 0 auto;
  background: #2563eb;
}

button.install-button:hover:not(:disabled) {
  background: #1d4ed8;
}

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

input:focus,
button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus), transparent 55%);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  background:
    linear-gradient(135deg, transparent 44%, #ffffff 45%, #ffffff 55%, transparent 56%),
    linear-gradient(135deg, #0f766e 0%, #2563eb 55%, #f59e0b 100%);
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.2;
}

p {
  margin: 3px 0 0;
  color: var(--muted);
}

.connect-form {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(120px, 150px) minmax(120px, 150px) 118px;
  align-items: end;
  gap: 10px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.side-panel {
  padding: 16px;
  background: #f8fafc;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: start;
  gap: 16px;
}

.session-box {
  display: grid;
  gap: 5px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-grid .danger {
  grid-column: 1 / -1;
}

.panel-group {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.panel-group p {
  margin: 0;
  font-size: 0.82rem;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.text-form {
  display: grid;
  gap: 8px;
}

.screen-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(24, 32, 42, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(24, 32, 42, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
}

#screenCanvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 118px);
  width: auto;
  height: auto;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 7px;
  box-shadow: 0 16px 38px rgba(24, 32, 42, 0.18);
  touch-action: none;
}

.empty-state {
  position: absolute;
  inset: auto;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-weight: 700;
}

.empty-state.hidden {
  display: none;
}

@media (max-width: 760px) {
  body {
    min-width: 320px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .connect-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .connect-form label:first-child,
  .connect-form button {
    grid-column: 1 / -1;
  }

  button.install-button {
    width: 100%;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .side-panel {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 12px;
  }

  .screen-panel {
    order: 1;
    min-height: 62svh;
    padding: 10px;
  }

  .quick-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  #screenCanvas {
    max-height: 60svh;
  }
}

@media (max-width: 420px) {
  .control-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }
}
