:root {
  /* Windows 11 light theme — slightly deeper neutrals */
  --bg-app: #ececec;
  --bg-panel: #f4f4f4;
  --bg-elevated: #efefef;
  --bg-canvas-area: #e0e0e0;
  --pad-paper: #f0efeb;
  --pad-paper-dark: #e0ded9;
  --bg-canvas: var(--pad-paper);
  --bg-canvas-border: #b8b6b3;
  --binder-metal: #8a8886;
  --binder-metal-light: #c4c2c0;
  --binder-bar: #605e5c;
  --text: #1a1a1a;
  --text-primary: var(--text);
  --text-muted: #5c5a58;
  --accent: #0067c0;
  --accent-hover: #0078d4;
  --accent-pressed: #005a9e;
  --accent-muted: rgba(0, 103, 192, 0.1);
  --accent-muted-strong: rgba(0, 103, 192, 0.16);
  --danger: #c42b1c;
  --danger-hover: #a52613;
  --border: #d6d6d6;
  --border-strong: #b8b6b3;
  --control-fill: #f2f2f2;
  --control-fill-hover: rgba(0, 0, 0, 0.05);
  --control-fill-pressed: rgba(0, 0, 0, 0.032);
  --selection: #0067c0;
  --shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --canvas-w: 480px;
  --canvas-h: 600px;
}

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

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-app);
  overflow: hidden;
}

input[type="range"] {
  accent-color: var(--accent);
}

.file-protocol-warning {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  background: var(--bg-panel);
  color: var(--text-primary);
  text-align: center;
  font-size: 1.1rem;
}

.file-protocol-warning[hidden] {
  display: none !important;
}

.file-protocol-warning a {
  color: var(--accent);
}

code {
  font-size: 0.85em;
  background: var(--control-fill-hover);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-header__lead {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.portal-back-btn {
  flex-shrink: 0;
  text-decoration: none;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-icon {
  font-size: 1.5rem;
  color: var(--accent);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-pressed);
  border-color: var(--accent-pressed);
}

.btn-ghost {
  background: var(--control-fill);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--control-fill-hover);
}

.btn-ghost:active:not(:disabled) {
  background: var(--control-fill-pressed);
}

.btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(196, 43, 28, 0.08);
}

/* Workspace layout */
.workspace {
  --parts-panel-width: 326px;
  --pad-position-stack-width: 9.5rem;
  display: grid;
  grid-template-columns: var(--parts-panel-width) 1fr 240px var(--pad-position-stack-width);
  height: calc(100vh - 52px - 32px);
  min-height: 0;
}

.panel {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-parts {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.panel-inspector {
  border-right: none;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.subject-info-section {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.subject-accordion {
  min-height: 0;
}

.subject-accordion:not([open]) {
  overflow: visible;
}

.subject-accordion[open] {
  overflow: visible;
}

.subject-accordion-trigger {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
}

.subject-accordion-trigger::-webkit-details-marker {
  display: none;
}

.subject-accordion-trigger::marker {
  content: "";
  display: none;
}

.subject-accordion-trigger::after {
  content: "";
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.15rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.subject-accordion[open] > .subject-accordion-trigger::after {
  transform: rotate(-135deg);
}

.subject-accordion-trigger:hover {
  background: var(--control-fill-hover);
}

.subject-accordion-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.subject-accordion-trigger h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.subject-accordion-body {
  min-width: 0;
}

.print-preview-section {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-width: 0;
  border-bottom: 1px solid var(--border);
}

.print-preview-section.print-preview-section--hidden {
  display: none !important;
}

.print-preview-section[open] {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.print-preview-header {
  flex-shrink: 0;
}

.print-preview-accordion-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.print-preview-section .output-preview-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 1rem 0.5rem;
}

.profile-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
  margin-top: auto;
}

.btn-block {
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

.print-preview-section[open] .output-preview {
  flex: 1;
  min-height: 14rem;
}

.print-preview-section .output-preview {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  container-type: inline-size;
  container-name: print-preview;
}

.inspector-layer-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.subject-fields {
  padding: 0.5rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subject-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.subject-field input {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--control-fill);
  color: var(--text-primary);
}

.subject-field select {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--control-fill);
  color: var(--text-primary);
}

.subject-field input:focus,
.subject-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.output-preview-wrap {
  padding: 0 1rem 0.85rem;
}

.output-preview-label {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.output-preview {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0.5rem;
  overflow: visible;
}

/* Shared print / preview sheet layout */
.print-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--pad-paper);
  color: #1a1a1a;
  font-family: Georgia, "Times New Roman", serif;
}

/* Sidebar preview: letter portrait (8.5" × 11"), scaled to fit the panel */
.print-sheet--screen {
  flex: 0 0 auto;
  width: min(100%, 100cqw);
  max-width: 100%;
  aspect-ratio: 8.5 / 11;
  height: auto;
  min-height: 10rem;
  max-height: 100%;
  margin: 0 auto;
  overflow: hidden;
  box-sizing: border-box;
}

.print-sheet--screen.print-sheet--blank {
  background: var(--pad-paper);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.print-sheet--screen.print-sheet--blank > .print-title-bar,
.print-sheet--screen.print-sheet--blank > .print-sketch-frame,
.print-sheet--screen.print-sheet--blank > .print-info-box {
  display: none !important;
}

.print-sheet--screen .print-title-bar {
  flex-shrink: 0;
  border: 2px solid #2a2a2a;
}

.print-sheet--screen .print-title-main {
  font-size: clamp(0.55rem, 8cqi, 1.1rem);
}

.print-sheet--screen .print-title-secondary {
  width: 100%;
  max-width: 100%;
  font-size: clamp(0.5rem, 6.5cqi, 0.95rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: normal;
}

.print-sheet--screen .print-title-block {
  min-width: 0;
}

.print-sheet--screen .print-info-grid-row {
  flex-wrap: nowrap;
}

.print-sheet--screen .print-info-item {
  flex: 0 1 auto;
  max-width: 100%;
}

.print-title-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #2a2a2a;
  background: #b91c1c;
  padding: 0.4rem 0.5rem;
  text-align: center;
  color: #fff;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.print-title-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  max-width: 100%;
}

.print-title-main {
  margin: 0;
  width: 100%;
  max-width: 100%;
  font-size: clamp(0.7rem, 5.5vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  color: #fff;
}

.print-title-secondary {
  margin: 0;
  font-size: clamp(0.65rem, 4vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
  word-break: break-word;
  text-align: center;
  color: #fff;
}

.print-title-secondary[hidden] {
  display: none;
}

.print-title-bar--single-line {
  min-height: 0;
  align-items: center;
  justify-content: center;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.print-title-bar--single-line .print-title-block,
.print-title-block--single-line {
  gap: 0;
  flex: 0 1 auto;
  width: 100%;
  justify-content: center;
  align-items: center;
}

.print-title-bar--single-line .print-title-main,
.print-title-bar--single-line .print-title-secondary {
  line-height: 1.1;
}

.print-sketch-frame {
  flex: 1 1 auto;
  min-height: 0;
  border: 2px solid #2a2a2a;
  background: var(--pad-paper, #f0efeb);
  box-sizing: border-box;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.print-sketch-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.print-sheet--no-title .print-title-bar {
  display: none;
}

.print-sheet--no-footer .print-info-box {
  display: none;
}

.print-sheet--sketch-only .print-sketch-frame {
  border: 2px solid #2a2a2a;
}

.print-sheet--no-title .print-title-main[hidden] {
  display: none;
}

.print-sheet--screen .print-sketch-frame {
  flex: 1 1 auto;
  min-height: 6rem;
}

.print-sheet--screen .print-sketch-frame img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  min-width: 1px;
  min-height: 1px;
}

.print-info-box {
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
  border: 2px solid #2a2a2a;
  background: var(--pad-paper-dark);
  display: flex;
  align-items: stretch;
}

/* Sidebar preview only — not physical 1in (that applies when printing letter size) */
.print-sheet--screen .print-info-box {
  flex: 0 0 auto;
  flex-shrink: 0;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 0.3rem 0.53rem;
}

.print-sheet--screen .print-info-grid {
  height: auto;
  max-height: none;
  gap: 0.18rem;
}

.print-info-grid {
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.12rem;
  margin: 0;
  box-sizing: border-box;
}

.print-info-grid--has-name .print-info-grid-row--split {
  display: none !important;
}

.print-info-grid:not(.print-info-grid--has-name) .print-info-grid-row--name,
.print-info-grid:not(.print-info-grid--has-name) .print-info-grid-row--all {
  display: none !important;
}

.print-info-grid-row,
.print-info-grid-row--split,
.print-info-grid-row--all,
.print-info-grid-row--name {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: 0 0.35rem;
  width: 100%;
  min-height: 0;
}

.print-info-grid-row--name {
  justify-content: flex-start;
}

.print-info-grid-row--name .print-info-item--span-3 {
  flex: 0 1 auto;
  max-width: 100%;
}

.print-info-grid-row:not(:has(.print-info-item:not([hidden]))) {
  display: none;
}

.print-info-grid-pad {
  display: none;
}

.print-info-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 0.2em;
  min-width: 0;
  font-size: 13.5pt;
  line-height: 1.2;
  overflow: hidden;
}

.print-info-item--span-2,
.print-info-item--span-3 {
  flex: 0 1 auto;
}

.print-info-item[hidden] {
  display: none !important;
}

.print-info-item--value-only .print-info-label {
  display: none;
}

.print-info-item--value-only {
  grid-template-columns: minmax(0, 1fr);
}

.print-info-item--value-only .print-info-value {
  font-weight: 400;
}

.print-sheet--screen .print-info-item {
  font-size: clamp(0.68rem, 3.15cqi, 0.93rem);
  line-height: 1.2;
}

.print-info-label {
  margin: 0;
  font-weight: 700;
  color: #333;
  white-space: nowrap;
  flex-shrink: 0;
}

.print-info-value {
  margin: 0;
  font-weight: 400;
  color: #1a1a1a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.panel-header-actions {
  display: flex;
  gap: 0.35rem;
}

/* Category tabs */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.category-tab {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  background: var(--control-fill);
  color: #1a1a1a;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.category-tab:hover:not(:disabled) {
  color: #1a1a1a;
  background: var(--control-fill-hover);
  border-color: var(--border-strong);
}

.category-tab.active {
  color: #1a1a1a;
  background: var(--accent-muted);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.category-tab--locked,
.category-tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Subcategory tabs (e.g. nose Male / Female) */
.subcategory-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.subcategory-tabs[hidden] {
  display: none !important;
}

.subcategory-tab {
  flex: 1;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  background: var(--control-fill);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}

.subcategory-tab:hover {
  color: var(--text-primary);
  background: var(--control-fill-hover);
}

.subcategory-tab.active {
  color: var(--accent);
  background: var(--accent-muted);
  border-color: var(--accent);
}

:root {
  --library-thumb-size: 98px;
}

.parts-fun-toggle {
  flex-shrink: 0;
  margin: 0 0.5rem 0.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.parts-fun-toggle input {
  margin-right: 0.35rem;
}

/* Parts grid */
.parts-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: min-content;
  gap: 0.5rem;
  align-content: start;
  align-items: start;
}

.part-thumb {
  position: relative;
  display: block;
  width: 100%;
  height: 0;
  padding: 0 0 100% 0;
  margin: 0;
  font: inherit;
  text-align: left;
  appearance: none;
  background: var(--control-fill);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.part-thumb:not(.empty-slot) {
  width: var(--library-thumb-size);
  max-width: 100%;
  justify-self: center;
  padding-bottom: var(--library-thumb-size);
}

.part-thumb.part-thumb--fun:not(.empty-slot):not(:disabled) {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent-muted);
}

.part-thumb.part-thumb--fun:hover:not(:disabled) {
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 1px var(--accent-muted-strong);
}

.part-thumb.part-thumb--fun:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted-strong);
}

.part-thumb-media {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.part-number {
  position: absolute;
  top: 3px;
  left: 4px;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  pointer-events: none;
}

.part-thumb:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.part-thumb:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.part-thumb-media > img {
  position: absolute;
  top: 1.15rem;
  right: 0.2rem;
  bottom: 0.2rem;
  left: 0.2rem;
  display: block;
  width: calc(100% - 0.4rem);
  height: calc(100% - 1.35rem);
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.part-thumb-pair {
  position: absolute;
  top: 1.15rem;
  right: 0.2rem;
  bottom: 0.2rem;
  left: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  box-sizing: border-box;
}

.part-thumb-pair img {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.part-thumb.empty-slot {
  cursor: default;
  opacity: 0.5;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  height: auto;
  min-height: 3.5rem;
  padding: 0.5rem;
}

.parts-hint {
  padding: 0.5rem 0.75rem;
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

.parts-locked-notice {
  grid-column: 1 / -1;
  padding: 0.65rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #7a5c00;
  background: #fff4ce;
  border: 1px solid #f2e084;
  border-radius: 4px;
}

.part-thumb--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Canvas area */
.canvas-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-canvas-area);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toolbar-group input[type="range"] {
  width: 80px;
}

.checkbox-label {
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  margin-right: 0.35rem;
}

.canvas-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  overflow: auto;
  padding: 1.5rem;
}

.canvas-wrapper > .pad-select-panel {
  order: -1;
}

.canvas-pad-cluster {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  gap: 0.75rem;
}

.pad-keyboard-hint {
  flex-shrink: 0;
  width: 100%;
  padding: 0.55rem 1rem;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  box-sizing: border-box;
  overflow-x: auto;
}

.pad-keyboard-hint__lead {
  margin: 0 auto 0.35rem;
  width: max-content;
  max-width: 100%;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
}

.pad-keyboard-hint__list {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  grid-template-rows: repeat(2, auto);
  gap: 0.4rem 2.5rem;
  margin: 0 auto;
  padding: 0;
  width: max-content;
  max-width: 100%;
  list-style: none;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-primary);
  justify-content: center;
}

.pad-keyboard-hint__list li {
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.pad-select-panel {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  align-self: center;
  position: relative;
  z-index: 20;
  width: 9.5rem;
  max-height: min(600px, calc(100vh - 12rem));
  padding: 0.5rem 0.4rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
}

.pad-select-panel__title {
  margin: 0 0 0.4rem;
  padding: 0 0.25rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

.pad-layers-list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.pad-select-empty {
  margin: 0.35rem 0 0;
  padding: 0 0.25rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
  text-align: center;
}

.pad-select-empty[hidden] {
  display: none !important;
}

.pad-position-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  padding: 0.5rem 0.4rem;
  overflow-y: auto;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  pointer-events: auto;
}

.pad-slot-position {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 0.45rem 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.pad-slot-position__title {
  margin: 0 0 0.4rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

.pad-slot-position__empty {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--text-muted);
  text-align: center;
}

.pad-slot-position__empty[hidden] {
  display: none !important;
}

.pad-slot-position__coords {
  margin: 0;
  padding: 0;
}

.pad-slot-position__coords[hidden] {
  display: none !important;
}

.pad-slot-position__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.08rem;
  margin-bottom: 0.35rem;
}

.pad-slot-position__row:last-child {
  margin-bottom: 0;
}

.pad-slot-position__row dt {
  margin: 0;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pad-slot-position__row dd {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.pad-position-stack__hint {
  margin: 0.15rem 0 0;
  padding: 0 0.15rem;
  font-size: 0.6rem;
  line-height: 1.35;
  color: var(--text-muted);
  text-align: center;
}

.pad-side-tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  align-self: center;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.pad-side-tools[hidden] {
  display: none !important;
}

.eye-spread-controls,
.hair-stretch-controls,
.opacity-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding: 0.35rem 0.25rem;
  min-width: 3.5rem;
  pointer-events: auto;
}

.opacity-value {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.2;
}

.hair-stretch-controls[hidden],
.eye-spread-controls[hidden],
.opacity-controls[hidden],
.size-controls[hidden],
.feature-stretch-controls[hidden] {
  display: none !important;
}

.size-controls,
.feature-stretch-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding: 0.35rem 0.25rem;
  min-width: 3.5rem;
  pointer-events: auto;
}

.hair-stretch-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.eye-spread-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.eye-spread-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.eye-spread-btn {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  padding: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--control-fill);
  color: var(--text-primary);
  cursor: pointer;
}

.eye-spread-btn:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.eye-spread-btn:active {
  transform: scale(0.96);
}

/* Studio settings (portal-style lock + modal) */
.header-actions .studio-admin-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.25rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  margin-left: 0.15rem;
  color: var(--accent);
}

.header-actions .studio-admin-lock:hover {
  color: var(--accent-hover);
  background: var(--control-fill-hover);
  border-radius: 4px;
}

.header-actions .sketch-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.25rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--accent);
}

.header-actions .sketch-help-btn:hover {
  color: var(--accent-hover);
  background: var(--control-fill-hover);
  border-radius: 4px;
}

.header-actions .sketch-help-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.studio-admin-lock svg {
  width: 1.25rem;
  height: 1.25rem;
}

body.studio-modal-open,
body.help-modal-open {
  overflow: hidden;
}

.help-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
  pointer-events: none;
}

.help-modal-overlay.is-open {
  display: flex;
  pointer-events: auto;
}

.help-modal {
  display: flex;
  flex-direction: column;
  width: min(42rem, 100%);
  max-height: min(90vh, 52rem);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.help-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-modal__head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.help-modal__subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.help-modal__close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.help-modal__close:hover {
  background: var(--control-fill-hover);
  color: var(--text-primary);
}

.help-modal__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem 1.1rem 1rem;
}

.help-modal__section {
  margin-bottom: 1rem;
}

.help-modal__section:last-child {
  margin-bottom: 0;
}

.help-modal__section h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.help-modal__section p,
.help-modal__section ul {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.help-modal__section ul {
  padding-left: 1.2rem;
}

.help-modal__section li {
  margin-bottom: 0.25rem;
}

.help-modal__foot {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid var(--border);
}

.studio-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.studio-modal-overlay.is-open {
  display: flex;
  pointer-events: auto;
}

.studio-modal {
  width: 75vw;
  height: 75vh;
  max-width: 75vw;
  max-height: 75vh;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-app);
  box-shadow: var(--shadow);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.studio-modal-overlay.is-login-only {
  padding: 1rem;
}

.studio-modal-overlay.is-login-only .studio-modal {
  width: min(22rem, 100%);
  height: auto;
  max-width: min(22rem, 100%);
  max-height: none;
}

.studio-modal-overlay.is-login-only .studio-modal__body {
  flex: 0 1 auto;
  overflow-y: visible;
}

.studio-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.studio-modal__head-lead {
  min-width: 0;
  flex: 1;
}

.studio-modal__head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.studio-modal__head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-modal__head p {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.studio-modal__close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.studio-modal__close:hover {
  background: var(--control-fill-hover);
  color: var(--text-primary);
}

.studio-modal__body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
}

.studio-modal__footer {
  flex-shrink: 0;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

.studio-modal__footer.studio-hidden {
  display: none !important;
}

#studio-admin-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#studio-admin-panel.studio-hidden {
  display: none !important;
}

.studio-modal__section--hide-parts {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.studio-modal__section {
  margin-bottom: 1rem;
}

.studio-modal__section--layout {
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.studio-layout-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.studio-layout-card {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-elevated);
  padding: 0.65rem 0.75rem 0.75rem;
  min-width: 0;
}

.studio-layout-card__title {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-layout-card--splash .studio-splash-enabled {
  margin: 0 0 0.5rem;
}

.studio-splash-upload--compact {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.studio-splash-upload--compact .studio-splash-preview {
  min-height: 5.5rem;
}

.studio-splash-upload--compact .studio-splash-preview img {
  max-height: 5rem;
}

.studio-layout-card--thumb .studio-library-thumb-preview {
  margin-top: 0.5rem;
}

.studio-layout-card--thumb .studio-library-thumb-size__control {
  margin: 0;
}

.studio-modal__section h3 {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.studio-admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.studio-admin-tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 0.35rem 0.35rem 0 0;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.studio-admin-tab:hover {
  background: var(--bg-elevated);
}

.studio-admin-tab.is-active {
  border-color: var(--border);
  border-bottom-color: var(--bg);
  background: var(--bg);
  color: #0c4a6e;
}

.studio-section-subhead {
  margin-top: 1.5rem !important;
}

.studio-security-questions {
  display: grid;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.startup-announcement-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.startup-announcement-overlay.studio-hidden {
  display: none !important;
}

.sketch-phone-notice {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

.sketch-phone-notice--hidden {
  display: none !important;
}

.sketch-phone-notice__panel {
  width: min(100%, 26rem);
  padding: 1.35rem 1.25rem;
  text-align: center;
  background: #faf8f5;
  border: 1px solid #a8a29e;
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.sketch-phone-notice__panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1c1917;
}

.sketch-phone-notice__panel p {
  margin: 0 0 1.15rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #292524;
  text-align: left;
}

.startup-announcement {
  width: min(32rem, 100%);
  border: 1px solid #a8a29e;
  border-radius: 0.5rem;
  background: #faf8f5;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.startup-announcement__row {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.startup-announcement__icon {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.25rem;
  font-style: italic;
}

.startup-announcement h2 {
  margin: 0;
  font-size: 1.15rem;
  color: #1c1917;
}

.startup-announcement__message {
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
  line-height: 1.5;
  color: #292524;
}

.startup-announcement__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.studio-forgot-title {
  margin: 0.75rem 0;
  font-size: 1.05rem;
}

.studio-modal__hint {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.studio-login-default-hint {
  margin-top: 0;
}

.studio-hide-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  margin-top: 0.35rem;
}

.studio-hide-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.studio-hide-toolbar-btn .studio-hide-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.studio-hide-icon {
  display: block;
  width: 1rem;
  height: 1rem;
  pointer-events: none;
}

.studio-hide-selection-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.studio-library-thumb-size__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}

.studio-library-thumb-size__readout {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.studio-library-thumb-size__readout strong {
  font-size: 1rem;
  color: var(--accent);
}

.studio-library-thumb-size__control input[type="range"] {
  width: 100%;
  margin: 0.35rem 0 0.2rem;
  accent-color: var(--accent);
}

.studio-library-thumb-size__scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 0 0.05rem;
}

.studio-library-thumb-preview {
  margin-top: 0.75rem;
}

.studio-library-thumb-preview__heading {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.studio-library-thumb-preview__chrome {
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg-panel);
  overflow: hidden;
}

.studio-library-thumb-preview__panel-title {
  display: block;
  padding: 0.35rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--control-fill);
}

.studio-library-thumb-preview__grid {
  display: grid;
  grid-template-columns: var(--studio-thumb-preview-size, var(--library-thumb-size));
  gap: 0;
  padding: 0.5rem;
  margin: 0;
  min-height: 0;
  overflow: visible;
  align-items: start;
  justify-content: start;
  box-sizing: border-box;
}

.studio-library-thumb-preview__sample.part-thumb {
  position: relative;
  display: block;
  width: var(--studio-thumb-preview-size, var(--library-thumb-size)) !important;
  max-width: none !important;
  height: 0 !important;
  margin: 0;
  padding: 0 !important;
  padding-bottom: var(--studio-thumb-preview-size, var(--library-thumb-size)) !important;
  box-sizing: border-box;
  pointer-events: none;
  overflow: hidden;
  background: var(--control-fill);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}

.studio-library-thumb-preview__sample .part-thumb-media {
  position: absolute;
  inset: 0;
}

.studio-library-thumb-preview__sample .part-thumb-media > img {
  top: 1.15rem;
  right: 0.2rem;
  bottom: 0.2rem;
  left: 0.2rem;
  width: calc(100% - 0.4rem);
  height: calc(100% - 1.35rem);
}

.studio-library-thumb-preview__note {
  margin: 0.4rem 0 0;
}

.studio-hide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--studio-hide-thumb-size, 7.5rem), 1fr));
  gap: 0.65rem;
  max-height: min(42vh, 28rem);
  overflow-y: auto;
  margin-top: 0.35rem;
  padding-bottom: 0.25rem;
}

.studio-hide-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--control-fill);
  overflow: hidden;
}

.studio-hide-card--hidden {
  border-color: var(--danger);
  border-style: dashed;
  background: #fdf3f2;
}

.studio-hide-card__media {
  position: relative;
  border-bottom: 1px solid var(--border);
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--pad-paper, #f0efeb);
  box-sizing: border-box;
}

.studio-hide-card__media .part-thumb-media {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.studio-hide-card__media .part-thumb-media > img,
.studio-hide-card__media .part-thumb-pair > img {
  pointer-events: none;
}

.studio-hide-card__media .studio-hide-card__number {
  z-index: 3;
}

.studio-hide-card__visibility {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
}

.studio-hide-card__visibility:disabled {
  opacity: 0.55;
  cursor: wait;
}

.studio-hide-card__visibility:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
}

.studio-hide-card__visibility--unhide {
  color: var(--danger);
  border-color: rgba(196, 43, 28, 0.45);
}

.studio-hide-card__visibility--unhide:hover {
  color: var(--danger-hover);
  border-color: var(--danger);
}

.studio-hide-card__fun {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.studio-hide-card__fun-input {
  margin: 0;
  cursor: pointer;
}

.studio-hide-card__badge--fun {
  background: #5b4a9e;
  color: #fff;
}

.studio-hide-card__badge {
  position: absolute;
  top: 32%;
  left: 50%;
  z-index: 2;
  pointer-events: none;
  transform: translate(-50%, -50%);
  padding: 0.12em 0.35em;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--danger);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(196, 43, 28, 0.5);
  border-radius: 4px;
  pointer-events: none;
}

.studio-hide-card__title {
  padding: 0.2em 0.35em;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: var(--text);
  background: var(--bg-elevated);
}

.studio-hide-card__title--hidden {
  color: var(--danger);
  font-weight: 700;
}

.studio-hide-empty {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.studio-hide-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--control-fill);
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1;
  appearance: none;
  font: inherit;
}

.studio-hide-item:hover {
  border-color: var(--accent);
}

.studio-hide-item--hidden {
  border-color: var(--danger);
  border-style: dashed;
  background: #fdf3f2;
}

.studio-hide-item__media {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
}

.studio-hide-item__media > img {
  position: absolute;
  top: 1.15rem;
  right: 0.2rem;
  bottom: 1.35rem;
  left: 0.2rem;
  display: block;
  width: calc(100% - 0.4rem);
  height: calc(100% - 2.5rem);
  object-fit: contain;
  pointer-events: none;
}

.studio-hide-item--pair .studio-hide-item__media > img {
  position: static;
  width: 100%;
  height: 100%;
}

.studio-hide-item__pair {
  position: absolute;
  top: 1.15rem;
  right: 0.2rem;
  bottom: 1.35rem;
  left: 0.2rem;
}

.studio-hide-item__label {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  z-index: 2;
  padding: 0.12em 0.3em;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 2px;
  pointer-events: none;
}

.studio-hide-item__label--hidden {
  color: var(--danger);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(196, 43, 28, 0.45);
}

.studio-hide-item__status {
  position: absolute;
  top: 28%;
  left: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  padding: 0.15em 0.4em;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--danger);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(196, 43, 28, 0.5);
  border-radius: 4px;
  pointer-events: none;
}

.studio-hide-item__unhide-hint {
  position: absolute;
  top: 42%;
  left: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  padding: 0.1em 0.35em;
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--danger-hover);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}

.studio-upload-status {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.studio-field {
  display: block;
  margin-bottom: 0.75rem;
}

.studio-field span {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.studio-field select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--control-fill);
  color: var(--text-primary);
  font: inherit;
}

.studio-field input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--control-fill);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.88rem;
}

.studio-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.studio-password-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.studio-password-wrap input {
  width: 100%;
  padding-right: 2.4rem;
}

.studio-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.studio-password-toggle:hover {
  color: var(--text-primary);
  background: var(--control-fill-hover);
}

.studio-password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.studio-password-toggle__icon {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

.studio-password-toggle__icon--hide {
  display: none;
}

.studio-password-toggle--visible .studio-password-toggle__icon--show {
  display: none;
}

.studio-password-toggle--visible .studio-password-toggle__icon--hide {
  display: block;
}

#studio-login-submit {
  margin-top: 0.25rem;
}

.studio-splash-enabled {
  margin: 0.5rem 0 0.75rem;
}

.studio-splash-upload {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.studio-splash-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 7rem;
  border-radius: 8px;
  border: 1px dashed var(--border-strong);
  background: var(--bg-elevated);
  overflow: hidden;
}

.studio-splash-preview img {
  display: block;
  max-width: 100%;
  max-height: 10rem;
  object-fit: contain;
}

.studio-splash-preview__empty {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.studio-splash-upload__actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.studio-splash-upload__status {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.studio-splash-upload__status.is-busy {
  color: var(--accent-hover);
}

.studio-btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.studio-btn-row #studio-logout {
  margin-right: auto;
}

@media (max-width: 52rem) {
  .studio-layout-cards {
    grid-template-columns: 1fr;
  }
}

.studio-msg {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.studio-msg--ok {
  background: rgba(0, 103, 192, 0.08);
  color: var(--accent);
  border: 1px solid rgba(0, 103, 192, 0.2);
}

.studio-msg--err {
  background: rgba(196, 43, 28, 0.08);
  color: var(--danger);
  border: 1px solid rgba(196, 43, 28, 0.2);
}

.studio-hidden {
  display: none !important;
}

/* Boot splash (custom image only) */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(243, 243, 243, 0.96);
  pointer-events: auto;
}

.app-splash[hidden] {
  display: none !important;
}

.app-splash img {
  display: block;
  max-width: min(100%, 56rem);
  max-height: min(100dvh - 3rem, 100vh - 3rem);
  object-fit: contain;
  border-radius: 8px;
  box-shadow:
    var(--shadow),
    0 0 0 1px var(--border);
}

body.app-splash-active .workspace,
body.app-splash-active .app-header {
  visibility: hidden;
}

/* Coil-bound sketch pad */
.sketch-pad {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transform-origin: left center;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.12));
}

.coil-binder {
  position: relative;
  z-index: 3;
  height: 44px;
  margin: 0 6px;
}

.binder-plate {
  position: absolute;
  left: 0;
  right: 0;
  top: 18px;
  height: 22px;
  background: linear-gradient(180deg, #a19f9d 0%, var(--binder-bar) 40%, #484644 100%);
  border-radius: 3px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.coil-rings {
  position: relative;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 20px;
  height: 100%;
}

.coil-ring {
  flex-shrink: 0;
  width: 18px;
  height: 26px;
  border: 2.5px solid #8a8886;
  border-radius: 50%;
  background: linear-gradient(
    145deg,
    var(--binder-metal-light) 0%,
    var(--binder-metal) 45%,
    #8a8886 100%
  );
  box-shadow:
    inset 1px 1px 2px rgba(255, 255, 255, 0.55),
    inset -1px -1px 2px rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(4px);
}

.sketch-pad-sheet {
  position: relative;
  background: var(--pad-paper-dark);
  padding: 0 14px 14px;
  border-radius: 0 0 4px 4px;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.04);
}

.pad-hole-margin {
  height: 28px;
  margin: 0 8px;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 23px,
    rgba(0, 0, 0, 0.04) 23px,
    rgba(0, 0, 0, 0.04) 24px
  );
}

.canvas-stage {
  position: relative;
  /* content-box so 480×600 is the drawable pad; border sits outside (global border-box would shrink inner area by 2px) */
  box-sizing: content-box;
  width: var(--canvas-w);
  height: var(--canvas-h);
  overflow: hidden;
  background-color: var(--pad-paper);
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E"),
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.35) 0%,
      transparent 12%,
      transparent 88%,
      rgba(0, 0, 0, 0.03) 100%
    );
  border: 1px solid var(--bg-canvas-border);
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.02),
    inset 2px 0 8px rgba(0, 0, 0, 0.03);
  transform-origin: center center;
  flex-shrink: 0;
}

.alignment-guides {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.alignment-guides.hidden {
  opacity: 0;
}

.guide-face,
.guide-center,
.guide-eyes,
.guide-nose,
.guide-mouth {
  fill: none;
  stroke: rgba(80, 75, 70, 0.28);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.guide-face {
  stroke: rgba(80, 75, 70, 0.2);
}

.layers-container {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.sketch-layer {
  position: absolute;
  cursor: move;
  transform-origin: center center;
  user-select: none;
  touch-action: none;
  pointer-events: none;
}

.sketch-layer img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: auto;
}

.sketch-layer.selected {
  outline: none;
}

/* Selection box */
.selection-box {
  position: absolute;
  border: 2px dashed var(--selection);
  pointer-events: none;
  z-index: 1000;
  box-sizing: border-box;
}

.selection-box .resize-handle {
  pointer-events: all;
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid var(--selection);
  border-radius: 2px;
  box-sizing: border-box;
}

.resize-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.resize-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.resize-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.resize-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.resize-handle.e {
  top: 50%;
  right: -6px;
  transform: translateY(-50%);
  cursor: ew-resize;
}
.resize-handle.w {
  top: 50%;
  left: -6px;
  transform: translateY(-50%);
  cursor: ew-resize;
}
.resize-handle.n {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}
.resize-handle.s {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.rotate-handle-connector {
  position: absolute;
  height: 2px;
  margin-top: -1px;
  background: var(--selection);
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.75;
}

.rotate-handle-connector[hidden] {
  display: none;
}

.rotate-handle {
  position: absolute;
  z-index: 1001;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--selection);
  border-radius: 50%;
  background: #fff;
  color: var(--selection);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: all;
  box-shadow: var(--shadow-sm);
}

.rotate-handle[hidden] {
  display: none;
}

.rotate-handle:active {
  cursor: grabbing;
}

.rotate-handle svg {
  display: block;
}

/* Inspector */
.inspector-empty {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.inspector-controls {
  padding: 0 1rem 1rem;
}

.layer-name {
  margin: 0 0 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  word-break: break-word;
}

.control-row {
  display: grid;
  grid-template-columns: 70px 1fr 42px;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.control-row input[type="range"] {
  width: 100%;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.layers-list-section {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  flex-shrink: 0;
  max-height: 40%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.layers-list-section h3 {
  margin: 0;
  padding: 0 1rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.layers-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem;
  overflow-y: auto;
}

.layers-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
}

.layers-list li:hover {
  background: var(--control-fill-hover);
}

.layers-list li.selected {
  background: var(--accent-muted);
  color: var(--accent);
}

.layers-list li .layer-preview {
  width: 28px;
  height: 28px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.layers-list li .layer-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.layers-list li .layer-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  line-height: 1.3;
}

/* Footer */
.app-footer {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-inspector {
  overflow-y: auto;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Print layout (uses system print dialog via window.print) */
.print-surface {
  display: none;
}

@media print {
  .file-protocol-warning,
  .app-header,
  .workspace,
  .app-footer,
  .toast {
    display: none !important;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #fff !important;
    overflow: hidden !important;
  }

  .print-surface,
  .print-surface * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .print-surface {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .print-surface .print-sheet {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 8.5in !important;
    height: 100% !important;
    max-height: 11in !important;
    min-height: 0 !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .print-surface .print-sheet.print-sheet--raster .print-title-bar,
  .print-surface .print-sheet.print-sheet--raster .print-info-box {
    display: none !important;
  }

  .print-surface .print-sheet.print-sheet--raster {
    display: block !important;
    width: 100% !important;
    max-width: 8.5in !important;
    height: 100% !important;
    max-height: 11in !important;
    margin: 0 auto !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .print-surface .print-sheet.print-sheet--raster .print-sketch-frame {
    display: block !important;
    flex: none !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-width: 8.5in !important;
    max-height: 11in !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .print-surface .print-sheet.print-sheet--raster .print-sketch-frame img,
  .print-surface .print-sheet.print-sheet--raster #print-sketch-img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 8.5in !important;
    max-height: 11in !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    object-position: center center !important;
    box-sizing: border-box !important;
  }

  .print-surface .print-title-bar {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #b91c1c !important;
    border: 2px solid #2a2a2a !important;
    color: #fff !important;
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 1 !important;
  }

  .print-surface .print-title-bar--single-line {
    align-items: center !important;
    justify-content: center !important;
  }

  .print-surface .print-title-bar--single-line .print-title-block {
    flex: 0 1 auto !important;
    justify-content: center !important;
    align-items: center !important;
  }

  .print-surface .print-title-main,
  .print-surface .print-title-secondary {
    color: #fff !important;
  }

  .print-surface .print-sketch-frame {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    background: var(--pad-paper, #f0efeb) !important;
    border: 2px solid #2a2a2a !important;
    box-sizing: border-box !important;
  }

  .print-surface .print-sketch-frame img,
  .print-surface #print-sketch-img {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    filter: none !important;
  }

  .print-surface .print-info-box {
    flex: 0 0 0.69in !important;
    height: 0.69in !important;
    min-height: 0.69in !important;
    max-height: 0.69in !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    padding: 0.045in 0.18in !important;
    margin-top: auto !important;
    background: var(--pad-paper-dark, #e0ded9) !important;
    border: 2px solid #2a2a2a !important;
  }

  .print-surface .print-info-grid {
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    justify-content: flex-start !important;
    gap: 0.03in !important;
    padding-top: 0.03in !important;
  }

  .print-surface .print-info-grid-row,
  .print-surface .print-info-grid-row--split,
  .print-surface .print-info-grid-row--all,
  .print-surface .print-info-grid-row--name {
    justify-content: flex-start !important;
    gap: 0 0.28in !important;
  }

  .print-surface .print-info-item {
    font-size: 13.5pt !important;
    line-height: 1.2 !important;
    font-weight: 400 !important;
  }

  .print-surface .print-info-label {
    font-weight: 700 !important;
  }

  .print-surface .print-info-value {
    font-weight: 400 !important;
  }

  .print-surface .print-title-main {
    font-size: clamp(16pt, 4.2vw, 26pt);
    letter-spacing: 0.02em;
    line-height: 1.08;
  }

  .print-surface .print-title-secondary {
    font-size: clamp(12pt, 3.2vw, 18pt);
    line-height: 1.15;
  }

  @page {
    size: letter portrait;
    margin: 0;
  }
}
