/* ==========================================================================
   OpenMobile-2 — live simulator card. Class namespace: lv-.
   The screen is the simulator's logical 360 x 800; om2-live.js scales the
   whole phone (.lv-scaler) to the space it has and sizes .lv-stage to match.
   The device material matches the hero phone: metallic rail with antenna
   lines, matte bezel, side buttons, ground shadow, ambient glow, glass sheen.
   ========================================================================== */
.lv {
  --lv-bezel: var(--surface-2);
  --lv-rail-hi: color-mix(in srgb, var(--text-hi) 52%, var(--lv-bezel));
  --lv-rail-mid: color-mix(in srgb, var(--text-hi) 16%, var(--lv-bezel));
  --lv-rail-lo: color-mix(in srgb, var(--bg) 72%, var(--lv-bezel));
  --lv-sheen: 0.06;
  --lv-edge: 0.35;
  --lv-ground: 1;
  --lv-blob: 0.22;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 28px 40px;
  align-items: start;
}
.lv.is-stacked { grid-template-columns: 1fr; }
:root[data-theme="light"] .lv {
  --lv-bezel: var(--surface-3);
  --lv-rail-hi: var(--surface-3);
  --lv-rail-mid: color-mix(in srgb, var(--text-hi) 10%, var(--lv-bezel));
  --lv-rail-lo: color-mix(in srgb, var(--text-hi) 32%, var(--lv-bezel));
  --lv-sheen: 0.35;
  --lv-edge: 0.08;
  --lv-ground: 0.45;
  --lv-blob: 0.15;
}

/* ------------------------------------------------------------- stage, depth */
.lv-stage { position: relative; z-index: 0; width: 380px; height: 856px; margin: 0 auto; }
.lv-scaler { position: absolute; left: 0; top: 0; width: 380px; height: 856px; transform-origin: 0 0; }
.lv-blob,
.lv-ground { position: absolute; z-index: -1; border-radius: 50%; pointer-events: none; }
.lv-blob {
  background: var(--accent-400);
  opacity: 0;
  filter: blur(44px);
  transition: opacity 0.8s ease;
}
.lv-blob-a { left: -12%; top: 4%; width: 66%; height: 36%; }
.lv-blob-b { right: -14%; bottom: 6%; width: 68%; height: 38%; background: var(--cyan-400); }
.lv.is-on .lv-blob { opacity: var(--lv-blob); }
.lv-ground {
  left: 18%; right: 18%; bottom: -16px;
  height: 34px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.26) 42%, transparent 72%);
  opacity: var(--lv-ground);
}

/* ------------------------------------------------------------------- frame */
.lv-phone {
  position: relative;
  display: flex;
  width: 380px; height: 856px;
  padding: 2px;
  border-radius: 46px;
  background:
    linear-gradient(var(--lv-rail-hi), var(--lv-rail-hi)) 0 11% / 100% 1px no-repeat,
    linear-gradient(var(--lv-rail-hi), var(--lv-rail-hi)) 0 89% / 100% 1px no-repeat,
    linear-gradient(135deg, var(--lv-rail-hi), var(--lv-rail-mid) 32%, var(--lv-rail-lo));
  box-shadow: 0 34px 60px -30px rgba(0, 0, 0, 0.75), var(--shadow);
}
:root[data-theme="light"] .lv-phone { box-shadow: 0 28px 50px -30px rgba(0, 0, 0, 0.35), var(--shadow); }
.lv-bezel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  padding: 8px;
  border-radius: 44px;
  background: var(--lv-bezel);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}
.lv-sbtn {
  position: absolute;
  width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, var(--lv-rail-hi), var(--lv-rail-lo));
}
.lv-vol1 { left: -3px; top: 17%; height: 6%; }
.lv-vol2 { left: -3px; top: 24.5%; height: 6%; }
.lv-power { right: -3px; top: 22%; height: 9%; }

/* ------------------------------------------------------------------ screen */
.lv-screen {
  position: relative;
  width: 360px; height: 836px;   /* 800 app area + 36 navigation bar */
  border-radius: 36px;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 20% 0%, color-mix(in srgb, var(--text-hi) 8%, transparent), transparent 60%),
    #0b0f14;
}
:root[data-theme="light"] .lv-screen { background: radial-gradient(120% 70% at 20% 0%, rgba(255, 255, 255, 0.5), transparent 60%), #0f141b; }
/* glass over everything, letting pointer events through to the simulator */
.lv-sheen {
  position: absolute; inset: 0; z-index: 5;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(115deg, rgba(255, 255, 255, var(--lv-sheen)), transparent 40%);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, var(--lv-edge)), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* the frame: exactly the logical screen; switches on once the simulator booted */
.lv-frame {
  position: absolute; left: 0; top: 0; z-index: 1;
  width: 360px; height: 800px;
  border: 0;
  background: #000;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.lv.is-ready .lv-frame { opacity: 1; transform: none; }

/* three-button navigation bar under the app area (the iframe keeps the
   simulator's 360 x 800); black like a phone's software nav bar */
.lv-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  height: 36px;
  display: flex; justify-content: center; align-items: center; gap: 64px;
  background: #05070a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
}
.lv.is-ready .lv-nav { opacity: 1; }
.lv-nav-key {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.lv-nav-key:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.lv-nav-key:active { transform: scale(0.88); }
.lv-nav-key:focus-visible { outline: 2px solid var(--accent-400); outline-offset: 2px; }

/* power-off screen */
.lv-off {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; align-content: center; gap: 14px;
  transition: opacity 0.4s ease;
}
.lv.is-on .lv-off { opacity: 0; pointer-events: none; }
.lv-boot {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02) 60%);
  color: var(--accent-300);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.03), 0 12px 30px -14px var(--accent-400);
  transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}
.lv-boot:hover { transform: scale(1.06); color: var(--accent-200); box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.04), 0 16px 36px -14px var(--accent-400); }
.lv-boot:focus-visible { outline: 2px solid var(--accent-400); outline-offset: 4px; }
.lv-boot-label {
  font: 600 11px/1 var(--font-body);
  letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* starting up: a breathing ring, then the frame switches on */
.lv-loading {
  position: absolute; inset: 0; z-index: 2;
  display: none; place-items: center; align-content: center; gap: 14px;
  color: rgba(255, 255, 255, 0.55);
  font: 500 11px/1 var(--font-body);
  letter-spacing: 0.2em; text-transform: uppercase;
}
.lv.is-on:not(.is-ready) .lv-loading { display: grid; }
.lv-spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent-300);
  animation: lv-spin 0.9s linear infinite;
}
@keyframes lv-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- side panel */
.lv-side { padding-top: 6px; min-width: 0; }
.lv-keys { display: flex; flex-wrap: wrap; gap: 8px; }
.lv-key { opacity: 0.45; pointer-events: none; transition: opacity 0.3s ease; }
.lv.is-on .lv-key-off, .lv.is-ready .lv-key { opacity: 1; pointer-events: auto; }
.lv-label { margin: 22px 0 10px; font-size: 13px; color: var(--text-dim); }
.lv-apps { display: flex; flex-wrap: wrap; gap: 6px; }
.lv-app { display: inline-flex; align-items: center; gap: 7px; padding-left: 8px; opacity: 0.45; pointer-events: none; transition: opacity 0.3s ease; }
.lv-app-ico { width: 18px; height: 18px; border-radius: 5px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); }
.lv-app-tile { width: 18px; height: 18px; border-radius: 5px; flex: none; display: grid; place-items: center; font: 600 10px/1 var(--font-body); font-style: normal; color: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.lv.is-ready .lv-app { opacity: 1; pointer-events: auto; }
.lv-apps-more { margin-top: 10px; height: 30px; font-size: 12.5px; }
.lv-apps-all { margin-top: 10px; display: grid; gap: 8px; }
.lv-apps-all[hidden] { display: none; }
.lv-app-group { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: start; }
.lv-app-dom { padding-top: 7px; font: 500 11px/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
@media (max-width: 700px) { .lv-app-group { grid-template-columns: 1fr; gap: 4px; } }
.lv-hint {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 22px 0 0; max-width: 520px;
  font-size: 13.5px; line-height: 1.55; color: var(--text-dim);
}
.lv-hint svg { flex: none; margin-top: 3px; color: var(--accent-400); }
.lv-note { margin-top: 18px; max-width: 520px; }

@media (prefers-reduced-motion: reduce) {
  .lv-spinner { animation: none; }
  .lv-frame { transition: opacity 0.2s ease; transform: none; }
}

/* ------------------------------------------------- status line + panels */
.lv-status {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 14px;
  font: 500 12px/1 var(--font-mono);
  color: var(--text-dim);
}
.lv-st-app { color: var(--accent-300); }
.lv-st-app::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: var(--accent-400); box-shadow: 0 0 8px var(--glow); vertical-align: 1px; }
.lv-st-route { color: var(--text-faint); }
.lv-st-route:empty { display: none; }
.lv-st-place { margin-left: auto; color: var(--text-dim); }

.lv-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}
.lv-panel {
  display: flex; flex-direction: column;
  min-height: 420px; max-height: 420px;
  padding: 16px 18px 14px;
  border-radius: var(--r);
  border: 1px solid var(--hairline-cool);
  background: var(--surface-1b);
  box-shadow: inset 0 1px 0 var(--edge-hi);
}
.lv-panel-head h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.lv-panel-head p { margin: 0 0 12px; font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }

.lv-log { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1 1 auto; min-height: 0; font: 500 12.5px/1.5 var(--font-mono); }
.lv-log-item { display: grid; grid-template-columns: 18px auto minmax(0, 1fr); gap: 8px; padding: 6px 0; border-top: 1px dashed var(--hairline-cool); animation: lv-in 0.25s ease; }
.lv-log-item:first-child { border-top: 0; }
.lv-log-n { color: var(--text-faint); }
.lv-log-name { color: var(--accent-300); }
.lv-log-args { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes lv-in { from { opacity: 0; transform: translateY(4px); } }
.lv-empty { margin: auto 0; font-size: 13px; color: var(--text-faint); }

.lv-state-app { font: 500 12px/1 var(--font-mono); color: var(--accent-300); margin: 0 0 10px; }
.lv-kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; margin: 0; overflow: auto; flex: 1 1 auto; min-height: 0; font-size: 13px; }
.lv-kv dt, .lv-kv dd { margin: 0; padding: 7px 0; border-top: 1px dashed var(--hairline-cool); }
.lv-kv dt:first-of-type, .lv-kv dd:first-of-type { border-top: 0; }
.lv-kv dt { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-kv dd { color: var(--text-hi); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.4s ease; }
.lv-kv dd.is-changed { color: var(--pop-400); animation: lv-flash 1.2s ease; }
@keyframes lv-flash { 0% { background: color-mix(in srgb, var(--pop-400) 22%, transparent); } 100% { background: transparent; } }

@media (max-width: 1380px) {
  .lv-panels { grid-template-columns: 1fr 1fr; }
  .lv-tools { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .lv-panels { grid-template-columns: 1fr; }
  .lv-panel { min-height: 0; max-height: 300px; }
}

/* ------------------------------------------------- app-native tools */
.lv-tool-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1 1 auto; min-height: 0; }
.lv-tool { border-top: 1px dashed var(--hairline-cool); }
.lv-tool:first-child { border-top: 0; }
.lv-tool-btn {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; align-items: start;
  width: 100%; padding: 8px 0; border: 0; background: transparent; color: inherit;
  text-align: left; cursor: pointer; font: inherit;
}
.lv-tool-btn:focus-visible { outline: 2px solid var(--pop-400); outline-offset: -2px; border-radius: 4px; }
.lv-tool-name { font: 500 12.5px/1.4 var(--font-mono); color: var(--pop-300); word-break: break-all; }
.lv-tool-btn:hover .lv-tool-name, .lv-tool-btn[aria-expanded="true"] .lv-tool-name { color: var(--pop-400); }
.lv-tool-tag { font: 500 10.5px/1 var(--font-mono); color: var(--text-faint); padding: 3px 6px; border: 1px solid var(--hairline-cool); border-radius: 4px; white-space: nowrap; }
.lv-tool-desc { grid-column: 1 / -1; font-size: 12.5px; line-height: 1.45; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lv-tool-form { display: grid; gap: 8px; padding: 2px 0 12px; }
.lv-tool-field { display: grid; gap: 3px; font: 500 11.5px/1.3 var(--font-mono); color: var(--text-dim); }
.lv-tool-field input[type="text"], .lv-tool-field input[type="number"] {
  height: 30px; padding: 0 9px; border-radius: 6px;
  border: 1px solid var(--hairline-cool); background: var(--surface-2); color: var(--text-hi);
  font: 400 12.5px var(--font-mono);
}
.lv-tool-field input::placeholder { color: var(--text-faint); font-family: var(--font-body); }
.lv-tool-field input:focus-visible { outline: 2px solid var(--pop-400); outline-offset: 1px; }
.lv-tool-run { display: flex; align-items: center; gap: 8px; }
.lv-tool-run .wt-btn { height: 30px; }
.lv-tool-run .wt-btn.is-tool { border-color: var(--pop-400); color: var(--pop-300); }
.lv-tool-run .wt-btn.is-tool:hover { color: var(--pop-400); }
.lv-tool-status { font: 500 11px var(--font-mono); color: var(--text-faint); }
.lv-tool-status.is-ok { color: var(--ok); }
.lv-tool-status.is-err { color: var(--bad); }
.lv-tool-out {
  margin: 0; padding: 8px 10px; max-height: 170px; overflow: auto;
  border-radius: 6px; border: 1px solid var(--hairline-cool); background: var(--surface-3);
  font: 400 11px/1.45 var(--font-mono); color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.lv-log-item.is-tool .lv-log-name { color: var(--pop-300); }
@media (prefers-reduced-motion: reduce) {
  .lv-log-item { animation: none; }
  .lv-kv dd.is-changed { animation: none; }
}
