/* LEOLOCALTECH look, shared with the ANDROID MANAGE panel. */
:root {
  --bg:        #05060d;
  --panel:     rgba(18, 21, 38, 0.85);
  --panel-2:   rgba(12, 14, 28, 0.9);
  --line:      rgba(120, 140, 220, 0.18);
  --text:      #e8ecff;
  --muted:     #8b93b8;
  --red:       #ff2d55;
  --red-glow:  rgba(255, 45, 85, 0.55);
  --blue:      #2f7bff;
  --blue-glow: rgba(47, 123, 255, 0.55);
  --green:     #1fd17a;
  --amber:     #ffb020;
  --accent:    #8aa2ff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 18% -10%, rgba(255,45,85,0.16), transparent 60%),
    radial-gradient(1100px 700px at 88% 110%, rgba(47,123,255,0.18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
.hidden { display: none !important; }
h1, h2, h3 { font-weight: 700; }
a { color: inherit; }

/* ---------------- Login ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 360px; max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 28px;
  text-align: center;
  backdrop-filter: blur(14px);
  box-shadow: 0 0 60px rgba(0,0,0,0.6), 0 0 1px var(--blue-glow);
}
.login-logo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 32px var(--red-glow), 0 0 48px var(--blue-glow); }
.login-card h1 { margin: 18px 0 2px; font-size: 22px; letter-spacing: 3px; }
.login-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 11px 13px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); font-size: 14px; outline: none;
}
.login-card input { margin: 7px 0; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
select option { background: #11142a; }
input[type=checkbox], input[type=range] { width: auto; box-shadow: none; }
input[type=range] { accent-color: var(--blue); padding: 0; border: none; background: none; }
input[type=color] { width: 44px; height: 40px; padding: 2px; }

button {
  cursor: pointer; border: none; border-radius: 10px;
  font: inherit; font-weight: 600; font-size: 14px; color: #fff;
  padding: 11px 16px;
  background: linear-gradient(100deg, var(--red), var(--blue));
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), 0 0 18px rgba(47,123,255,0.25);
  transition: transform .08s ease, filter .15s ease, opacity .15s ease;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; filter: none; }
.login-card button { width: 100%; margin-top: 12px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }
.hint { color: var(--muted); font-size: 13px; }

button.ghost {
  background: transparent; border: 1px solid var(--line); box-shadow: none;
  color: var(--muted); padding: 8px 14px;
}
button.ghost:hover { color: var(--text); border-color: var(--blue); }
button.mini { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
button.ghostish { background: rgba(255,255,255,0.06); box-shadow: none; border: 1px solid var(--line); }
button.danger { background: linear-gradient(100deg, #ff2d55, #ff5e3a); }
button.warn { background: linear-gradient(100deg, #ffb020, #ff7a18); color: #1a1300; }
button.ok { background: linear-gradient(100deg, #1fd17a, #2f7bff); }
button.plain { background: rgba(255,255,255,0.07); box-shadow: none; border: 1px solid var(--line); }
button.plain:hover { border-color: var(--blue); }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(5,6,13,0.7); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: 2px; text-decoration: none; white-space: nowrap; }
.brand img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 16px var(--red-glow), 0 0 22px var(--blue-glow); }
.tabs { display: flex; gap: 6px; }
.tab { background: transparent; box-shadow: none; color: var(--muted); padding: 8px 14px; border: 1px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: #fff; border-color: var(--blue); background: rgba(47,123,255,0.14); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.live { width: 9px; height: 9px; border-radius: 50%; background: #44485f; }
.live.on { background: var(--green); box-shadow: 0 0 10px var(--green); }

/* ---------------- Layout ---------------- */
.layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; padding: 18px; align-items: start; }
.page { padding: 18px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 6px 0; font-size: 22px; }

.panel, .card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; margin-bottom: 16px;
  backdrop-filter: blur(10px);
}
.card { padding: 16px; margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h2, .card h3 { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin: 0; }
.card h3 { margin-bottom: 12px; }
.card h3.spaced { margin-top: 18px; }
.bulk { display: flex; flex-wrap: wrap; gap: 6px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 5px;
  border-left: 3px solid var(--pet, transparent);
}
.list li:hover { background: var(--panel-2); }
.list li.active { border-color: var(--blue); background: rgba(47,123,255,0.10); border-left-color: var(--pet, var(--blue)); }
.list .ltext { display: flex; align-items: center; gap: 9px; min-width: 0; }
.list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.list .sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.list .empty { color: var(--muted); cursor: default; border-left-color: transparent; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: #44485f; }
.dot.idle { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.working, .dot.thinking { background: var(--blue); box-shadow: 0 0 10px var(--blue); }
.dot.waiting { background: var(--amber); box-shadow: 0 0 12px var(--amber); animation: pulse 1.2s ease-in-out infinite; }
.dot.error { background: var(--red); box-shadow: 0 0 10px var(--red); }
@keyframes pulse { 50% { transform: scale(1.35); } }

.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.red { color: #fff; background: rgba(255,45,85,0.18); border-color: var(--red); }
.badge.blue { color: #fff; background: rgba(47,123,255,0.18); border-color: var(--blue); }
.badge.green { color: #fff; background: rgba(31,209,122,0.18); border-color: var(--green); }
.badge.amber { color: #fff; background: rgba(255,176,32,0.18); border-color: var(--amber); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 + .grid2, .detail .card + .card, .detail .grid2 + .card, .detail .card + .grid2 { margin-top: 16px; }

/* ---------------- Overview: every pet at a glance ---------------- */
.overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.pet-card {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-top: 3px solid var(--pet, var(--blue));
  border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.pet-card:hover { transform: translateY(-2px); border-color: var(--blue); }
.pet-card.waiting { box-shadow: 0 0 0 1px var(--amber), 0 0 24px rgba(255,176,32,0.25); }
.pet-card .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pet-card .name { font-weight: 700; font-size: 16px; color: var(--pet, var(--text)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet-card .stage { display: grid; place-items: center; height: 150px; }
.pet-card .quick { display: flex; gap: 6px; flex-wrap: wrap; }
.pet-card .quick button { flex: 1; min-width: 0; }
.add-card { display: grid; place-items: center; min-height: 250px; color: var(--muted); border-style: dashed; border-top-style: dashed; }
.add-card span { font-size: 42px; line-height: 1; }

canvas.sprite { image-rendering: pixelated; filter: drop-shadow(0 8px 14px rgba(0,0,0,0.55)); }
canvas.sprite.small { width: 128px; height: 139px; }
canvas.sprite.big { width: 176px; height: 191px; }
canvas.sprite.offline { opacity: .4; filter: grayscale(1); }

/* the pet's speech bubble */
.bubble {
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--pet, var(--blue));
  border-radius: 12px; padding: 9px 11px; min-height: 46px;
}
.bubble.waiting { border-color: var(--amber); border-left-color: var(--amber); }
.bubble.error { border-left-color: var(--red); }
.bubble .headline { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.pet-card .bubble .headline { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bubble .detail-line { color: var(--muted); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }

.pill { font-size: 10px; letter-spacing: .8px; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: rgba(255,255,255,0.08); color: var(--muted); }
.pill.idle { background: rgba(31,209,122,.16); color: #7ee7a8; }
.pill.working, .pill.thinking { background: rgba(47,123,255,.2); color: #9ec5ff; }
.pill.waiting { background: rgba(255,176,32,.22); color: #ffd666; }
.pill.error { background: rgba(255,45,85,.2); color: #ff9cb0; }

/* battery */
.battery { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.battery .body { position: relative; width: 28px; height: 13px; border: 1.5px solid rgba(255,255,255,.55); border-radius: 3px; overflow: hidden; }
.battery .fill { position: absolute; inset: 1px auto 1px 1px; border-radius: 1px; background: var(--green); }
.battery .cap { width: 3px; height: 6px; border-radius: 0 2px 2px 0; background: rgba(255,255,255,.55); }
.battery.low .fill { background: var(--amber); }
.battery.critical .fill, .battery.exhausted .fill { background: var(--red); }
.battery.info .fill { background: var(--accent); opacity: .6; }
.battery.unknown .body { border-style: dashed; opacity: .6; }

.folder { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Detail ---------------- */
.detail { min-width: 0; }
.dhead { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.dhead h1 { margin: 0; font-size: 26px; color: var(--pet, var(--text)); overflow-wrap: anywhere; }
.dhead .meta { color: var(--muted); font-size: 13px; margin: 4px 0 10px; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.actions button { flex: 1 1 130px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: none; }
.row .k { color: var(--muted); font-size: 13px; white-space: nowrap; }
.row .v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.rows a { color: #9ec5ff; }

.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 200px; resize: vertical; }
.composer button { flex: 0 0 auto; }

.transcript { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.transcript .msg { padding: 6px 10px; border-radius: 10px; font-size: 13px; overflow-wrap: anywhere; max-width: 92%; }
.transcript .msg.user { align-self: flex-end; background: rgba(47,123,255,0.18); border: 1px solid rgba(47,123,255,0.4); }
.transcript .msg.agent { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }

.recent { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.recent button { text-align: left; font-weight: 400; font-size: 12px; padding: 7px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* usage bars */
.usage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 12px; }
.urow { display: grid; grid-template-columns: 90px 1fr 52px; gap: 10px; align-items: center; margin: 8px 0 2px; }
.urow .ulabel { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow.binding .ulabel { color: var(--text); font-weight: 700; }
.urow.info { opacity: .6; }
.ubar { height: 9px; border-radius: 5px; background: rgba(255,255,255,0.08); overflow: hidden; }
.ufill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--green), #6ef0b0); }
.ufill.low { background: linear-gradient(90deg, var(--amber), #ffd666); }
.ufill.critical, .ufill.exhausted { background: linear-gradient(90deg, var(--red), #ff7a90); }
.upct { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.ureset { font-size: 11px; color: var(--muted); padding-left: 100px; }
.umeta { font-size: 12px; color: var(--muted); margin-top: 8px; overflow-wrap: anywhere; }

/* terminal */
.term-wrap { background: #0e1016; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.term-bar { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 2px solid var(--pet, var(--blue)); font-size: 12px; color: var(--muted); }
.term-bar .grow { flex: 1; }
.term { height: 440px; padding: 4px 0 0 6px; }
.term-wrap.full { position: fixed; inset: 10px; z-index: 40; display: flex; flex-direction: column; }
.term-wrap.full .term { flex: 1; height: auto; }

/* settings */
.field { display: grid; grid-template-columns: 1fr 180px auto; gap: 10px; align-items: center; padding: 7px 0; font-size: 14px; }
.field output { color: var(--muted); font-size: 12px; min-width: 44px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }
.switch .lbl { font-size: 14px; }
.switch .lbl small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.toggle { position: relative; width: 50px; height: 28px; flex: 0 0 auto; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: #2a2e44; transition: .2s; }
.toggle span::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.toggle input:checked + span { background: linear-gradient(100deg, var(--red), var(--blue)); }
.toggle input:checked + span::after { transform: translateX(22px); }
.toggle input:focus-visible + span { box-shadow: 0 0 0 3px var(--blue-glow); }

/* ---------------- Modal ---------------- */
.modal-back { position: fixed; inset: 0; background: rgba(2,3,8,0.72); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(4px); padding: 16px; }
.modal { width: 520px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.modal h3 { margin: 0 0 14px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.modal .two { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions button { flex: 1; }
.note { color: var(--muted); font-size: 12px; white-space: pre-line; margin-top: 4px; }

.dirs { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }
.dirs button { display: block; width: 100%; text-align: left; background: none; box-shadow: none; border-radius: 0; font-weight: 400;
  padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.dirs button:hover { background: rgba(47,123,255,0.12); }
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.path { font-family: ui-monospace, "Cascadia Code", monospace; font-size: 13px; color: #9ec5ff; overflow-wrap: anywhere; margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; max-width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); font-size: 14px; }
.toast.bad { border-color: var(--red); }

/* ---------------- Phone / tablet ---------------- */
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  .layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .brand { font-size: 14px; letter-spacing: 1px; }
  .brand img { width: 30px; height: 30px; }
  .layout, .page { padding: 12px; }
  .dhead { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .dhead .badges { justify-content: center; }
  .actions button { flex: 1 1 100%; }
  .field { grid-template-columns: 1fr; }
  .term { height: 60vh; }
  .ureset { padding-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.waiting { animation: none; }
  .pet-card, button { transition: none; }
}
