/* PHYSICS LAB - level editor chrome (loads after style.css) */

.is-editor .hud { gap: 8px; padding: 0 10px; }
.is-editor .iconbtn { flex: 0 0 auto; text-decoration: none; }
.iconbtn:disabled { opacity: 0.35; cursor: default; }

.ed-title {
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 4px 6px;
  border-radius: 10px;
  cursor: pointer;
}
.ed-title:hover { background: rgba(255, 255, 255, 0.04); }
.ed-title__kicker {
  font: 800 9px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.22em;
  color: var(--accent);
}
.ed-title__name {
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#editor {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---------------- floating context bar ---------------- */
.ctxbar {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(14, 22, 34, 0.94);
  border: 1px solid rgba(63, 224, 207, 0.28);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.15s;
  will-change: transform;
}
.ctxbar[hidden] { display: none; }
.ctxbar--tight .ctxbar__kind { display: none; }
.ctxbar.is-dragging { opacity: 0; pointer-events: none; }
.ctxbar__kind {
  padding: 0 8px 0 10px;
  font: 700 10px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}
.ctxbar__sep { width: 1px; height: 22px; margin: 0 3px; background: rgba(255, 255, 255, 0.12); }
.ctxbar__val {
  min-width: 34px;
  text-align: center;
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text);
}
.ctxbtn {
  appearance: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.ctxbtn:hover { background: rgba(63, 224, 207, 0.12); color: var(--accent); }
.ctxbtn:active { transform: scale(0.92); }
.ctxbtn[data-act="del"] { color: #ff8da0; }
.ctxbtn--text {
  width: auto;
  min-width: 44px;
  padding: 0 6px;
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
}

/* ---------------- bottom bar ---------------- */
.edbar {
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  padding: 8px 10px 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(0deg, var(--panel-2), var(--panel));
}
.tools {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.tools::-webkit-scrollbar { display: none; }
.tools.is-more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
.tools.is-back { -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px); mask-image: linear-gradient(90deg, transparent, #000 40px); }
.tools.is-back.is-more { -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
.tool {
  appearance: none;
  flex: 1 0 58px;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 4px 2px;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
}
.tool__icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.tool:hover .tool__icon { border-color: var(--line); background: rgba(63, 224, 207, 0.1); }
.tool:active .tool__icon { transform: scale(0.92); }
.tool--alt .tool__icon { color: var(--accent); border-color: rgba(63, 224, 207, 0.3); }
@media (min-width: 640px) { .tool { flex: 1 1 0; min-width: 52px; } }
.tool__label {
  white-space: nowrap;
  font: 600 10px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.edbar__row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: stretch;
}
.edbar__row .btn { padding: 12px 16px; font-size: 13px; letter-spacing: 0.12em; }
/* phones: slimmer buttons leave the status chip room for a translated line */
@media (max-width: 420px) {
  .edbar__row .btn { padding: 12px 13px; letter-spacing: 0.08em; }
}
.btn.is-locked { opacity: 0.55; }

.vstate {
  appearance: none;
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 3px;
  text-align: left;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
}
.vstate b {
  font: 800 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.08em;
  color: #ffc15a;
}
.vstate span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vstate--ok { border-color: rgba(110, 231, 168, 0.4); background: rgba(110, 231, 168, 0.07); }
.vstate--ok b { color: var(--success); }
.vstate--bad { border-color: rgba(255, 84, 112, 0.35); background: rgba(255, 84, 112, 0.06); }
.vstate--bad b { color: var(--danger); }

/* ---------------- panels ---------------- */
/* the panel scrolls inside the stage instead of running under the tool bar */
.is-editor .overlay { grid-template-rows: minmax(0, 1fr); padding: 12px; }
.overlay__card--wide { width: min(400px, 100%); max-height: 100%; min-height: 0; display: flex; align-self: center; }
.panel {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  background: linear-gradient(180deg, rgba(23, 34, 50, 0.98), rgba(14, 22, 34, 0.98));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 16px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: pop 0.24s cubic-bezier(0.2, 1.3, 0.5, 1) both;
}
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel__head h2 { margin: 0; font-size: 17px; }
.panel__head h2 em {
  font: 600 12px/1 ui-monospace, "SF Mono", Menlo, monospace;
  font-style: normal;
  color: var(--accent);
  margin-left: 6px;
}
.panel__head .iconbtn { font-size: 20px; line-height: 1; }
.panel__sub {
  margin: 18px 0 8px;
  font: 700 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel__note { margin: 8px 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text); }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.field > span b { color: var(--accent); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.field input:not([type]),
.field input[type="text"],
.field textarea,
.field select,
.linkbox input {
  width: 100%;
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 11px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.field textarea { resize: none; }
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63, 224, 207, 0.15); }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 2px 0 6px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.gadlist { display: grid; gap: 6px; margin: 6px 0 4px; }
.gad {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.gad__pic { display: block; width: 72px; height: 44px; }
.gad__txt { display: grid; gap: 2px; min-width: 0; }
.gad__txt b { font-size: 13px; }
.gad__txt span { font-size: 11px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper span { min-width: 16px; text-align: center; font: 700 13px/1 ui-monospace, "SF Mono", Menlo, monospace; }

.liblist { display: grid; gap: 6px; margin-bottom: 4px; }
.lib {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 4px 4px 4px 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.lib--current { border-color: rgba(63, 224, 207, 0.4); }
.lib__open {
  appearance: none;
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: left;
  padding: 8px 10px;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
}
.lib__open b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib__open span { font-size: 11px; color: var(--muted); }
.lib__open .ok { font-style: normal; color: var(--success); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none;
  display: inline-block;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  text-decoration: none;
  cursor: pointer;
}
.chip:hover { border-color: var(--line); color: var(--accent); }
.chips--nets { margin-top: 14px; justify-content: center; }

.linkbox { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 12px 0 4px; }
.linkbox input { font: 12px/1.3 ui-monospace, "SF Mono", Menlo, monospace; }
.linkbox .btn { padding: 10px 14px; font-size: 12px; }
.panel .result__actions a.btn { display: grid; place-items: center; text-decoration: none; padding: 13px 10px; font-size: 13px; letter-spacing: 0.12em; }

@media (max-height: 640px) {
  .tool__icon { width: 36px; height: 36px; }
  .edbar { gap: 6px; padding: 6px 8px 8px; }
  .edbar__row .btn { padding: 10px 14px; }
}
.panel__note a { color: var(--accent); }
.pub { margin-top: 16px; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.pub .ok, .panel__note .ok { color: var(--success); }
.pub a.btn { display: grid; place-items: center; text-decoration: none; padding: 13px 10px; font-size: 13px; letter-spacing: 0.12em; }

/* ---------------- CJK: tracked mono labels ----------------
 * Wide letter-spacing and a monospace fallback make Hangul / kana / hanzi look
 * spaced out ("에 디 터"). In these languages the translated labels keep the mono
 * face for Latin characters but take a proper CJK face and near-zero tracking. */
html:is(:lang(ko), :lang(ja), :lang(zh-Hans), :lang(zh-Hant)) :is(.ed-title__kicker, .ctxbar__kind, .tool__label, .edbar__row .btn:not(#btnTest), .vstate b, .panel__sub, .panel .result__actions a.btn, .pub a.btn) {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, var(--cjk, sans-serif), monospace;
  letter-spacing: 0.01em;
}
