/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme Variables (Neon Night default) ────────────── */
:root {
  --bg:        #040d1f;
  --surf:      #080f26;
  --surf2:     #0c1530;
  --surf3:     #111e3d;
  --surf4:     #16264a;
  --border:    rgba(0,229,255,0.09);
  --border2:   rgba(0,229,255,0.18);
  --text:      #d0e8ff;
  --muted:     #3a5070;
  --muted2:    #6080a0;
  --neon:      #00e5ff;
  --neon2:     #7c4dff;
  --nglow:     rgba(0,229,255,0.28);
  --danger:    #ff2d6b;
  --green:     #00ff88;
  --yellow:    #ffd60a;
  --canvas-bg: #030b18;
  --r:         8px;
  --shadow:    0 10px 50px rgba(0,0,0,.8);
  --ir-w:      62px;
  --sp-w:      242px;
  --tb-w:      56px;
  --topbar-h:  50px;
  --opts-h:    46px;
}

/* ── Base ────────────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}

/* scanline overlay */
body.scanlines::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(transparent 0px,transparent 3px,rgba(0,0,0,0.04) 3px,rgba(0,0,0,0.04) 4px);
  pointer-events: none;
  z-index: 9999;
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surf);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; gap: 8px; flex-shrink: 0; z-index: 200;
}
.tb-l, .tb-r { display: flex; align-items: center; gap: 6px; }
.tb-sep { width: 1px; height: 20px; background: var(--border2); margin: 0 4px; }

.logo {
  font-family: 'Space Mono', monospace;
  font-size: 15px; font-weight: 700; white-space: nowrap; user-select: none;
}
.logo-b   { color: var(--muted2); }
.logo-w   { color: var(--text); }
.logo-dot { color: var(--neon); text-shadow: 0 0 10px var(--neon); }

.board-title {
  background: transparent; border: none;
  border-bottom: 1.5px solid transparent;
  color: var(--muted2); font-size: 12px; font-family: 'Space Mono', monospace;
  padding: 3px 6px; width: 180px; transition: all .18s; border-radius: 4px;
}
.board-title:hover { background: var(--surf3); color: var(--text); border-radius: 5px; }
.board-title:focus { outline: none; background: var(--surf3); border-bottom-color: var(--neon); color: var(--text); border-radius: 5px; }

.tb-icon {
  width: 30px; height: 30px; border: none; background: transparent;
  color: var(--muted2); border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all .14s;
}
.tb-icon:hover  { background: var(--surf3); color: var(--text); }
.tb-icon.active { color: var(--neon); text-shadow: 0 0 8px var(--neon); }

.tb-ghost {
  padding: 5px 12px; border: 1px solid var(--border2);
  background: transparent; color: var(--muted2); border-radius: 6px;
  cursor: pointer; font-size: 12px; transition: all .14s;
}
.tb-ghost:hover { background: var(--surf3); color: var(--text); border-color: var(--neon); }

.tb-neon {
  padding: 5px 14px; border: 1px solid var(--neon);
  background: rgba(0,229,255,0.08); color: var(--neon); border-radius: 6px;
  cursor: pointer; font-size: 12px; font-weight: 600; transition: all .15s;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 0 12px rgba(0,229,255,0.15), inset 0 0 12px rgba(0,229,255,0.05);
}
.tb-neon:hover {
  background: rgba(0,229,255,0.18);
  box-shadow: 0 0 20px var(--nglow), inset 0 0 16px rgba(0,229,255,0.1);
  transform: translateY(-1px);
}

/* ── Options Bar ─────────────────────────────────────── */
.opts-bar {
  height: var(--opts-h);
  background: var(--surf);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 12px 0 calc(var(--tb-w) + 14px);
  gap: 14px; flex-shrink: 0; z-index: 90; overflow-x: auto;
}
.opts-bar.hidden { display: none; }

.opt-sep  { width: 1px; height: 18px; background: var(--border2); flex-shrink: 0; }
.opt-g    { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.opt-lbl  { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; white-space: nowrap; }

/* Palette */
.pal      { display: flex; gap: 4px; align-items: center; }
.pal-sw   { width: 17px; height: 17px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform .14s; flex-shrink: 0; }
.pal-sw:hover { transform: scale(1.3); }
.pal-sw.sel   { border-color: #fff; box-shadow: 0 0 0 2px var(--neon), 0 0 8px var(--nglow); }
.pal-custom   { width: 17px; height: 17px; border-radius: 50%; border: 1.5px dashed var(--border2); cursor: pointer; overflow: hidden; background: conic-gradient(red,yellow,lime,cyan,blue,magenta,red); flex-shrink: 0; position: relative; }
.pal-custom input { position: absolute; inset: -4px; opacity: 0; cursor: pointer; width: 200%; height: 200%; }

/* Sliders */
.sw-range, .op-range, .dash-range { accent-color: var(--neon); cursor: pointer; }
.sw-range  { width: 70px; }
.op-range  { width: 70px; }
.dash-range{ width: 50px; }
.sw-val, .op-val, .dash-val { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sw-val  { width: 24px; }
.op-val  { width: 28px; }
.dash-val{ width: 22px; }

/* Line style */
.ls-grp { display: flex; gap: 2px; }
.ls-btn { height: 25px; padding: 0 7px; border: 1px solid var(--border2); background: transparent; color: var(--muted2); border-radius: 5px; cursor: pointer; font-size: 12px; transition: all .12s; white-space: nowrap; }
.ls-btn:hover { background: var(--surf3); color: var(--text); }
.ls-btn.sel   { border-color: var(--neon); background: rgba(0,229,255,0.1); color: var(--neon); box-shadow: 0 0 8px rgba(0,229,255,0.15); }

/* Dash sub */
.dash-sub { display: flex; align-items: center; gap: 5px; }

/* Cap / fill / font */
.cap-grp { display: flex; gap: 2px; }
.cap-btn { height: 25px; padding: 0 7px; border: 1px solid var(--border2); background: transparent; color: var(--muted2); border-radius: 5px; cursor: pointer; font-size: 11px; transition: all .12s; }
.cap-btn:hover { background: var(--surf3); color: var(--text); }
.cap-btn.sel   { border-color: var(--neon); background: rgba(0,229,255,0.1); color: var(--neon); }

.fill-tog { height: 25px; padding: 0 9px; border: 1px solid var(--border2); background: transparent; color: var(--muted2); border-radius: 5px; cursor: pointer; font-size: 11px; transition: all .12s; }
.fill-tog:hover{ background: var(--surf3); }
.fill-tog.on   { border-color: var(--neon); background: rgba(0,229,255,0.1); color: var(--neon); }

.font-sz  { width: 42px; background: var(--surf3); border: 1px solid var(--border2); color: var(--text); border-radius: 5px; padding: 3px 5px; font-size: 12px; text-align: center; }
.font-sz:focus { outline: none; border-color: var(--neon); }
.font-fam { background: var(--surf3); border: 1px solid var(--border2); color: var(--text); border-radius: 5px; padding: 3px 6px; font-size: 11px; cursor: pointer; }
.font-fam:focus { outline: none; border-color: var(--neon); }
.font-sty { width: 25px; height: 25px; border: 1px solid var(--border2); background: transparent; color: var(--muted2); border-radius: 5px; cursor: pointer; font-size: 12px; transition: all .12s; }
.font-sty:hover { background: var(--surf3); color: var(--text); }
.font-sty.on    { border-color: var(--neon); background: rgba(0,229,255,0.1); color: var(--neon); }

/* ── App Body ────────────────────────────────────────── */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Icon Rail ───────────────────────────────────────── */
.ir {
  width: var(--ir-w); background: var(--surf); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0; flex-shrink: 0; z-index: 150;
  justify-content: space-between;
}
.ir-top, .ir-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.ir-btn {
  width: 44px; height: 44px; border: none; background: transparent;
  color: var(--muted2); border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all .15s; position: relative;
}
/* Discord-style pill indicator */
.ir-btn::before {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 0; border-radius: 2px; background: var(--neon);
  transition: height .2s; box-shadow: 0 0 8px var(--neon);
}
.ir-btn:hover { background: var(--surf3); color: var(--text); }
.ir-btn:hover::before { height: 14px; }
.ir-btn.active { background: rgba(0,229,255,0.12); color: var(--neon); }
.ir-btn.active::before { height: 32px; }

.ir-premium { color: #ffd60a; }
.ir-premium:hover { background: rgba(255,214,10,0.12); color: #ffd60a; }
.ir-premium.active { background: rgba(255,214,10,0.12); color: #ffd60a; }
.ir-premium.active::before { background: #ffd60a; box-shadow: 0 0 8px #ffd60a; }

.ir-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--neon), var(--neon2));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--bg); cursor: pointer;
  margin-top: 6px; transition: all .15s;
  box-shadow: 0 0 12px var(--nglow);
}
.ir-avatar:hover { transform: scale(1.08); }

/* ── Side Panel ──────────────────────────────────────── */
.sp {
  width: var(--sp-w); min-width: var(--sp-w);
  background: var(--surf); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .22s cubic-bezier(.4,0,.2,1), min-width .22s cubic-bezier(.4,0,.2,1);
  flex-shrink: 0; z-index: 100;
}
.sp.closed { width: 0; min-width: 0; }

.sp-panel { display: none; flex-direction: column; height: 100%; overflow-y: auto; padding: 0 10px 16px; }
.sp-panel.active { display: flex; }

.sp-head {
  font-family: 'Space Mono', monospace;
  font-size: 12px; font-weight: 700; color: var(--neon);
  text-transform: lowercase; letter-spacing: .3px;
  padding: 14px 4px 10px; flex-shrink: 0;
  text-shadow: 0 0 12px var(--neon);
}
.plus-tag {
  background: linear-gradient(90deg, #ffd60a, #ff6b35);
  color: #000; font-size: 8px; padding: 1px 5px;
  border-radius: 4px; margin-left: 5px; font-family: 'Inter', sans-serif;
  font-weight: 700; vertical-align: middle; letter-spacing: 0;
}

.sp-new-btn {
  width: 100%; padding: 8px; border: 1px dashed var(--border2);
  background: transparent; color: var(--muted2); border-radius: var(--r);
  cursor: pointer; font-size: 12px; display: flex; align-items: center;
  justify-content: center; gap: 7px; transition: all .14s; font-weight: 500; flex-shrink: 0;
}
.sp-new-btn:hover { border-color: var(--neon); color: var(--neon); background: rgba(0,229,255,0.05); box-shadow: 0 0 12px rgba(0,229,255,0.1); }

.sp-section-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; padding: 10px 4px 4px; flex-shrink: 0; }

/* Board list items */
.sp-list { display: flex; flex-direction: column; gap: 4px; }
.sp-item {
  border: 1px solid var(--border); background: var(--surf2);
  border-radius: var(--r); overflow: hidden; cursor: pointer;
  transition: all .14s; display: flex; align-items: stretch; flex-shrink: 0;
}
.sp-item:hover { border-color: var(--neon); background: rgba(0,229,255,0.05); box-shadow: 0 0 12px rgba(0,229,255,0.08); }
.sp-thumb { width: 52px; background: var(--surf3); flex-shrink: 0; display: flex; align-items: center; justify-content: center; min-height: 40px; }
.sp-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sp-thumb .no-t { font-size: 18px; }
.sp-info { flex: 1; padding: 6px 8px; min-width: 0; }
.sp-iname { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-idate { font-size: 10px; color: var(--muted); margin-top: 1px; }
.sp-del {
  width: 26px; border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 10px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; transition: all .13s;
}
.sp-del:hover { color: var(--danger); background: rgba(255,45,107,0.12); }

.sp-empty { text-align: center; color: var(--muted); font-size: 11px; padding: 24px 10px; line-height: 1.8; }
.sp-empty i { font-size: 24px; display: block; margin-bottom: 8px; opacity: .3; }
.sp-empty-sm { font-size: 11px; color: var(--muted); padding: 8px 4px; }

/* ── Theme Cards ─────────────────────────────────────── */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; flex-shrink: 0; }

.theme-card {
  border: 1px solid var(--border2); border-radius: 10px; overflow: hidden;
  cursor: pointer; transition: all .15s; position: relative;
}
.theme-card:hover { transform: translateY(-2px); border-color: var(--neon); box-shadow: 0 0 14px rgba(0,229,255,0.15); }
.theme-card.active-theme { border-color: var(--neon) !important; box-shadow: 0 0 16px var(--nglow) !important; }

.tc-preview-strip {
  height: 42px; display: flex; align-items: stretch; overflow: hidden;
}
.tcp-ui   { width: 28%; }
.tcp-main { flex: 1; }
.tc-card-info { padding: 7px 9px; background: var(--surf2); }
.tc-card-name { font-size: 11px; font-weight: 700; color: var(--text); }
.tc-card-tag  { font-size: 9px; color: var(--muted); margin-top: 1px; }
.active-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--neon); color: var(--bg); font-size: 8px; font-weight: 700;
  padding: 1px 5px; border-radius: 4px; box-shadow: 0 0 8px var(--nglow);
}

.sp-create-theme-btn {
  width: 100%; margin-top: 12px; padding: 9px; border: 1px solid var(--border2);
  background: transparent; color: var(--muted2); border-radius: var(--r);
  cursor: pointer; font-size: 12px; display: flex; align-items: center;
  justify-content: center; gap: 7px; transition: all .14s; flex-shrink: 0;
}
.sp-create-theme-btn:hover { border-color: var(--neon2); color: var(--neon2); background: rgba(124,77,255,0.08); }

/* ── Premium Panel ───────────────────────────────────── */
.premium-hero { text-align: center; padding: 16px 0 12px; flex-shrink: 0; }
.ph-crown { font-size: 36px; line-height: 1; }
.ph-title { font-family: 'Space Mono', monospace; font-size: 16px; font-weight: 700; color: #ffd60a; text-shadow: 0 0 14px #ffd60a; margin-top: 6px; }
.ph-sub   { font-size: 11px; color: var(--muted2); margin-top: 4px; }

.pricing-row { display: flex; gap: 8px; flex-shrink: 0; }
.pricing-card {
  flex: 1; border: 1px solid var(--border2); border-radius: 10px;
  padding: 12px 10px; background: var(--surf2);
}
.pricing-card.active-plan {
  border-color: #ffd60a;
  box-shadow: 0 0 16px rgba(255,214,10,0.2);
  position: relative;
}
.pc-badge {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(90deg, #ffd60a, #ff6b35);
  color: #000; font-size: 8px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
}
.pc-name  { font-size: 11px; font-weight: 700; color: var(--muted2); margin-bottom: 4px; }
.pc-price { font-family: 'Space Mono', monospace; font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.pc-price span { font-size: 11px; color: var(--muted); }
.pc-list  { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.pc-list li { font-size: 10px; display: flex; align-items: center; gap: 5px; }
.pc-list li.yes { color: var(--text); }
.pc-list li.no  { color: var(--muted); }
.pc-list li.yes i { color: var(--green); font-size: 9px; }
.pc-list li.no  i { color: var(--muted); font-size: 9px; }
.pc-cta {
  width: 100%; margin-top: 12px; padding: 7px; border: 1px solid #ffd60a;
  background: rgba(255,214,10,0.1); color: #ffd60a; border-radius: 7px;
  cursor: pointer; font-size: 11px; font-weight: 700; transition: all .15s;
  box-shadow: 0 0 10px rgba(255,214,10,0.15);
}
.pc-cta:hover { background: rgba(255,214,10,0.2); box-shadow: 0 0 18px rgba(255,214,10,0.25); }

.donate-strip {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; border-top: 1px solid var(--border); margin-top: 12px;
  flex-shrink: 0; gap: 8px;
}
.donate-strip span { font-size: 11px; color: var(--muted); }
.donate-pill {
  padding: 5px 12px; background: linear-gradient(90deg, #f7b731, #f0932b);
  border: none; color: #1a1000; border-radius: 20px; font-size: 11px; font-weight: 700;
  cursor: pointer; transition: all .15s; box-shadow: 0 2px 8px rgba(247,183,49,.3);
  white-space: nowrap;
}
.donate-pill:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(247,183,49,.4); }

/* ── Settings Panel ──────────────────────────────────── */
.profile-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; flex-shrink: 0; }
.pr-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--neon), var(--neon2)); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: var(--bg); flex-shrink: 0; box-shadow: 0 0 12px var(--nglow); }
.pr-info { min-width: 0; }
.pr-name { font-size: 13px; font-weight: 600; outline: none; cursor: text; color: var(--text); border-bottom: 1px solid transparent; transition: border-color .15s; }
.pr-name:focus { border-bottom-color: var(--neon); }
.pr-plan { font-size: 10px; color: var(--muted); margin-top: 2px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 12px; flex-shrink: 0; }
.setting-row input[type="color"] { width: 28px; height: 26px; border: 1px solid var(--border2); border-radius: 5px; cursor: pointer; background: none; padding: 2px; }

.tog { position: relative; display: inline-block; width: 34px; height: 18px; cursor: pointer; }
.tog input { opacity: 0; width: 0; height: 0; }
.tog-t { position: absolute; inset: 0; background: var(--surf3); border-radius: 10px; transition: background .2s; }
.tog input:checked + .tog-t { background: var(--neon); box-shadow: 0 0 8px var(--nglow); }
.tog-k { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog input:checked + .tog-t .tog-k { transform: translateX(16px); }

/* ── Draw Area ───────────────────────────────────────── */
.draw-area { display: flex; flex: 1; overflow: hidden; }

/* ── Drawing Toolbar ─────────────────────────────────── */
.dtb {
  width: var(--tb-w); background: var(--surf); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0; gap: 1px; flex-shrink: 0; z-index: 50; overflow-y: auto;
}
.dtb-group { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 100%; padding: 0 5px; }
.dtb-sep   { width: 26px; height: 1px; background: var(--border); margin: 4px 0; flex-shrink: 0; }

.dtb-btn {
  width: 44px; height: 44px; border: none; background: transparent;
  color: var(--muted2); border-radius: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 14px; transition: all .14s; flex-shrink: 0;
}
.dtb-btn:hover  { background: var(--surf3); color: var(--text); }
.dtb-btn.active {
  background: rgba(0,229,255,0.1); color: var(--neon);
  box-shadow: 0 0 0 1px var(--neon), 0 0 14px rgba(0,229,255,0.2);
}
.dtb-widget {
  height: 48px;
  background: rgba(124,77,255,0.1); color: var(--neon2);
  border: 1.5px dashed rgba(124,77,255,0.4);
}
.dtb-widget:hover { background: rgba(124,77,255,0.2) !important; color: var(--neon2) !important; border-color: var(--neon2) !important; }

/* ── Canvas ──────────────────────────────────────────── */
.canvas-wrap {
  flex: 1; overflow: hidden; position: relative;
  background: var(--canvas-bg);
  background-image: radial-gradient(circle, rgba(0,229,255,0.12) 1px, transparent 0);
  background-size: 28px 28px;
}
.canvas-wrap.grid-dots { background-image: radial-gradient(circle, rgba(0,229,255,0.18) 1px, transparent 0); background-size: 28px 28px; }
.canvas-wrap.grid-lines {
  background-image:
    linear-gradient(rgba(0,229,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,255,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
}
.canvas-wrap.no-grid { background-image: none; }

#whiteboard { position: absolute; top: 0; left: 0; }
.widget-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }

/* Cursor helpers */
.canvas-wrap.cur-cross    #whiteboard { cursor: crosshair !important; }
.canvas-wrap.cur-text     #whiteboard { cursor: text !important; }
.canvas-wrap.cur-grab     #whiteboard { cursor: grab !important; }
.canvas-wrap.cur-grabbing #whiteboard { cursor: grabbing !important; }
.canvas-wrap.cur-cell     #whiteboard { cursor: cell !important; }

/* ── Zoom Bar ────────────────────────────────────────── */
.zoom-bar {
  position: fixed; bottom: 18px; right: 18px;
  background: var(--surf); border: 1px solid var(--border2);
  border-radius: 24px; display: flex; align-items: center;
  gap: 2px; padding: 4px 8px; box-shadow: var(--shadow); z-index: 500;
}
.zoom-bar button { width: 26px; height: 26px; border: none; background: transparent; color: var(--muted2); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 11px; transition: all .14s; }
.zoom-bar button:hover { background: var(--surf3); color: var(--neon); }
#zoom-pct { font-size: 10px; color: var(--muted); width: 36px; text-align: center; font-family: 'Space Mono', monospace; }

/* ── Modals ──────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 700; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-bg.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surf2); border: 1px solid var(--border2);
  border-radius: 14px; padding: 22px; width: 440px; max-width: 95vw;
  box-shadow: 0 0 0 1px var(--border), 0 24px 80px rgba(0,0,0,.8);
  transform: scale(.94) translateY(8px); transition: transform .22s;
}
.modal-bg.open .modal { transform: scale(1) translateY(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; font-family: 'Space Mono', monospace; font-size: 13px; font-weight: 700; color: var(--neon); text-shadow: 0 0 10px var(--neon); }
.modal-x { width: 28px; height: 28px; border: none; background: transparent; color: var(--muted2); border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all .14s; }
.modal-x:hover { background: var(--surf3); color: var(--text); }

/* Widget picker */
.widget-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wcard {
  background: var(--surf3); border: 1px solid var(--border2); border-radius: 10px;
  padding: 16px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all .15s; color: var(--muted);
}
.wcard:hover { border-color: var(--neon); background: rgba(0,229,255,0.06); color: var(--text); transform: translateY(-2px); box-shadow: 0 0 14px rgba(0,229,255,0.1); }
.wc-icon { font-size: 26px; }
.wc-name { font-size: 11px; font-weight: 700; color: var(--text); }

/* Theme Creator */
.tc-body { display: flex; flex-direction: column; gap: 14px; }
.tc-row  { display: flex; flex-direction: column; gap: 5px; }
.tc-lbl  { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.tc-input { background: var(--surf3); border: 1px solid var(--border2); color: var(--text); border-radius: 7px; padding: 8px 12px; font-size: 13px; width: 100%; outline: none; font-family: 'Space Mono', monospace; }
.tc-input:focus { border-color: var(--neon); box-shadow: 0 0 10px rgba(0,229,255,0.12); }

.tc-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tc-color-row { display: flex; flex-direction: column; gap: 4px; }
.tc-color-row label { font-size: 10px; color: var(--muted); }
.tc-pick { display: flex; align-items: center; gap: 6px; }
.tc-pick input[type="color"] { width: 32px; height: 28px; border: 1px solid var(--border2); border-radius: 5px; cursor: pointer; background: none; padding: 2px; flex-shrink: 0; }
.tc-hex { flex: 1; background: var(--surf3); border: 1px solid var(--border2); color: var(--text); border-radius: 5px; padding: 4px 8px; font-size: 11px; font-family: 'Space Mono', monospace; outline: none; }
.tc-hex:focus { border-color: var(--neon); }

.tc-preview-wrap { }
.tc-plbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.tc-preview {
  height: 70px; border-radius: 8px; overflow: hidden; display: flex;
  border: 1px solid var(--border2);
}
.tcp-rail   { width: 24px; flex-shrink: 0; }
.tcp-panel  { width: 70px; flex-shrink: 0; }
.tcp-canvas { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.tcp-line   { position: absolute; border-radius: 2px; }
.tcp-l1 { width: 50px; height: 2px; top: 25px; left: 20px; transform: rotate(-15deg); }
.tcp-l2 { width: 35px; height: 2px; top: 40px; left: 30px; transform: rotate(10deg); }
.tcp-dot { width: 10px; height: 10px; border-radius: 50%; }

.tc-footer { display: flex; gap: 8px; justify-content: flex-end; }
.tc-cancel { padding: 8px 16px; border: 1px solid var(--border2); background: transparent; color: var(--muted2); border-radius: 7px; cursor: pointer; font-size: 12px; transition: all .14s; }
.tc-cancel:hover { background: var(--surf3); color: var(--text); }
.tc-save { padding: 8px 18px; border: 1px solid var(--neon2); background: rgba(124,77,255,0.15); color: var(--neon2); border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 600; transition: all .14s; display: flex; align-items: center; gap: 6px; }
.tc-save:hover { background: rgba(124,77,255,0.3); box-shadow: 0 0 14px rgba(124,77,255,0.3); }

/* ── Floating Widgets ────────────────────────────────── */
.fw {
  position: absolute; background: var(--surf2); border: 1px solid var(--border2);
  border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,.7), 0 0 0 1px var(--border);
  overflow: hidden; pointer-events: all; min-width: 200px; user-select: none;
}
.fw-head { background: var(--surf); padding: 7px 10px; display: flex; align-items: center; justify-content: space-between; cursor: move; border-bottom: 1px solid var(--border); gap: 8px; }
.fw-title { font-size: 9px; font-weight: 700; color: var(--neon); text-transform: uppercase; letter-spacing: .8px; font-family: 'Space Mono', monospace; text-shadow: 0 0 8px var(--neon); }
.fw-x { width: 18px; height: 18px; border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 10px; transition: all .13s; }
.fw-x:hover { background: rgba(255,45,107,0.2); color: var(--danger); }
.fw-body { padding: 10px; }

/* Calculator */
.calc-screen { background: var(--bg); border-radius: 6px; padding: 8px 12px; text-align: right; margin-bottom: 8px; border: 1px solid var(--border); }
.calc-expr { font-size: 10px; color: var(--muted); min-height: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; font-family: 'Space Mono', monospace; }
.calc-val  { font-size: 24px; font-weight: 300; font-family: 'Space Mono', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--neon); text-shadow: 0 0 10px var(--nglow); }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cb { height: 38px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all .1s; color: var(--text); }
.cb:active { transform: scale(.91); }
.cb.num  { background: var(--surf3); }
.cb.num:hover  { background: var(--surf4); }
.cb.op   { background: rgba(0,229,255,0.1); color: var(--neon); }
.cb.op:hover   { background: rgba(0,229,255,0.2); }
.cb.eq   { background: rgba(0,229,255,0.15); color: var(--neon); border: 1px solid var(--neon); box-shadow: 0 0 10px rgba(0,229,255,0.2); }
.cb.eq:hover   { background: rgba(0,229,255,0.25); }
.cb.clr  { background: rgba(255,45,107,0.15); color: var(--danger); }
.cb.clr:hover  { background: rgba(255,45,107,0.28); }
.cb.span2 { grid-column: span 2; }

/* Chart */
.chart-controls { padding: 8px 10px; display: flex; gap: 5px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chart-type-btn { padding: 3px 9px; border: 1px solid var(--border2); background: transparent; color: var(--muted2); border-radius: 5px; cursor: pointer; font-size: 11px; transition: all .13s; }
.chart-type-btn.active { border-color: var(--neon); background: rgba(0,229,255,0.1); color: var(--neon); }
.chart-canvas-box { padding: 10px; width: 320px; height: 210px; }

/* Timer */
.timer-disp { font-size: 30px; font-weight: 400; text-align: center; padding: 10px 0 6px; letter-spacing: 4px; font-variant-numeric: tabular-nums; font-family: 'Space Mono', monospace; color: var(--neon); text-shadow: 0 0 14px var(--nglow); }
.timer-btns { display: flex; gap: 7px; justify-content: center; padding-bottom: 4px; }
.t-btn { padding: 5px 15px; border: 1px solid var(--border2); background: transparent; color: var(--muted2); border-radius: 6px; cursor: pointer; font-size: 12px; transition: all .13s; }
.t-btn:hover { background: var(--surf3); color: var(--text); }
.t-btn.go   { background: rgba(0,255,136,0.08); border-color: var(--green); color: var(--green); }
.t-btn.stop { background: rgba(255,45,107,0.08); border-color: var(--danger); color: var(--danger); }

/* Table */
.table-scroll { overflow: auto; max-height: 200px; }
.fw-table { border-collapse: collapse; width: 100%; font-size: 11px; }
.fw-table th, .fw-table td { border: 1px solid var(--border2); padding: 5px 9px; text-align: left; white-space: nowrap; }
.fw-table th { background: var(--bg); color: var(--neon); font-weight: 700; font-size: 10px; font-family: 'Space Mono', monospace; letter-spacing: .4px; }
.fw-table td { background: var(--surf2); }
.fw-table td:focus { outline: none; background: rgba(0,229,255,0.06); }

/* Sticky */
.fw.sticky { background: #1a1400; border-color: rgba(255,214,10,0.4); box-shadow: 0 0 20px rgba(255,214,10,0.1); }
.fw.sticky .fw-head { background: rgba(255,214,10,0.08); border-bottom-color: rgba(255,214,10,0.15); }
.fw.sticky .fw-title { color: #ffd60a; text-shadow: 0 0 8px #ffd60a; }
.fw.sticky .fw-x { color: rgba(255,214,10,0.5); }
.fw.sticky .fw-x:hover { background: rgba(255,45,107,0.2); color: var(--danger); }
.fw.sticky textarea { width: 100%; min-height: 110px; background: transparent; border: none; resize: none; font-size: 13px; color: #ffe080; font-family: inherit; line-height: 1.6; outline: none; }

/* Image */
.img-drop { width: 240px; height: 120px; border: 2px dashed var(--border2); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; cursor: pointer; color: var(--muted); font-size: 12px; transition: all .14s; }
.img-drop:hover { border-color: var(--neon); color: var(--neon); box-shadow: 0 0 14px rgba(0,229,255,0.1); }
.img-drop i { font-size: 24px; }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 62px; right: 18px;
  background: var(--surf2); border: 1px solid var(--neon);
  color: var(--neon); padding: 7px 16px; border-radius: 8px; font-size: 12px;
  box-shadow: 0 0 16px var(--nglow); z-index: 999;
  opacity: 0; transform: translateY(6px); transition: all .22s; pointer-events: none;
  font-family: 'Space Mono', monospace;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon); box-shadow: 0 0 6px var(--nglow); }
