:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --bg2: var(--tg-theme-secondary-bg-color, #181b22);
  --card: var(--tg-theme-section-bg-color, #1c2029);
  --text: var(--tg-theme-text-color, #f2f3f5);
  --hint: var(--tg-theme-hint-color, #8b93a1);
  --link: var(--tg-theme-link-color, #6ea8ff);
  --accent: var(--tg-theme-button-color, #7c5cff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #ff5c5c);
  --ok: #34c77b;
  --radius: 16px;
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg2) 88%, transparent); backdrop-filter: blur(12px); }
.brand { font-size: 20px; letter-spacing: .2px; }
.brand b { background: linear-gradient(90deg, #7c5cff, #19c3ff); -webkit-background-clip: text; color: transparent; }
.pill { background: var(--card); padding: 7px 12px; border-radius: 999px; font-weight: 600; }
.pill .plus { color: var(--accent); margin-left: 2px; }

main { padding: 4px 16px 16px; }
h2 { font-size: 22px; margin: 8px 0 4px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--hint); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.sub { color: var(--hint); margin: 0 0 12px; }
.hello { margin: 6px 0 14px; }
.hello small { color: var(--hint); display: block; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 14px; text-align: left; min-height: 92px;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.tile .ic { font-size: 26px; }
.tile .nm { font-weight: 650; }
.tile .pr { color: var(--hint); font-size: 12.5px; }
.tile.wide { grid-column: span 2; min-height: 64px; flex-direction: row; align-items: center; gap: 12px; justify-content: flex-start; }
.tile.hot { background: linear-gradient(135deg, #7c5cff, #3aa3ff); color: #fff; }
.tile.hot .pr { color: rgba(255,255,255,.85); }
.tile.off { opacity: .45; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 1.5px solid transparent; padding: 8px 12px; border-radius: 12px; font-weight: 550; }
.chip small { display: block; color: var(--hint); font-weight: 500; font-size: 12px; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.chip:disabled { opacity: .4; }
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }

textarea, input[type=text] { width: 100%; background: var(--card); border: 1.5px solid transparent; border-radius: 14px;
  padding: 12px; min-height: 96px; resize: vertical; outline: none; }
input[type=text] { min-height: 0; }
textarea:focus, input[type=text]:focus { border-color: var(--accent); }
.count { text-align: right; color: var(--hint); font-size: 12px; margin-top: 4px; }

.drop { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1.5px dashed var(--line);
  border-radius: var(--radius); padding: 14px; width: 100%; text-align: left; }
.drop .th { width: 56px; height: 56px; border-radius: 12px; background: var(--bg2); display: grid; place-items: center;
  font-size: 24px; overflow: hidden; flex: none; }
.drop .th img, .drop .th video { width: 100%; height: 100%; object-fit: cover; }
.drop.done { border-style: solid; border-color: var(--ok); }
.drop small { color: var(--hint); display: block; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg2) 92%, transparent); backdrop-filter: blur(12px); }
.bar .inner { max-width: 608px; margin: 0 auto; }
.btn { width: 100%; background: var(--accent); color: var(--accent-text); border-radius: 14px; padding: 14px; font-weight: 700; font-size: 16px; }
.btn:disabled { opacity: .45; }
.btn.ghost { background: var(--card); color: var(--text); }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 12px; }
.link { color: var(--link); font-weight: 600; }

.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl { background: var(--card); border-radius: var(--radius); overflow: hidden; text-align: left; }
.tpl .pv { aspect-ratio: 3/4; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 25%, var(--bg2)), var(--bg2));
  display: grid; place-items: center; font-size: 42px; overflow: hidden; }
.tpl .pv img, .tpl .pv video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl .meta { padding: 10px; }
.tpl .meta b { display: block; font-size: 14px; }
.tpl .meta span { color: var(--hint); font-size: 12.5px; }

.voice { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.voice:last-child { border-bottom: 0; }
.play { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text); flex: none; font-size: 15px; }
.voice .nm { flex: 1; }
.voice.sel { color: var(--accent); }

.job { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.job .hd { display: flex; justify-content: space-between; gap: 8px; }
.job .st { font-size: 13px; font-weight: 600; }
.job .st.ok { color: var(--ok); } .job .st.fail { color: var(--danger); } .job .st.run { color: var(--accent); }
.job .ds { color: var(--hint); font-size: 13px; margin-top: 4px; word-break: break-word; }
.job img, .job video { width: 100%; border-radius: 12px; margin-top: 10px; display: block; background: var(--bg2); }
.job audio { width: 100%; margin-top: 10px; }
.job .imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.empty { text-align: center; color: var(--hint); padding: 30px 10px; }

.pack { display: flex; justify-content: space-between; align-items: center; width: 100%; background: var(--card);
  border-radius: 14px; padding: 14px; margin-bottom: 8px; text-align: left; }
.pack b { font-size: 17px; }
.pack .gift { color: var(--ok); font-weight: 650; font-size: 13px; }
.pack .go { color: var(--accent); font-weight: 700; }
.note { color: var(--hint); font-size: 13px; }
.copy { background: var(--bg2); border-radius: 12px; padding: 12px; font-weight: 650; font-size: 17px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; }
.sheet.hidden { display: none; }
.sheet-card { width: 100%; max-width: 640px; margin: 0 auto; background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-card h2 { margin-top: 0; }
.lines { margin: 8px 0 14px; }
.lines div { padding: 6px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; margin: 10px 0 14px; }
.stack > * + * { margin-top: 8px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: 96px; z-index: 30; max-width: 608px; margin: 0 auto;
  background: #222733; color: #fff; padding: 12px 14px; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.toast.hidden { display: none; }
.loader { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  margin: 60px auto; animation: spin .8s linear infinite; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.lang { display: flex; gap: 8px; justify-content: center; margin: 22px 0 6px; }
.lyr { white-space: pre-wrap; background: var(--bg2); border-radius: 12px; padding: 12px; max-height: 260px; overflow: auto; font-size: 14px; }
