* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}

/* themed scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #3a4150 #1b1e24;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: #1b1e24;
}
*::-webkit-scrollbar-thumb {
  background: #3a4150;
  border-radius: 5px;
  border: 2px solid #1b1e24;
}
*::-webkit-scrollbar-thumb:hover {
  background: #4a5568;
}
*::-webkit-scrollbar-corner {
  background: #1b1e24;
}
/* Base stack covers Latin, Cyrillic, Vietnamese (all system UI fonts carry
   full Vietnamese diacritics), plus broad CJK and Thai fallbacks so every
   supported language renders on Windows, macOS, Linux, and mobile. */
body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans",
    "PingFang SC",
    "Hiragino Sans",
    "Microsoft YaHei",
    "Microsoft JhengHei",
    "Yu Gothic UI",
    Meiryo,
    "Malgun Gothic",
    "Apple SD Gothic Neo",
    "Leelawadee UI",
    Thonburi,
    "Noto Sans Thai",
    sans-serif;
  background: #14161a;
  color: #d8dbe0;
  font-size: 14px;
}
/* Language-specific preferred fonts (html[lang] is set by the i18n system) */
:lang(zh-Hans) {
  font-family:
    "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
}
:lang(zh-Hant) {
  font-family:
    "Segoe UI", system-ui, "PingFang TC", "Hiragino Sans CNS",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}
:lang(ja) {
  font-family:
    "Segoe UI", system-ui, "Hiragino Sans", "Yu Gothic UI", Meiryo,
    "Noto Sans JP", sans-serif;
}
:lang(ko) {
  font-family:
    "Segoe UI", system-ui, "Apple SD Gothic Neo", "Malgun Gothic",
    "Noto Sans KR", sans-serif;
}
:lang(th) {
  font-family:
    "Segoe UI", system-ui, "Leelawadee UI", Thonburi, "Noto Sans Thai",
    sans-serif;
}
/* Thai stacked diacritics need extra line height to avoid clipping */
:lang(th) body,
:lang(th) .row span,
:lang(th) button,
:lang(th) .hint2 {
  line-height: 1.6;
}
#app {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 320px;
  min-width: 320px;
  background: #1b1e24;
  border-right: 1px solid #2a2e36;
  padding: 14px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.sidebar-scroll {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 -6px;
  padding: 0 6px;
}

/* ----- right sidebar (editor) ----- */
#rightbar {
  width: 300px;
  min-width: 300px;
  background: #1b1e24;
  border-left: 1px solid #2a2e36;
  padding: 14px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.rb-scroll {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 -6px;
  padding: 0 6px;
}
#rb-actions {
  position: sticky;
  bottom: 0;
  background: #1b1e24;
  border-top: 1px solid #2a2e36;
  padding: 10px 0 12px;
  margin-top: auto;
}
#rb-actions button {
  margin: 4px 0;
}

/* ----- resizable sidebar handles ----- */
.resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 20;
}
#resize-left {
  right: -3px;
}
#resize-right {
  left: -3px;
}
.resize-handle:hover {
  background: #2d6cdf55;
}
#action-bar {
  position: sticky;
  bottom: 0;
  background: #1b1e24;
  border-top: 1px solid #2a2e36;
  padding: 10px 0 12px;
  margin-top: auto;
}
#action-bar #btn-generate {
  margin: 0;
  padding: 13px;
  font-size: 15px;
  letter-spacing: 0.5px;
}
#sidebar h1 {
  font-size: 18px;
  margin: 0 0 4px;
  color: #7ec8ff;
  letter-spacing: 0.5px;
}
.panel {
  background: #20242c;
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 12px;
}
.panel h2 {
  font-size: 13px;
  margin: 0 0 10px;
  color: #9aa3b0;
  text-transform: uppercase;
  letter-spacing: 1px;
}
/* collapsible panels */
details.panel > summary {
  font-size: 13px;
  color: #9aa3b0;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
details.panel > summary::-webkit-details-marker {
  display: none;
}
details.panel > summary::before {
  content: "▸";
  font-size: 10px;
  color: #6b7482;
  transition: transform 0.12s;
}
details.panel[open] > summary::before {
  transform: rotate(90deg);
}
details.panel[open] > summary {
  margin-bottom: 10px;
}
.subhead {
  font-size: 11px;
  color: #6b7482;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 12px 0 4px;
  border-top: 1px solid #262a32;
  padding-top: 8px;
}
.btn-row {
  display: flex;
  gap: 6px;
  margin: 6px 0;
}
button.mini {
  flex: 1;
  width: auto;
  padding: 6px 4px;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  background: #2a2e36;
  color: #d8dbe0;
}
button.mini:hover:not(:disabled) {
  background: #3a4150;
}
button.mini.danger:hover:not(:disabled) {
  background: #a33c3c;
  color: #fff;
}

.filedrop {
  display: block;
  border: 2px dashed #3a4150;
  border-radius: 8px;
  padding: 18px 10px;
  text-align: center;
  cursor: pointer;
  color: #9aa3b0;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.filedrop:hover,
.filedrop.dragover {
  border-color: #7ec8ff;
  background: #232a36;
}
.filedrop input {
  display: none;
}
.filedrop .hint {
  display: block;
  font-size: 11px;
  margin-top: 6px;
  color: #6b7482;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0;
}
.row span {
  flex: 1;
  /* long translated labels wrap instead of overflowing the sidebar */
  min-width: 0;
  overflow-wrap: break-word;
}
.row[title],
.row-triple[title] {
  cursor: help;
}
.row em {
  font-style: normal;
  color: #7ec8ff;
  margin-left: 4px;
}
.row input[type="range"] {
  flex: 1;
  max-width: 130px;
  min-width: 0;
}
.row input[type="number"] {
  width: 90px;
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
}
/* rows combining a slider + number input (e.g. voxel resolution) must not
   overflow the sidebar */
.row:has(input[type="range"]):has(input[type="number"]) input[type="range"] {
  max-width: 90px;
}
.row:has(input[type="range"]):has(input[type="number"]) input[type="number"] {
  width: 60px;
  padding: 4px 4px;
  flex-shrink: 0;
}
.row select {
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
  max-width: 160px;
}
.row input[type="checkbox"] {
  transform: scale(1.2);
}

details summary {
  cursor: pointer;
  color: #9aa3b0;
  margin: 8px 0 4px;
}

.row-triple {
  display: grid;
  grid-template-columns: 74px 1fr 1fr 1fr;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}
.row-triple span {
  font-size: 12px;
  color: #9aa3b0;
  min-width: 0;
  overflow-wrap: break-word;
}
.row-triple input {
  width: 100%;
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 4px;
  min-width: 0;
}
.hint2 {
  font-size: 11px;
  color: #6b7482;
  margin-top: 4px;
}

#tx-canvas {
  width: 100%;
  image-rendering: pixelated;
  border: 1px solid #3a4150;
  border-radius: 6px;
  background: repeating-conic-gradient(#23262d 0 25%, #1b1e24 0 50%) 0 0/16px
    16px;
  touch-action: none;
}
#tx-select {
  width: 100%;
  margin-bottom: 6px;
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
}

.mode-group {
  border-left: 2px solid #2d6cdf55;
  padding-left: 8px;
  margin: 6px 0 10px;
}

.row-checks {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px 8px;
  margin: 8px 0;
  font-size: 12px;
  color: #d8dbe0;
  cursor: help;
}
.row-checks label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

#recon-list {
  margin-top: 8px;
  font-size: 12px;
}
#recon-list .recon-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid #262a32;
}
#recon-list .recon-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#recon-list .recon-count {
  color: #6b7482;
  white-space: nowrap;
}
#recon-list .recon-del {
  background: none;
  border: none;
  color: #6b7482;
  cursor: pointer;
  width: auto;
  padding: 0 4px;
  margin: 0;
  font-size: 13px;
}
#recon-list .recon-del:hover {
  color: #f0b429;
}

button {
  width: 100%;
  padding: 10px;
  margin: 6px 0;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: #2d6cdf;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover:not(:disabled) {
  background: #3d7ceb;
}
button:disabled {
  background: #2a2e36;
  color: #6b7482;
  cursor: not-allowed;
}
#btn-cancel {
  background: #a33c3c;
}
#btn-cancel:hover:not(:disabled) {
  background: #b84a4a;
}
#btn-download {
  background: #22a06b;
}
#btn-download:hover:not(:disabled) {
  background: #2ab377;
}
#btn-download:disabled {
  color: rgba(255, 255, 255, 0.55);
}
button.secondary {
  background: #2a2e36;
  color: #9aa3b0;
  font-weight: 400;
  padding: 7px;
  font-size: 12px;
}
button.secondary:hover:not(:disabled) {
  background: #3a4150;
  color: #d8dbe0;
}

.stat-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  font-size: 12px;
  margin-top: 8px;
}
.stat-grid .k {
  color: #9aa3b0;
}
.stat-grid .v {
  color: #d8dbe0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stat-grid .warn {
  color: #f0b429;
}

#texture-list {
  margin-top: 8px;
  font-size: 12px;
}
#texture-list .tex-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid #262a32;
}
#texture-list .tex-name {
  color: #d8dbe0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#texture-list .tex-status {
  color: #6b7482;
  white-space: nowrap;
}
#texture-list .tex-status.used {
  color: #36d47e;
}
#texture-list .tex-status.applied {
  color: #7ec8ff;
}
#texture-list .tex-status.staged {
  color: #f0b429;
}

#progress {
  height: 5px;
  background: #2a2e36;
  border-radius: 3px;
  margin: 6px 0;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0;
  background: #7ec8ff;
  transition: width 0.2s;
}

#viewport {
  flex: 1;
  position: relative;
  min-width: 0;
}
#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ----- viewport toolbar ----- */
#vp-topbars {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 10;
  max-width: calc(100% - 20px);
  pointer-events: none;
}
#vp-topbars > * {
  pointer-events: auto;
}
#vp-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: center;
}
.tb-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(27, 30, 36, 0.92);
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 3px;
  backdrop-filter: blur(4px);
}
.tb-btn {
  width: auto;
  margin: 0;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  color: #9aa3b0;
  border-radius: 5px;
}
.tb-btn:hover:not(:disabled) {
  background: #2a2e36;
  color: #d8dbe0;
}
.tb-btn.active {
  background: #2d6cdf;
  color: #fff;
}
.tb-btn.tb-toggle.pressed {
  background: #2a3546;
  color: #7ec8ff;
}
.tb-btn:disabled {
  background: transparent;
  color: #4a5160;
}
#tb-snapstep {
  width: 52px;
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 4px;
  margin: 0 3px 0 1px;
  font-size: 12px;
}
.tb-select {
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 4px;
  margin: 0 3px 0 1px;
  font-size: 12px;
}
.tb-select:disabled {
  color: #4a5160;
  border-color: #2a2e36;
  cursor: not-allowed;
}

/* contextual place bar */
#tb-place {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(27, 30, 36, 0.92);
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 5px 10px;
  z-index: 10;
  backdrop-filter: blur(4px);
}
#tb-place[hidden] {
  display: none;
}
#tb-place .tb-label {
  font-size: 12px;
  color: #9aa3b0;
}
#tb-place select,
#tb-place input[type="number"] {
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
}
#tb-place input[type="number"] {
  width: 64px;
}

/* ----- camera navigation gizmo ----- */
#nav-widget {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#nav-gizmo {
  width: 96px;
  height: 96px;
  cursor: pointer;
  touch-action: none;
}
#nav-proj {
  width: auto;
  margin: 0;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(27, 30, 36, 0.92);
  border: 1px solid #2a2e36;
  border-radius: 6px;
  color: #9aa3b0;
}
#nav-proj:hover {
  background: #2a2e36;
  color: #d8dbe0;
}

/* ----- viewport status bar ----- */
#vp-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  color: #9aa3b0;
  background: rgba(27, 30, 36, 0.85);
  border-top: 1px solid #2a2e36;
  z-index: 10;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#vp-status span:empty {
  display: none;
}
#vp-status .warn,
#stat-warnings .warn-row {
  color: #f0b429;
}
#stat-warnings .warn-row {
  font-size: 12px;
  margin-top: 6px;
  display: flex;
  gap: 6px;
}
#drop-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #4a5160;
  font-size: 20px;
  pointer-events: none;
}
footer {
  font-size: 11px;
  color: #6b7482;
  text-align: center;
}
footer a {
  color: #7ec8ff;
}
/* floating Tutorial button — visible but out of the way (top-left) */
#btn-tutorial {
  position: absolute;
  left: 12px;
  top: 12px;
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 400;
  background: rgba(27, 30, 36, 0.9);
  color: #9aa3b0;
  border: 1px solid #3a4150;
  z-index: 25;
}
#btn-tutorial:hover:not(:disabled) {
  background: #2a2e36;
  color: #d8dbe0;
}

/* first-visit welcome bubble pointing at the Tutorial button */
#tut-welcome {
  position: absolute;
  left: 12px;
  top: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1b1e24;
  border: 1px solid #2d6cdf;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #d8dbe0;
  z-index: 26;
  max-width: 320px;
}
#tut-welcome button.mini,
#gen-notice button.mini {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  font-size: 12px;
}
.tut-x {
  background: none !important;
  color: #6b7482 !important;
  padding: 4px 6px !important;
}
.tut-x:hover {
  color: #d8dbe0 !important;
}

/* tutorial overlay: spotlight hole + popover */
#tut-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
}
#tut-overlay .tut-hole {
  position: fixed;
  border-radius: 8px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.6);
  border: 2px solid #2d6cdf;
  pointer-events: none;
  transition: all 0.2s ease;
}
#tut-overlay .tut-pop {
  position: fixed;
  background: #1b1e24;
  border: 1px solid #3a4150;
  border-radius: 8px;
  padding: 12px 14px;
  color: #d8dbe0;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#tut-overlay .tut-pop h3 {
  margin: 0 0 6px;
  font-size: 14px;
}
#tut-overlay .tut-body {
  color: #9aa3b0;
  line-height: 1.45;
}
#tut-overlay .tut-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
#tut-overlay .tut-prog {
  flex: 1;
  color: #6b7482;
  font-size: 11px;
}
#tut-overlay .tut-bar button.mini {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  font-size: 12px;
}
#tut-overlay .tut-next {
  background: #2d6cdf;
  color: #fff;
}

/* post-generation notice (base model hidden, restorable) */
#gen-notice {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(27, 30, 36, 0.95);
  border: 1px solid #3a4150;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #d8dbe0;
  z-index: 30;
  max-width: min(92%, 800px);
}
#gen-notice button.mini {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  font-size: 12px;
}
#gen-notice .gen-notice-x,
#long-notice .gen-notice-x {
  background: none;
  color: #6b7482;
  padding: 4px 6px;
}
#gen-notice .gen-notice-x:hover:not(:disabled),
#long-notice .gen-notice-x:hover:not(:disabled) {
  background: none;
  color: #d8dbe0;
}

/* generation warnings under the Conversion result stats */
#gen-warnings .warn-row {
  display: flex;
  gap: 6px;
  color: #f0b429;
  font-size: 12px;
  margin-top: 6px;
}

/* clipboard-import chooser (multiple files pasted) */
#paste-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
#paste-modal .paste-box {
  background: #1b1e24;
  border: 1px solid #3a4150;
  border-radius: 8px;
  padding: 16px 18px;
  min-width: 320px;
  max-width: 460px;
  max-height: 70vh;
  overflow-y: auto;
}
#paste-modal h2 {
  margin: 0 0 4px;
  font-size: 15px;
}
#paste-modal .paste-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #262a32;
  cursor: pointer;
  font-size: 13px;
}
#paste-modal .paste-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#paste-modal .paste-kind {
  color: #6b7482;
  font-size: 11px;
  white-space: nowrap;
}
#paste-modal .btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* language selector pinned at the top of the sidebar, above all panels */
#lang-row {
  text-align: left;
  font-size: 12px;
  color: #9aa3b0;
  margin: 0 0 2px;
  flex-shrink: 0;
}
#lang-row select {
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
  max-width: 170px;
}

h1 .badge {
  font-size: 10px;
  vertical-align: middle;
  background: #2d6cdf;
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
#btn-view-prims {
  background: #22a06b;
}
#btn-view-prims:hover:not(:disabled) {
  background: #2ab377;
}

/* primitives popup */
#prim-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
#prim-modal[hidden] {
  display: none;
}
.modal-box {
  width: min(1100px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #1b1e24;
  border: 1px solid #3a4150;
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #2a2e36;
}
.modal-head h2 {
  margin: 0;
  font-size: 14px;
  color: #d8dbe0;
}
.modal-spacer {
  flex: 1;
}
button.small {
  width: auto;
  padding: 6px 12px;
  margin: 0;
  font-size: 12px;
}
#btn-copy-json {
  background: #22a06b;
}
#btn-copy-json:hover:not(:disabled) {
  background: #2ab377;
}
#btn-close-modal {
  background: #2a2e36;
}
#btn-close-modal:hover {
  background: #3a4150;
}
.modal-body {
  overflow: auto;
  padding: 0 14px 14px;
}
#btn-more-rows {
  margin-top: 8px;
  background: #2a2e36;
}

.modal-sub {
  padding: 8px 14px;
  font-size: 11px;
  color: #9aa3b0;
  border-bottom: 1px solid #2a2e36;
  line-height: 1.5;
}

#prim-table {
  width: 100%;
  /* separate borders: collapsed borders detach from sticky headers and
     leave a see-through gap at the top while scrolling */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid #3a4150;
}
#prim-table th,
#prim-table td {
  padding: 4px 8px;
  text-align: center;
  border-bottom: 1px solid #262a32;
  white-space: nowrap;
}
#prim-table thead th {
  position: sticky;
  z-index: 2;
  background: #1b1e24;
  color: #9aa3b0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #3a4150;
}
#prim-table thead tr:first-child th {
  top: 0;
}
#prim-table thead tr:last-child th.sub {
  top: 25px; /* re-measured in JS */
}
#prim-table th.grp-head {
  text-align: center;
}
/* borders around grouped sections (Position / Rotation / Zoom), not around
   each individual X/Y/Z column */
#prim-table th.grp-start,
#prim-table td.grp-start {
  border-left: 1px solid #3a4150;
}
#prim-table td {
  cursor: copy;
}
#prim-table td:first-child {
  cursor: default;
}
#prim-table tr.done td {
  color: #5a6270;
  text-decoration: line-through;
}
#prim-table tr.done .swatch {
  opacity: 0.35;
}
.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid #3a4150;
  vertical-align: -2px;
}

#marquee {
  position: fixed;
  border: 1px solid #7ec8ff;
  background: rgba(126, 200, 255, 0.12);
  pointer-events: none;
  z-index: 60;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(10px);
  background: #22a06b;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s,
    transform 0.18s;
  z-index: 100;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- workflow switch + sprite studio ---------- */
.workflow-switch {
  display: flex;
  gap: 6px;
}
.workflow-switch button {
  flex: 1;
  width: auto;
  margin: 0;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  background: #2a2e36;
  color: #9aa3b0;
  border: 1px solid transparent;
  border-radius: 6px;
}
.workflow-switch button:hover:not(.active) {
  background: #3a4150;
  color: #d8dbe0;
}
/* active tab: accent tint + border — the strongest non-Generate emphasis
   in the sidebar (stands above the import buttons) */
.workflow-switch button.active {
  background: rgba(45, 108, 223, 0.22);
  border-color: #2d6cdf;
  color: #fff;
}

/* sprite studio panels stack like the model workflow */
#sprite-studio {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#sprite-studio[hidden] {
  display: none;
}
/* subtle divider between control groups inside a panel */
.ss-divider {
  border-top: 1px solid #2a2e36;
  margin: 12px 0 4px;
}
/* text inputs share the number-input look everywhere (asset name, sprite
   name, …) */
.row input[type="text"] {
  flex: 1;
  min-width: 0;
  max-width: 160px;
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
}
/* compact icon-button strips (same pattern as the Optimize actions) */
.btn-strip {
  display: flex;
  gap: 6px;
  margin: 8px 0;
}
.btn-strip select {
  flex: none;
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
}
/* a mini button sitting inside a label row (e.g. the FPS/SPF toggle) */
#sprite-studio .row button.mini {
  flex: none;
  width: auto;
  padding: 4px 9px;
}
/* pivot X/Y pair shares the sidebar row without overflowing */
#ss-pivot-row input[type="number"] {
  width: 62px;
  flex: none;
}
/* icon buttons: keep glyphs optically centered and aligned with any text */
.btn-strip button,
.ss-frame button,
.se-frame-btns button,
.workflow-switch button,
.ah-nav button,
.ah-head button,
.se-head button,
.se-foot button,
.ap-foot button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  line-height: 1;
}

/* frames list */
.ss-frames {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
}
.ss-frame {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border: 1px solid #2a2e36;
  border-radius: 6px;
  cursor: pointer;
  background: #1b1e24;
  transition: border-color 0.12s;
}
.ss-frame:hover {
  border-color: #3a4150;
}
.ss-frame.sel {
  border-color: #2d6cdf;
}
.ss-frame span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.ss-frame canvas {
  background: #14161a;
  border-radius: 4px;
  flex: none;
}
.ss-frame button {
  flex: none;
  width: auto;
  margin: 0;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 400;
  background: #2a2e36;
  color: #9aa3b0;
}
.ss-frame button:hover:not(:disabled) {
  background: #3a4150;
  color: #d8dbe0;
}

.ss-error {
  color: #e07a6e;
  font-size: 11px;
  margin-top: 6px;
  overflow-wrap: break-word;
}
/* no reserved space when there is nothing to report */
.ss-error:empty {
  display: none;
}

/* preview player */
#ss-canvas {
  display: block;
  width: 100%;
  background: #14161a;
  border: 1px solid #2a2e36;
  border-radius: 6px;
  image-rendering: pixelated;
}
.ss-scrub {
  display: block;
  width: 100%;
  margin: 6px 0 0;
}
/* ---------- prompt modal (replaces the native browser prompt) ---------- */
.app-prompt {
  background: #20242c;
  border: 1px solid #3a4150;
  border-radius: 8px;
  color: #d8dbe0;
  padding: 0;
  width: min(320px, 90vw);
  font-size: 13px;
}
.app-prompt::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
.ap-head {
  padding: 10px 14px;
  border-bottom: 1px solid #2a2e36;
}
.ap-head .ap-title {
  font-size: 13px;
  color: #9aa3b0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.ap-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 0;
}
.ap-body .ap-label {
  font-size: 12px;
  color: #9aa3b0;
}
.ap-body .ap-input {
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
}
.ap-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
}
.ap-foot button {
  width: auto;
  margin: 0;
  padding: 6px 14px;
  font-size: 12px;
}

/* ---------- shared dialog chrome (sheet editor + animation help) ---------- */
.sheet-editor,
.anim-help {
  background: #20242c;
  border: 1px solid #3a4150;
  border-radius: 8px;
  color: #d8dbe0;
  padding: 0;
  font-size: 13px;
}
.sheet-editor::backdrop,
.anim-help::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
/* dialog buttons are compact — opt out of the full-width sidebar default */
.sheet-editor button,
.anim-help button {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 12px;
}
.sheet-editor .se-head strong,
.anim-help .ah-title {
  font-size: 13px;
  color: #9aa3b0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* sprite sheet editor */
.sheet-editor {
  max-width: 96vw;
}
.se-head,
.se-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.se-head {
  border-bottom: 1px solid #2a2e36;
}
.se-foot {
  border-top: 1px solid #2a2e36;
  justify-content: flex-end;
  margin-top: 10px;
}
.se-foot .se-foot-spacer {
  flex: 1;
}
.se-head .se-hint {
  flex: 1;
  font-size: 11px;
  color: #6b7482;
}
.se-main {
  display: flex;
  gap: 10px;
  padding: 10px 14px 0;
}
.se-side {
  width: 250px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet-editor fieldset {
  border: 1px solid #2a2e36;
  border-radius: 6px;
  margin: 0;
  padding: 8px;
}
.sheet-editor legend {
  font-size: 11px;
  color: #6b7482;
  padding: 0 4px;
}
.se-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.se-params label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: #9aa3b0;
  min-width: 0;
}
.se-params input {
  width: 100%;
  box-sizing: border-box;
  background: #14161a;
  color: #d8dbe0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  padding: 4px 6px;
}
.se-params .se-reset {
  grid-column: 1 / -1;
  margin-top: 2px;
}
.se-frames .se-list {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.se-item {
  text-align: left;
  font-size: 11px;
  padding: 3px 8px;
  background: #1b1e24;
  color: #d8dbe0;
  border: 1px solid #2a2e36;
  border-radius: 4px;
  font-weight: 400;
}
.se-item:hover:not(:disabled) {
  background: #2a2e36;
}
.se-item.sel {
  border-color: #2d6cdf;
}
.se-frame-btns {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.se-frame-btns button {
  flex: 1;
  padding: 4px 0;
}
.se-canvas {
  background: #14161a;
  border: 1px solid #2a2e36;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}
.se-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #9aa3b0;
}
.se-pv {
  background: #14161a;
  border: 1px solid #2a2e36;
  border-radius: 4px;
  image-rendering: pixelated;
}
.se-error {
  color: #e07a6e;
  font-size: 11px;
  min-height: 15px;
  overflow-wrap: break-word;
}

/* animation help dialog — FIXED size; images scale to fit (no layout
   shifts while paging). Zoom shows the image at natural size with
   scrollbars inside the same fixed body. */
.anim-help {
  width: min(920px, 92vw);
  height: min(660px, 86vh);
}
.anim-help[open] {
  display: flex;
  flex-direction: column;
}
.ah-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #2a2e36;
}
.ah-head .ah-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ah-head .ah-count {
  flex: none;
  color: #6b7482;
  font-size: 12px;
}
.ah-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  padding: 10px 14px;
}
.ah-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  margin: auto;
}
.ah-img.zoomed {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: unset;
  cursor: zoom-out;
  margin: auto;
}
.ah-caption {
  flex: none;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #e6e9ee;
  padding: 8px 14px 0;
}
.ah-nav {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #2a2e36;
}

/* attention pulse when a setting is revealed via a notice shortcut */
@keyframes pulse-highlight {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(45, 108, 223, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(45, 108, 223, 0.55);
  }
}
.pulse-highlight {
  animation: pulse-highlight 0.9s ease-in-out 3;
  border-radius: 4px;
}
/* long-running conversion notice — a card with a title, short paragraphs and
   an action row; sits in the post-generation notice slot above the status bar */
#long-notice {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  box-sizing: border-box;
  width: min(92%, 460px);
  max-height: calc(100% - 54px);
  overflow-y: auto;
  /* the card sizes itself, so its children can adapt to the space it actually
     has — narrow viewports squeeze it well before the window gets small */
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(27, 30, 36, 0.97);
  border: 1px solid #3a4150;
  border-radius: 10px;
  padding: 18px 20px;
  color: #d8dbe0;
  text-align: left;
  z-index: 30;
}
#long-notice .long-notice-title {
  margin: 0;
  padding-right: 22px; /* keeps the title clear of the close button */
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #f0f2f5;
}
#long-notice .long-notice-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#long-notice .long-notice-body p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: #b9c0cb;
  text-wrap: pretty; /* avoids a lone word on the last line where supported */
  overflow-wrap: break-word;
}
/* a grid row rather than a flex row, so the buttons share one height even when
   a long translation forces the primary label onto a second line */
#long-notice .long-notice-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
  align-items: stretch;
  gap: 10px;
}
#long-notice button.mini {
  width: auto;
  min-height: 32px;
  max-width: 100%;
  margin: 0;
  padding: 6px 14px;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap; /* the label stays on one line; the button widens */
}
#long-notice .long-notice-open {
  background: #2d6cdf;
  color: #fff;
}
#long-notice .long-notice-open:hover:not(:disabled) {
  background: #3d7cef;
}
#long-notice .gen-notice-x {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 0;
  padding: 3px 7px;
  font-size: 12px;
  line-height: 1;
}
/* too narrow for the labels to stay on one line: stack the buttons full width
   and let the text wrap rather than spill out of the card */
@container (max-width: 350px) {
  #long-notice .long-notice-actions {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-auto-rows: 1fr;
  }
  #long-notice button.mini {
    width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
  }
  #long-notice .gen-notice-x {
    width: auto;
  }
}
