/* Base */
:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #111827;
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
}

/* Toolbar / status */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem .75rem;
  background: #1f2937;
  border-bottom: 1px solid #374151;
  z-index: 10;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 9rem;
  font-size: .88rem;
  white-space: nowrap;
}

#status-dot {
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  background: #f59e0b;
}

body.connected #status-dot { background: #22c55e; }

body.failed #status-dot { background: #ef4444; }

/* Buttons */
.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .35rem;
}

button {
  min-height: 2.15rem;
  padding: .3rem .65rem;
  border: 1px solid #4b5563;
  border-radius: .38rem;
  color: #f9fafb;
  background: #374151;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover { background: #4b5563; }

button:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

button[aria-pressed="true"] {
  color: #111827;
  background: #fbbf24;
  border-color: #fbbf24;
}

button.danger {
  background: #991b1b;
  border-color: #b91c1c;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* Screen */
#screen {
  min-width: 0;
  min-height: 0;
  margin: 20px;
  overflow: auto;
  background: #666;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen:focus { outline: none; }

/* Soft keyboard / Message */
#soft-keyboard {
  position: fixed;
  left: -10000px;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: .01;
}

#message {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: min(34rem, 90vw);
  padding: 1rem 1.25rem;
  color: #fff;
  background: rgba(127, 29, 29, .96);
  border-radius: .5rem;
  box-shadow: 0 10px 30px #0008;
  z-index: 20;
}

/* Media queries */
@media (max-width: 820px) {
  body { grid-template-rows: auto 1fr; }
  #toolbar { align-items: flex-start; flex-direction: column; }
  .keys { justify-content: flex-start; }
  button { min-height: 2.5rem; }
}
