[hidden] {
  display: none !important;
}

:root {
  color-scheme: dark;
  --bg: #111418;
  --panel: #1a1f25;
  --line: #2c333b;
  --text: #d8dee6;
  --dim: #8a96a3;
  --accent: #6cb6ff;
  font: 14px/1.4 system-ui, sans-serif;
}

body {
  margin: 0;
  padding: 0 16px 16px;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.05em;
}

#status {
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* The zero-choice page shows the plain progress line only; the developer's
   status text is for ?advanced=1 (tests read it either way). */
body[data-mode='simple'] #status {
  display: none;
}

/* One line that says what the machine is doing (download, start, ready). */
#progress-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-width: 0;
  font-size: 15px;
}

#progress-line[data-kind='error'] {
  color: #ff7b72;
}

#progress-bar {
  width: 14rem;
  max-width: 100%;
  height: 0.8rem;
}

/* The browser cannot run Vetro (or may not run it well): said on the page. */
#unsupported {
  border: 1px solid #d29922;
  background: rgb(210 153 34 / 0.12);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

#unsupported[data-kind='error'] {
  border-color: #ff7b72;
  background: rgb(255 123 114 / 0.12);
}

#unsupported ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

fieldset {
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  max-width: 100%;
}

label {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

input:not([type='checkbox']),
select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 3px 6px;
}

input[type='number'] {
  width: 6em;
}

button {
  background: var(--accent);
  color: #000;
  border: 0;
  padding: 6px 14px;
  font-weight: 600;
  cursor: pointer;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}

#screen-box {
  flex: 2 1 480px;
  min-width: 0;
}

#screen-wrap {
  position: relative;
  margin: 0 auto;
  background: #000;
  line-height: 0;
}

#screen {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  outline: none;
  /* The host pointer stays visible (touchscreen guests like Android draw no
     pointer); it is hidden only while the guest draws its own cursor. */
  cursor: crosshair;
}

#screen.guest-cursor {
  cursor: none;
}

#screen:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

#cursor {
  position: absolute;
  pointer-events: none;
  image-rendering: pixelated;
}

/* Touch feedback drawn by the page at once, before the guest answers: the
   press registered even when the emulated phone takes a while to redraw. */
.touch-ripple {
  position: absolute;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.45);
  box-shadow: 0 0 0 2px rgb(0 0 0 / 0.25);
  pointer-events: none;
  animation: touch-ripple 450ms ease-out forwards;
}

@keyframes touch-ripple {
  from { transform: scale(0.35); opacity: 1; }
  to { transform: scale(1.6); opacity: 0; }
}

/* The machine is busy outside the guest (saving its snapshot): inputs wait. */
#screen-busy {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 14px;
  background: rgb(0 0 0 / 0.7);
  color: #fff;
  font-size: 13px;
  line-height: 1.3;
  pointer-events: none;
}

/* Scanout off: explanation and test pattern button. The box
   lets mouse and touches through to the canvas, the button doesn't. */
#screen-off {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8em;
  padding: 12px 16px;
  box-sizing: border-box;
  overflow: hidden;
  text-align: center;
  color: var(--dim);
  font-size: clamp(11px, 1.6vw, 15px);
  line-height: 1.4;
  pointer-events: none;
}

#screen-off p {
  margin: 0;
  max-width: 36em;
}

#screen-off strong {
  color: var(--text);
}

#screen-off button {
  pointer-events: auto;
  font-size: inherit;
}

#controls {
  display: flex;
  gap: 16px;
  align-items: center;
  padding-top: 8px;
  flex-wrap: wrap;
}

#nav {
  display: flex;
  gap: 8px;
}

#nav[hidden] {
  display: none;
}

#stats,
#snapinfo {
  color: var(--dim);
  font: 12px ui-monospace, monospace;
}

#save,
#forget {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--dim);
  font-weight: 400;
}

/* The developer panels behind one small toggle (closed on the default page). */
#tools {
  flex: 1 1 100%;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

#tools > summary {
  cursor: pointer;
  color: var(--dim);
  width: max-content;
  padding: 2px 0;
}

#tools[open] > summary {
  margin-bottom: 10px;
}

#tools-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

#tools-bar {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

#console-box {
  flex: 1 1 360px;
  min-width: 0;
}

#console {
  margin: 0;
  height: 70vh;
  overflow: auto;
  background: #000;
  color: #c8d0d8;
  border: 1px solid var(--line);
  padding: 8px;
  font: 12px/1.3 ui-monospace, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  outline: none;
}

#console:focus {
  border-color: var(--accent);
}

/* AOSP: the Apps panel and the APK drop; under Tools, boot phases and adb (M5/M6) */
#android-box,
#android-dev {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#prebuilt-bar {
  width: 100%;
  height: 0.9rem;
}

#android-box h3,
#android-dev h3 {
  margin: 4px 0 0;
  font-size: 14px;
}

#phases {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
}

#phases li {
  color: var(--dim);
}

#phases li.done {
  color: inherit;
}

#phases li.current {
  color: var(--accent);
  font-weight: 600;
}

#phases .t {
  color: var(--dim);
  font-size: 12px;
  margin-left: 6px;
  font-weight: 400;
}

#apk-drop {
  border: 2px dashed var(--line);
  padding: 14px;
  border-radius: 6px;
  text-align: center;
}

#apk-drop .file-button {
  display: inline-block;
}

#apk-drop.over,
#screen-wrap.over {
  border-color: var(--accent);
  outline: 2px dashed var(--accent);
}

/* App catalog (M6, ADR 0033) */
.app-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.app-card[data-state="failed"] {
  border-color: #ff7b72;
}

.app-icon {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
}

.app-icon.missing {
  visibility: hidden;
}

.app-body {
  flex: 1;
  min-width: 0;
}

.app-desc,
.app-meta {
  margin: 2px 0;
}

.app-badge {
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
  color: var(--dim);
}

.app-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.app-progress {
  flex: 1 1 120px;
  height: 0.8rem;
}

.app-status {
  overflow-wrap: anywhere;
}

#catalog-advanced summary {
  cursor: pointer;
  margin: 4px 0;
}

#adb-shell {
  display: flex;
  gap: 6px;
}

#adb-cmd {
  flex: 1;
  min-width: 0;
}

#adb-out {
  max-height: 30vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* File manager (M8) */
#files-box {
  flex: 1 1 380px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 90vh;
}

#files-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

#files-status,
#files-info,
.fmeta,
.fnote {
  color: var(--dim);
  font: 12px ui-monospace, monospace;
}

#files-roots {
  flex: 1;
  min-width: 0;
}

#files-tree {
  flex: 0 1 35vh;
  min-height: 120px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  font: 12px/1.6 ui-monospace, monospace;
}

.fnode {
  display: flex;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.fnode:hover {
  background: var(--line);
}

.fnode.sel {
  background: #24405c;
}

.fempty {
  color: var(--dim);
  font-style: italic;
  white-space: nowrap;
}

.twisty {
  width: 1em;
  color: var(--dim);
}

.fname.dir {
  color: var(--accent);
}

.fname.symlink {
  color: #c792ea;
}

.fmeta {
  margin-left: auto;
  padding-right: 6px;
}

.ferr,
#files-message.err {
  color: #ff7b72;
  font-size: 12px;
}

#files-message {
  font-size: 12px;
  color: var(--dim);
  min-height: 1.2em;
}

#files-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 0;
}

#files-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#files-path {
  font: 12px ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

#files-save:disabled {
  opacity: 0.4;
  cursor: default;
}

#files-content {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.fedit {
  width: 100%;
  box-sizing: border-box;
  min-height: 40vh;
  background: #000;
  color: #c8d0d8;
  border: 1px solid var(--line);
  font: 12px/1.35 ui-monospace, monospace;
  white-space: pre;
  tab-size: 4;
}

.fimg {
  max-width: 100%;
  image-rendering: auto;
  background: repeating-conic-gradient(#333 0 25%, #222 0 50%) 0 0 / 16px 16px;
}

.ftable {
  border-collapse: collapse;
  font: 12px ui-monospace, monospace;
}

.ftable th,
.ftable td {
  border: 1px solid var(--line);
  padding: 2px 6px;
  text-align: left;
  vertical-align: top;
  max-width: 32em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ftable th {
  background: var(--panel);
}

.fnull {
  color: var(--dim);
  font-style: italic;
}

.fsmall {
  padding: 2px 8px;
  font-weight: 400;
}

/* Network inspector, timeline, recording (M7, M10) */
#analysis-box {
  flex: 1 1 100%;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

#tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

#tabs button {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  font-weight: 600;
}

#tabs button[aria-selected='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--panel);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 6px;
}

.toolbar button,
.file-button {
  padding: 4px 10px;
}

button.quiet,
.file-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 400;
  cursor: pointer;
}

.file-button input {
  display: none;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button.recording {
  background: #ff7b72;
}

.dim {
  color: var(--dim);
  font-size: 12px;
}

#net-filter {
  flex: 1 1 220px;
  min-width: 0;
}

.split {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.table-wrap {
  flex: 3 1 560px;
  min-width: 0;
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--line);
}

#net-table {
  border-collapse: collapse;
  width: 100%;
  font: 12px ui-monospace, monospace;
}

#net-table th {
  position: sticky;
  top: 0;
  background: var(--panel);
  text-align: left;
  font-weight: 600;
}

#net-table th,
#net-table td {
  padding: 2px 6px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  max-width: 22em;
  overflow: hidden;
  text-overflow: ellipsis;
}

#net-table tbody tr {
  cursor: pointer;
}

#net-table tbody tr:hover {
  background: var(--line);
}

#net-table tbody tr.sel {
  background: #24405c;
}

#net-table td.num {
  text-align: right;
}

#net-table td.guessed {
  color: var(--dim);
  font-style: italic;
}

#net-table .method {
  color: var(--accent);
}

#net-table .status.s2 {
  color: #7ee787;
}

#net-table .status.s3 {
  color: #e3b341;
}

#net-table .status.s4,
#net-table .status.s5,
#net-table .status.s0 {
  color: #ff7b72;
}

#net-table .wf {
  width: 120px;
  min-width: 120px;
  position: relative;
}

#net-table td.wf span {
  position: absolute;
  top: 5px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
}

#net-detail {
  flex: 2 1 380px;
  min-width: 0;
  max-height: 50vh;
  overflow: auto;
  font-size: 12px;
}

#net-detail section {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px 8px;
  margin-bottom: 8px;
}

#net-detail h4,
#analysis-box h4 {
  margin: 4px 0;
  font-size: 13px;
}

.nd-url {
  font: 12px ui-monospace, monospace;
  word-break: break-all;
}

.mono,
.kv,
.body-view pre,
.mono-box {
  font: 12px/1.35 ui-monospace, monospace;
}

.kv {
  border-collapse: collapse;
}

.kv th,
.kv td {
  text-align: left;
  vertical-align: top;
  padding: 1px 8px 1px 0;
  word-break: break-all;
}

.kv th {
  color: var(--dim);
  font-weight: 400;
  white-space: nowrap;
}

.body-view pre,
.mono-box {
  background: #000;
  color: #c8d0d8;
  border: 1px solid var(--line);
  padding: 6px;
  margin: 4px 0;
  max-height: 40vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.body-view pre.hex,
.mono-box {
  white-space: pre;
}

.body-mode {
  font-size: 11px;
  padding: 0 4px;
}

.part {
  margin: 4px 0;
}

.phases {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  font-size: 10px;
}

.ph {
  padding: 1px 3px;
  white-space: nowrap;
  overflow: hidden;
  color: #000;
  min-width: 0;
}

.ph-blocked { background: #8a96a3; }
.ph-dns { background: #56d4dd; }
.ph-connect { background: #e3b341; }
.ph-send { background: #7ee787; }
.ph-wait { background: #d2a8ff; }
.ph-receive { background: #79c0ff; }

#tl-track {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 6px;
}

#tl-list,
#rr-events {
  max-height: 50vh;
  overflow: auto;
  font-size: 12px;
}

.tl-input {
  border-bottom: 1px solid var(--line);
  padding: 3px 0;
}

.tl-head,
.tl-effect {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.tl-effects {
  margin-left: 7.5em;
}

.tl-effect.loose {
  opacity: 0.75;
  border-bottom: 1px solid var(--line);
  padding: 2px 0;
}

.tl-time {
  font: 12px ui-monospace, monospace;
  color: var(--dim);
  min-width: 7em;
  text-align: right;
}

.badge {
  font-size: 10px;
  color: #000;
  padding: 0 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.tl-label {
  font: 12px ui-monospace, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

a.tl-label {
  color: var(--accent);
}

.rr-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.rr-cols > div {
  flex: 1 1 420px;
  min-width: 0;
}

#rr-status.err {
  color: #ff7b72;
}

/* SQLite and SharedPreferences editing (ADR 0021). */
.fsql td[data-r] {
  cursor: pointer;
}

.fsql td[data-r]:hover {
  background: var(--panel);
}

.fsql-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  margin: 6px 0;
  padding: 6px;
  border: 1px solid var(--line);
}

.fsql-col {
  flex-basis: 100%;
}

.fsql-query {
  flex-basis: 100%;
  font: 12px/1.35 ui-monospace, monospace;
}

.fsql-params {
  flex-basis: 100%;
  font: 12px ui-monospace, monospace;
  color: var(--dim);
  white-space: pre-wrap;
}

.fprefs input,
.fprefs select,
.fprefs textarea {
  font: 12px ui-monospace, monospace;
}

.bad {
  outline: 2px solid #d33;
}

/* ---- The site's look (web/site/index.html): its palette, shapes and links.
   Kept as a last layer over the rules above. ---- */
:root {
  --bg: #0a0e14;
  --panel: #121923;
  --line: #223042;
  --line-soft: #1a2433;
  --text: #e3eaf3;
  --dim: #8e9bad;
  --accent: #6aa8ff;
  --cyan: #7fe3ff;
  --violet: #a58bff;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
}

body {
  padding: 0 20px 20px;
  min-height: 100vh;
  background:
    radial-gradient(80% 50% at 88% -12%, rgba(165, 139, 255, 0.1), transparent 60%),
    radial-gradient(70% 45% at 4% -12%, rgba(127, 227, 255, 0.09), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

header {
  padding: 14px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

h1 {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.header-links {
  display: flex;
  gap: 6px;
  flex: none;
  margin-left: auto;
}

.header-links a {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(22, 31, 43, 0.7);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.header-links a:hover {
  border-color: var(--accent);
}

button {
  border-radius: 9px;
  padding: 7px 14px;
  font: inherit;
  font-weight: 650;
  color: #06121f;
  transition: filter 0.15s, border-color 0.15s, background 0.15s;
}

button:hover:not(:disabled) {
  filter: brightness(1.1);
}

button.quiet,
.file-button,
#save,
#forget {
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(22, 31, 43, 0.7);
  color: var(--text);
}

#screen-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.9), 0 26px 64px -48px rgba(106, 168, 255, 0.55);
}

#screen:focus {
  outline: none;
}

#controls {
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
}

/* Back, Home, Recents: one bar, as on the phone. */
#nav {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}

#nav button,
#power {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

#nav button {
  border-radius: 0;
  padding: 9px 18px;
  border-right: 1px solid var(--line);
}

#nav button:last-child {
  border-right: 0;
}

#nav button:hover,
#power:hover {
  filter: none;
  background: rgba(106, 168, 255, 0.14);
}

#nav svg,
#power svg {
  width: 14px;
  height: 14px;
  color: var(--cyan);
}

#power {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 16px;
}

#net-hint {
  margin: 12px 0 0;
  padding: 9px 14px;
  border: 1px solid rgba(127, 227, 255, 0.24);
  border-radius: 10px;
  background: rgba(127, 227, 255, 0.06);
  color: var(--text);
  font-size: 13px;
}

#android-box,
#android-dev {
  gap: 10px;
}

#apk-drop {
  border: 1px dashed #33475f;
  border-radius: 14px;
  padding: 18px;
  background: rgba(18, 25, 35, 0.6);
  color: var(--dim);
}

#console {
  border-radius: 12px;
  padding: 10px 12px;
}

#tools {
  margin-top: 8px;
  padding-top: 12px;
  border-top-color: var(--line-soft);
}

#tools > summary {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(22, 31, 43, 0.7);
  color: var(--text);
  font-weight: 600;
}

.app-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 12px;
}

.app-foot span {
  margin-right: auto;
}

.app-foot a {
  color: var(--dim);
}

.app-foot a:hover {
  color: var(--text);
}

@media (max-width: 640px) {
  .header-links a:not(:last-child) {
    display: none;
  }
}

