/* SaasFZ panel */
:root {
  --accent: #2F7BFF;
  --accent2: #38C6FF;
  --grad: linear-gradient(135deg, #38C6FF 0%, #2F7BFF 100%);
  --ok: #22C55E;
  --err: #F43F5E;
  --r: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.theme-dark {
  --bg: #15171c;
  --panel: #1c1f26;
  --card: #23262f;
  --card-hi: #2a2e39;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .12);
  --fg: #eef1f6;
  --fg2: #a3abba;
  --fg3: #6b7383;
  --input: #14161b;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 6px 18px rgba(0, 0, 0, .25);
  --pv-bg: radial-gradient(120% 90% at 50% 0%, #252a35 0%, #17191f 100%);
  --pv-fg: #eef1f6;
  --pv-card: #363b48;
}

body.theme-light {
  --bg: #eef1f6;
  --panel: #f7f9fc;
  --card: #ffffff;
  --card-hi: #f2f6ff;
  --line: rgba(20, 30, 50, .07);
  --line2: rgba(20, 30, 50, .12);
  --fg: #172033;
  --fg2: #5b6578;
  --fg3: #8d96a8;
  --input: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 16px rgba(20, 30, 60, .06);
  --pv-bg: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #e8edf6 100%);
  --pv-fg: #172033;
  --pv-card: #d5dce9;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input, select { font: inherit; color: var(--fg); }
.hidden { display: none !important; }
.ico { width: 16px; height: 16px; display: block; }

#app { height: 100%; display: flex; flex-direction: column; }

/* ---------- header */
.top {
  display: flex; align-items: center; justify-content: space-between;
  margin: 10px 10px 0; padding: 10px 10px 10px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(160deg, rgba(56, 198, 255, .16), rgba(47, 123, 255, .10));
  border: 1px solid var(--line2); display: grid; place-items: center;
}
.logo img { width: 30px; height: 30px; }
.title { font-weight: 800; font-size: 17px; letter-spacing: -.2px; line-height: 1.1; white-space: nowrap; }
.title span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.title em { font-style: normal; font-weight: 600; font-size: 10px; color: var(--fg3); margin-left: 2px; }
.sub { font-size: 11px; color: var(--fg2); margin-top: 2px; }
.actions { display: flex; gap: 6px; }
.iconbtn {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  color: var(--fg2); background: var(--card); border: 1px solid var(--line);
  transition: color .15s, background .15s, transform .1s;
}
.iconbtn:hover { color: var(--accent2); background: var(--card-hi); }
.iconbtn:active { transform: scale(.94); }

/* ---------- views */
.view { flex: 1; overflow-y: auto; padding: 10px 10px 16px; overscroll-behavior: contain; }
/* each card/tile lays itself out on its own, so a change inside one never relayouts the whole panel */
.card, .tile, .param, .group { contain: layout style; }
.stage canvas, .tile canvas { contain: strict; }
.view::-webkit-scrollbar { width: 8px; }
.view::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; border: 2px solid var(--bg); }

.search input {
  width: 100%; height: 32px; padding: 0 12px; border-radius: 10px;
  background: var(--input); border: 1px solid var(--line); outline: none;
}
.search input:focus { border-color: rgba(47, 123, 255, .6); }
.search input::placeholder { color: var(--fg3); }

.cat { margin-top: 14px; }
.cat-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; }
.cat-badge {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; color: #fff;
  background: var(--grad); box-shadow: 0 3px 10px rgba(47, 123, 255, .35);
}
.cat-badge .ico { width: 13px; height: 13px; }
.cat-name { font-weight: 700; font-size: 13px; }
.cat-line { flex: 1; height: 1px; background: var(--line); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 7px; }
.card {
  display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 10px 0 7px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  text-align: left; transition: background .15s, border-color .15s, transform .1s;
}
.card:hover { background: var(--card-hi); border-color: rgba(47, 123, 255, .35); }
.card:active { transform: scale(.98); }
.card .ci {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--tint-bg); color: var(--tint);
}
.card .cn { flex: 1; font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cc { color: var(--fg3); }
.card .cc .ico { width: 13px; height: 13px; }
.tip { color: var(--fg3); font-size: 11px; text-align: center; margin: 18px 0 4px; }
.tip b { color: var(--fg2); }
.empty { color: var(--fg3); text-align: center; padding: 30px 0; }

/* ---------- tool view */
.toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.ticon {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff;
  background: var(--grad); box-shadow: 0 4px 12px rgba(47, 123, 255, .35);
}
.tt { flex: 1; min-width: 0; }
.tname { font-weight: 800; font-size: 15px; letter-spacing: -.2px; }
.tdesc { color: var(--fg2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live {
  display: inline-flex; align-items: center; gap: 5px; font-size: 9.5px; font-weight: 800; letter-spacing: .8px;
  color: var(--ok); background: rgba(34, 197, 94, .12); padding: 4px 8px; border-radius: 20px;
}
.live i { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.stage {
  position: relative; height: 178px; border-radius: 14px; overflow: hidden;
  background: var(--pv-bg); border: 1px solid var(--line);
}
.stage canvas { width: 100%; height: 100%; display: block; }
.replay {
  position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; color: var(--fg2); background: var(--card); border: 1px solid var(--line); opacity: .85;
}
.replay:hover { color: var(--accent2); opacity: 1; }
.replay .ico { width: 14px; height: 14px; }

.ptext { margin-top: 8px; }
.ptext input {
  width: 100%; height: 30px; padding: 0 10px; border-radius: 9px; font-size: 12px;
  background: var(--input); border: 1px solid var(--line); outline: none; color: var(--fg2);
}
.ptext input:focus { border-color: rgba(47, 123, 255, .6); color: var(--fg); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  height: 28px; padding: 0 12px; border-radius: 20px; font-size: 12px; font-weight: 600; color: var(--fg2);
  background: var(--card); border: 1px solid var(--line); transition: color .15s, border-color .15s, background .15s;
}
.chip:hover { color: var(--fg); border-color: var(--line2); }
.chip.on { color: #fff; background: var(--grad); border-color: transparent; box-shadow: 0 4px 12px rgba(47, 123, 255, .35); }

.params { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 12px; }
.param { min-width: 0; }
.param.full { grid-column: 1 / -1; }
.plabel { display: flex; justify-content: space-between; align-items: baseline; font-size: 11.5px; color: var(--fg2); margin-bottom: 5px; }
.plabel b { color: var(--accent2); font-weight: 700; font-variant-numeric: tabular-nums; }
body.theme-light .plabel b { color: var(--accent); }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent2), var(--accent)) 0 / var(--fill, 50%) 100% no-repeat, var(--line2);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5.5px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); border: 0;
}
input[type=range]:focus { outline: none; }

.sel-wrap { position: relative; }
.sel-wrap select {
  -webkit-appearance: none; appearance: none; width: 100%; height: 30px; padding: 0 26px 0 10px;
  border-radius: 9px; background: var(--input); border: 1px solid var(--line); outline: none; font-size: 12px;
}
.sel-wrap::after {
  content: ''; position: absolute; right: 11px; top: 11px; width: 6px; height: 6px;
  border-right: 1.6px solid var(--fg3); border-bottom: 1.6px solid var(--fg3); transform: rotate(45deg); pointer-events: none;
}
.txt {
  width: 100%; height: 30px; padding: 0 10px; border-radius: 9px; font-size: 12px;
  background: var(--input); border: 1px solid var(--line); outline: none;
}
.txt:focus, .sel-wrap select:focus { border-color: rgba(47, 123, 255, .6); }

.color { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 9px; background: var(--input); border: 1px solid var(--line); }
.color input[type=color] { -webkit-appearance: none; width: 20px; height: 20px; border: 0; padding: 0; background: none; cursor: pointer; }
.color input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.color input[type=color]::-webkit-color-swatch { border: 1px solid var(--line2); border-radius: 6px; }
.color span { font-size: 11.5px; color: var(--fg2); font-variant-numeric: tabular-nums; text-transform: uppercase; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 30px; cursor: pointer; font-size: 12px; color: var(--fg2); }
.switch { position: relative; width: 32px; height: 18px; border-radius: 18px; background: var(--line2); flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle.on .switch { background: var(--accent); }
.toggle.on .switch::after { transform: translateX(14px); }

.palettes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pal { height: 34px; border-radius: 9px; border: 2px solid transparent; position: relative; overflow: hidden; }
.pal.on { border-color: var(--accent2); }
.pal i { position: absolute; left: 6px; bottom: 3px; font-style: normal; font-size: 9.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }

.hint {
  margin-top: 14px; padding: 9px 11px; border-radius: 10px; font-size: 11.5px; color: var(--fg2);
  background: rgba(47, 123, 255, .09); border: 1px solid rgba(47, 123, 255, .22);
}

/* ---------- footer */
.foot {
  display: flex; align-items: center; gap: 10px; padding: 10px; margin: 0 10px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.sel { flex: 1; font-size: 11px; color: var(--fg3); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel b { color: var(--fg2); font-weight: 600; }
.apply {
  height: 38px; padding: 0 26px; border-radius: 12px; font-weight: 800; font-size: 14px; color: #fff;
  background: var(--grad); box-shadow: 0 6px 18px rgba(47, 123, 255, .45), 0 1px 0 rgba(255, 255, 255, .3) inset;
  transition: transform .1s, filter .15s, box-shadow .15s;
}
.apply:hover { filter: brightness(1.08); box-shadow: 0 8px 24px rgba(47, 123, 255, .55), 0 1px 0 rgba(255, 255, 255, .3) inset; }
.apply:active { transform: scale(.97); }
.apply.busy { pointer-events: none; filter: saturate(.6); }
.apply.busy span::after { content: '…'; }
.apply.wide { width: 100%; margin-top: 10px; }

/* ---------- settings */
.group { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.glabel { font-weight: 700; font-size: 12px; margin-bottom: 8px; }
.gtext { margin: 0 0 10px; color: var(--fg2); font-size: 11.5px; }
.btn {
  width: 100%; height: 32px; border-radius: 10px; font-weight: 600; font-size: 12px; color: #fff; background: var(--grad); margin-top: 6px;
}
.btn:first-of-type { margin-top: 0; }
.btn.ghost { color: var(--fg); background: var(--card); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--line2); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { height: 26px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--fg2); }
.seg button.on { background: var(--card-hi); color: var(--fg); box-shadow: var(--shadow); }

/* ---------- license */
.lic { max-width: 300px; margin: 30px auto 0; text-align: center; }
.lic-logo { width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 22px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line2); box-shadow: var(--shadow); }
.lic-logo img { width: 56px; height: 56px; }
.lic h1 { font-size: 20px; margin: 0 0 6px; letter-spacing: -.3px; }
.lic h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lic p { color: var(--fg2); font-size: 12px; margin: 0 0 16px; }
.lic input { width: 100%; height: 38px; text-align: center; border-radius: 11px; background: var(--input); border: 1px solid var(--line2); outline: none; font-size: 13px; letter-spacing: .5px; user-select: text; }
.lic input:focus { border-color: rgba(47, 123, 255, .7); }
.lic-err { min-height: 18px; margin-top: 8px; color: var(--err); font-size: 11.5px; }
.link { margin-top: 14px; color: var(--accent2); font-size: 12px; font-weight: 600; }

/* ---------- toast */
.toast {
  position: fixed; left: 50%; bottom: 76px; transform: translate(-50%, 12px); max-width: calc(100% - 28px);
  padding: 9px 14px; border-radius: 11px; font-size: 12px; font-weight: 600; color: #fff; background: #222733;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  display: flex; gap: 8px; align-items: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: linear-gradient(135deg, #16a34a, #22c55e); }
.toast.err { background: linear-gradient(135deg, #e11d48, #f43f5e); }
.toast.info { background: linear-gradient(135deg, #2F7BFF, #38C6FF); }
.toast .ico { width: 14px; height: 14px; flex: none; }

@media (max-width: 400px) {
  .card .cc { display: none; }
  .card { padding-right: 8px; }
}
@media (max-width: 300px) {
  .params { grid-template-columns: 1fr; }
}

/* ---------- style grid (Text Animation, Cursor) */
.chips.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.tile {
  display: flex; flex-direction: column; align-items: stretch; padding: 0 0 6px; border-radius: 12px; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); transition: border-color .15s, background .15s, transform .1s;
}
.tile canvas { width: 100%; height: 54px; display: block; background: var(--pv-bg); }
.tile span { font-size: 11px; font-weight: 600; color: var(--fg2); margin-top: 5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.tile:hover { border-color: var(--line2); }
.tile:active { transform: scale(.97); }
.tile.on { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2), 0 6px 16px rgba(47, 123, 255, .25); }
.tile.on span { color: var(--fg); }

/* ---------- segmented + flag buttons */
.segs, .flags { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 10px; background: var(--input); border: 1px solid var(--line); }
.segs button, .flags button {
  flex: 1 1 auto; min-width: 34px; height: 26px; padding: 0 8px; border-radius: 8px; font-size: 11.5px; font-weight: 600; color: var(--fg2);
  transition: background .15s, color .15s;
}
.segs button:hover, .flags button:hover { color: var(--fg); }
.segs button.on { color: #fff; background: var(--grad); box-shadow: 0 3px 10px rgba(47, 123, 255, .3); }
.flags { background: none; border: 0; padding: 0; gap: 6px; }
.flags button { flex: 0 0 auto; height: 28px; padding: 0 14px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); }
.flags button.on { color: #fff; background: var(--grad); border-color: transparent; box-shadow: 0 3px 10px rgba(47, 123, 255, .3); }
.link-btn { cursor: pointer; font-size: 13px; }
