/* NotSkin MC-SKINEDITOR — IDE-flavoured dark UI (JetBrains "New UI" dark palette). */

:root {
  --bg:          #1e1f22;  /* editor / main background */
  --panel:       #2b2d30;  /* tool windows, title bar, dialogs */
  --panel-hi:    #35373b;  /* hover */
  --panel-sunk:  #1e1f22;
  --border:      #393b40;
  --border-str:  #4e5157;
  --text:        #dfe1e5;
  --text-dim:    #9da0a8;
  --text-mute:   #6f737a;
  --accent:      #3574f0;
  --accent-hi:   #4a86f7;
  --accent-soft: #2e436e;
  --green:       #57965c;
  --red:         #db5c5c;
  --orange:      #e08d50;
  --yellow:      #f2c55c;

  --tw-w-left:  268px;
  --tw-w-right: 300px;
  --stripe-w:   30px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

.ico {
  width: 16px; height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ide {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ═══════════════ title bar ═══════════════ */

.titlebar {
  flex: 0 0 auto;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.app-icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: linear-gradient(140deg, #3574f0, #7b4fe0 60%, #e0553c);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .02em;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.menubar { display: flex; gap: 1px; }

.menu-btn {
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 4px 9px;
  border-radius: 5px;
  cursor: pointer;
}
.menu-btn:hover { background: var(--panel-hi); }
.menu-btn.open { background: var(--accent); color: #fff; }

.project-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
}
.project-chip:hover { background: var(--panel-hi); }
.project-chip .ico { color: var(--accent); }

.titlebar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-sunk);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  height: 26px;
}
.name-chip .ico { color: var(--text-mute); }
.name-chip input {
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  width: 140px;
  padding: 0;
}
.name-chip input:focus { outline: none; }
.name-chip:focus-within { border-color: var(--accent); }

.tb-group { display: flex; gap: 1px; }

.tb-btn {
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
}
.tb-btn:hover:not(:disabled) { background: var(--panel-hi); color: var(--text); }
.tb-btn:disabled { opacity: .35; cursor: default; }

/* ═══════════════ menus ═══════════════ */

.menu-dropdown {
  position: fixed;
  z-index: 80;
  min-width: 232px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border-str);
  border-radius: 8px;
  box-shadow: 0 10px 34px rgba(0,0,0,.55);
}
.menu-dropdown[hidden] { display: none; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  background: none;
  border: 0;
  border-radius: 5px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover:not(:disabled) { background: var(--accent); color: #fff; }
.menu-item:hover .menu-key { color: rgba(255,255,255,.75); }
.menu-item:disabled { color: var(--text-mute); cursor: default; }
.menu-item .menu-label { flex: 1; }
.menu-key { color: var(--text-mute); font-size: 11.5px; font-family: var(--mono); }
.menu-tick { width: 16px; height: 16px; flex: 0 0 auto; color: var(--accent); }
.menu-item:hover .menu-tick { color: #fff; }
.menu-tick.hidden { visibility: hidden; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ═══════════════ workbench ═══════════════ */

.workbench {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  background: var(--bg);
}

.stripe {
  flex: 0 0 var(--stripe-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
}
.stripe-right { border-right: 0; border-left: 1px solid var(--border); }

.stripe-btn {
  writing-mode: vertical-rl;
  background: none;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 11.5px;
  padding: 10px 5px;
  border-radius: 5px;
  cursor: pointer;
  letter-spacing: .02em;
}
.stripe-left .stripe-btn { writing-mode: vertical-rl; transform: rotate(180deg); }
.stripe-btn:hover { background: var(--panel-hi); color: var(--text); }
.stripe-btn.on { background: var(--accent-soft); color: var(--text); }

.toolwindow {
  flex: 0 0 var(--tw-w-left);
  min-width: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
#tw-right {
  flex-basis: var(--tw-w-right);
  border-right: 0;
  border-left: 1px solid var(--border);
}
.toolwindow[hidden] { display: none; }

.tw-header {
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 10px;
  border-bottom: 1px solid var(--border);
}
.tw-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex: 1;
}
.tw-action {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 4px;
  color: var(--text-mute);
  cursor: pointer;
}
.tw-action:hover { background: var(--panel-hi); color: var(--text); }

.tw-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: #4e5157 transparent;
}
.tw-body::-webkit-scrollbar { width: 10px; }
.tw-body::-webkit-scrollbar-thumb { background: #4a4d52; border-radius: 6px; border: 3px solid var(--panel); }
.tw-body::-webkit-scrollbar-track { background: transparent; }

.section { margin-top: 16px; }
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.section-title.sub { border: 0; margin-top: 12px; padding-bottom: 0; }

.note {
  color: var(--text-mute);
  font-size: 11.5px;
  line-height: 1.45;
  margin: 6px 0 0;
}
.note[hidden] { display: none; }

/* ═══════════════ controls ═══════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-hi);
  border: 1px solid var(--border-str);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.btn:hover:not(:disabled) { background: #41444a; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hi); }
.btn.danger { border-color: #5c3a3a; color: #f0a9a7; }
.btn.danger:hover { background: #3d2b2b; border-color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn .ico { width: 14px; height: 14px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 5px; }

input[type="text"], select {
  background: var(--panel-sunk);
  border: 1px solid var(--border-str);
  color: var(--text);
  border-radius: 5px;
  padding: 4px 7px;
  font: inherit;
  font-size: 12.5px;
}
input[type="text"]:focus, select:focus { outline: none; border-color: var(--accent); }
select { cursor: pointer; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 16px;
  flex: 1;
  min-width: 54px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--border-str); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px; margin-top: -5px;
  border-radius: 50%; background: var(--accent);
  border: 2px solid var(--panel);
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--border-str); }
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
}

input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }

kbd {
  display: inline-block;
  background: var(--panel-sunk);
  border: 1px solid var(--border-str);
  border-radius: 4px;
  padding: 1px 5px;
  font: 11px var(--mono);
  color: var(--text-dim);
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.row:last-child { margin-bottom: 0; }
.row > span:first-child { color: var(--text-dim); flex: 0 0 auto; min-width: 62px; }
.row.check { cursor: pointer; }
.row.check > span { color: var(--text); min-width: 0; }
.row.check em { color: var(--text-mute); font-style: normal; font-size: 11px; }
.row output { font: 11px var(--mono); color: var(--text-mute); min-width: 30px; text-align: right; }

.segmented { display: inline-flex; border: 1px solid var(--border-str); border-radius: 5px; overflow: hidden; }
.segmented button {
  background: var(--panel-sunk);
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 11.5px;
  padding: 4px 10px;
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--border-str); }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--accent); color: #fff; }

/* tool grid */

.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px 5px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
}
.tool span { font-size: 9.5px; letter-spacing: .02em; }
.tool:hover { background: var(--panel-hi); color: var(--text); }
.tool.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.tool.on .ico { color: #7ea9ff; }

/* color */

.color-head { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 9px; }

#color-input {
  -webkit-appearance: none;
  appearance: none;
  width: 50px; height: 50px;
  border: 1px solid var(--border-str);
  border-radius: 6px;
  background: none;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
#color-input::-webkit-color-swatch-wrapper { padding: 3px; }
#color-input::-webkit-color-swatch { border: 0; border-radius: 4px; }
#color-input::-moz-color-swatch { border: 0; border-radius: 4px; }

.color-meta { flex: 1; min-width: 0; }
#color-hex { width: 100%; font-family: var(--mono); text-transform: uppercase; margin-bottom: 7px; }
.row.alpha { margin: 0; }
.row.alpha > span { min-width: 36px; font-size: 11.5px; }

.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }

.swatch {
  aspect-ratio: 1;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.1);
  cursor: pointer;
  padding: 0;
}
.swatch:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch.empty { border-style: dashed; opacity: .25; cursor: default; }
.swatch.empty:hover { outline: none; }

/* ═══════════════ editor area ═══════════════ */

.editor-area {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.tabbar {
  flex: 0 0 auto;
  height: 32px;
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding-left: 4px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  cursor: default;
  user-select: none;
}
.tab.active {
  background: var(--bg);
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab-ico { color: var(--green); }
.tab-dirty { color: var(--orange); font-size: 10px; }
.tab-dirty[hidden] { display: none; }

.editor-toolbar {
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-dim);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.crumb-sep { color: var(--text-mute); }
.crumb.dim { color: var(--text-mute); }
.crumb.tag {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
}

.et-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.et-sep { width: 1px; height: 16px; background: var(--border); }

.mini-field { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-mute); }
.mini-field select { padding: 2px 5px; font-size: 11.5px; }

.icon-toggle {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 5px;
  color: var(--text-mute);
  cursor: pointer;
}
.icon-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.icon-toggle:hover { background: var(--panel-hi); color: var(--text); }
.icon-toggle:has(input:checked),
.icon-toggle.on { background: var(--accent-soft); color: #9dbcff; }

.canvas-holder {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    radial-gradient(circle at 50% 45%, #26282d, #1a1b1e 78%) border-box;
}
#editor {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
#editor.panning { cursor: grabbing; }

/* ═══════════════ 3D preview ═══════════════ */

.viewer-holder {
  position: relative;
  aspect-ratio: 3 / 4;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 34%, #313640 0%, #1a1c20 74%);
  touch-action: none;
  margin-bottom: 11px;
}
#viewer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#viewer.paint { cursor: crosshair; }
#viewer.dragging { cursor: grabbing; }

.viewer-badge {
  position: absolute;
  top: 7px; left: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}
.viewer-badge[hidden] { display: none; }

.viewer-controls { display: flex; flex-direction: column; gap: 8px; }
.viewer-controls .row { margin-bottom: 0; }

/* ═══════════════ status bar ═══════════════ */

.statusbar {
  flex: 0 0 auto;
  height: 25px;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 10px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
}
.status-msg { overflow: hidden; text-overflow: ellipsis; }
.status-spacer { flex: 1 1 auto; }
.status-cell {
  padding: 0 9px;
  border-left: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
}
.status-cell:first-of-type { border-left: 0; }
.status-cell.save { color: var(--text-dim); padding-right: 0; }
.status-cell.save.dirty { color: var(--orange); }
.status-cell.save.ok { color: var(--green); }

/* ═══════════════ dialogs ═══════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 11, 13, .6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 20px 30px;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }

.dialog {
  background: var(--panel);
  border: 1px solid var(--border-str);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  width: min(520px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
}
.dialog.wide { width: min(940px, 100%); }

.dialog-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--border);
}
.dialog-title { font-size: 13.5px; font-weight: 600; }
.dialog-sub { color: var(--text-mute); font-size: 11.5px; flex: 1; }

.dialog-body { padding: 14px 16px; overflow-y: auto; }
.dialog-body .note:first-child { margin-top: 0; margin-bottom: 12px; }

.dialog-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.keymap { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.keymap td { padding: 4px 8px 4px 0; color: var(--text-dim); }
.keymap td:nth-child(odd) { width: 92px; white-space: nowrap; }

/* gallery */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 10px;
}

.card {
  background: var(--panel-sunk);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card.current { border-color: var(--accent); }

.card-art {
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 40%, #2f343c, #1b1d21);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
}
.card-art img {
  width: 74%;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
}
.card-badge {
  position: absolute; top: 5px; right: 5px;
  background: rgba(0,0,0,.55);
  color: var(--text-dim);
  font-size: 9px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 5px; border-radius: 4px;
}
.card-body { padding: 7px 8px 8px; display: flex; flex-direction: column; gap: 5px; }
.card-name { font-size: 12.5px; font-weight: 500; word-break: break-word; }
.card-date { font-size: 10.5px; color: var(--text-mute); font-family: var(--mono); }
.card-actions { display: flex; gap: 3px; flex-wrap: wrap; }
.card-actions .btn { padding: 2px 6px; font-size: 11px; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 44px 0;
  color: var(--text-mute);
  font-size: 12.5px;
}

/* ═══════════════ balloon notification ═══════════════ */

.balloon {
  position: fixed;
  right: 16px;
  bottom: 36px;
  z-index: 95;
  max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--border-str);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text);
  box-shadow: 0 12px 34px rgba(0,0,0,.55);
  animation: balloon-in .16s ease;
}
.balloon[hidden] { display: none; }
.balloon.bad { border-left-color: var(--red); }
@keyframes balloon-in { from { opacity: 0; transform: translateY(6px); } }

/* ═══════════════ responsive ═══════════════ */

@media (max-width: 1240px) {
  :root { --tw-w-left: 236px; --tw-w-right: 268px; }
}

@media (max-width: 1000px) {
  html, body { overflow: auto; }
  .ide { height: auto; min-height: 100%; }
  .workbench { flex-wrap: wrap; }
  .stripe { display: none; }
  .toolwindow { flex: 1 1 260px; border-left: 0; border-right: 0; border-top: 1px solid var(--border); }
  .editor-area { flex: 1 1 100%; height: 60vh; order: -1; }
  .titlebar { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 6px 4px; }
  .project-chip { display: none; }
  .titlebar-right { margin-left: auto; }
  .name-chip input { width: 110px; }
}
