/* Afkalt — macro editor blocks, palette and log (shared by site + panel) */

/* ---------- palette ---------- */
.mpal { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.mpal.is-trash { outline: 2px dashed var(--redstone); outline-offset: -6px; background: rgba(255, 93, 93, 0.08); }
.mpal-search {
  width: 100%; height: 36px; padding: 0 12px;
  background: #0d1220; border: 1px solid var(--line-2); border-radius: 4px;
  font-size: 0.86rem;
}
.mpal-search:focus { outline: none; border-color: var(--diamond); }
.mpal-cats { display: flex; flex-wrap: wrap; gap: 5px; }
.mpal-cat {
  --c: #6b748b;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 7px;
  border: 0; border-radius: 3px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted); font-size: 0.74rem; font-weight: 600;
  transition: background-color 0.15s, color 0.15s;
}
.mpal-cat::before { content: ''; width: 8px; height: 8px; background: var(--c); }
.mpal-cat:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.mpal-cat[aria-pressed='true'] { background: var(--c); color: #fff; }
.mpal-cat[aria-pressed='true']::before { background: rgba(255, 255, 255, 0.85); }
.mpal-list { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; overflow-y: auto; min-height: 0; padding-right: 4px; }
.mpal-title {
  margin: 8px 0 2px; font-family: var(--font-pixel); font-size: 0.66rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim);
}
.mpal-title:first-child { margin-top: 0; }
.mpal-empty { color: var(--dim); font-size: 0.85rem; padding: 8px 0; }

/* ---------- variables: palette tab and {…} picker ---------- */
.mpal-hint { color: var(--dim); font-size: 0.78rem; line-height: 1.4; margin: 0 0 4px; }
.mpal-hint.is-warn { color: var(--gold, #f5c542); }
.mvar-chip {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  padding: 6px 9px;
  border-left: 4px solid #2f9e8f; border-radius: 4px;
  background: rgba(47, 158, 143, 0.12);
  cursor: grab;
}
.mvar-chip:hover, .mvar-chip:focus-visible { background: rgba(47, 158, 143, 0.24); outline: none; }
.mvar-chip code, .mvar-item code { font: 600 0.82rem/1.2 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: var(--text); }
.mvar-hint { font-size: 0.72rem; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.mvar-menu {
  position: fixed; z-index: 1000;
  width: 280px; max-height: 260px; overflow-y: auto;
  padding: 4px;
  background: #151b2e; border: 1px solid var(--line-2); border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.mvar-head { margin: 2px 6px 4px; font-size: 0.7rem; color: var(--dim); }
.mvar-empty { margin: 4px 6px 6px; font-size: 0.8rem; color: var(--muted); }
.mvar-item { display: flex; flex-direction: column; gap: 1px; padding: 5px 8px; border-radius: 4px; cursor: pointer; }
.mvar-item[aria-selected='true'], .mvar-item:hover { background: rgba(47, 158, 143, 0.28); }

/* ---------- workspace ---------- */
.mws {
  position: relative;
  overflow: auto;
  background-color: #10162a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 18px 18px;
}
.mzone { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 30px; }
.mzone-root { min-height: 100%; padding: 16px 16px 60px; }
.mzone-root.is-empty::before {
  content: attr(data-empty);
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center;
  color: var(--dim); font-size: 0.9rem; pointer-events: none;
}
.mb-mouth > .mzone.is-empty { width: 130px; border: 1px dashed rgba(255, 255, 255, 0.28); border-radius: 4px; }
.mzone.is-over:not(.mzone-root) { background: rgba(79, 224, 213, 0.06); border-radius: 4px; }
.mdrop { width: 160px; height: 4px; margin: 1px 0; background: var(--diamond); border-radius: 2px; box-shadow: 0 0 10px var(--diamond); flex-shrink: 0; }

/* ---------- blocks ---------- */
.mb {
  --c: #3d7fe0;
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  max-width: 100%;
  color: #fff;
  font-size: 0.84rem; font-weight: 600; line-height: 1.2;
  cursor: grab;
  user-select: none;
  outline: none;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.28));
  animation: mb-in 0.2s cubic-bezier(.2, 1.4, .4, 1);
}
.mb:active { cursor: grabbing; }
@keyframes mb-in { from { transform: scale(0.9); opacity: 0; } }

.mb-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  min-height: 36px; max-width: 100%;
  padding: 6px 10px;
  background: var(--c);
  border-radius: 6px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: filter 0.12s, box-shadow 0.12s;
}
.mb:hover > .mb-head { filter: brightness(1.07); }
.mb-hat > .mb-head { border-radius: 18px 18px 6px 6px; padding-top: 10px; }
.mb-cap > .mb-head { border-radius: 6px 6px 2px 2px; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.mb-c > .mb-head, .mb-ce > .mb-head { border-bottom-left-radius: 0; }
.mb-else { border-radius: 0 6px 6px 0; min-height: 28px; padding: 4px 10px; }
.mb-mouth { border-left: 14px solid var(--c); padding: 4px 0 4px 6px; min-width: 150px; }
.mb-foot { width: 110px; height: 14px; background: var(--c); border-radius: 0 0 6px 6px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22); }

.mb-txt { white-space: nowrap; }
.mb-input, .mb-pill {
  min-width: 3ch;
  padding: 3px 8px;
  border: 0; border-radius: 10px;
  background: #fff; color: #1b1b1b;
  font: 600 0.8rem/1.2 var(--font-body);
}
.mb-input { outline: none; cursor: text; }
.mb textarea.mb-area {
  display: inline-block; vertical-align: top;
  padding: 4px 8px; border-radius: 8px;
  font: 600 0.8rem/1.35 var(--font-body);
  resize: none; overflow-y: auto; white-space: pre-wrap;
}
.mb-input:focus { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4); }
.mb-pill { display: inline-block; white-space: nowrap; }
.mb-select {
  -webkit-appearance: none; appearance: none;
  max-width: 190px;
  padding: 3px 22px 3px 9px;
  border: 0; border-radius: 10px;
  background: rgba(0, 0, 0, 0.26) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23fff'/%3E%3C/svg%3E") no-repeat right 8px center / 8px;
  color: #fff;
  font: 600 0.8rem/1.2 var(--font-body);
  cursor: pointer;
}
.mb-select:focus { outline: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
.mb-select option { color: #111; background: #fff; }
.mb-cond { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 2px; border-radius: 12px; background: rgba(0, 0, 0, 0.16); }
.mb-cond-arg { display: inline-flex; align-items: center; gap: 5px; }

.mb-tools { display: inline-flex; gap: 3px; margin-left: 4px; opacity: 0; transition: opacity 0.12s; }
.mb-head:hover > .mb-tools, .mb:focus-within > .mb-head > .mb-tools { opacity: 1; }
@media (hover: none) { .mb-tools { opacity: 1; } }
.mb-tool {
  width: 22px; height: 22px;
  border: 0; border-radius: 4px; cursor: pointer;
  background: rgba(0, 0, 0, 0.24); color: #fff;
  font-size: 0.85rem; line-height: 1;
}
.mb-tool:hover { background: rgba(0, 0, 0, 0.45); }

.mb:focus-visible > .mb-head { box-shadow: 0 0 0 2px #fff, inset 0 -3px 0 rgba(0, 0, 0, 0.22); }
.mb.is-dragging { opacity: 0.35; }
.mb.is-running > .mb-head { filter: brightness(1.18); box-shadow: 0 0 0 2px #fff, 0 0 18px var(--c), inset 0 -3px 0 rgba(0, 0, 0, 0.22); }

.mb-preview { animation: none; cursor: grab; }
.mb-preview > .mb-head { min-height: 32px; padding: 5px 9px; font-size: 0.8rem; }
.mb-preview:focus-visible > .mb-head { box-shadow: 0 0 0 2px #fff; }

/* ---------- simple mode (the panel): tips, + Add step, ⋯ menu, checks ---------- */
.mpal-sheet-head { display: none; }
.mpal-target { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 7px 10px; border-radius: 6px; background: rgba(79, 224, 213, 0.1); border: 1px solid rgba(79, 224, 213, 0.3); font-size: 0.8rem; color: var(--text); }
.mpal-target[hidden] { display: none; }
.mpal-target-x { border: 0; background: none; color: var(--diamond); font-size: 0.76rem; cursor: pointer; padding: 0; }
.mpal-target-x:hover { text-decoration: underline; }
.mpal-simple .mpal-list { gap: 10px; }
.mpal-tip { display: block; max-width: 260px; margin: 3px 2px 0; color: var(--dim); font-size: 0.72rem; font-weight: 400; line-height: 1.35; white-space: normal; }
.mpal-adv { display: flex; align-items: flex-start; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.76rem; line-height: 1.35; cursor: pointer; }
.mpal-adv input { margin-top: 2px; accent-color: var(--grass); }

.mzone-add {
  align-self: flex-start;
  padding: 5px 12px; margin-top: 2px;
  border: 1px dashed rgba(255, 255, 255, 0.22); border-radius: 6px;
  background: rgba(255, 255, 255, 0.02); color: var(--dim);
  font: 600 0.76rem/1.2 var(--font-body); cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background-color 0.12s;
}
.mzone-add:hover, .mzone-add:focus-visible { color: var(--text); border-color: var(--diamond); background: rgba(79, 224, 213, 0.08); outline: none; }
.mzone-root > .mzone-add { padding: 9px 16px; font-size: 0.84rem; margin-top: 8px; }
.mzone-root.is-empty > .mzone-add { padding: 16px 26px; font-size: 0.95rem; border-color: rgba(108, 198, 68, 0.5); color: var(--grass); }
.mb-mouth > .mzone.is-empty { min-height: 34px; padding: 3px; }

.mmenu {
  position: fixed; z-index: 1000; min-width: 210px; max-width: 290px; padding: 5px;
  background: #151b2e; border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}
.mmenu-note { margin: 4px 8px 6px; color: var(--dim); font-size: 0.74rem; line-height: 1.4; }
.mmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.mmenu-item { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 5px; background: none; color: var(--text); font: 500 0.86rem/1.2 var(--font-body); text-align: left; cursor: pointer; }
.mmenu-item:hover:not(:disabled), .mmenu-item:focus-visible { background: rgba(255, 255, 255, 0.07); outline: none; }
.mmenu-item:disabled { color: var(--dim); cursor: default; }
.mmenu-item.is-danger { color: #ff8a8a; }
.mb-more { display: inline-grid; place-items: center; width: 26px; }
.mws-simple .mb-tools { opacity: 1; }

.missues { padding: 8px 14px; border-bottom: 1px solid var(--line); background: rgba(108, 198, 68, 0.06); font-size: 0.82rem; }
.missues[hidden] { display: none; }
.missues.has-issues { background: rgba(242, 201, 76, 0.07); }
.missues-ok { color: var(--grass); font-weight: 600; }
.missues-head { color: var(--gold); font-weight: 700; margin-bottom: 4px; }
.missue { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 3px 0; }
.missue-text { flex: 1 1 260px; min-width: 0; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; text-align: left; cursor: pointer; }
.missue-text::before { content: '⚠ '; color: var(--gold); }
.missue-text:hover { color: var(--text); }
.missue-fix { padding: 3px 10px; border: 1px solid rgba(242, 201, 76, 0.45); border-radius: 5px; background: rgba(242, 201, 76, 0.1); color: var(--gold); font: 600 0.76rem/1.2 var(--font-body); cursor: pointer; white-space: nowrap; }
.missue-fix:hover { background: rgba(242, 201, 76, 0.2); }
.mb.has-issue > .mb-head { box-shadow: 0 0 0 2px var(--gold), inset 0 -3px 0 rgba(0, 0, 0, 0.22); }
.mb.is-flash > .mb-head { animation: mb-flash 1.1s ease-out; }
@keyframes mb-flash { 0%, 40% { box-shadow: 0 0 0 3px #fff, 0 0 22px var(--c); } }

/* Phones: the palette becomes a sheet that slides up from the bottom ("+ Add step"). */
@media (max-width: 760px) {
  .mpal-simple {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    height: min(78vh, 640px); padding: 0 14px 14px;
    background: #121829; border-top: 1px solid var(--line-2); border-radius: 16px 16px 0 0;
    box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(105%); transition: transform 0.24s cubic-bezier(.2, .8, .2, 1);
  }
  .mpal-simple.is-picking { transform: none; }
  .mpal-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 2px; position: sticky; top: 0; }
  .mpal-sheet-head strong { font-size: 1rem; }
  .mpal-close { width: 34px; height: 34px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, 0.07); color: var(--text); font-size: 1.3rem; cursor: pointer; }
  .mpal-tip { max-width: none; }
  .mpal-cat { min-height: 34px; }
  .mzone-add { padding: 9px 14px; font-size: 0.84rem; }
  .mb-tools { opacity: 1; }
  .mb-tool { width: 30px; height: 30px; }
  .mb-head { min-height: 40px; }
}

/* ---------- run log ---------- */
.mlog {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
  overflow-y: auto;
}
.mlog-line { white-space: pre-wrap; word-break: break-word; }
.mlog-line time { color: var(--dim); margin-right: 8px; }
.mlog .ok { color: var(--grass); }
.mlog .warn { color: var(--gold); }
.mlog .error { color: var(--redstone); }
.mlog .macro { color: var(--diamond); }
.mlog .logic { color: #93a7ff; }
.mlog .self { color: #b8f5a0; }
.mlog .cmd { color: #cfb3ff; }
.mlog .chat { color: var(--text); }
.mlog .system { color: var(--dim); }
