/* Pixel 6 Console - dark, dependency-free, no external fonts or CDNs. */

:root {
  --bg:            #0c0e12;
  --bg-elev:       #14171d;
  --bg-elev-2:     #1b1f27;
  --bg-input:      #0f1218;
  --border:        #262b35;
  --border-strong: #363d4a;
  --fg:            #e6e9ef;
  --fg-muted:      #8b93a3;
  --fg-dim:        #5f6673;
  --accent:        #4f8cff;
  --accent-hover:  #6ba0ff;
  --accent-soft:   rgba(79, 140, 255, 0.14);
  --ok:            #3ecf8e;
  --warn:          #e8b339;
  --danger:        #ef5f5f;
  --radius:        10px;
  --radius-sm:     7px;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas,
          "DejaVu Sans Mono", "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

/* The browser's `[hidden] { display: none }` lives in the UA stylesheet, and
   ANY author `display` declaration outranks it regardless of specificity. Without
   this rule, `el.hidden = true` silently does nothing on .login-shade,
   .screen-overlay and .progress - the login overlay would stay on screen after a
   successful connect. Keep the attribute authoritative. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code, pre, .terminal, .log-box, .mono { font-family: var(--mono); }

.muted { color: var(--fg-muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }
.grow  { flex: 1 1 auto; min-width: 0; }

/* ───────────────────────────── login ───────────────────────────── */
.login-shade {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    var(--bg);
  z-index: 100;
}

.login-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.login-card h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.login-card p  { margin: 0; font-size: 13px; }
.login-card label { font-size: 12px; color: var(--fg-muted); margin-top: 6px; }

code {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 12px;
}

/* ───────────────────────────── controls ───────────────────────────── */
input[type="text"], input[type="password"], input[type="search"], select {
  width: 100%;
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select { width: auto; padding: 6px 8px; }

button {
  font-family: inherit;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
  white-space: nowrap;
}

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

button.primary {
  background: var(--accent);
  color: #05070c;
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); }

button.ghost {
  background: var(--bg-elev-2);
  color: var(--fg);
  border-color: var(--border-strong);
}
button.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button.ghost.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }

button.small { padding: 6px 11px; font-size: 12px; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-muted);
  cursor: pointer;
}
.checkbox input { accent-color: var(--accent); }

label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); }

.row { display: flex; align-items: center; }
.row.gap { gap: 8px; flex-wrap: wrap; }

/* ───────────────────────────── topbar ───────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; font-size: 14px; }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--fg-dim);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}
.dot.ok      { background: var(--ok);     box-shadow: 0 0 0 3px rgba(62, 207, 142, .16); }
.dot.booting { background: var(--warn);   box-shadow: 0 0 0 3px rgba(232, 179, 57, .16); }
.dot.down    { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 95, 95, .16); }

.device-meta { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }

.chip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}
.chip.warn { color: var(--warn); border-color: rgba(232, 179, 57, .35); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ───────────────────────────── layout ───────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.pane {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pane-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); }
.pane-head-actions { display: flex; align-items: center; gap: 8px; }

/* ───────────────────────────── device ───────────────────────────── */
.screen-wrap { display: flex; justify-content: center; }

.phone {
  position: relative;
  /* Derive the width from a viewport-bounded height so the whole device pane -
     screen, nav bar and text input - fits without scrolling on a laptop. The
     tap mapping reads getBoundingClientRect(), so any size works. */
  height: min(760px, calc(100vh - 275px));
  width: auto;
  max-width: 100%;
  aspect-ratio: 1080 / 2400;
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .03);
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: crosshair;
  user-select: none;
  -webkit-user-drag: none;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(6, 8, 12, .82);
  color: var(--fg-muted);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  * { transition-duration: .01ms !important; }
}

.navbar {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 10px;
  flex-wrap: wrap;
}

.navbtn {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  min-width: 44px;
  padding: 7px 10px;
  font-size: 14px;
}
.navbtn:hover { color: var(--accent); border-color: var(--accent); }

.type-row { display: flex; gap: 6px; }
.hint { margin: 8px 0 0; text-align: center; }

/* ───────────────────────────── tabs ───────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--fg-muted);
  padding: 8px 12px;
  font-size: 13px;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tabpanel { display: none; flex-direction: column; gap: 10px; }
.tabpanel.active { display: flex; }

/* ───────────────────────────── terminal ───────────────────────────── */
.terminal, .log-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.terminal { height: min(46vh, 420px); }
.log-box  { height: min(52vh, 480px); }
.grow-box { flex: 1 1 auto; }

.term-line { display: block; }
.term-line.cmd    { color: var(--accent); }
.term-line.out    { color: var(--fg); }
.term-line.err    { color: var(--danger); }
.term-line.meta   { color: var(--fg-dim); }

.term-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px 4px 10px;
}
.term-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.term-input .prompt { color: var(--accent); font-family: var(--mono); }
.term-input input { border: none; background: transparent; box-shadow: none; font-family: var(--mono); }
.term-input input:focus { border: none; box-shadow: none; }

/* logcat colouring by level */
.lg-E, .lg-F { color: var(--danger); }
.lg-W        { color: var(--warn); }
.lg-I        { color: var(--fg); }
.lg-D, .lg-V { color: var(--fg-muted); }

/* ───────────────────────────── apps ───────────────────────────── */
.app-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(56vh, 520px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.app-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
}
.app-list li:last-child { border-bottom: none; }
.app-list li:hover { background: var(--bg-elev-2); }
.app-list .pkg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-list .actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ───────────────────────────── install ───────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 34px 18px;
  text-align: center;
  transition: border-color .12s ease, background .12s ease;
  background: var(--bg-input);
}
.dropzone.hover { border-color: var(--accent); background: var(--accent-soft); }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dz-inner p { margin: 0; }
.dz-icon { font-size: 26px; color: var(--fg-dim); }

.progress { display: flex; flex-direction: column; gap: 6px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg-muted); font-family: var(--mono); }
.progress-track { height: 7px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width .15s ease; }
.progress-bar.done { background: var(--ok); }
.progress-bar.fail { background: var(--danger); }

/* ───────────────────────────── toasts ───────────────────────────── */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  animation: slide-in .16s ease;
  word-break: break-word;
}
.toast.ok    { border-left-color: var(--ok); }
.toast.err   { border-left-color: var(--danger); }
.toast.info  { border-left-color: var(--accent); }
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ───────────────────────────── responsive ───────────────────────────── */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .phone { max-width: 300px; }
  .terminal { height: 38vh; }
  .log-box { height: 42vh; }
  .device-meta { order: 3; width: 100%; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px 12px; }
  .layout { padding: 10px; gap: 10px; }
  .pane { padding: 11px; }
}
