:root {
  --bg: #101114;
  --panel: #181a1f;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f2f2f2;
  --muted: #9aa0a8;
  --accent: #c9a66b;
  --danger: #d9776c;
  --ok: #7dba8a;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(800px 400px at 10% -10%, rgba(201,166,107,.12), transparent 50%), var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
.wrap { width: min(1120px, calc(100% - 24px)); margin: 0 auto; }

.top {
  height: calc(64px + var(--safe-top));
  padding-top: var(--safe-top);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(16,17,20,.94);
  z-index: 20;
}
.top-inner { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 12px; }
.brand { font-weight: 800; display: inline-flex; align-items: center; gap: 8px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand span { color: var(--accent); margin-left: 4px; font-size: 12px; }
.top-nav { display: flex; gap: 14px; align-items: center; }
.top-nav a, .top-nav button {
  background: none; border: 0; cursor: pointer; color: var(--muted); min-height: 40px;
}
.top-nav a:hover, .top-nav button:hover { color: var(--text); }

.page { padding: 24px 0 64px; }
h1 { font-size: 26px; margin-bottom: 8px; }
.lead { color: var(--muted); margin-bottom: 24px; }
.lead.tight { margin-bottom: 0; font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}
.panel h2 { font-size: 18px; margin-bottom: 8px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  background: #111318;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  font-size: 16px;
}
.field textarea { min-height: 84px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 700;
  min-height: 42px;
}
.btn-primary { background: var(--accent); color: #1a1408; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: rgba(217,119,108,.16); color: #f0b0a8; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.progress {
  height: 8px;
  background: #111;
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0;
  display: none;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.editor {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 22px;
  align-items: start;
}
.preview-col { position: sticky; top: 88px; }
.live-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #0b0c0e;
  border: 1px dashed var(--line);
}
.live-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.live-ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.live-card .card-mask {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 40px 14px 12px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,.82) 72%);
}
.live-card h3 {
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.live-card .desc {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,.65);
  font-size: 12px;
  min-height: 0;
}
.live-card .badge {
  display: inline-flex;
  margin-top: 8px;
  color: #1a1408;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
}
.file-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  background: #12141a;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.file-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.file-pick {
  display: block;
  background: #111318;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}
.file-pick input { display: none; }
.file-pick-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.file-pick-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}

.visual-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.visual-item {
  background: #12141a;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.visual-item.is-editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.visual-item .live-card {
  border: 0;
  border-radius: 0;
}
.visual-meta {
  padding: 10px 12px 12px;
}
.visual-meta p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.visual-meta .apk-name {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 4px;
  word-break: break-all;
}
.visual-item .ops {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 12px;
}
.visual-item .ops .btn {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 12px;
}

.login-box {
  max-width: 420px;
  margin: 10vh auto 0;
  text-align: center;
}
.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  margin: 0 auto 16px;
}
.login-box form { text-align: left; }
.warn {
  background: rgba(201,166,107,.12);
  border: 1px solid rgba(201,166,107,.3);
  color: #e6d2a8;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.hidden { display: none !important; }
.toast-host {
  position: fixed; top: calc(16px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 50; display: flex; flex-direction: column; gap: 8px;
  width: min(92vw, 360px);
}
.toast {
  background: #111; border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; text-align: center;
}
.empty { color: var(--muted); padding: 20px 0; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .preview-col { position: static; max-width: 360px; }
  .visual-list { grid-template-columns: 1fr 1fr; }
  .file-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .visual-list { grid-template-columns: 1fr; }
  .preview-col { max-width: none; }
  .panel { padding: 16px 14px; }
  .brand span { display: none; }
}
