/* CloudNest Java Cloud — node UI. No external assets: the CSP allows only this origin. */
:root {
  --bg: #060b16;
  --bg-2: #0a1222;
  --panel: #0d1628;
  --panel-2: #111d34;
  --line: #1b2944;
  --line-2: #263857;
  --text: #e8eef9;
  --text-2: #b8c5db;
  --muted: #7f91ae;
  --accent: #22d3ee;
  --accent-2: #0ea5e9;
  --accent-ink: #032a33;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #60a5fa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .38);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(14, 165, 233, .14), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(34, 211, 238, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.mt { margin-top: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: rgba(6, 11, 22, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.brand small { font-weight: 600; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; color: var(--accent); border: 1px solid rgba(34, 211, 238, .35);
}
.top-chips { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text-2); font-size: 13px; white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.chip svg { width: 14px; height: 14px; color: var(--muted); }

/* ---------- layout ---------- */
#app { max-width: 1240px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.2px; }
.sub { margin: 4px 0 0; color: var(--muted); }
.summary { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  min-width: 112px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--line);
}
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 20px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #172645; border-color: #34507c; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: linear-gradient(135deg, #3fdcf2, #23b0f0); }
.btn-danger { color: #fecaca; border-color: rgba(248, 113, 113, .45); background: rgba(248, 113, 113, .08); }
.btn-danger:hover { background: rgba(248, 113, 113, .16); border-color: rgba(248, 113, 113, .7); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel); border-color: var(--line); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.icon-btn { width: 38px; padding: 0; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill-ok { color: var(--ok); background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .25); }
.pill-ok i { box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); animation: pulse 2s infinite; }
.pill-warn { color: var(--warn); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .25); }
.pill-err { color: var(--err); background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .28); }
.pill-info { color: var(--info); background: rgba(96, 165, 250, .1); border-color: rgba(96, 165, 250, .25); }
.pill-muted { color: var(--muted); background: rgba(127, 145, 174, .08); border-color: rgba(127, 145, 174, .2); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); } }

/* ---------- slot grid ---------- */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 18px; }
.slot-card {
  display: grid; grid-template-columns: 132px 1fr; gap: 16px;
  padding: 16px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  min-width: 0;
}
.thumb {
  position: relative; display: block; align-self: start;
  aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden;
  background: #02060d; border: 1px solid var(--line-2);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: none; }
.thumb.has-img img { display: block; }
.thumb.has-img .thumb-empty { display: none; }
.thumb-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 10px; color: var(--muted); font-size: 12.5px;
}
.thumb-empty svg { width: 26px; height: 26px; display: block; margin: 0 auto 6px; opacity: .7; }
.slot-body { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.slot-head h3 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-game {
  color: var(--text-2); font-size: 14px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.meta-game b { color: var(--text); }
.meta-lines { display: flex; flex-direction: column; gap: 2px; }
.meta-line { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.meta-line span { color: var(--text-2); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot-card .meters { grid-template-columns: 1fr; gap: 8px; }
.meter-label { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.meter-label b { color: var(--text-2); font-weight: 600; }
.meter { --v: 0; height: 6px; border-radius: 999px; background: #0a1324; overflow: hidden; border: 1px solid var(--line); }
.meter::after {
  content: ""; display: block; height: 100%;
  width: calc(var(--v) * 100%);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px; transition: width .4s;
}
.meter.hot::after { background: linear-gradient(90deg, var(--warn), var(--err)); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.actions .btn { flex: 1 1 8rem; }

/* ---------- egress IPs (dashboard) ---------- */
.ips { margin-top: 28px; }
.section-head { margin-bottom: 12px; }
.section-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 19px; }
.section-head h2 svg { width: 19px; height: 19px; color: var(--accent); }
.ip-table { display: flex; flex-direction: column; gap: 10px; }
.ip-row {
  display: grid; grid-template-columns: minmax(170px, 220px) minmax(140px, 180px) 1fr auto; gap: 16px; align-items: center;
  padding: 12px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
}
.ip-row.missing { border-color: rgba(248, 113, 113, .45); }
.ip-addr { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.ip-addr b { font-size: 15px; }
.ip-addr small { color: var(--err); }
.ip-slots { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.slot-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: #0a1324; border: 1px solid var(--line-2); color: var(--text-2); font-size: 13px; font-weight: 600;
}
.slot-chip:hover { border-color: var(--accent); text-decoration: none; }
.slot-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.slot-chip.on i { background: var(--ok); }
.slot-chip small { color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); font-size: 13.5px; }
.tag {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  color: var(--info); background: rgba(96, 165, 250, .12); border: 1px solid rgba(96, 165, 250, .3);
}
.net-admin { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.mt-sm { margin-top: 8px; }

/* ---------- slot (play) page ---------- */
.slot-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.slot-top .back { color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; flex: none; }
.slot-top .back svg { width: 18px; height: 18px; }
.slot-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.slot-title h1 { margin: 0; font-size: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.slot-title input { font-size: 20px; font-weight: 700; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 4px 10px; max-width: 260px; }
.slot-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.play { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 22px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.phone {
  position: relative;
  padding: 16px 16px 18px; border-radius: 30px;
  background: linear-gradient(160deg, #1a2742, #0b1324 55%, #0e182c);
  border: 1px solid #2b3d61;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.phone-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 10px; font-size: 12.5px; color: var(--muted); }
.live { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on { color: var(--ok); }
.live.on i { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }
.live.down { color: var(--warn); }
.live.down i { background: var(--warn); }
.screen-wrap {
  --ar: 240 / 320;
  position: relative; width: 100%; aspect-ratio: var(--ar);
  border-radius: 14px; overflow: hidden; background: #000;
  border: 1px solid #22324f; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6);
  touch-action: none; user-select: none;
}
.screen-wrap canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; cursor: crosshair; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; background: rgba(3, 7, 15, .86); color: var(--text-2);
}
.overlay h3 { margin: 10px 0 6px; color: var(--text); }
.overlay p { margin: 0 0 14px; font-size: 14px; }
.overlay svg { width: 34px; height: 34px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(34, 211, 238, .2); border-top-color: var(--accent); animation: spin .9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* the game's text box, mirrored as a real input between the screen and the keypad */
.textbar {
  margin-top: 12px; padding: 10px 12px 12px; border-radius: 14px;
  background: #0a1426; border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .12);
  animation: tb-in .18s ease-out;
}
@keyframes tb-in { from { opacity: 0; transform: translateY(-4px); } }
.tb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; font-weight: 700; color: var(--text); }
.tb-head svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.tb-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-count { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tb-row { display: flex; gap: 8px; }
.tb-row .tb-input { flex: 1 1 auto; min-width: 0; height: 42px; font-size: 16px; } /* 16px: no zoom-on-focus in iOS Safari */
.tb-row .btn { flex: none; min-height: 42px; }
.tb-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.key {
  min-height: 48px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #1c2a46, #142038); border: 1px solid #2c3f63;
  color: var(--text); font-weight: 700; font-size: 16px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .05s, background .1s;
}
.key:hover { border-color: #3d5888; }
.key.down, .key:active { transform: translateY(1px) scale(.98); background: #0f1a2f; border-color: var(--accent); color: var(--accent); }
.key.soft { font-size: 13.5px; color: var(--text-2); }
.key.ok { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; }
.key.ok.down, .key.ok:active { color: var(--accent-ink); filter: brightness(.9); }
.key.on { border-color: var(--accent); color: var(--accent); }

.phone:fullscreen { display: flex; flex-direction: column; justify-content: center; max-width: none; border-radius: 0; padding: 18px; background: #050a14; }
.phone:fullscreen .screen-wrap { width: auto; height: min(68vh, calc(100vw * 1.33)); margin: 0 auto; }
.phone:fullscreen .keypad, .phone:fullscreen .numpad { width: min(520px, 100%); margin-left: auto; margin-right: auto; }

/* ---------- panels ---------- */
.panel { padding: 16px 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.panel h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 15px; letter-spacing: .2px; }
.panel h2 svg { width: 17px; height: 17px; color: var(--accent); }
.panel .hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input[type=text], .row > input[type=password] { flex: 1 1 auto; min-width: 0; }
.field {
  height: 40px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: #091224; border: 1px solid var(--line-2); color: var(--text);
}
.field:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(34, 211, 238, .15); }
select.field { padding-right: 28px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; margin-top: 8px; cursor: pointer; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.dropzone {
  display: grid; place-items: center; text-align: center; gap: 6px;
  padding: 18px; margin-top: 12px; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line-2); background: #091224; color: var(--muted); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(34, 211, 238, .05); color: var(--text-2); }
.dropzone svg { width: 26px; height: 26px; color: var(--accent); }
.dropzone b { color: var(--text); }
.progress { height: 6px; border-radius: 999px; background: #0a1324; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }

.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; margin-top: 4px; }
.res {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  background: #091224; border: 1px solid var(--line-2); cursor: pointer; text-align: left;
}
.res:hover { border-color: #3d5888; }
.res.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .12); }
.res .shape { flex: none; border: 2px solid var(--muted); border-radius: 3px; }
.res.on .shape { border-color: var(--accent); }
.res b { display: block; font-size: 13.5px; }
.res small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.2; }
.settings-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-top: 14px; }
.settings-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow: auto; }
.events li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.events li:last-child { border-bottom: 0; }
.events time { display: block; color: var(--muted); font-size: 12px; }
.events .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: var(--info); }
.events .warn .dot { background: var(--warn); }
.events .error .dot { background: var(--err); }
.events .empty { color: var(--muted); grid-template-columns: 1fr; }

.keys-help { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13.5px; }
kbd {
  display: inline-block; min-width: 24px; padding: 1px 7px; border-radius: 6px; text-align: center;
  background: #162440; border: 1px solid #2c3f63; border-bottom-width: 2px; font-family: inherit; font-size: 12px; color: var(--text);
}

/* ---------- login ---------- */
body.is-login .topbar { display: none; }
.login-wrap { min-height: calc(100vh - 48px); display: grid; place-items: center; }
.login-card {
  width: min(420px, 100%); padding: 30px; border-radius: 20px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card img { width: 52px; height: 52px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; color: var(--muted); }
.form-error { color: var(--err); font-size: 13.5px; min-height: 20px; }

/* ---------- toasts + modal ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 380px); }
.toast {
  padding: 11px 14px; border-radius: 12px; background: #111d34; border: 1px solid var(--line-2);
  box-shadow: var(--shadow); font-size: 14px; animation: toast-in .2s ease-out;
  border-left: 4px solid var(--info);
}
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-err { border-left-color: var(--err); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .4s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(2, 5, 12, .7); backdrop-filter: blur(3px); }
.modal {
  width: min(480px, 100%); padding: 22px; border-radius: 18px;
  background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 12px; color: var(--text-2); }
.modal .actions { justify-content: flex-end; margin-top: 18px; }
.modal .actions .btn { flex: 0 0 auto; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { flex: 1; min-width: 0; }

/* ---------- automation (Tự động) ---------- */
.runbar, .recbar {
  display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap;
  margin: 0 0 10px; padding: 8px 10px; border-radius: 12px; font-size: 13.5px;
}
.runbar { background: rgba(96, 165, 250, .1); border: 1px solid rgba(96, 165, 250, .4); }
.recbar { background: rgba(248, 113, 113, .09); border: 1px solid rgba(248, 113, 113, .5); }
.bar-text { flex: 1 1 9rem; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.bar-text small { color: var(--text-2); font-weight: 500; font-size: 13px; }
.bar-actions { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 100%; }
.bar-actions .btn { flex: 1 1 auto; }
.runbar .btn { flex: none; }
.run-dot, .rec-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.run-dot { background: var(--info); animation: run-pulse 1.4s infinite; }
.rec-dot { background: var(--err); animation: rec-blink 1s steps(2, start) infinite; }
@keyframes run-pulse { 0% { box-shadow: 0 0 0 0 rgba(96, 165, 250, .5); } 100% { box-shadow: 0 0 0 8px rgba(96, 165, 250, 0); } }
@keyframes rec-blink { to { visibility: hidden; } }

.panel .hint.first { margin: -4px 0 12px; }
.auto-status { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.auto-line { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; color: var(--text-2); }
.auto-line i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; transform: translateY(-1px); }
.auto-line.ok i { background: var(--ok); }
.auto-line.warn i { background: var(--warn); }
.auto-line.err i { background: var(--err); }
.auto-line.info i { background: var(--info); }
.auto-line.muted { color: var(--muted); font-size: 13px; }
.macro-list { display: flex; flex-direction: column; gap: 8px; }
.macro {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 10px 12px; border-radius: var(--radius-sm); background: #091224; border: 1px solid var(--line-2);
}
.macro.off { opacity: .72; }
.macro.running { border-color: var(--info); box-shadow: 0 0 0 3px rgba(96, 165, 250, .12); }
.macro-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.macro-head b { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trig {
  flex: none; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--accent); background: rgba(34, 211, 238, .1); border: 1px solid rgba(34, 211, 238, .3);
}
.trig-manual { color: var(--muted); background: rgba(127, 145, 174, .08); border-color: rgba(127, 145, 174, .25); }
.macro-meta { font-size: 12.5px; color: var(--muted); }
.macro-act { display: flex; gap: 6px; flex-wrap: wrap; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; position: relative; cursor: pointer;
  width: 40px; height: 22px; border-radius: 999px; background: #1b2944; border: 1px solid var(--line-2); transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-2); transition: transform .15s;
}
.switch:checked { background: var(--accent-2); border-color: transparent; }
.switch:checked::after { transform: translateX(18px); background: #fff; }
.switch:disabled { opacity: .5; cursor: wait; }
.row.wrap { flex-wrap: wrap; }

.modal { max-height: calc(100vh - 32px); overflow: auto; }
.modal-lg { width: min(640px, 100%); }
.editor { display: flex; flex-direction: column; gap: 10px; }
.editor .check { margin-top: 0; }
.editor .hint { margin: -2px 0 0; color: var(--muted); font-size: 13px; }
.ed-row { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.ed-row .stack { flex: 1 1 14rem; } /* only in a row: in the editor's column a flex-basis would become a 14rem height */
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-2); flex-wrap: wrap; }
.field.num { width: 86px; }
.field.sm { height: 34px; padding: 4px 8px; font-size: 13.5px; }
.field.num.sm { width: 74px; }
.ed-steps-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px; }
.steps {
  list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  max-height: 42vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #091224;
}
.st { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 6px; border-radius: 8px; font-size: 13.5px; min-width: 0; }
.st:hover { background: rgba(255, 255, 255, .03); }
.st.empty { color: var(--muted); }
.st-i { width: 22px; flex: none; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.st-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.st-wait .st-label, .st-screen .st-label { color: var(--text-2); }
.st-num { display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--muted); font-size: 12.5px; }
.st-act { display: inline-flex; flex: none; }
.st-act .icon-btn { width: 30px; min-height: 30px; }
.st-act .icon-btn:disabled { opacity: .25; }
.ref-thumb { height: 40px; width: auto; flex: none; image-rendering: pixelated; border-radius: 4px; border: 1px solid var(--line-2); background: #000; }
.cp p { font-size: 14px; }
.cp-shot { display: grid; place-items: center; margin: 4px 0 6px; }
.region-canvas {
  width: 100%; max-width: 260px; height: auto; display: block; image-rendering: pixelated;
  touch-action: none; cursor: crosshair; border-radius: 10px; border: 1px solid var(--line-2);
}

/* ---------- link-expired page ---------- */
body.gone { display: grid; place-items: center; min-height: 100vh; text-align: center; padding: 24px; }
body.gone p { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .play { grid-template-columns: 1fr; }
  .phone { max-width: 460px; margin: 0 auto; width: 100%; }
  .ip-row { grid-template-columns: 1fr; gap: 10px; }
  .ip-act .btn { width: 100%; }
}
@media (max-width: 560px) {
  #app { padding: 14px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand span.name { display: none; }
  .chip.opt { display: none; }
  .page-head h1 { font-size: 21px; }
  .slot-card { grid-template-columns: 96px 1fr; padding: 12px; gap: 12px; }
  .slot-title h1 { font-size: 19px; max-width: 70vw; }
  .slot-actions { margin-left: 0; width: 100%; }
  .slot-actions .btn { flex: 1 1 auto; }
  .phone { padding: 12px 12px 14px; border-radius: 24px; }
  .key { min-height: 52px; }
  .meters { grid-template-columns: 1fr; }
  .modal { padding: 18px 16px; }
  .st { flex-wrap: wrap; row-gap: 2px; }
  .st-label { flex-basis: calc(100% - 30px); }
  .st-num { margin-left: 30px; }
  .st-act { margin-left: auto; }
  .macro-head { flex-wrap: wrap; }
  .macro-head b { flex-basis: calc(100% - 52px); }
  .macro-head .switch { order: 1; } /* name + switch on the first line, trigger below */
  .macro-head .trig { order: 2; }
}
