/* One Piece Studio · Combined UI Stylesheet
 * ④ World Economy News Broadsheet Masthead & 4-Corner Photo Mount
 * ② Shonen Jump Manga G-Pen Ink Borders, Screentone & "咚!!" Action Strip
 * ① Tavern Ship-Plank Wood Pinboard & Authentic WANTED 2D Portrait Cards
 */

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

html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background: var(--color-newsprint);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  height: 100vh;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-style: normal;
  overflow-wrap: anywhere;
  min-width: 0;
  margin: 0;
}

button, input, select, output {
  font-family: var(--font-body);
  font-size: var(--text-xs);
}

/* Manga G-Pen Inked Controls */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 10px;
  border: 2px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  background: var(--color-newsprint);
  color: var(--color-ink);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-ink-sm);
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

button:hover:not(:disabled) {
  background: var(--color-straw-gold);
  color: var(--color-ink);
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-ink-md);
}

button:active:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--color-comic-border);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

#scene:focus-visible {
  outline: 2px solid var(--color-focus-wood);
  outline-offset: -4px;
}

button:disabled,
input:disabled,
select:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: none;
}

select,
input[type="text"],
input[type="search"],
input[type="number"] {
  min-height: 32px;
  padding: 4px 8px;
  border: 2px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  background: oklch(97.5% 0.014 85 / 0.92);
  color: var(--color-ink);
  font-weight: 700;
  outline: 2px solid transparent;
  outline-offset: 1px;
  font-variant-numeric: tabular-nums;
}

/* Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: var(--color-paper-3);
  border: 1px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-comic-border);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-comic-border);
}

/* Crimson Stamp Checkboxes */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 15px;
  height: 15px;
  margin: 0;
  flex-shrink: 0;
  border: 2px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  background: oklch(98% 0.01 85);
  cursor: pointer;
}

input[type="checkbox"]:checked {
  background: var(--color-accent);
  border-color: var(--color-comic-border);
}

input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: solid var(--color-accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Primary Stamp CTA (#apply & Dialog Save) */
.primary {
  background: var(--color-ink);
  color: var(--color-straw-gold);
  border: 2.5px solid var(--color-comic-border);
  box-shadow: 3px 3px 0 var(--color-accent);
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.05em;
}

.primary:hover:not(:disabled) {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  box-shadow: 3px 3px 0 var(--color-comic-border);
}

#apply.pending,
dialog .primary {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  box-shadow: 3px 3px 0 var(--color-comic-border);
}

#apply.pending:hover:not(:disabled),
dialog .primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
  color: var(--color-accent-ink);
}

.apply-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 1.5px solid currentColor;
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: 900;
  transform: rotate(-4deg);
}

/* =====================================================================
   ④ WORLD ECONOMY NEWS MASTHEAD × ② COMIC INK HEADER
   ===================================================================== */
header {
  height: var(--banner-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0 var(--space-md);
  background-color: var(--color-newsprint);
  background-image: radial-gradient(oklch(20% 0.02 48 / 0.07) 1px, transparent 1px);
  background-size: 7px 7px;
  border-bottom: 4px double var(--color-comic-border);
  z-index: var(--z-header);
}

.mast-left {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
}

.jolly-medallion {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-comic-border);
  border: 2px solid var(--color-straw-gold-2);
  box-shadow: var(--shadow-ink-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mast-kicker {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--color-ink-2);
  line-height: 1.1;
  white-space: nowrap;
}

.brand-main-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2xs);
  min-width: 0;
}

.brand-main-row h1 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  padding: 1px 6px;
  background: var(--color-comic-border);
  color: var(--color-straw-gold);
  font-size: var(--text-2xs);
  font-weight: 900;
  letter-spacing: 0.05em;
  transform: skewX(-6deg);
  white-space: nowrap;
}

.brand-rule {
  width: 1.5px;
  height: 12px;
  background: var(--color-rule-strong);
  flex-shrink: 0;
  align-self: center;
}

#cast-summary {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#status {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.extra-stamp {
  padding: 3px 8px;
  border: 2px solid var(--color-accent);
  color: var(--color-accent);
  background: oklch(97% 0.02 82 / 0.8);
  font-family: var(--font-display);
  font-size: var(--text-2xs);
  font-weight: 900;
  letter-spacing: 0.06em;
  transform: rotate(-2.5deg);
  white-space: nowrap;
}

.ink-btn {
  min-height: 30px;
  padding: 4px 10px;
  background: var(--color-newsprint-2);
}

.lang-switch {
  display: inline-flex;
  border: 2px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-ink-sm);
  overflow: hidden;
  background: var(--color-newsprint-2);
}

.lang-switch button {
  min-height: 26px;
  padding: 2px 8px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: var(--text-2xs);
  font-weight: 800;
  color: var(--color-ink-2);
}

.lang-switch button + button {
  border-left: 1.5px solid var(--color-comic-border);
}

.lang-switch button:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  background: oklch(93% 0.035 82);
}

.lang-switch button[aria-pressed="true"],
.lang-switch button[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--color-straw-gold);
  color: var(--color-ink);
  font-weight: 900;
}

kbd {
  font-family: var(--font-outlier);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 1px 4px;
  border: 1.5px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  background: var(--color-straw-gold);
  color: var(--color-ink);
}

/* =====================================================================
   SPLIT STUDIO: ④ PHOTO-CORNER SCOOP STAGE + ② MANGA ACTION BAR
   ===================================================================== */
main {
  flex: 1;
  min-height: 0;
  display: flex;
}

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 46%, var(--color-stage-center), var(--color-stage-edge) 78%);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

/* Newspaper Front-Page Photo Mat & 4 Vintage Sepia Photo Corners */
.viewfinder-frame {
  position: absolute;
  inset: 10px 12px 58px 12px;
  border: 2.5px solid var(--color-comic-border);
  box-shadow: 0 0 0 60px var(--color-newsprint);
  pointer-events: none;
  z-index: 4;
}

.vf-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--color-comic-border);
  border-style: solid;
}

.vf-tl { top: -5px; left: -5px; border-width: 6px 0 0 6px; }
.vf-tr { top: -5px; right: -5px; border-width: 6px 6px 0 0; }
.vf-bl { bottom: -5px; left: -5px; border-width: 0 0 6px 6px; }
.vf-br { bottom: -5px; right: -5px; border-width: 0 6px 6px 0; }

/* Bottom Press Caption & Manga "咚!!" Shutter Bar */
.stage-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0 6px;
  border-top: 2px solid var(--color-comic-border);
  pointer-events: none;
  z-index: var(--z-overlay);
}

.gestures {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gestures::before {
  content: "▲ 航拍实录：";
  color: var(--color-accent);
  font-weight: 900;
}

html[lang="en"] .gestures::before {
  content: "▲ PRESS CAM: ";
}

.toolbar {
  pointer-events: auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.toolbar button {
  min-height: 31px;
  padding: 4px 11px;
  background: oklch(98% 0.012 85);
  border: 2px solid var(--color-comic-border);
  box-shadow: var(--shadow-ink-sm);
  transform: skewX(-4deg);
}

.toolbar button:hover:not(:disabled) {
  background: var(--color-straw-gold);
  transform: skewX(-4deg) translate(-1px, -1px);
  box-shadow: var(--shadow-ink-md);
}

.toolbar button[aria-pressed="true"],
.toolbar button[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--color-comic-border);
  color: var(--color-straw-gold);
  box-shadow: 2px 2px 0 var(--color-accent);
}

.toolbar .shutter-btn {
  padding: 5px 15px;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border: 2.5px solid var(--color-comic-border);
  box-shadow: var(--shadow-ink-md);
  font-size: var(--text-sm);
  font-weight: 900;
  letter-spacing: 0.03em;
}

.toolbar .shutter-btn:hover:not(:disabled) {
  background: var(--color-accent-hover);
  color: var(--color-accent-ink);
}

.don-sfx {
  display: inline-block;
  padding: 1px 5px;
  background: var(--color-straw-gold);
  color: var(--color-ink);
  border: 1.5px solid var(--color-comic-border);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
}

.divider {
  width: 2px;
  height: 18px;
  background: var(--color-rule-strong);
  margin: 0 2px;
}

/* =====================================================================
   FLOATING INSPECTOR DOCK (Pose, Placement & Pirate Props)
   ===================================================================== */
.inspector-dock {
  position: absolute;
  top: 20px;
  left: 22px;
  width: 306px;
  max-height: calc(100% - 88px);
  overflow-y: auto;
  z-index: var(--z-dock);
  scrollbar-width: thin;
  scrollbar-color: var(--color-rule-strong) transparent;
}

.inspector-dock:not(:has(> :not([hidden]))) {
  display: none;
}

.position-panel,
.pose-panel {
  background: url('ui-assets/wanted-parchment.jpg') center/cover, var(--color-paper);
  color: var(--color-ink);
  border: 2.5px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-ink-lg);
  overflow: hidden;
}

.position-panel + .pose-panel {
  margin-top: var(--space-2xs);
}

.sheet-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2xs);
  padding: 7px 12px;
  background: var(--color-comic-border);
  color: var(--color-straw-gold);
  border-bottom: 2px solid var(--color-comic-border);
}

.sheet-banner h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 900;
  color: var(--color-straw-gold);
}

#position-state {
  font-size: var(--text-2xs);
  color: var(--color-wood-ink);
  white-space: nowrap;
}

.sheet-body {
  padding: 10px 12px 12px;
}

.placement-tools,
.presets {
  display: grid;
  gap: 5px;
}

.placement-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: var(--space-2xs);
}

.presets {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 7px;
}

.placement-tools button[aria-pressed="true"],
.presets button.active {
  background: var(--color-straw-gold);
  color: var(--color-ink);
  font-weight: 900;
  box-shadow: var(--shadow-ink-sm);
}

.sheet-body > select {
  width: 100%;
}

#placement-hint {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-2);
  margin: 6px 0 8px;
}

.position-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.position-fields label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 7px;
  background: oklch(98% 0.012 85 / 0.85);
  border: 1.5px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  min-height: 32px;
}

.position-fields label span {
  font-size: var(--text-2xs);
  font-weight: 800;
  color: var(--color-ink-2);
  white-space: nowrap;
}

.position-fields input {
  width: 62px;
  min-height: 26px;
  border: 0;
  padding: 2px;
  text-align: right;
  background: transparent;
}

.size-control {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1.5px dashed var(--color-rule-strong);
}

.size-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  font-weight: 700;
}

#pos-scale-reset {
  min-height: 24px;
  padding: 0 7px;
  font-size: var(--text-2xs);
}

.size-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.size-inputs input[type="range"] { flex: 1; min-width: 40px; }
.size-inputs input[type="number"] { width: 54px; min-height: 28px; text-align: right; }

.position-actions,
.pose-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.position-actions button,
.pose-actions button {
  flex: 1;
}

.props-box {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px solid var(--color-comic-border);
}

.props-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 900;
}

#prop-clear {
  min-height: 22px;
  padding: 0 6px;
  font-size: var(--text-2xs);
  box-shadow: none;
}

.props-add {
  display: flex;
  align-items: center;
  gap: 6px;
}

.props-add select { flex: 1; min-width: 0; height: 32px; }
.props-add button { min-height: 32px; }

#prop-list {
  margin-top: 6px;
  max-height: 110px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prop-item { display: flex; align-items: center; gap: 4px; }
.prop-item button.prop-pick {
  flex: 1; min-width: 0; justify-content: flex-start;
  min-height: 26px; overflow: hidden; text-overflow: ellipsis;
}
.prop-item button.prop-pick[aria-pressed="true"] {
  background: var(--color-straw-gold);
}
.prop-item button.prop-del { min-height: 26px; padding: 2px 7px; }

.pose-face-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; font-size: var(--text-xs); font-weight: 700;
}
.pose-face-row select { flex: 1; min-width: 0; }

.pose-weapon-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; font-size: var(--text-xs); font-weight: 700;
}
.pose-weapon-label { flex-shrink: 0; white-space: nowrap; }
.pose-weapon-toggle {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
.pose-weapon-toggle button {
  min-height: 28px; padding: 2px 6px;
  font-size: var(--text-2xs); white-space: nowrap;
}
.pose-weapon-toggle button[aria-pressed="true"]:not(:disabled) {
  background: var(--color-straw-gold);
  color: var(--color-ink);
  font-weight: 900;
  box-shadow: var(--shadow-ink-sm);
}

.pose-selects {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px; margin: 6px 0 8px;
}
.pose-selects select { width: 100%; min-width: 0; }

#pose-library {
  margin: 0 0 8px; padding-top: 8px;
  border-top: 1.5px dashed var(--color-rule-strong);
}
#pose-library label { display: block; margin-bottom: 4px; font-size: var(--text-xs); font-weight: 700; }
#pose-source-query { width: 100%; margin-bottom: 4px; }
#pose-source { width: 100%; min-height: 88px; }

.pose-slider {
  display: flex; align-items: center; gap: 6px;
  margin: 6px 0; font-size: var(--text-xs); font-weight: 700; white-space: nowrap;
}
.pose-slider span { width: 28px; flex-shrink: 0; }
.pose-slider input[type="range"] { flex: 1; min-width: 40px; }
.pose-slider input[type="number"] { width: 46px; min-height: 28px; padding: 2px 4px; text-align: right; appearance: textfield; }
.pose-slider input::-webkit-inner-spin-button { display: none; }
.pose-slider i { font-style: normal; color: var(--color-ink-2); }
#pose-note { font-size: var(--text-2xs); color: var(--color-ink-2); margin: 6px 0 0; }

/* Unified Placement + Pose Join */
.placement-posing .position-fields,
.placement-posing .position-actions,
.placement-posing .size-control,
.placement-posing .props-box,
.placement-posing #position-state,
.placement-posing #pose-character { display: none; }
.placement-posing .position-panel { border-bottom: 0; }
.placement-posing .position-panel .sheet-body { padding-bottom: 6px; }
.placement-posing .position-panel + .pose-panel { margin-top: 0; }
.placement-posing .pose-panel .sheet-banner { display: none; }

/* Loading & Toast Plaques */
.loading {
  position: absolute;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 280px;
  padding: 10px 14px;
  background: var(--color-comic-border);
  border: 2px solid var(--color-straw-gold);
  box-shadow: var(--shadow-ink-lg);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-wood-ink);
  pointer-events: none;
  z-index: var(--z-overlay);
}

.loading > div:first-child {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-md); font-variant-numeric: tabular-nums;
}

.track { height: 4px; background: var(--color-wood-2); margin-top: 6px; }
.track span { display: block; height: 100%; width: 0; background: var(--color-straw-gold); }

#toast {
  position: absolute;
  top: 22px;
  right: 24px;
  max-width: min(380px, calc(100% - 40px));
  padding: 7px 13px;
  background: var(--color-comic-border);
  border: 2px solid var(--color-straw-gold);
  box-shadow: var(--shadow-ink-md);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-wood-ink);
  opacity: 0;
  pointer-events: none;
  z-index: var(--z-toast);
  transition: opacity var(--dur-short) var(--ease-out);
}
#toast.show { opacity: 1; }

#empty {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 12px 18px;
  background: url('ui-assets/wanted-parchment.jpg') center/cover, var(--color-paper);
  border: 2.5px solid var(--color-comic-border);
  box-shadow: var(--shadow-ink-lg);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 900;
  color: var(--color-ink);
  z-index: var(--z-overlay);
}

/* =====================================================================
   ① TAVERN SHIP-PLANK WOOD PINBOARD & WANTED PORTRAIT CARDS (ASIDE)
   ===================================================================== */
aside {
  position: relative;
  width: 396px;
  flex-shrink: 0;
  background:
    linear-gradient(180deg, oklch(18% 0.03 45 / 0.24), oklch(14% 0.03 45 / 0.44)),
    url('ui-assets/tavern-wood.jpg') center/380px repeat,
    var(--color-wood);
  border-left: 3.5px solid var(--color-comic-border);
  box-shadow: inset 2px 0 0 oklch(68% 0.11 78 / 0.35);
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow: hidden;
}

/* Pinned Aged Parchment Cards on Tavern Wood */
.pinned-sheet {
  position: relative;
  background: url('ui-assets/wanted-parchment.jpg') center/cover, var(--color-paper);
  border: 2px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
  box-shadow: 3px 3px 0 oklch(12% 0.02 42 / 0.72);
  padding: 9px 11px;
  flex-shrink: 0;
}

/* Forged Iron Tack Heads in Top Corners */
.pinned-sheet::before,
.pinned-sheet::after {
  content: "";
  position: absolute;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e6c387, #2b180a 72%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.55);
}
.pinned-sheet::before { left: 6px; }
.pinned-sheet::after  { right: 6px; }

.comic-tag {
  display: inline-block;
  padding: 2px 6px;
  margin-right: 4px;
  background: var(--color-comic-border);
  color: var(--color-straw-gold);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  transform: skewX(-8deg);
}

.environment-heading,
.lineups-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 0 6px 6px;
}

.environment-heading label,
.lineups-title h3 {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 900;
  color: var(--color-ink);
  line-height: 1;
}

.environment-heading a {
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.environment-panel select {
  width: 100%;
}

.environment-panel p {
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--color-ink-2);
  line-height: 1.38;
  margin: 5px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.environment-panel [aria-busy="true"] {
  color: var(--color-accent);
  font-weight: 800;
}

#save-lineup {
  min-height: 25px;
  padding: 2px 8px;
  font-size: var(--text-2xs);
}

#saved-lineups {
  max-height: 68px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.saved-lineup {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.lineup-load {
  flex: 1;
  min-width: 0;
  justify-content: space-between;
  min-height: 26px;
  padding: 2px 8px;
}

.lineup-load span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineup-load small { font-size: var(--text-2xs); color: var(--color-ink-2); }
.lineup-load[aria-pressed="true"] { background: var(--color-straw-gold); }

.lineup-action {
  min-height: 26px;
  padding: 2px 6px;
  font-size: var(--text-2xs);
  box-shadow: none;
}

.lineup-empty,
#lineup-status {
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--color-ink-2);
  margin: 2px 6px 0;
}
#lineup-status:empty { display: none; }

/* WANTED Bounty Roster Board */
.roster-board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: oklch(14% 0.025 45 / 0.56);
  border: 2px solid oklch(48% 0.07 62);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
}

.roster-header {
  flex-shrink: 0;
  margin-bottom: 7px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.panel-title h2 {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--color-wood-ink);
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
}

#selected-count {
  padding: 2px 8px;
  background: var(--color-accent);
  border: 1.5px solid var(--color-straw-gold);
  border-radius: var(--radius-xs);
  color: var(--color-accent-ink);
  font-size: var(--text-2xs);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.presets button {
  min-height: 28px;
  background: oklch(26% 0.04 48 / 0.9);
  color: var(--color-wood-muted);
  border-color: oklch(50% 0.07 62);
}

.search-filter-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  padding: 0 8px;
  background: oklch(96% 0.02 82 / 0.95);
  border: 2px solid var(--color-comic-border);
  border-radius: var(--radius-xs);
}

.search svg { color: var(--color-ink-2); flex-shrink: 0; }
.search input {
  flex: 1; min-width: 0; min-height: 0; padding: 0;
  border: 0; outline: none; background: transparent;
  color: var(--color-ink); font-size: var(--text-xs); font-weight: 700;
}
.search input::placeholder { color: var(--color-muted); font-weight: 500; }
.search button {
  min-height: 22px; width: 22px; padding: 0;
  border: 0; box-shadow: none; background: transparent;
  color: var(--color-ink-2); font-size: 15px;
}

.filters {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filters select { flex: 1; min-width: 0; min-height: 28px; padding: 2px 6px; }
.filters button { min-height: 28px; padding: 2px 8px; }

/* 2-Column Authentic WANTED Poster Grid */
.cast-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-brass-dim) transparent;
}

#selected-cast {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 2px dashed oklch(75% 0.08 78 / 0.45);
}

#selected-cast h3 {
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 900;
  color: var(--color-straw-gold);
  letter-spacing: 0.04em;
}

#selected-cast-items,
.available-cast-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#selected-cast-items > .notice,
.available-cast-items > .notice {
  grid-column: 1 / -1;
  color: var(--color-wood-muted);
  margin: 4px 0;
}

/* Each Character = Miniature WANTED Bounty Poster! */
.cast-row {
  position: relative;
  display: flex;
  flex-direction: column;
  background: url('ui-assets/wanted-parchment.jpg') center/cover, var(--color-paper);
  border: 2px solid #3c220e;
  border-radius: 2px;
  padding: 5px 6px 6px;
  box-shadow: 3px 3px 0 rgba(12, 6, 2, 0.65);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.cast-row:hover {
  transform: translateY(-2px);
  border-color: var(--color-straw-gold);
}

.cast-row.selected {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1.5px var(--color-straw-gold), 3px 3px 0 rgba(12, 6, 2, 0.75);
}

.cast-row > label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  text-align: center;
}

/* Visually keep checkbox accessible for keyboard & tests while card acts as toggle */
.cast-row > label > input[type="checkbox"] {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 14px;
  height: 14px;
  z-index: 3;
}

.wanted-hdr {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #2b1708;
  line-height: 1;
  padding-bottom: 3px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(60, 34, 14, 0.45);
}

.wanted-pic {
  position: relative;
  width: 100%;
  height: 76px;
  background: radial-gradient(circle, #e5d1aa 0%, #ab8858 100%);
  border: 1.5px solid #3c220e;
  overflow: hidden;
}

.wanted-pic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
}

.wanted-stamp {
  display: none;
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
  padding: 1px 4px;
  background: oklch(97% 0.02 84 / 0.92);
  border: 1.5px solid var(--color-accent);
  color: var(--color-accent);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  transform: rotate(10deg);
}

.cast-row.selected .wanted-stamp {
  display: block;
}

.wanted-doa {
  font-family: "Georgia", serif;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #533318;
  margin-top: 3px;
  line-height: 1;
}

.cast-row .name {
  font-size: var(--text-xs);
  font-weight: 900;
  color: #201005;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  font-size: 10px;
  font-weight: 700;
  color: #5c3b1e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag.warn {
  color: var(--color-accent);
}

.variant {
  display: block;
  margin-top: 4px;
  width: 100%;
  min-height: 24px;
  padding: 1px 4px;
  font-size: 11px;
  border-width: 1.5px;
  background: oklch(97% 0.015 84 / 0.9);
}

/* Bottom Compact Stamp Tray */
.panel-bottom {
  padding: 8px 11px 9px;
}

.bottom-compact-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 7px;
}

.setting {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
}

.setting label {
  font-weight: 800;
  color: var(--color-ink);
  flex-shrink: 0;
}

.setting input { flex: 1; min-width: 0; }
.setting output {
  width: 30px;
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.toggles-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fan-disclaimer {
  margin: 5px 0 0;
  padding-top: 4px;
  border-top: 1px dashed oklch(24% 0.03 48 / 0.25);
  font-size: 10px;
  line-height: 1.35;
  color: oklch(34% 0.03 48);
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--color-ink);
  cursor: pointer;
}

.wide {
  width: 100%;
  min-height: 36px;
  justify-content: space-between;
  padding: 0 12px;
  font-size: var(--text-sm);
}

.panel-bottom .notice {
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--color-ink-2);
  margin: 5px 0 0;
}

/* Dialog */
dialog {
  border: 3px solid var(--color-comic-border);
  background: url('ui-assets/wanted-parchment.jpg') center/cover, var(--color-paper);
  color: var(--color-ink);
  border-radius: var(--radius-xs);
  padding: var(--space-lg);
  width: min(400px, calc(100vw - 32px));
  box-shadow: var(--shadow-dialog);
}
dialog::backdrop { background: var(--color-backdrop); }
dialog h2 {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 900;
  margin-bottom: var(--space-sm);
  padding-bottom: 6px;
  border-bottom: 2.5px double var(--color-comic-border);
}
dialog label { display: block; font-size: var(--text-sm); font-weight: 800; }
dialog input { display: block; width: 100%; margin-top: 6px; }
dialog p { font-size: var(--text-xs); line-height: 1.5; color: var(--color-ink-2); min-height: 2.2em; margin: 10px 0 16px; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

[hidden] { display: none !important; }

/* Clean Pure-Frame Mode (H) */
.clean .chrome,
.clean #toast {
  display: none !important;
}

.clean main,
.clean .stage {
  height: 100vh;
}

body.clean { cursor: default; }
.clean #scene { cursor: grab; }

/* Responsive — Verified Down to 320px */
@media (max-width: 1280px) {
  .gestures { display: none; }
  .stage-bar { justify-content: center; }
  .toolbar { margin-left: 0; }
}

@media (max-width: 900px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  header {
    padding: 0 var(--space-xs);
  }
  .mast-kicker,
  .brand-sub,
  .extra-stamp,
  #status {
    display: none;
  }
  main {
    flex-direction: column;
    height: auto;
  }
  .stage {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    flex: none;
  }
  #scene {
    height: 52vh;
    min-height: 300px;
    flex: none;
  }
  .viewfinder-frame {
    inset: 8px 8px auto 8px;
    height: calc(52vh - 16px);
    min-height: 284px;
    box-shadow: 0 0 0 8px var(--color-newsprint);
  }
  .stage-bar {
    position: static;
    order: 2;
    height: auto;
    padding: 8px;
    background: var(--color-newsprint);
    border-top: 2.5px solid var(--color-comic-border);
    pointer-events: auto;
  }
  .toolbar {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }
  .toolbar button {
    transform: none;
  }
  .toolbar button:hover:not(:disabled) {
    transform: translate(-1px, -1px);
  }
  .divider { display: none; }
  .inspector-dock {
    position: static;
    order: 3;
    width: 100%;
    max-height: none;
    padding: var(--space-xs);
    background: var(--color-newsprint-2);
    border-top: 2px solid var(--color-comic-border);
  }
  aside {
    width: 100%;
    border-left: 0;
    border-top: 3.5px solid var(--color-comic-border);
    overflow: visible;
  }
  .cast-list {
    max-height: 380px;
  }
  .clean main,
  .clean .stage,
  .clean #scene {
    height: 100vh;
  }
}

@media (max-width: 640px) {
  .brand-rule,
  #cast-summary {
    display: none;
  }
  .jolly-medallion {
    width: 28px;
    height: 28px;
  }
  .jolly-medallion svg {
    width: 20px;
    height: 20px;
  }
  .brand-main-row h1 {
    font-size: var(--text-xs);
    letter-spacing: 0.01em;
  }
  .top-meta {
    gap: 5px;
  }
  .lang-switch button {
    min-height: 24px;
    padding: 2px 6px;
  }
  .ink-btn {
    min-height: 26px;
    padding: 2px 7px;
    font-size: var(--text-2xs);
  }
  #clean kbd {
    display: none;
  }
  .toolbar button {
    padding: 4px 8px;
  }
}

@media (max-width: 360px) {
  #selected-cast-items,
  .available-cast-items {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 120ms !important;
  }
}
