/* wg-editor.css - Wings Editor + 3D viewer (wings.9minecraft.net). Mobile first.
   Light/dark via [data-theme] on an ancestor or prefers-color-scheme. Host page may set --wge-top (sticky header height). */
.wge {
  --wge-bg: #ffffff; --wge-fg: #1b2233; --wge-mut: #5d6880; --wge-card: #f5f8fd; --wge-line: #dbe3f0;
  --wge-acc: #3f5fb8; --wge-acc-fg: #ffffff; --wge-gold: #f0b429; --wge-chip: #ffffff; --wge-chip-on: #e3ecfb;
  --wge-navy: #1b2559; --wge-danger: #c43a3a; --wge-top: 0px; --wge-cur: #3f5fb8;
  --wge-h3d: clamp(260px, 46vh, 400px);
  display: block; position: relative; color: var(--wge-fg); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-width: 0; outline: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wge {
    --wge-bg: #141925; --wge-fg: #e7ecf5; --wge-mut: #9aa6bd; --wge-card: #1b2130; --wge-line: #2d3548;
    --wge-acc: #8fb3ee; --wge-acc-fg: #0e1426; --wge-chip: #20283a; --wge-chip-on: #273a63; --wge-navy: #8fb3ee; --wge-danger: #ff8080;
  }
}
[data-theme="dark"] .wge, .wge[data-theme="dark"] {
  --wge-bg: #141925; --wge-fg: #e7ecf5; --wge-mut: #9aa6bd; --wge-card: #1b2130; --wge-line: #2d3548;
  --wge-acc: #8fb3ee; --wge-acc-fg: #0e1426; --wge-chip: #20283a; --wge-chip-on: #273a63; --wge-navy: #8fb3ee; --wge-danger: #ff8080;
}
.wge *, .wge *::before, .wge *::after { box-sizing: border-box; }
.wge [hidden] { display: none !important; }
.wge button, .wge input, .wge select { font: inherit; color: inherit; }
.wge button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; cursor: pointer; }
.wge :focus-visible { outline: 2px solid var(--wge-gold); outline-offset: 2px; }
.wge.is-drop { outline: 3px dashed var(--wge-acc); outline-offset: 4px; }

/* bar */
.wge-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; flex-wrap: wrap; }
.wge-bar-l { display: flex; gap: 6px; }
.wge-status { flex: 1 1 160px; min-width: 0; font-size: 13px; color: var(--wge-mut); min-height: 1.4em; overflow-wrap: anywhere; }
.wge-status.is-err { color: var(--wge-danger); font-weight: 600; }
.wge-ib {
  width: 40px; height: 40px; flex: 0 0 40px; display: inline-grid; place-items: center; padding: 0; border-radius: 10px;
  border: 1px solid var(--wge-line); background: var(--wge-chip); color: var(--wge-fg);
}
.wge-ib:disabled { opacity: .4; cursor: default; }
.wge-ib.is-on { background: var(--wge-acc); color: var(--wge-acc-fg); border-color: var(--wge-acc); }
.wge-ib-s { width: 34px; height: 34px; flex-basis: 34px; border-radius: 9px; background: rgba(255, 255, 255, .88); color: #1b2559; border-color: rgba(27, 37, 89, .18); }
.wge-ib-s.is-on { background: #1b2559; color: #fff; }

/* segmented + chips */
.wge-seg { display: inline-flex; gap: 4px; flex-wrap: nowrap; align-items: center; }
.wge-seg.wge-wrap { flex-wrap: wrap; }
.wge-chip {
  min-height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--wge-line); background: var(--wge-chip);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.wge-chip.is-on { background: var(--wge-chip-on); border-color: var(--wge-acc); color: var(--wge-fg); box-shadow: inset 0 0 0 1px var(--wge-acc); }
.wge-viewseg .wge-chip { min-height: 32px; padding: 0 10px; }

/* tools */
.wge-tools {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 8px; border: 1px solid var(--wge-line);
  border-radius: 12px; background: var(--wge-card); margin-bottom: 6px;
}
.wge-colwrap { display: inline-flex; align-items: center; gap: 6px; }
.wge-color { position: relative; width: 40px; height: 40px; border-radius: 10px; overflow: hidden; border: 2px solid var(--wge-line); background: var(--wge-cur); cursor: pointer; }
.wge-color input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; border: 0; padding: 0; }
.wge-hex { width: 84px; height: 36px; border-radius: 9px; border: 1px solid var(--wge-line); background: var(--wge-bg); padding: 0 8px; font: 13px ui-monospace, Consolas, monospace; }

/* palette */
.wge-pal { display: grid; gap: 4px; margin-bottom: 8px; }
.wge-sw-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.wge-sw { width: 28px; height: 28px; border-radius: 7px; border: 1px solid rgba(0, 0, 0, .18); padding: 0; flex: 0 0 28px; }
.wge-sw:hover { transform: translateY(-1px); }
.wge-sw-lab { font-size: 12px; color: var(--wge-mut); margin-right: 4px; }
.wge-recent .wge-sw { width: 24px; height: 24px; flex-basis: 24px; }

/* views */
.wge-views { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 10px; }
.wge-views[data-view="3d"] .wge-v2, .wge-views[data-view="2d"] .wge-v3 { display: none; }
.wge-v3, .wge-v2 { position: relative; min-width: 0; }
.wge-stage { height: var(--wge-h3d); border-radius: 14px; overflow: hidden; border: 1px solid var(--wge-line); }
.wge-views[data-view="3d"] .wge-stage { height: clamp(320px, 66vh, 620px); }
.wge-ov { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; pointer-events: none; }
.wge-ov > * { pointer-events: auto; }
.wge-ov2 { top: 8px; }
.wge-mini {
  height: 34px; border-radius: 9px; border: 1px solid rgba(27, 37, 89, .18); background: rgba(255, 255, 255, .9); color: #1b2559;
  padding: 0 8px; font-size: 13px; font-weight: 600;
}
.wge-cbl { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.wge-cbl input { width: 16px; height: 16px; margin: 0; accent-color: #3f5fb8; }
.wge-hint { font-size: 12px; color: var(--wge-mut); margin-top: 4px; }
.wge-uvwrap {
  height: var(--wge-h3d); border-radius: 14px; border: 1px solid var(--wge-line); background: #2a3350;
  display: grid; place-items: center; overflow: hidden; padding: 48px 4px 4px;
}
.wge-uvwrap.is-zoomed { place-items: start; overflow: auto; overscroll-behavior: contain; }
.wge-views[data-view="2d"] .wge-uvwrap { height: clamp(320px, 66vh, 620px); }
.wge-uv { display: block; image-rendering: pixelated; cursor: crosshair; border-radius: 4px; }
.wge[data-tool="picker"] .wge-uv { cursor: copy; }
.wge[data-tool="fill"] .wge-uv { cursor: cell; }

/* tabs + panels */
.wge-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--wge-line); overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; }
.wge-tabs::-webkit-scrollbar { display: none; }
.wge-tab {
  border: 0; background: none; padding: 10px 12px; font-weight: 700; font-size: 14px; color: var(--wge-mut);
  border-bottom: 3px solid transparent; white-space: nowrap; flex: 0 0 auto;
}
.wge-tab[aria-selected="true"] { color: var(--wge-fg); border-bottom-color: var(--wge-gold); }
.wge-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.wge-card { border: 1px solid var(--wge-line); border-radius: 14px; padding: 12px; background: var(--wge-card); min-width: 0; }
.wge-card h3 { margin: 0 0 4px; font-size: 16px; }
.wge-sub { margin: 0 0 10px; font-size: 13px; color: var(--wge-mut); }
.wge-card hr { border: 0; border-top: 1px solid var(--wge-line); margin: 10px 0; }
.wge-row { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; flex-wrap: wrap; min-width: 0; }
.wge-row-l { flex: 1 1 130px; font-size: 13px; font-weight: 600; min-width: 0; }
.wge-row select, .wge-row input[type="text"] {
  flex: 1 1 180px; min-width: 0; height: 38px; border-radius: 9px; border: 1px solid var(--wge-line); background: var(--wge-bg); padding: 0 8px;
}
.wge-row input[type="range"] { flex: 1 1 160px; accent-color: var(--wge-acc); }
.wge-row input[type="color"] { width: 46px; height: 36px; border: 1px solid var(--wge-line); border-radius: 8px; padding: 2px; background: var(--wge-bg); }
.wge-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--wge-acc); margin: 0; }
.wge-row-cb { cursor: pointer; }
.wge-row-cb .wge-row-l { flex: 1 1 auto; }
.wge-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.wge-acts-col { display: grid; grid-template-columns: minmax(0, 1fr); }
.wge-btn {
  min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--wge-line); background: var(--wge-chip);
  font-weight: 700; font-size: 14px;
}
.wge-btn-p { background: var(--wge-acc); color: var(--wge-acc-fg); border-color: var(--wge-acc); }
.wge-btn-dl { min-height: 46px; }
.wge-btn:active { transform: translateY(1px); }
.wge-pre {
  margin: 6px 0 10px; padding: 8px 10px; border-radius: 9px; background: var(--wge-bg); border: 1px solid var(--wge-line);
  font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto;
}
.wge-packpick { margin-top: 6px; }

/* templates */
.wge-tpl { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.wge-tplb {
  display: grid; gap: 4px; padding: 6px; border-radius: 12px; border: 1px solid var(--wge-line); background: var(--wge-bg);
  font-size: 12px; font-weight: 700; text-align: center; color: var(--wge-fg);
}
.wge-tplb:hover { border-color: var(--wge-acc); }
.wge-tpl-img { width: 100%; height: auto; aspect-ratio: 6 / 5; border-radius: 8px; background: radial-gradient(circle at 50% 40%, #3f5fb8, #1b2559); display: block; }

/* desktop */
@media (min-width: 860px) {
  .wge { --wge-h3d: clamp(380px, 62vh, 560px); }
  .wge-views[data-view="split"] { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .wge-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .wge-panel[data-panel="start"] .wge-card:first-child { grid-column: 1 / -1; }
  .wge-tpl { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
}
@media (min-width: 1200px) {
  .wge-panel[data-panel="gen"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .wge-chip { padding: 0 9px; }
  .wge-tools { gap: 6px 8px; padding: 6px; }
  .wge-ib { width: 38px; height: 38px; flex-basis: 38px; }
  .wge-hex { width: 76px; }
  .wge-sw { width: 26px; height: 26px; flex-basis: 26px; }
}

/* read-only viewer embeds (WG3D.mount / [data-wg3d]) */
.wg3d { position: relative; overflow: hidden; border-radius: 12px; min-height: 120px; }
.wg3d-cv { cursor: grab; }
.wg3d-cv:active { cursor: grabbing; }
