/* ============================================================
   BLOCKFORGE — style.css
   ============================================================ */

:root {
  --bg: #0e1116;
  --bg2: #11151c;
  --panel: #151a22;
  --panel2: #1a202a;
  --line: #242c38;
  --line2: #2e3845;
  --txt: #e3e9f1;
  --dim: #8b97a8;
  --accent: #5b8cff;
  --c-structure: #53c2f0;
  --c-content: #f08bb8;
  --c-layout: #f2c14e;
  --c-style: #6fd99a;
  --red: #f06a6a;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-color: var(--line2) var(--bg); scrollbar-width: thin; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--txt); font-family: var(--font); font-size: 13px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============ TOP BAR ============ */
header {
  height: 54px; display: flex; align-items: center; gap: 9px; padding: 0 18px;
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; font-size: 15px; }
.logo b { color: var(--accent); }
.tag { color: var(--dim); font-size: 12px; }
.spacer { flex: 1; }
.btn {
  background: var(--panel); border: 1px solid var(--line2); color: var(--txt);
  font-family: var(--font); font-size: 12.5px; font-weight: 500;
  padding: 8px 13px; border-radius: 8px; cursor: pointer; transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel2); border-color: #3a4656; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--dim); }
.btn.quiet:hover { color: var(--red); background: rgba(240,106,106,.08); }

/* ============ LAYOUT ============ */
main {
  display: grid; height: calc(100% - 54px);
  grid-template-columns: 225px minmax(280px, 1fr) 6px var(--pvw, 560px);
  grid-template-rows: minmax(0, 1fr);
}
main.pv-hidden { grid-template-columns: 225px 1fr 0 0; }
main.pv-hidden #resizer, main.pv-hidden #preview-wrap { display: none; }

/* ============ PALETTE ============ */
#palette-wrap {
  background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
#pal-search {
  margin: 12px 12px 6px; background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  font-family: var(--font); font-size: 12.5px; padding: 8px 11px; border-radius: 8px;
  flex-shrink: 0;
}
#pal-search:focus { outline: none; border-color: var(--accent); }
#pal-search::placeholder { color: var(--dim); }
.pal-hint {
  color: var(--dim); font-size: 11px; text-align: center; padding: 2px 8px 10px;
  border-bottom: 1px solid var(--line); margin: 0 12px; flex-shrink: 0;
}

/* ---- Scrollable block list inside palette ---- */
#palette { flex: 1; overflow-y: auto; padding: 10px 12px 30px; min-height: 0; }

/* ---- Block type scroll navigator ---- */
#pal-cat-nav {
  display: flex; gap: 4px; padding: 6px 12px 0; flex-shrink: 0; flex-wrap: wrap;
}
.pal-cat-btn {
  background: none; border: 1px solid var(--line); color: var(--dim);
  font-family: var(--font); font-size: 10px; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; padding: 3px 8px; border-radius: 6px; cursor: pointer;
  transition: background .1s, color .1s, border-color .1s;
  white-space: nowrap;
}
.pal-cat-btn:hover, .pal-cat-btn.active {
  background: var(--panel2); color: var(--txt); border-color: var(--line2);
}
.pal-cat-btn.active { border-color: var(--accent); color: var(--accent); }

.cat { margin-bottom: 14px; }
.cat-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: 1.2px; color: var(--dim);
  text-transform: uppercase; margin: 6px 2px 7px; display: flex; align-items: center; gap: 7px;
}
.cat-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.pal-block {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 11px; margin-bottom: 5px; cursor: grab; user-select: none;
  font-size: 12.5px; font-weight: 500; transition: border-color .12s, background .12s;
}
.pal-block:active { cursor: grabbing; }
.pal-block:hover { background: var(--panel2); border-color: var(--line2); }
.pal-block .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.pal-block .plus { margin-left: auto; color: var(--dim); font-size: 14px; opacity: 0; transition: opacity .12s; }
.pal-block:hover .plus { opacity: 1; }

/* ============ PANEL HEADS ============ */
.panel-head {
  height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 14px; flex: none;
  background: var(--bg2); border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--dim); text-transform: uppercase;
}

/* ============ WORKSPACE ============ */
#workspace-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
#workspace { flex: 1; overflow-y: auto; padding: 16px 18px 90px; background: var(--bg); }
#workspace.drag-over { box-shadow: inset 0 0 0 2px var(--accent); }
.empty-hint {
  border: 1.5px dashed var(--line2); border-radius: 12px; padding: 38px 22px; text-align: center;
  color: var(--dim); font-size: 13px; line-height: 2;
}
.empty-hint b { color: var(--txt); }

.wblock {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; position: relative; overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.wblock:hover { border-color: var(--line2); }
.wblock.dragging { opacity: .3; }
.wblock.flash { box-shadow: 0 0 0 2px var(--accent); }
.wblock.unknown { border-style: dashed; opacity: .7; }
.wb-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: grab; user-select: none; }
.wb-head:active { cursor: grabbing; }
.wb-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.wb-head .name { font-weight: 600; font-size: 12.5px; cursor: pointer; }
.wb-head .caret { color: var(--dim); font-size: 10px; cursor: pointer; transition: transform .15s; }
.wblock.collapsed .caret { transform: rotate(-90deg); }
.wb-head .acts { margin-left: auto; display: flex; gap: 2px; opacity: .35; transition: opacity .12s; }
.wblock:hover .acts, .wb-head:focus-within .acts { opacity: 1; }
.wb-act {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-family: var(--font); font-size: 12px; padding: 3px 6px; border-radius: 5px; line-height: 1;
}
.wb-act:hover { color: var(--txt); background: var(--panel2); }
.wb-act.danger:hover { color: var(--red); background: rgba(240,106,106,.1); }
.wb-act:focus-visible { outline: 1px solid var(--accent); }
.wb-body { padding: 2px 12px 12px; display: flex; flex-wrap: wrap; gap: 10px; }
.wblock.collapsed .wb-body, .wblock.collapsed .cols { display: none; }

.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 110px; }
.field.small { flex: 0 1 auto; min-width: 78px; max-width: 135px; }
.field.wide { flex: 1 1 100%; }
.field label { font-size: 10px; font-weight: 600; letter-spacing: .6px; color: var(--dim); text-transform: uppercase; }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--line); color: var(--txt);
  font-family: var(--font); font-size: 12.5px; padding: 6px 8px; border-radius: 7px; width: 100%;
}
.field textarea { resize: vertical; min-height: 46px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field input[type=color] { width: 100%; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); padding: 2px; cursor: pointer; }
.field input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.range-val { font-size: 10px; color: var(--dim); text-align: right; }

.cols { display: grid; gap: 8px; padding: 0 12px 12px; }
.col-zone {
  border: 1.5px dashed var(--line2); border-radius: 8px; min-height: 52px; padding: 8px;
  background: rgba(0,0,0,.18); transition: border-color .12s, background .12s;
}
.col-zone.drag-over { border-color: var(--accent); background: rgba(91,140,255,.06); }
.col-zone .zone-hint { color: var(--dim); font-size: 11px; text-align: center; padding: 9px 0; }
.col-zone .wblock { margin-bottom: 8px; }
.col-zone .wblock:last-child { margin-bottom: 0; }

.drop-line {
  height: 4px; background: var(--accent); border-radius: 3px; margin: 5px 0;
  box-shadow: 0 0 0 1px rgba(91,140,255,.4); pointer-events: none;
}

/* ============ RESIZER ============ */
#resizer { background: var(--line); cursor: col-resize; position: relative; transition: background .12s; }
#resizer:hover, #resizer.active { background: var(--accent); }

/* ============ PREVIEW ============ */
#preview-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg2); }
#preview-frame-holder { flex: 1; padding: 14px; display: flex; justify-content: center; overflow: auto; }
#preview {
  width: 100%; height: 100%; border: 1px solid var(--line2); border-radius: 10px;
  background: var(--panel); transition: width .25s;
}
#preview.tablet { width: 768px; flex: none; }
#preview.mobile { width: 390px; flex: none; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  background: none; border: none; color: var(--dim); font-family: var(--font); font-size: 11px;
  font-weight: 600; padding: 5px 10px; cursor: pointer; letter-spacing: .4px;
}
.seg button.on { background: var(--panel2); color: var(--txt); }
.ph-act {
  background: none; border: none; color: var(--dim); font-family: var(--font); font-size: 12px;
  cursor: pointer; padding: 4px 8px; border-radius: 6px; font-weight: 600; letter-spacing: .5px;
}
.ph-act:hover { color: var(--txt); background: var(--panel2); }

/* ============ MODAL ============ */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 500;
  display: none; align-items: center; justify-content: center;
}
#modal-overlay.open { display: flex; }
#modal {
  background: var(--panel); border: 1px solid var(--line2); border-radius: 14px;
  width: min(440px, 92vw); padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
#modal h2 { font-size: 15px; margin-bottom: 4px; }
#modal .sub { color: var(--dim); font-size: 12px; margin-bottom: 16px; }
#modal .field { margin-bottom: 12px; }
#modal .row { display: flex; gap: 10px; }
#modal .row .field { flex: 1; }
#modal .modal-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.fav-preview {
  font-size: 22px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; flex: none; align-self: flex-end;
}

/* toast */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(90px);
  background: var(--panel2); border: 1px solid var(--line2); color: var(--txt);
  padding: 10px 20px; border-radius: 9px; font-size: 12.5px; font-weight: 500; z-index: 1000;
  transition: transform .25s; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.warn { border-color: var(--red); color: var(--red); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3c4858; }
