/* ============================================================
   Material Design 3 — Primitive Shaper (Global static port)
   Seed: Indigo #4355B9 — carried over from the Miliastra toolkit
   ============================================================ */

:root {
  --md-primary: #4355B9;
  --md-on-primary: #FFFFFF;
  --md-primary-container: #DEE0FF;
  --md-on-primary-container: #00105C;

  --md-secondary: #5C5F71;
  --md-on-secondary: #FFFFFF;
  --md-secondary-container: #E1E0F9;
  --md-on-secondary-container: #191C2B;

  --md-tertiary: #006A6A;
  --md-on-tertiary: #FFFFFF;
  --md-tertiary-container: #9CF1F0;
  --md-on-tertiary-container: #002020;

  --md-error: #BA1A1A;
  --md-on-error: #FFFFFF;
  --md-error-container: #FFDAD6;
  --md-on-error-container: #410002;

  --md-background: #FBF8FF;
  --md-on-background: #1B1B21;
  --md-surface: #FBF8FF;
  --md-on-surface: #1B1B21;
  --md-surface-variant: #E4E1EC;
  --md-on-surface-variant: #46464F;
  --md-surface-container-lowest: #FFFFFF;
  --md-surface-container-low: #F5F2FA;
  --md-surface-container: #EFEDF5;
  --md-surface-container-high: #E9E7EF;
  --md-surface-container-highest: #E3E1E9;
  --md-outline: #777680;
  --md-outline-variant: #C7C5D0;
  --md-inverse-surface: #303036;
  --md-inverse-on-surface: #F2F0F7;

  --md-elevation-1: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px 1px rgba(0,0,0,.04);
  --md-elevation-2: 0 1px 2px rgba(0,0,0,.06), 0 2px 6px 2px rgba(0,0,0,.04);
  --md-elevation-3: 0 4px 8px 3px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);

  --md-shape-xs: 4px;
  --md-shape-sm: 8px;
  --md-shape-md: 12px;
  --md-shape-lg: 16px;
  --md-shape-xl: 28px;
  --md-shape-full: 9999px;

  /* System font stacks: complete glyph coverage for all 15 languages. */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
               "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans",
               "Microsoft YaHei", "Malgun Gothic", "Leelawadee UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --success: var(--md-tertiary);
  --warning: #E8A317;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  color-scheme: light;
}

/* ── Dark theme (default; toggled via data-theme, persisted) ──
   Same indigo seed mapped to the M3 dark tonal palette. */
:root[data-theme="dark"] {
  --md-primary: #BAC3FF;
  --md-on-primary: #08218A;
  --md-primary-container: #293CA0;
  --md-on-primary-container: #DEE0FF;

  --md-secondary: #C5C4DD;
  --md-on-secondary: #2E3042;
  --md-secondary-container: #444559;
  --md-on-secondary-container: #E1E0F9;

  --md-tertiary: #80D4D4;
  --md-on-tertiary: #003737;
  --md-tertiary-container: #004F50;
  --md-on-tertiary-container: #9CF1F0;

  --md-error: #FFB4AB;
  --md-on-error: #690005;
  --md-error-container: #93000A;
  --md-on-error-container: #FFDAD6;

  /* softened dark neutrals (a few tones lighter than stock M3 dark —
     less contrast strain on large surfaces) */
  --md-background: #1E2028;
  --md-on-background: #E8E6F0;
  --md-surface: #1E2028;
  --md-on-surface: #E8E6F0;
  --md-surface-variant: #4C4D58;
  --md-on-surface-variant: #CDCBD6;
  --md-surface-container-lowest: #191B22;
  --md-surface-container-low: #262832;
  --md-surface-container: #2B2D38;
  --md-surface-container-high: #333644;
  --md-surface-container-highest: #3D404E;
  --md-outline: #9C9BA8;
  --md-outline-variant: #4C4D58;
  --md-inverse-surface: #E8E6F0;
  --md-inverse-on-surface: #303036;

  --md-elevation-1: 0 1px 2px rgba(0,0,0,.35), 0 1px 3px 1px rgba(0,0,0,.25);
  --md-elevation-2: 0 1px 2px rgba(0,0,0,.35), 0 2px 6px 2px rgba(0,0,0,.25);
  --md-elevation-3: 0 4px 8px 3px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.35);

  --warning: #F5C518;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Layout display rules must never reveal intentionally hidden controls. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--md-background);
  color: var(--md-on-surface);
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--md-outline-variant); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--md-outline); }

/* ============================================================
   Top App Bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 0 24px;
  height: 64px;
  background: var(--md-surface-container-low);
  border-bottom: 1px solid var(--md-outline-variant);
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* long localized titles shrink with ellipsis instead of overflowing:
   the subtitle gives way first, then the title; tabs/links never shrink */
.topbar-left > a { min-width: 0; flex: 0 1 auto; overflow: hidden; }

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--md-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 2 auto;
  min-width: 0;
}

.topbar-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-primary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--md-shape-full);
  transition: background .15s;
  white-space: nowrap;
}
.topbar-link:hover { background: var(--md-primary-container); }
.topbar-link-subtle { color: var(--md-on-surface-variant); }

.topbar-status {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  white-space: nowrap;
}
.topbar-status.active {
  background: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
}

/* language picker */
.lang-select {
  appearance: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-on-surface);
  background: var(--md-surface-container)
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2346464F'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-full);
  padding: 6px 30px 6px 14px;
  cursor: pointer;
}
.lang-select:hover { background-color: var(--md-surface-container-high); }
.lang-select:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 1px; }

/* ============================================================
   Layout
   ============================================================ */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.panel {
  width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--md-surface);
  padding: 16px;
}

.panel-left { border-right: 1px solid var(--md-outline-variant); }
.panel-right { border-left: 1px solid var(--md-outline-variant); width: 300px; }

.center-area {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--md-surface-container-low);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.panel-section:last-child { margin-bottom: 0; }
.panel-section > :is(.hint, .field-label, .config-row, .param-item,
  .export-name-field, .export-action, .btn-sm, .gia-export-group,
  .outline-intro, .primitive-toolbar) { margin: 0; }
.panel-section > .hint:empty { display: none; }

/* The upload panel is split into a scrolling content region and a fixed
   footer holding Start Processing. The scrollbar therefore belongs to the
   content region and physically ends above the footer, instead of running
   across it as it did when the whole panel was the scroll container. */
.panel-split {
  display: flex;
  flex-direction: column;
  overflow: hidden;   /* the inner region scrolls, not the panel */
  padding: 0;
}

.panel-split > .panel-scroll {
  flex: 1 1 auto;
  min-height: 0;      /* let it shrink so the footer is never pushed off */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  scrollbar-gutter: stable; /* reserve the track so content never shifts */
}

.panel-split > .panel-submit {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 16px 16px;
  border: none;
  border-top: 1px solid var(--md-outline-variant);
  border-radius: 0;
  background: var(--md-surface);
  box-shadow: 0 -6px 14px rgba(0, 0, 0, .10);
}

.panel-section > h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--md-on-surface-variant);
  margin-bottom: 0;
}

.hint {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 8px;
}

/* A hint that introduces controls has to clear them. `.hint` only carries a
   top margin, so a trailing hint keeps the section's own padding as its
   bottom spacing, but one followed by controls would otherwise sit flush
   against them. */
.hint + .config-row,
.hint + .shape-checks,
.hint + .empty-panel,
.hint + .primitive-list,
.hint + .btn-sm,
.hint + .btn-primary { margin-top: var(--space-md); }
.panel-section > .hint + * { margin-top: 0; }

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary, .btn-tonal, .btn-sm, .btn-chip, .btn-text {
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: box-shadow .15s, background .15s, filter .15s;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.btn-primary {
  width: 100%;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--md-on-primary);
  background: var(--md-primary);
  border-radius: var(--md-shape-full);
  box-shadow: var(--md-elevation-1);
}
.btn-primary:hover { box-shadow: var(--md-elevation-2); filter: brightness(1.08); }
.button-block { width: 100%; text-align: center; }
.btn-primary:disabled { opacity: .5; cursor: default; box-shadow: none; }

.btn-tonal {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--md-on-secondary-container);
  background: var(--md-secondary-container);
  border-radius: var(--md-shape-full);
  text-decoration: none;
  display: inline-block;
}
.btn-tonal:hover { box-shadow: var(--md-elevation-1); }

.btn-sm {
  width: 100%;
  padding: 9px 16px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-primary);
  background: transparent;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-full);
}
.btn-sm:hover { background: var(--md-primary-container); border-color: var(--md-primary-container); }
.btn-sm:disabled { opacity: .5; cursor: default; }

.btn-chip {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-secondary-container);
  background: var(--md-secondary-container);
  border-radius: var(--md-shape-sm);
}
.btn-chip:hover { filter: brightness(.96); }

.btn-text {
  background: transparent;
  color: var(--md-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--md-shape-full);
}
.btn-text:hover { background: var(--md-primary-container); }
.btn-text.danger { color: var(--md-error); }
.btn-text.danger:hover { background: var(--md-error-container); }

.btn-copy {
  font-family: inherit;
  border: 1px solid var(--md-outline-variant);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 12px;
  padding: 0 12px;
  border-radius: var(--md-shape-full);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-copy:hover { background: var(--md-surface-container); }
.btn-copy.is-success { color: var(--md-tertiary); border-color: var(--md-tertiary); }

.export-action { display: flex; gap: var(--space-sm); margin-bottom: 8px; min-width: 0; }
.export-action .btn-sm { margin-bottom: 0; flex: 1; }

/* ── GIA image download ──────────────────────────────────────
   The Server and the Client output are the same image in two different
   control-template structures, and picking the wrong one produces a file
   the game will not load. They therefore get separate cards with their own
   accent colour and an explicit badge, never two look-alike buttons. */
.gia-export-group {
  margin-top: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  border: 1px solid var(--md-outline-variant);
  border-left: 4px solid var(--gia-accent);
  border-radius: var(--md-shape-md);
  background: var(--md-surface-container-low);
}
.gia-export-group--server {
  --gia-accent: var(--md-primary);
  --gia-badge-bg: var(--md-primary-container);
  --gia-badge-fg: var(--md-on-primary-container);
}
.gia-export-group--client {
  --gia-accent: var(--md-tertiary);
  --gia-badge-bg: var(--md-tertiary-container);
  --gia-badge-fg: var(--md-on-tertiary-container);
}
.gia-export-group__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.gia-export-group__badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-radius: var(--md-shape-full);
  color: var(--gia-badge-fg);
  background: var(--gia-badge-bg);
}
.gia-export-group__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-on-surface);
}
.gia-export-group__desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--md-on-surface-variant);
}
.gia-export-group__note {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--md-on-surface-variant);
  border-left: 2px solid var(--warning);
  padding-left: 8px;
}
.gia-export-group__note[hidden] { display: none; }
/* Keep export modes paired; long localized labels may wrap within a button. */
.gia-export-group .export-action {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 0;
}
.gia-export-group .btn-sm {
  min-width: 0;
  white-space: normal;
  overflow-wrap: normal;
  color: var(--gia-accent);
  padding: 8px 12px;
  line-height: 1.3;
}
#btnExportClientLua { grid-column: 1 / -1; }
.gia-export-group .btn-sm:hover {
  background: var(--gia-badge-bg);
  border-color: var(--gia-badge-bg);
  color: var(--gia-badge-fg);
}
.gia-export-group .btn-sm:disabled:hover {
  background: transparent;
  border-color: var(--md-outline-variant);
  color: var(--gia-accent);
}
/* Required input inside a card (the Lua script's Image Control Template
   index): compact label with a required marker, and an error border once
   something non-numeric is typed. */
/* Same 10px step the card uses between its description and the buttons,
   and the input shares the buttons' font size, padding and line height so
   the stack reads as one column of equal-height controls. */
.gia-export-group__field { margin: 0; display: grid; gap: 6px; }
.gia-export-group__field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--md-on-surface-variant);
  margin-bottom: 0;
}
.gia-export-group__field > label::after { content: " *"; color: var(--md-error); }
.gia-export-group__field .form-input {
  font-size: 13px;
  padding: 8px 12px;
  line-height: 1.3;
}
.gia-export-group__field .form-input.is-invalid { border-color: var(--md-error); }
.lua-export-section {
  border-top: 1px solid var(--md-outline-variant);
  padding-top: 10px;
  min-width: 0;
}
.lua-export-options .check-label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 11px; font-weight: 600; color: var(--md-on-surface-variant); }
.lua-export-options .hint { margin: 6px 0 0; font-size: 11px; line-height: 1.45; }
.animation-lua-methods {
  font-size: 11px;
  line-height: 1.45;
  color: var(--md-on-surface-variant);
  min-width: 0;
}
.animation-lua-methods h4 { margin: 0 0 8px; font-size: 12px; color: var(--md-on-surface); }
.animation-lua-methods dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 10px; margin: 0; }
.animation-lua-methods dt, .animation-lua-methods dd { margin: 0; }
.animation-lua-methods p { margin: 10px 0 4px; }
.animation-lua-methods code { font-size: 11px; color: var(--gia-accent); }
.animation-lua-methods__example { display: block; overflow-wrap: anywhere; }
.gia-export-group__desc--field { margin: 0; }

/* Optional per-batch template index next to Download all (ZIP). The dashed,
   borderless-looking field and italic placeholder read as "optional" beside
   the tonal button; it is hidden together with the button. */
.batch-template-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--md-on-surface-variant);
}
.batch-template-field[hidden] { display: none; }
.batch-template-field input {
  font-family: inherit;
  font-size: 12px;
  width: 120px;
  padding: 6px 10px;
  color: var(--md-on-surface);
  background: transparent;
  border: 1px dashed var(--md-outline, var(--md-outline-variant));
  border-radius: var(--md-shape-full);
}
.batch-template-field input::placeholder {
  color: var(--md-on-surface-variant);
  opacity: .7;
  font-style: italic;
}
.batch-template-field input:focus {
  outline: 2px solid var(--md-primary);
  outline-offset: -1px;
  border-style: solid;
  border-color: transparent;
}
.batch-template-field input.is-invalid { border-style: solid; border-color: var(--md-error); }
.batch-template-field input[type="number"] { width: 72px; }

/* ============================================================
   Drop zone
   ============================================================ */
.drop-zone {
  position: relative;
  border: 2px dashed var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--md-surface-container-low);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}
.drop-zone.ready { border-style: solid; border-color: var(--md-tertiary); }

.drop-zone-content p { font-size: 13px; color: var(--md-on-surface-variant); margin-top: 6px; }

.drop-icon {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--md-primary);
  background: var(--md-primary-container);
  padding: 4px 10px;
  border-radius: var(--md-shape-sm);
}

.upload-ready {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--md-on-tertiary-container);
  background: var(--md-tertiary-container);
  border-radius: var(--md-shape-sm);
  padding: 6px 10px;
}

.upload-warning {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-error-container);
  background: var(--md-error-container);
  border-radius: var(--md-shape-sm);
  padding: 6px 10px;
}

/* Adaptive preview grid: 1 image = large preview; more images = tighter
 * grid (columns set via --thumb-cols from JS). Aspect ratios preserved via
 * object-fit: contain on a checkered backdrop. */
.file-thumbs {
  display: grid;
  grid-template-columns: repeat(var(--thumb-cols, 3), 1fr);
  gap: 8px;
  margin-top: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
}
.file-thumbs:empty { display: none; }
/* Each thumbnail is its own stacking context, so its buttons stay above the
   image but never above the header, menus or the focus editor. */
.file-thumb {
  position: relative;
  isolation: isolate;
  min-width: 0;
  container-type: inline-size;
}
.file-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: var(--md-shape-xs);
  border: 1px solid var(--md-outline-variant);
  background:
    repeating-conic-gradient(#eceaf2 0 25%, #ffffff 0 50%) 0 0/14px 14px;
  transition: aspect-ratio .2s ease, border-color .15s ease;
}
.file-thumbs[data-count="1"] {
  grid-template-columns: 1fr;
}
.file-thumbs[data-count="1"] .file-thumb img {
  aspect-ratio: auto;
  max-height: 260px;
}
.file-thumbs[data-count="2"] .file-thumb img,
.file-thumbs[data-count="3"] .file-thumb img,
.file-thumbs[data-count="4"] .file-thumb img {
  aspect-ratio: 4 / 3;
}
.file-thumb-btn {
  position: absolute;
  top: 4px;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  font: 600 13px/1 inherit;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.file-thumb-btn[hidden] { display: none; }
.file-thumb-btn:hover, .file-thumb-btn:focus-visible {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}
.file-thumb-remove { right: 4px; }
.file-thumb-remove:hover, .file-thumb-remove:focus-visible {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
}
.file-thumb-focus {
  top: auto;
  bottom: 4px;
  left: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 8px);
  padding: 0 10px 0 8px;
  border-color: var(--md-primary);
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-size: 12px;
  white-space: nowrap;
}
.file-thumb-focus:hover, .file-thumb-focus:focus-visible {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}
.file-thumb-label { overflow: hidden; text-overflow: ellipsis; }
/* Small thumbnails drop the "Focus:" prefix but keep the state; tiny ones keep the icon. */
@container (max-width: 110px) {
  .file-thumb-prefix { display: none; }
  .file-thumb-focus { padding: 0 6px; font-size: 11px; }
}
@container (max-width: 52px) {
  .file-thumb-label { display: none; }
}
.file-thumbs.focusable .file-thumb img { cursor: pointer; }
.file-thumbs.focusable .file-thumb img:hover { border-color: var(--md-primary); }
.focus-thumb-hint { margin-top: 6px; }

.focus-settings { display: grid; gap: 4px; }
.focus-settings[hidden] { display: none; }
.experimental-settings { border-top: 1px solid var(--md-outline-variant); padding-top: 4px; }
.experimental-settings[hidden] { display: none; }
.experimental-settings summary { cursor: pointer; padding: 6px 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--md-on-surface); }
.experimental-settings summary::-webkit-details-marker { display: none; }
.experimental-settings summary::before { content: "▸"; width: 10px; color: var(--md-on-surface-variant); }
.experimental-settings[open] summary::before { content: "▾"; }
.experimental-list { display: grid; gap: 6px; padding-bottom: 4px; }
/* Shared enhancement switches for upload and re-processing. */
/* Settings row: text on the left, switch on the right, centered vertically. */
.enhancement-controls {
  min-width: 0;
  margin: 0;
  padding: 4px 0;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  background: var(--md-surface-container);
}
.enhancement-controls legend {
  margin-left: 10px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--md-on-surface-variant);
}
.enhancement-controls .focus-switch {
  margin-top: 0;
  border: 0;
  border-radius: 0;
}
.focus-switch {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  background: var(--md-surface-container);
  cursor: pointer;
}
.focus-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.focus-switch-track {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  width: 36px;
  height: 20px;
  border-radius: var(--md-shape-full);
  background: var(--md-outline);
  transition: background .15s;
}
.focus-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--md-surface-container-lowest);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .15s;
}
.focus-switch input:checked + .focus-switch-track { background: var(--md-primary); }
.focus-switch input:checked + .focus-switch-track::after { transform: translateX(16px); }
.focus-switch input:focus-visible + .focus-switch-track { outline: 2px solid var(--md-primary); outline-offset: 2px; }
.focus-switch-text { grid-column: 1; grid-row: 1; display: grid; gap: 2px; min-width: 0; }
.focus-switch-text strong { font-size: 13px; }
.focus-switch-text small { font-size: 12px; line-height: 1.4; color: var(--md-on-surface-variant); }

/* Focus editor: a modal above every page layer. */
.focus-editor {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .5);
}
.focus-editor[hidden] { display: none; }
.focus-editor-panel {
  display: grid;
  gap: var(--space-sm, 8px);
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
  border-radius: var(--md-shape-lg);
  background: var(--md-surface-container-low);
  color: var(--md-on-surface);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .35);
}
.focus-stage {
  position: relative;
  justify-self: center;
  max-width: 100%;
  line-height: 0;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
  border-radius: var(--md-shape-xs);
  background:
    repeating-conic-gradient(#eceaf2 0 25%, #ffffff 0 50%) 0 0/14px 14px;
}
.focus-stage img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  pointer-events: none;
}
.focus-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.focus-shade[hidden] { display: none; }
.focus-areas { position: absolute; inset: 0; }
.focus-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-sm, 8px); }
.focus-stage.off { cursor: default; }
.focus-stage.off .focus-areas { opacity: .35; }
.focus-mode {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  background: var(--md-surface-container);
  cursor: pointer;
}
.focus-mode:has(input:checked) { border-color: var(--md-primary); background: var(--md-primary-container); color: var(--md-on-primary-container); }
.focus-mode input { margin-top: 3px; accent-color: var(--md-primary); }
.focus-mode span { display: grid; gap: 2px; min-width: 0; }
.focus-mode strong { font-size: 14px; }
.focus-mode small { font-size: 12px; line-height: 1.35; opacity: .85; }
@media (max-width: 520px) { .focus-modes { grid-template-columns: 1fr; } }
.focus-instruction { margin: 0; font-size: 13px; font-weight: 600; color: var(--md-on-surface); }
.focus-instruction:empty { display: none; }
.focus-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--md-on-surface-variant); }
.focus-legend[hidden], .focus-legend-item[hidden] { display: none; }
.focus-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.focus-swatch { width: 18px; height: 12px; border-radius: 2px; flex: 0 0 auto; }
.focus-swatch-auto { background: linear-gradient(90deg, rgba(0, 0, 0, .63), #fff); border: 1px solid var(--md-outline-variant); }
.focus-swatch-mine { border: 2px solid var(--md-primary); background: color-mix(in srgb, var(--md-primary) 20%, transparent); }
.focus-editor-actions .btn-text:disabled { opacity: .45; cursor: default; background: transparent; }
.focus-status { min-height: 1.4em; margin: 0; }
.focus-status:empty { min-height: 0; }
.focus-area {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--md-primary);
  background: color-mix(in srgb, var(--md-primary) 20%, transparent);
}
.focus-area button {
  position: absolute;
  top: -12px;
  right: -12px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  font: 600 13px/1 inherit;
  cursor: pointer;
}
.focus-area button:hover, .focus-area button:focus-visible {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
}
.focus-editor-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-sm, 8px); }
.focus-editor-actions .btn-primary, .focus-editor-actions .btn-text { width: auto; white-space: nowrap; overflow-wrap: normal; }
.focus-editor-actions .btn-primary { padding: 10px 28px; }

/* ============================================================
   Shape checks / params
   ============================================================ */
.shape-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
/* Four equal cards in a compact 2 × 2 grid, including translated labels. */
#legacyShapeChecks .shape-check,
#retryShapeChecks .shape-check { justify-content: center; min-height: 76px; }
#legacyShapeChecks .shape-check > span:last-child,
#retryShapeChecks .shape-check > span:last-child { line-height: 1.3; }
#fillShapeSection { display: grid; gap: var(--space-md); }
#fillShapeSection > .hint { margin: 0; }
.form-stack { display: grid; gap: var(--space-md); min-width: 0; }
.form-field { display: grid; gap: 6px; min-width: 0; }
.form-field > label { font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); }

/* Sub-label for a control group inside a panel section (e.g. the primitive
   type picker in the Re-process panel), tighter than a section heading. */
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  margin-bottom: 6px;
}

/* Keep following controls off the picker when it is not the last element. */
.shape-checks + .config-row,
.shape-checks + .btn-sm,
.shape-checks + .btn-primary { margin-top: 0; }

.shape-check {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  min-width: 0;
  text-align: center;
  overflow-wrap: anywhere;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  cursor: pointer;
  font-size: 12px;
  color: var(--md-on-surface-variant);
  transition: background .15s, border-color .15s;
}
.shape-check input { display: none; }
.shape-check:has(input:disabled) { opacity: .45; cursor: default; }
.shape-check .shape-icon { font-size: 18px; line-height: 1; }
.shape-check.active {
  background: var(--md-primary-container);
  border-color: var(--md-primary);
  color: var(--md-on-primary-container);
  font-weight: 600;
}

.param-item { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: 16px; }
.param-item:last-child { margin-bottom: 0; }
.param-item:has(#enhancedMode:disabled) { display: none; }

.param-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: 0;
}
.param-title { font-size: 13px; font-weight: 600; }
.val-tag {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--md-on-primary-container);
  background: var(--md-primary-container);
  border-radius: var(--md-shape-xs);
  padding: 1px 8px;
}
.param-desc { font-size: 12px; color: var(--md-on-surface-variant); margin-bottom: 0; }
.param-desc:empty { display: none; }

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--md-on-surface);
  cursor: pointer;
}

input[type="range"] {
  display: block;
  margin-block: 8px;
  width: 100%;
  height: 4px;
  appearance: none;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--md-primary) 0%,
    var(--md-primary) var(--slider-fill, 50%),
    var(--md-surface-variant) var(--slider-fill, 50%),
    var(--md-surface-variant) 100%);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--md-primary);
  border: 3px solid var(--md-surface-container-lowest);
  box-shadow: var(--md-elevation-1);
  cursor: grab;
}

.num-input, .form-input, .form-select {
  font-family: inherit;
  font-size: 13px;
  color: var(--md-on-surface);
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-sm);
  padding: 7px 10px;
  width: 100%;
  min-width: 0;
  min-height: 36px;
}
.num-input:focus, .form-input:focus, .form-select:focus {
  outline: 2px solid var(--md-primary);
  outline-offset: -1px;
  border-color: transparent;
}

.config-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, 110px);
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 8px;
}
.config-row label { font-size: 13px; color: var(--md-on-surface-variant); flex-shrink: 0; }
.config-row .num-input { width: 100%; min-width: 0; }
.config-row--paired { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); }
.check-label input, .radio-row input { flex-shrink: 0; margin-top: 4px; accent-color: var(--md-primary); }

.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 0;
}

/* ============================================================
   Primitive cards (outline mode)
   ============================================================ */
.outline-intro {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--md-surface-container-low);
  border-radius: var(--md-shape-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--md-on-surface-variant);
}
.outline-intro strong { font-size: 13px; color: var(--md-on-surface); }

.primitive-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.primitive-list { display: flex; flex-direction: column; gap: 10px; }

.primitive-card {
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  padding: 12px;
  background: var(--md-surface-container-lowest);
}

.primitive-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.primitive-card-head .form-select { flex: 1; width: auto; }

.primitive-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--md-shape-xs);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  white-space: nowrap;
}
.primitive-badge[data-shape="rect"] {
  background: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
}

.primitive-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primitive-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.primitive-field-label { font-size: 11px; font-weight: 600; color: var(--md-on-surface-variant); }

.primitive-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--md-on-surface-variant);
}

.primitive-remove { margin-left: auto; }

.primitive-empty {
  text-align: center;
  padding: 18px 10px;
  border: 1px dashed var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  color: var(--md-on-surface-variant);
}
.primitive-empty p { font-weight: 600; font-size: 13px; }
.primitive-empty span { font-size: 12px; }

/* ============================================================
   Batch queue
   ============================================================ */
.batch-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.batch-header h2 { font-size: 16px; font-weight: 600; margin-right: auto; }

.overall-progress {
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-lg);
  padding: 14px 16px;
}
.overall-progress .progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-bottom: 6px;
}

.progress-track {
  height: 8px;
  background: var(--md-surface-variant);
  border-radius: var(--md-shape-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--md-shape-full);
  background: var(--md-primary);
  transition: width .3s ease;
  min-width: 0;
}

.job-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
}

/* ── theme toggle / result editor controls ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-full);
  width: 32px;
  height: 32px;
  line-height: 1;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--md-surface-container-high); }

.edit-tools { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.btn-text.danger { color: var(--md-error); }
.btn-text.active, .btn-sm.active {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.btn-text:disabled { opacity: 0.4; cursor: default; }

.edit-panel { display: flex; flex-direction: column; gap: var(--space-md); margin-top: 0; border-top: 1px solid var(--md-outline-variant); padding-top: 12px; }
.edit-panel h3, .edit-panel .config-row, .edit-panel .hint { margin: 0; }
.edit-panel .config-row { flex-wrap: wrap; }
.color-input {
  width: 44px;
  height: 26px;
  padding: 0 2px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-xs);
  background: var(--md-surface-container-lowest);
  cursor: pointer;
}
.background-color-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

#mainCanvas.picking { cursor: crosshair; }

.job-card {
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-lg);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--md-elevation-1);
  /* large batches: skip layout/paint for off-screen cards */
  content-visibility: auto;
  contain-intrinsic-size: auto 92px;
}

.job-thumb {
  width: 64px; height: 64px;
  object-fit: contain;
  border-radius: var(--md-shape-sm);
  border: 1px solid var(--md-outline-variant);
  background:
    repeating-conic-gradient(#e8e8ee 0 25%, #ffffff 0 50%) 0 0/16px 16px;
  flex-shrink: 0;
}

.job-body { flex: 1; min-width: 0; }

.job-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 6px;
  font-size: 12px;
  color: var(--md-on-surface-variant);
}

.job-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--md-shape-full);
  white-space: nowrap;
}
.job-status.queued { background: var(--md-surface-container-high); color: var(--md-on-surface-variant); }
.job-status.processing { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.job-status.done { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.job-status.error { background: var(--md-error-container); color: var(--md-on-error-container); }
.job-status.cancelled { background: var(--md-surface-container-high); color: var(--md-outline); }
.job-status.paused { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.job-status.pausing { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.generation-preview-heading { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.generation-preview-heading h3 { margin:0; }

.job-progress { margin-bottom: 6px; }
.job-progress .progress-track { height: 5px; }

.job-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.job-actions .btn-text { padding: 4px 10px; font-size: 12px; }

.job-error {
  font-size: 12px;
  color: var(--md-on-error-container);
  background: var(--md-error-container);
  padding: 6px 8px;
  border-radius: var(--md-shape-xs);
  margin-bottom: 6px;
  word-break: break-word;
}

.batch-empty {
  border: 2px dashed var(--md-outline-variant);
  border-radius: var(--md-shape-lg);
  text-align: center;
  padding: 48px 20px;
  color: var(--md-on-surface-variant);
}
.batch-empty p { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.batch-empty span { font-size: 13px; }

/* ============================================================
   Guide / notices
   ============================================================ */
.guide-card .steps {
  margin: 0 0 0 18px;
  font-size: 13px;
  color: var(--md-on-surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tips {
  list-style: disc;
  margin-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--md-on-surface-variant);
}
.tips a { color: var(--md-primary); }

/* ============================================================
   Result view
   ============================================================ */
.canvas-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--md-surface-container-low);
  overflow: hidden;
}

.canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px;
}

/* Out of flow: the canvas is sized from the wrap, so it must not size the wrap
   (on narrow layouts that made the canvas grow on every render). */
#mainCanvas {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--md-shape-sm);
  touch-action: none;   /* wheel zoom + pointer pan/pinch handled in JS */
  cursor: grab;
}
#mainCanvas.dragging { cursor: grabbing; }
.layer-pill {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  border: 1px solid var(--md-outline-variant);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.layer-pill[hidden] { display: none; }
.layer-pill-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.layer-pill-btn:hover:not(:disabled) { background: var(--md-surface-container-highest); }
.layer-pill-btn:disabled { opacity: 0.35; cursor: default; }
.layer-pill-pos { padding: 0 8px 0 4px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--md-on-surface-variant); }

.zoom-label {
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 44px;
  text-align: right;
  color: var(--md-on-surface-variant);
}

.tooltip {
  position: absolute;
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  font-size: 12px;
  line-height: 1.6;
  border-radius: var(--md-shape-sm);
  padding: 8px 10px;
  pointer-events: none;
  z-index: 10;
  box-shadow: var(--md-elevation-2);
  max-width: 260px;
}

.canvas-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--md-outline-variant);
  background: var(--md-surface);
  font-size: 12px;
  color: var(--md-on-surface-variant);
}
.canvas-bar label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.preview-compare {
  display: flex;
    flex-wrap: wrap;
  gap: 12px;
  padding: 0 16px 12px;
  justify-content: center;
}
.preview-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.preview-label { font-size: 11px; color: var(--md-on-surface-variant); font-weight: 600; }
.preview-hint { flex-basis: 100%; margin: 0; text-align: center; }
.preview-toggle {
  appearance: none;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: var(--md-shape-md);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.preview-toggle:hover { background: var(--md-surface-container-high); }
.preview-toggle:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }
.preview-toggle[aria-pressed="true"] {
  border-color: var(--md-primary);
  background: color-mix(in srgb, var(--md-primary) 14%, transparent);
}
.preview-toggle[aria-pressed="true"] .preview-label { color: var(--md-primary); }
.preview-thumb {
  width: auto;
  max-inline-size: 100%;
  max-width: 160px;
  max-height: 110px;
  border-radius: var(--md-shape-sm);
  border: 1px solid var(--md-outline-variant);
  background:
    repeating-conic-gradient(#e8e8ee 0 25%, #ffffff 0 50%) 0 0/12px 12px;
}

.elem-info table { width: 100%; border-collapse: collapse; font-size: 12px; }
.elem-info td { padding: 5px 4px; border-bottom: 1px solid var(--md-surface-variant); }
.elem-info td:first-child { color: var(--md-on-surface-variant); white-space: nowrap; }
.elem-info td:last-child { font-family: var(--font-mono); text-align: right; word-break: break-all; }
.elem-info tr:last-child td { border-bottom: none; }

.empty-panel {
  text-align: center;
  padding: 20px 10px;
  color: var(--md-on-surface-variant);
}
.empty-panel p { font-weight: 600; font-size: 13px; }
.empty-panel span { font-size: 12px; }

.export-name-field { display: grid; gap: 6px; margin-bottom: 0; }
.export-name-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--md-on-surface-variant);
  margin-bottom: 0;
}

/* ============================================================
   Classic (GIA convert) tool
   ============================================================ */
.tool-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.classic-tool-copy { max-width: 440px; text-align: center; }
.classic-tool-copy h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.classic-tool-copy p { font-size: 14px; color: var(--md-on-surface-variant); }
.classic-tool-copy code {
  font-family: var(--font-mono);
  background: var(--md-surface-container-high);
  padding: 1px 6px;
  border-radius: var(--md-shape-xs);
}

.file-name { display: block; margin-top: 6px; font-size: 12px; color: var(--md-on-surface-variant); word-break: break-all; }

/* ============================================================
   Footer note
   ============================================================ */
.local-note {
  text-align: center;
  font-size: 11px;
  color: var(--md-outline);
  padding: 4px 0 8px;
}

/* ============================================================
   Views
   ============================================================ */
.view { display: none; }
.view.active { display: flex; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .panel { width: 300px; }
  .panel-right { width: 260px; }
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; padding: 12px 20px; }
  .topbar-left { flex-wrap: wrap; overflow: visible; gap: 8px 12px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-layout { flex-direction: column; flex: 0 0 auto; min-height: calc(100vh - 128px); }
  .panel, .panel-right {
    width: 100%;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid var(--md-outline-variant);
    overflow: visible;
  }
  .center-area { order: -1; min-height: 200px; }
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 16px;
  }
  .topbar-subtitle { display: none; }
  /* stacked layout scrolls the page, not the panel, so there is no inner
     scroll container to separate: the footer becomes a normal section */
  .panel-split { display: block; overflow: visible; padding: 16px; }
  .panel-split > .panel-scroll {
    overflow: visible;
    padding: 0;
    scrollbar-gutter: auto;
  }
  .panel-split > .panel-submit {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--md-outline-variant);
    border-radius: var(--md-shape-lg);
    background: var(--md-surface-container-lowest);
    box-shadow: none;
  }
  /* narrow screens: both topbar rows wrap instead of overflowing */
  .topbar-left { flex: 1 1 100%; flex-wrap: wrap; overflow: visible; gap: 8px 12px; }
  .topbar-right { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; gap: 8px; justify-content: flex-start; }
  .topbar-status { margin-left: auto; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .canvas-area { min-height: 60vh; }
  #viewResult > .canvas-area { order: -1; }
  .canvas-wrap { min-height: 320px; }
  .canvas-bar { gap: 8px 12px; }
  .center-area { overflow: visible; padding: 20px 16px; }
}

.compression-limits { margin-top: 12px; }
#legacyShapeChecks, #retryShapeChecks { grid-template-columns: repeat(3,minmax(0,1fr)); }
#legacyShapeChecks.primeval-palette, #retryShapeChecks.primeval-palette { grid-template-columns: repeat(2,minmax(0,1fr)); }
#legacyShapeChecks[hidden], #retryShapeChecks[hidden] { display:none; }
#primevalSettings, #retryPrimevalSettings { margin-top:12px; }
.compression-limits summary, #retryLegacySettings summary { cursor: pointer; padding: 8px 0; }
#compressionReport [role="status"] { font-weight: 600; }
#compressionReport[data-valid="false"] [role="status"] { color: var(--md-error, #ffb4ab); }
#compressionReport td { overflow-wrap: anywhere; }
.job-status.quality-failed, .topbar-status.quality-failed { color: var(--md-error, #ffb4ab); background: var(--md-error-container, #4a2529); }

@media (max-width: 520px) {
  .topbar { padding: 12px; }
  .topbar-left > a:first-child { flex: 1; }
  .topbar-link { padding: 6px 8px; font-size: 12px; }
  .lang-select { max-width: 144px; }
  .panel { padding: 12px; }
  .panel-split { padding: 12px; }
  .panel-section { padding: 14px; }
  .center-area { padding: 16px 12px; }
  .canvas-bar, .preview-compare { padding: 12px; }
  .batch-header { gap: 8px; }
  .batch-header > h2 { flex-basis: 100%; }
}

.generation-preview{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:16px;border:1px solid var(--md-outline-variant);border-radius:16px;margin-bottom:16px}.generation-preview img{width:100%;max-height:420px;object-fit:contain;background:repeating-conic-gradient(#454545 0% 25%,#333 0% 50%) 0/20px 20px}.generation-preview select{min-width:0;width:100%}

.job-card{cursor:pointer}.job-card.preview-selected{outline:2px solid var(--md-primary);outline-offset:-2px}#generationVector{background:repeating-conic-gradient(#454545 0% 25%,#333 0% 50%) 0/20px 20px}#generationVector>svg{display:block;width:100%;height:420px;max-height:50vh}#refinementProgress{width:100%;accent-color:var(--md-primary)}

.screen-sizing-dialog{margin:auto;width:min(1000px,94vw);max-height:94vh;overflow:auto;border:1px solid var(--md-outline-variant);border-radius:20px;padding:20px;background:var(--md-surface);color:var(--md-on-surface)}
.screen-sizing-dialog::backdrop{background:#0009}.screen-sizing-dialog h3{margin:0 0 12px}.screen-devices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.screen-devices button{white-space:normal}.screen-devices [aria-pressed="true"]{outline:2px solid var(--md-primary)}
.screen-sizing-stage{position:relative;aspect-ratio:16/9;background:#333 center/100% 100% no-repeat;overflow:hidden;touch-action:none;border:2px solid var(--md-outline-variant)}
.screen-sizing-art{display:contents}#screenSizingImage{position:absolute;max-width:none;height:auto;transform:translate(-50%,-50%);cursor:move;user-select:none;outline:1px solid #64c8ff}#screenSizingHandle{position:absolute;width:22px;height:22px;background:#64c8ff;border:2px solid white;border-radius:4px;cursor:nwse-resize;transform:translate(-50%,-50%)}
.screen-sizing-controls,.screen-sizing-actions{display:flex;gap:16px;align-items:center;flex-wrap:wrap}.screen-sizing-controls label{display:flex;gap:8px;align-items:center}.screen-sizing-controls input[type="number"]{width:130px}.screen-sizing-actions{justify-content:flex-end;margin-top:16px}
@media(max-width:520px){.screen-sizing-dialog{padding:12px}.screen-devices{grid-template-columns:repeat(2,minmax(0,1fr))}}

.screen-sizing-actions .btn-sm,.screen-sizing-actions .btn-primary{width:auto;margin:0;white-space:nowrap}.screen-sizing-actions{gap:8px}.screen-devices .btn-sm{margin:0}.screen-sizing-dialog>.hint{margin:8px 0}.screen-sizing-dialog>.screen-devices{margin-bottom:12px}

.screen-sizing-stage[data-device="0"]{background-image:url("../assets/screen-backdrops/pc.png")}

.screen-sizing-stage[data-device="1"]{background-image:url("../assets/screen-backdrops/mobile.png")}

.screen-sizing-stage[data-device="2"]{background-image:url("../assets/screen-backdrops/controller.png")}

.screen-sizing-stage[data-device="3"]{background-image:url("../assets/screen-backdrops/mobile-controller.png")}

.screen-sizing-controls .btn-sm{width:auto;margin:0}

.input-drop-overlay{position:fixed;inset:12px;z-index:10000;pointer-events:none;display:grid;place-items:center;border:3px dashed var(--md-primary);border-radius:24px;background:color-mix(in srgb,var(--md-surface) 85%,transparent);color:var(--md-on-surface);font-size:20px;text-align:center;padding:24px}.input-drop-overlay[hidden]{display:none}

.animation-preview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--md-outline-variant);
}
.animation-preview .btn-sm { width: auto; margin: 0; }
.animation-preview input { flex: 1; min-width: 100px; accent-color: var(--md-primary); }
.animation-preview .hint { flex-basis: 100%; margin: 0; }
#animationSettings {
  margin-top: 12px;
  padding: 12px;
  display: grid;
  gap: 12px;
}
#animationSettings .hint { margin: 0; }
.animation-loop { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.animation-loop input { margin: 0; accent-color: var(--md-primary); }

#viewResult.animation-result .panel-right>.panel-section:first-child>:not(#btnBackToJobs),#viewResult.animation-result #editTools,#viewResult.animation-result #clientMaskPreviewRow{display:none}

/* Animation export options follow the shared checkbox controls. */
#batchAnimationCompact { width: auto; padding: 0; accent-color: var(--md-primary); }
#clientAnimationCompactField .hint { margin-top: 4px; }
#clientAnimationCompactField .check-label { display: flex; align-items: center; gap: 8px; }
#clientAnimationCompactField input { margin: 0; }

.animation-fps { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.animation-fps input { width: 90px; }
.animation-source { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.animation-source canvas { width: 100%; height: auto; max-height: 180px; object-fit: contain; background: #171921; border-radius: 8px; }
.animation-source .hint { margin: 0; flex: 1; }
.animation-source .btn-sm { width: auto; }

.animation-generation-toolbar,.animation-generation-active { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.animation-generation-toolbar { justify-content:space-between; margin:8px 0; }
.animation-generation-toolbar .check-label { display:flex; gap:6px; align-items:center; font-size:12px; }
.animation-generation-active .btn-sm { width:auto; }
#animationGenerationFrame { width:100%; accent-color:var(--md-primary); }
.animation-generation-strip { overflow-x:auto; height:94px; margin-top:6px; }
#animationGenerationTrack { position:relative; height:84px; }
.animation-generation-thumb { position:absolute; width:72px; padding:3px; border:1px solid var(--md-outline-variant); border-radius:6px; background:transparent; color:var(--md-on-surface); cursor:pointer; }
.animation-generation-thumb[aria-pressed="true"] { border-color:var(--md-primary); }
.animation-generation-thumb img { width:64px; height:64px; object-fit:contain; display:block; }
.animation-generation-thumb span { font-size:10px; }

/* Pixel-perfect previews: scale bitmaps with hard pixel edges. */
img.pixelated, .pixelated img, .pixelated canvas { image-rendering: pixelated; }
