:root {
  --bg: #0f0d1a;
  --panel: #1a1729;
  --panel-2: #241f38;
  --line: #2f2947;
  --text: #f3f0ff;
  --muted: #a59fc2;
  --gold: #ffc83d;
  --gold-2: #ff9f1c;
  --pink: #ff3881;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, sans-serif;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(180deg, #17142a, var(--bg));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { display: grid; grid-template-columns: 1fr 1fr; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 2px #0006, 0 6px 18px #ffc83d33; }
.logo i:nth-child(1) { background: var(--gold); }
.logo i:nth-child(2) { background: var(--pink); }
.logo i:nth-child(3) { background: #3690ea; }
.logo i:nth-child(4) { background: #00cc78; }
.brand h1 {
  margin: 0; font-family: 'Secular One', 'Rubik', sans-serif; font-weight: 400;
  font-size: 24px; line-height: 1.05; letter-spacing: .5px; direction: ltr; text-align: right;
}
.brand h1 span { color: var(--gold); }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.chips { display: flex; gap: 8px; align-items: center; }
.chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-variant-numeric: tabular-nums; direction: ltr; white-space: nowrap;
}
.chip.live { display: inline-flex; align-items: center; gap: 6px; color: #7eed56; direction: rtl; }
.chip.live b { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; }
.chip.live.off { color: var(--muted); }
.chip.live.off b { animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #7eed5688; } 70% { box-shadow: 0 0 0 8px #7eed5600; } 100% { box-shadow: 0 0 0 0 #7eed5600; } }

/* ---------- stage ---------- */
.stage { position: relative; overflow: hidden; touch-action: none; background:
  radial-gradient(circle at 50% 40%, #1c1832 0%, var(--bg) 70%); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
#view.panning { cursor: grabbing; }
#view.dropping { cursor: copy; }
.loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 15px;
  pointer-events: none; transition: opacity .3s;
}
.loading.hidden { opacity: 0; }

.tools { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; }
.tool {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(8px);
  font-size: 22px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 6px 18px #0007; transition: transform .12s, background .12s;
}
.tool:hover { background: var(--panel-2); }
.tool:active { transform: scale(.94); }
.tool#goto { color: var(--pink); }
.tool-text { height: auto; padding: 6px 0; font-size: 11px; font-weight: 500; line-height: 1.25; }

/* ---------- dock ---------- */
.dock {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.pool { position: relative; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ring { width: 48px; height: 48px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear; }
.pool-num { position: absolute; right: 0; width: 48px; text-align: center; font-weight: 800; font-size: 15px; color: var(--gold); font-variant-numeric: tabular-nums; }
.pool-text { display: flex; flex-direction: column; line-height: 1.2; }
.pool-text strong { font-size: 18px; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.pool-text span { font-size: 12px; color: var(--muted); }
.pool.empty .ring .bar { stroke: var(--pink); }
.pool.empty .pool-num { color: var(--pink); }

.palette {
  flex: 1; display: grid; grid-template-columns: repeat(24, minmax(18px, 30px)); grid-auto-rows: 26px; gap: 5px;
  justify-content: center; overflow-x: auto; padding: 4px;
}
.swatch {
  border: 0; border-radius: 7px; padding: 0; box-shadow: inset 0 0 0 1px #ffffff22, 0 2px 4px #0005;
  transition: transform .1s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--gold); transform: scale(1.12); }

.picker { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.dropper {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2);
  display: grid; place-items: center; color: #94b3ff;
}
.dropper.active { background: #3690ea; color: white; border-color: #3690ea; }
.current { width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--gold); }

/* ---------- dialog / toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
  padding: 20px 22px; min-width: 280px; box-shadow: 0 20px 60px #000a;
}
dialog::backdrop { background: #0008; backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
dialog .row { display: flex; gap: 12px; }
dialog label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); direction: ltr; }
dialog input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  padding: 10px; font: inherit; font-size: 16px; width: 100%;
}
dialog input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
dialog .actions { margin-top: 16px; justify-content: flex-start; }
.primary, .ghost { border-radius: 10px; padding: 9px 18px; border: 1px solid var(--line); background: transparent; }
.primary { background: var(--gold); color: #1a1300; border-color: var(--gold); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px;
  font-size: 14px; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 10px 30px #0008;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- user chip / pixel info ---------- */
.chip.user { cursor: pointer; color: var(--gold); font-weight: 700; direction: rtl; }
.chip.user:hover { background: var(--panel-2); }
.chip.user.in::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-inline-end: 6px; }

.pixel-info {
  position: absolute; bottom: 14px; left: 14px; display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px;
  box-shadow: 0 6px 18px #0007; pointer-events: none; max-width: calc(100% - 28px);
}
.pi-coords { direction: ltr; font-variant-numeric: tabular-nums; color: var(--muted); }
.pi-swatch { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px #fff3; flex-shrink: 0; }
.pi-owner { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-owner b { color: var(--gold); }
.pi-owner.none { color: var(--muted); }

.tool.active { background: var(--gold); color: #1a1300; border-color: var(--gold); }

/* ---------- image panel ---------- */
.panel {
  position: absolute; top: 14px; right: 14px; width: 300px; max-height: calc(100% - 28px); overflow-y: auto;
  background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: 0 16px 40px #000a;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel h2 { margin: 0; font-size: 17px; }
.x { background: none; border: 0; color: var(--muted); font-size: 16px; width: 30px; height: 30px; border-radius: 8px; }
.x:hover { background: var(--panel-2); color: var(--text); }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 12px; color: var(--muted); cursor: pointer; font-size: 13px;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--gold); background: #ffc83d0d; color: var(--text); }
.drop.has { padding: 10px; flex-direction: row; justify-content: center; }
.drop.has svg { width: 18px; height: 18px; }
.panel-body { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.field-row { display: flex; justify-content: space-between; color: var(--muted); }
.field-row strong { color: var(--text); direction: ltr; font-variant-numeric: tabular-nums; }
.field.two { flex-direction: row; gap: 10px; }
.field.two label { flex: 1; display: flex; flex-direction: column; gap: 4px; color: var(--muted); direction: ltr; }
.panel input[type=number], dialog input[type=text] {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  padding: 8px 10px; font: inherit; font-size: 15px; width: 100%;
}
.panel input[type=range] { width: 100%; accent-color: var(--gold); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--muted); }
.progress { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .3s; }
.panel-actions { display: flex; gap: 8px; }
.panel-actions .primary { flex: 1; }
.danger { border-radius: 10px; padding: 9px 18px; border: 1px solid #ff3881; background: #ff388122; color: #ff99aa; font-weight: 700; }

dialog .sub { margin: -6px 0 14px; font-size: 13px; color: var(--muted); max-width: 320px; }
dialog .err { min-height: 18px; margin: 6px 0 0; font-size: 13px; color: #ff99aa; }
/* ---------- accounts ---------- */
dialog.accounts { width: min(420px, calc(100vw - 24px)); }
.acc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.acc-head h2 { margin: 0; }
.acc-total { font-size: 13px; color: var(--muted); font-weight: 500; margin-inline-start: 6px; direction: ltr; display: inline-block; }
.acc-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; margin-bottom: 12px; }
.acc { display: flex; align-items: center; gap: 6px; }
.acc-main {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 9px 12px; text-align: right;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.acc-main:hover { border-color: #4a4170; }
.acc.active .acc-main { border-color: var(--gold); background: #ffc83d0f; }
.acc-dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0; }
.acc.active .acc-dot { background: var(--gold); border-color: var(--gold); }
.acc-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-meter { width: 70px; height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; flex-shrink: 0; }
.acc-meter i { display: block; height: 100%; background: var(--gold); transition: width .25s; }
.acc-count { width: 42px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; text-align: left; }
.acc.banned .acc-name { text-decoration: line-through; color: var(--muted); }
.acc.banned .acc-count { color: #ff99aa; }
.acc-add { display: flex; gap: 8px; }
.acc-add input { flex: 1; }
.acc-add button:disabled { opacity: .4; cursor: not-allowed; }
.workers { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.link { background: none; border: 0; padding: 0; color: var(--gold); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; flex-shrink: 0; }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .brand p { display: none; }
  .brand h1 { font-size: 20px; }
  .dock { flex-wrap: wrap; gap: 10px; padding: 8px 10px; }
  .palette { order: 3; flex-basis: 100%; grid-template-columns: repeat(12, 1fr); grid-auto-rows: 24px; gap: 4px; }
  .pool { order: 1; }
  .picker { order: 2; margin-inline-start: auto; }
  .tools { top: 12px; transform: none; }
  .toast { bottom: 150px; }
  .panel { top: auto; bottom: 10px; right: 10px; left: 10px; width: auto; max-height: 60%; }
  .pixel-info { top: 10px; bottom: auto; left: auto; right: 10px; }
}

/* ---------- free colors ---------- */
.colors { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.colors .palette { flex: none; width: 100%; }
.recent { display: flex; gap: 5px; align-items: center; }
.recent::before { content: 'אחרונים'; font-size: 11px; color: var(--muted); margin-inline-end: 4px; }
.recent .swatch { width: 22px; height: 18px; }
.current { position: relative; cursor: pointer; overflow: hidden; }
.current input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.current::after {
  content: ''; position: absolute; right: -2px; bottom: -2px; width: 16px; height: 16px; border-radius: 50%;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); box-shadow: 0 0 0 2px var(--panel); pointer-events: none;
}
.current { overflow: visible; }
.hex {
  display: flex; align-items: center; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 8px; height: 40px; direction: ltr; font-variant-numeric: tabular-nums;
}
.hex span { color: var(--muted); }
.hex input {
  width: 66px; background: none; border: 0; color: var(--text); font: inherit; font-size: 15px; text-transform: uppercase;
  letter-spacing: .5px; outline: none;
}
.hex:focus-within { border-color: var(--gold); }
.hex input.bad { color: #ff99aa; }
.pi-hex { direction: ltr; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
@media (max-width: 820px) {
  .colors { order: 3; flex-basis: 100%; }
  .hex { height: 36px; }
}
