/* Kare's phone page: a trackpad over a remote's few keys, panels for the rest, dark for a
   dark room. */
:root {
  --bg: #0d0f12;
  --panel: #171a1f;
  --key: #20242b;
  --key-down: #2f3540;
  --line: #2a2f37;
  --text: #e9ecf1;
  --dim: #8a93a1;
  --faint: #59616d;
  --accent: #ffc21a;
  --ok: #3ecf75;
  --relay: #6aa7ff;
  --bad: #ff6b5e;
  --r: 14px;
  --gap: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  touch-action: manipulation;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- the top line ---- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 2px;
  gap: 8px;
}

.mac {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel);
  font-weight: 600;
  font-size: 15px;
  max-width: 75%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.mac.online .dot { background: var(--ok); }
.mac.relay .dot { background: var(--relay); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel);
  font-size: 20px;
  line-height: 1;
}

.banner {
  margin: 4px 12px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--dim);
  font-size: 14px;
}
.banner.error { color: var(--bad); }

/* ---- screens ---- */

section { flex: 1; min-height: 0; }

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 12px;
}
.center p { color: var(--dim); max-width: 22em; margin: 0; }
.center h1 { margin: 0; font-size: 26px; }

.logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
}

.wide {
  margin-top: 4px;
  padding: 14px 28px;
  border-radius: 999px;
  background: var(--accent);
  color: #111;
  font-weight: 700;
}

#scanner video { width: min(80vw, 340px); border-radius: var(--r); margin-top: 12px; }

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- the remote ---- */

.remote {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 6px 12px 8px;
}

.pad {
  flex: 1;
  min-height: 120px;
  border-radius: 20px;
  background: radial-gradient(120% 90% at 50% 0%, #1b1f26 0%, var(--panel) 60%);
  border: 1px solid var(--line);
  touch-action: none;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}
.pad.active { border-color: #3a414c; }
.pad.dragging { border-color: var(--accent); }
.pad.away { opacity: 0.55; }
.pad-hint, .pad-away {
  margin: 0;
  padding: 12px 18px;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
  pointer-events: none;
}
.pad-away { align-self: center; color: var(--dim); font-size: 14px; }

.panel {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.media, .row6, .row4, .row2 { display: grid; gap: var(--gap); }
.media, .row6 { grid-template-columns: repeat(6, 1fr); }
.row4 { grid-template-columns: repeat(4, 1fr); }
.row2 { grid-template-columns: 1fr 1fr; }

.key {
  min-height: 50px;
  padding: 0 4px;
  border-radius: var(--r);
  background: var(--key);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.15;
  text-align: center;
  transition: background 0.08s, transform 0.08s;
}
.key svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
.row4 .key, .row2 .key { font-size: 13px; color: #c9ced6; }
.key.down { background: var(--key-down); transform: scale(0.96); }
.key.on { background: var(--accent); color: #111; }
.key:disabled { opacity: 0.35; }
.key.small { min-height: 0; padding: 0 14px; font-size: 13px; }
.row6 .key { min-height: 44px; font-size: 17px; }

/* ---- the dock ---- */

.dock {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}
.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 2px;
  font-size: 11.5px;
  color: var(--dim);
  border-radius: 12px;
}
.dock-btn svg { width: 24px; height: 24px; fill: currentColor; }
.dock-btn.on { color: var(--accent); }

/* ---- the keyboard ---- */

.mac-field {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel);
  font-size: 14px;
  min-width: 0;
}
.mac-field-label { color: var(--faint); font-size: 12px; flex: none; }
.mac-field-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.type-row { display: grid; grid-template-columns: 1fr auto; gap: var(--gap); }
.type-box, .search {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: #0f1216;
  color: var(--text);
  font: inherit;
  resize: none;
  -webkit-user-select: text;
  user-select: text;
}
.type-box:focus, .search:focus { outline: none; border-color: #4a5260; }
.type-box.wanted { border-color: var(--accent); }

/* ---- apps ---- */

.app-list { display: flex; flex-direction: column; }
.app-list .app { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 8px 6px; font-size: 15px; }
.app-list .app img, .app-list .app .ph { width: 32px; height: 32px; }
.app-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 4px; }
.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: 12px;
  font-size: 11.5px;
  color: #c9ced6;
  min-width: 0;
}
.app span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app img, .app .ph { width: 44px; height: 44px; border-radius: 10px; }
.app .ph { background: var(--key); }
.app.front span { color: var(--accent); }
.app.down { background: var(--key); }

/* ---- the menu ---- */

.shade { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}
.menu-list { display: flex; flex-direction: column; }
.menu-item {
  text-align: left;
  padding: 15px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item.danger { color: var(--bad); }
.menu-list .step { margin: 0; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.45; }
