@font-face {
  font-family: "Postal Roman";
  src: url("assets/roman.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Postal Roman";
  src: url("assets/italic.woff") format("woff");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #faf5ea;
  --table-top: #e8dfd0;
  --table-mid: #ded3c1;
  --table-deep: #cfc1ab;
  --ink: #3f332d;
  --quiet: #695b50;
  --wine: #923e43;
  --moss: #546c52;
  --moss-dark: #3d523b;
  --moss-hover: #496147;
  --wood-light: #dab98d;
  --wood-mid: #c59f6e;
  --wood-dark: #9c774a;
  --wood-edge: #7b5b36;
  --squeegee-red: #b23930;
  --squeegee-dark: #7d221c;
  --ink1: #47644b;
  --ink2: #cc493a;
  --active-ink: #47644b;
  --serif: "Postal Roman", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --type: ui-monospace, "Courier New", monospace;
}

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

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  min-height: 100%;
  background-color: var(--table-mid);
  color: var(--ink);
  font: 1rem/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
}

body {
  /* Ánh sáng xiên nhẹ từ trên-trái xuống dưới-phải trên mặt bàn xưởng */
  background:
    radial-gradient(ellipse 92% 76% at 18% 12%, rgba(255, 250, 239, 0.72) 0%, rgba(255, 250, 239, 0) 64%),
    linear-gradient(134deg, var(--table-top) 0%, var(--table-mid) 54%, var(--table-deep) 100%);
  background-attachment: fixed;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: url("assets/grain.png") repeat;
  opacity: 0.42;
  z-index: 0;
}

button, a {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible, a:focus-visible, .press-bed:focus-visible, .squeegee:focus-visible {
  outline: 3px solid #4d6e63;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.studio {
  position: relative;
  z-index: 1;
  width: min(100%, 86rem);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3.2vw, 2.6rem) max(0.85rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* === THANH TRÊN TỐI GIẢN === */
.topbar {
  height: 3.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(133, 114, 93, 0.22);
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.52rem;
  color: var(--wine);
  font: 400 1.55rem/1 var(--serif);
  letter-spacing: -0.04em;
  user-select: none;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink1);
  box-shadow: 5px 0 0 -0.5px var(--ink2);
  margin-right: 4px;
  flex-shrink: 0;
}

.music-toggle {
  border: 1px solid rgba(125, 108, 91, 0.38);
  border-radius: 999px;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.3rem 0.85rem;
  background: rgba(250, 245, 234, 0.56);
  color: var(--ink);
  font-size: 0.84rem;
  transition: background-color 0.16s ease;
}

.music-toggle:hover {
  background: rgba(250, 245, 234, 0.9);
}

.equalizer {
  height: 13px;
  width: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--wine);
}

.equalizer i {
  width: 2px;
  height: 40%;
  background: currentColor;
  border-radius: 1px;
}
.equalizer i:nth-child(2) { height: 90%; }
.equalizer i:nth-child(3) { height: 64%; }
.equalizer i:nth-child(4) { height: 38%; }

.music-toggle[aria-pressed="true"] .equalizer i {
  animation: listen 0.9s ease-in-out alternate infinite;
}
.equalizer i:nth-child(2) { animation-delay: -0.22s !important; }
.equalizer i:nth-child(3) { animation-delay: -0.57s !important; }

@keyframes listen {
  from { transform: scaleY(0.55); }
  to { transform: scaleY(1.08); }
}

/* === BÀN IN 3 CỘT TRÊN DESKTOP (1440×900 VỪA KHÍT KHÔNG CẦN CUỘN) === */
.workbench {
  flex: 1;
  display: grid;
  grid-template-columns: 11.5rem minmax(0, 1fr) 13.5rem;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.8rem);
  padding: 0.85rem 0 0.5rem;
}

/* --- Cột trái: Các tờ in thử nhỏ cạnh bàn --- */
.proofs-tray {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.proofs-list {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  width: 100%;
  align-items: center;
}

.proof-card {
  position: relative;
  border: 0;
  padding: 5px 5px 7px;
  background: var(--paper);
  border-radius: 2px;
  width: 7.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.32rem;
  box-shadow:
    1px 1px 0 #dcd0bc,
    4px 7px 14px rgba(59, 44, 30, 0.20),
    0 1px 2px rgba(59, 44, 30, 0.12);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease;
}

.proof-card:nth-child(1) { transform: rotate(-2.2deg); }
.proof-card:nth-child(2) { transform: rotate(1.8deg); }
.proof-card:nth-child(3) { transform: rotate(-1.3deg); }

.proof-card:hover {
  transform: translateY(-3px) rotate(0deg) scale(1.02);
  box-shadow:
    1px 1px 0 #dcd0bc,
    7px 12px 20px rgba(59, 44, 30, 0.24);
}

.proof-card[aria-checked="true"] {
  transform: translateY(-2px) rotate(0deg) scale(1.03);
  box-shadow:
    0 0 0 2px var(--wine),
    6px 11px 18px rgba(59, 44, 30, 0.25);
}

.proof-card canvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--paper);
  border: 1px solid rgba(186, 173, 152, 0.36);
}

.proof-name {
  font: 400 0.86rem/1.15 var(--serif);
  color: var(--ink);
  letter-spacing: -0.015em;
}

/* --- Cột giữa: Bàn in & Khung lụa gỗ --- */
.press-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-width: 0;
}

.prompt-line {
  margin: 0;
  min-height: 1.6rem;
  font: italic 400 clamp(1.1rem, 1.5vw, 1.32rem)/1.3 var(--serif);
  color: var(--ink);
  text-align: center;
  letter-spacing: -0.015em;
  transition: opacity 0.2s ease;
}

.press-bed-wrap {
  position: relative;
  width: min(100%, 30.5rem, calc((100svh - 11.2rem) * 0.75));
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.press-bed {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  /* Chỉ khóa cử chỉ cảm ứng trong vùng thao tác bàn in */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Độ dày xấp giấy kem & bóng đổ xiên trên mặt bàn */
.paper-stack {
  position: absolute;
  inset: 22px 22px 22px 22px;
  border-radius: 2px;
  background: #ede4d2;
  transform: translate(3px, 4px);
  box-shadow:
    3px 4px 0 #d9ccb6,
    10px 15px 28px rgba(61, 46, 30, 0.24),
    3px 5px 8px rgba(61, 46, 30, 0.14);
}

.paper-sheet {
  position: absolute;
  inset: 22px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--paper);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.85),
    inset -1px -1px 0 rgba(196, 181, 158, 0.5),
    1px 2px 0 #ded3bf;
}

#paper-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* === KHUNG LỤA BẰNG GỖ === */
.screen-frame {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  z-index: 4;
  transform-origin: 50% 42%;
  will-change: transform, opacity;
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.34s ease, filter 0.38s ease;
  /* Bóng khung gỗ đổ xiên xuống mặt bàn và tờ giấy */
  filter: drop-shadow(11px 16px 18px rgba(56, 40, 24, 0.28));
}

.screen-frame.is-dragging-frame {
  transition: none;
  cursor: grabbing;
}

.screen-frame.can-align {
  cursor: grab;
}

/* Trạng thái nhấc khung lên rời khỏi mặt giấy */
.screen-frame.is-lifted {
  transform: translate3d(10px, -28px, 0) scale(1.045) rotate(-1.4deg);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(24px 36px 32px rgba(56, 40, 24, 0.18));
}

/* Khung đang hạ xuống từ trên */
.screen-frame.is-entering {
  transform: translate3d(-6px, -30px, 0) scale(1.05) rotate(1.1deg);
  opacity: 0;
  pointer-events: none;
}

.wood-rail {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}

.wood-top {
  top: 0; left: 0; right: 0; height: 24px;
  border-radius: 6px 6px 0 0;
  background:
    repeating-linear-gradient(90deg, rgba(120, 82, 42, 0.06) 0 3px, transparent 3px 11px),
    linear-gradient(180deg, #e2c59c 0%, var(--wood-light) 35%, var(--wood-mid) 88%, var(--wood-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 248, 232, 0.72), 0 3px 6px rgba(68, 48, 28, 0.22);
}

.wood-bottom {
  bottom: 0; left: 0; right: 0; height: 24px;
  border-radius: 0 0 6px 6px;
  background:
    repeating-linear-gradient(90deg, rgba(120, 82, 42, 0.06) 0 4px, transparent 4px 12px),
    linear-gradient(180deg, var(--wood-mid) 0%, #b58d5c 72%, var(--wood-edge) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 240, 212, 0.42), inset 0 -2px 0 rgba(92, 64, 34, 0.42);
}

.wood-left {
  top: 22px; bottom: 22px; left: 0; width: 24px;
  background:
    repeating-linear-gradient(180deg, rgba(120, 82, 42, 0.06) 0 3px, transparent 3px 11px),
    linear-gradient(90deg, #e0c298 0%, var(--wood-light) 42%, var(--wood-mid) 88%, var(--wood-dark) 100%);
  box-shadow: inset 1px 0 0 rgba(255, 248, 232, 0.65), 3px 0 6px rgba(68, 48, 28, 0.18);
}

.wood-right {
  top: 22px; bottom: 22px; right: 0; width: 24px;
  background:
    repeating-linear-gradient(180deg, rgba(120, 82, 42, 0.06) 0 4px, transparent 4px 12px),
    linear-gradient(90deg, var(--wood-mid) 0%, #b48c5b 68%, var(--wood-edge) 100%);
  box-shadow: inset 1px 0 0 rgba(255, 240, 212, 0.35), inset -2px 0 0 rgba(92, 64, 34, 0.42);
}

/* Đinh tán đồng ở 4 góc khung gỗ */
.brass-pin {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  z-index: 7;
  pointer-events: none;
  background: radial-gradient(circle at 32% 32%, #f4dc9e 0%, #b58c44 65%, #6e501f 100%);
  box-shadow: 0 1px 1px rgba(45, 30, 14, 0.45);
}
.pin-tl { top: 8px; left: 8px; }
.pin-tr { top: 8px; right: 8px; }
.pin-bl { bottom: 8px; left: 8px; }
.pin-br { bottom: 8px; right: 8px; }

/* Ô lưới lụa trong khung */
.silk-window {
  position: absolute;
  inset: 22px;
  overflow: hidden;
  box-shadow:
    inset 3px 4px 10px rgba(66, 48, 28, 0.24),
    inset -1px -1px 3px rgba(255, 248, 232, 0.45);
}

.silk-mesh {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    repeating-linear-gradient(0deg, rgba(255, 252, 244, 0.22) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(168, 152, 128, 0.14) 0 1px, transparent 1px 4px),
    rgba(248, 242, 228, 0.20);
}

.stencil-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* Vệt mực mỏng phủ qua lưới sau lưng thanh gạt */
.mesh-ink-flood {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0%;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(180deg, var(--active-ink) 0%, var(--active-ink) 88%, transparent 100%);
  opacity: 0.11;
}

/* Vòng dẫn canh ở 2 góc đối diện (khớp REG_TL 108/1200=9%, 176/1600=11% & REG_BR 1092/1200=91%, 1396/1600=87.25%) */
.reg-guide {
  position: absolute;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border-radius: 50%;
  border: 1.5px dashed rgba(146, 62, 67, 0.78);
  background: rgba(250, 245, 234, 0.28);
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.22s ease, transform 0.22s ease, border-color 0.2s ease;
}

.reg-guide-tl { left: 9%; top: 11%; }
.reg-guide-br { left: 91%; top: 87.25%; }

.screen-frame.can-align .reg-guide {
  opacity: 1;
  transform: scale(1);
}

.screen-frame.is-aligned-straight .reg-guide {
  border-style: solid;
  border-color: rgba(71, 108, 76, 0.85);
}

/* === THANH GẠT CÁN ĐỎ CÓ VỆT MỰC CŨ === */
.squeegee {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 2.5%;
  height: 46px;
  z-index: 8;
  cursor: ns-resize;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  /* Vùng chạm rộng rãi cho ngón tay */
  padding: 6px 0 4px;
}

.squeegee::before {
  /* Mở rộng vùng chạm cảm ứng trên dưới thêm 14px mà không che hình */
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: -14px;
  bottom: -14px;
}

.squeegee.is-dragging {
  cursor: grabbing;
}

.squeegee-handle {
  position: relative;
  width: 100%;
  height: 25px;
  border-radius: 5px 5px 3px 3px;
  background:
    linear-gradient(180deg, #cb4c41 0%, var(--squeegee-red) 38%, #932a23 82%, var(--squeegee-dark) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 198, 186, 0.45),
    inset 0 -1px 0 rgba(64, 14, 10, 0.45),
    4px 7px 11px rgba(45, 26, 18, 0.34);
  overflow: hidden;
}

.handle-highlight {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 4px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 224, 212, 0.12), rgba(255, 224, 212, 0.38), rgba(255, 224, 212, 0.14));
}

/* Vệt mực cũ bám trên cán gỗ đỏ */
.ink-smudge {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(0.4px);
}
.smudge-1 {
  width: 34px; height: 11px; left: 13%; top: 11px;
  background: rgba(34, 46, 38, 0.46);
  transform: rotate(-11deg);
}
.smudge-2 {
  width: 24px; height: 9px; right: 20%; top: 5px;
  background: rgba(29, 36, 56, 0.42);
  transform: rotate(14deg);
}
.smudge-3 {
  width: 44px; height: 8px; left: 46%; bottom: 2px;
  background: rgba(54, 24, 28, 0.38);
  transform: rotate(-4deg);
}

.handle-grip {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 4px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(255, 234, 224, 0.38);
  box-shadow: 0 -4px 0 rgba(255, 234, 224, 0.18), 0 4px 0 rgba(80, 18, 14, 0.25);
}

.squeegee-rubber {
  width: 96%;
  height: 6px;
  background: linear-gradient(180deg, #3c342f, #221d1a);
  border-radius: 0 0 2px 2px;
  box-shadow: 2px 4px 6px rgba(36, 24, 16, 0.32);
}

/* Vệt mực ướt bóng trước lưỡi gạt */
.squeegee-ink-bead {
  position: absolute;
  bottom: 0;
  left: 4%;
  right: 4%;
  height: 7px;
  border-radius: 50% / 100%;
  background: var(--active-ink);
  opacity: 0.9;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.34), 0 2px 4px rgba(36, 24, 16, 0.18);
  transform: translateY(3px);
}

/* Thanh nút thao tác gọn (1 chạm / bàn phím) */
.press-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.35rem;
}

.action-pill {
  min-height: 2.25rem;
  padding: 0.38rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--moss-dark);
  background: var(--moss);
  color: #faf6ec;
  font: 500 0.88rem/1.2 var(--sans);
  box-shadow: 0 2px 0 rgba(48, 66, 46, 0.24);
  transition: background-color 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}

.action-pill:hover:not(:disabled) {
  background: var(--moss-hover);
}

.action-pill:active:not(:disabled) {
  transform: translateY(1px);
}

.action-pill:disabled {
  opacity: 0.48;
  cursor: default;
}

.action-pill.subtle {
  border-color: rgba(110, 93, 76, 0.38);
  background: rgba(250, 245, 234, 0.72);
  color: var(--ink);
  box-shadow: none;
}

.action-pill.subtle:hover:not(:disabled) {
  background: rgba(250, 245, 234, 0.96);
}

/* --- Cột phải: Hai hũ mực đang mở & chọn cặp mực --- */
.ink-station {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.15rem;
}

.ink-jars {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

.jar-unit {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.38rem;
}

.ink-jar {
  position: relative;
  width: 66px;
  height: 66px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e9e2d4;
  box-shadow:
    0 0 0 3px #dcd3c2,
    7px 11px 18px rgba(55, 40, 25, 0.28),
    2px 3px 5px rgba(55, 40, 25, 0.16);
  transition: transform 0.16s ease;
}

.ink-jar:hover {
  transform: scale(1.04);
}

.jar-rim {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 3px solid #b6aa98;
  background: #2f2822;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.55);
}

.jar-liquid {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.2) 0%, transparent 45%), var(--ink1);
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.32);
  transition: background-color 0.22s ease;
}

#jar-liquid-2 {
  background: radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.22) 0%, transparent 45%), var(--ink2);
}

.jar-gloss {
  position: absolute;
  top: 15px;
  left: 18px;
  width: 14px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 252, 245, 0.36);
  transform: rotate(-28deg);
  pointer-events: none;
}

/* Nắp hũ mực đặt hé mở bên cạnh */
.jar-lid {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 32%, #f4efe6 0%, #cdc3b3 58%, #9f9482 100%);
  border: 2px solid #aba08e;
  box-shadow: 5px 8px 12px rgba(55, 40, 25, 0.22);
  pointer-events: none;
  z-index: -1;
}
.jar-lid-1 { top: -10px; right: -28px; }
.jar-lid-2 { bottom: 16px; left: -28px; }

.jar-tag {
  font: 400 0.78rem/1.2 var(--type);
  letter-spacing: 0.02em;
  color: var(--quiet);
}

/* Bộ chọn cặp mực */
.palette-bar {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  width: 100%;
}

.palette-chip {
  display: flex;
  align-items: center;
  gap: 0.52rem;
  width: 100%;
  padding: 0.38rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(133, 114, 93, 0.28);
  background: rgba(250, 245, 234, 0.56);
  color: var(--ink);
  font-size: 0.79rem;
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.palette-chip:hover {
  background: rgba(250, 245, 234, 0.88);
}

.palette-chip[aria-checked="true"] {
  background: var(--paper);
  border-color: var(--wine);
  box-shadow: 0 2px 8px rgba(59, 44, 30, 0.12);
}

.swatch-pair {
  position: relative;
  width: 24px;
  height: 15px;
  flex-shrink: 0;
}

.swatch-pair i {
  position: absolute;
  top: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid rgba(250, 245, 234, 0.75);
}

.swatch-pair i:first-child { left: 0; }
.swatch-pair i:last-child { right: 0; mix-blend-mode: multiply; }

.palette-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === GIÁ PHƠI BẢN IN HOÀN CHỈNH === */
.drying-rack {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.05rem;
  padding: 0.5rem 0 0.85rem;
  position: relative;
  animation: rack-enter 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rack-enter {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

.rack-wire {
  position: relative;
  width: min(100%, 46rem);
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #98866f, #6a5a47);
  box-shadow: 0 4px 8px rgba(55, 40, 25, 0.22);
  margin-bottom: -1.15rem;
  z-index: 2;
}

.rack-poster-stage {
  display: flex;
  justify-content: center;
  width: 100%;
}

.rack-poster-wrap {
  position: relative;
  width: min(88vw, 33rem, calc((100svh - 10.6rem) * 0.75));
  aspect-ratio: 3 / 4;
  background: var(--paper);
  border-radius: 2px;
  box-shadow:
    1px 2px 0 #dcd0bc,
    12px 20px 36px rgba(52, 38, 24, 0.26),
    2px 4px 10px rgba(52, 38, 24, 0.14);
  transform-origin: 50% 0%;
  animation: poster-sway 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes poster-sway {
  0% { transform: translateY(28px) rotate(-1.4deg) scale(0.96); }
  65% { transform: translateY(-2px) rotate(0.45deg) scale(1); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

#rack-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 2px;
}

/* Hai chiếc kẹp gỗ treo poster trên dây phơi */
.clothespin {
  position: absolute;
  top: -15px;
  width: 14px;
  height: 36px;
  border-radius: 3px;
  z-index: 4;
  background: linear-gradient(90deg, #dfc298 0%, #c69f6c 62%, #9a7446 100%);
  border: 1px solid #8c673b;
  box-shadow: 3px 5px 8px rgba(48, 34, 20, 0.28);
}

.clothespin::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: 13px;
  height: 4px;
  background: #6c6358;
}

.pin-left { left: 19%; transform: rotate(-2deg); }
.pin-right { right: 19%; transform: rotate(2deg); }

.rack-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-save {
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.6rem 1.45rem;
  border: 1px solid var(--moss-dark);
  border-radius: 6px;
  background: var(--moss);
  color: #fff9ee;
  text-decoration: none;
  font: 600 0.96rem/1.2 var(--sans);
  box-shadow: 0 2px 0 rgba(48, 66, 46, 0.25);
  transition: background-color 0.16s ease, transform 0.12s ease;
}

.btn-save:hover {
  background: var(--moss-hover);
}
.btn-save:active {
  transform: translateY(1px);
}

.icon-save {
  position: relative;
  width: 16px;
  height: 15px;
  border: 1.4px solid currentColor;
  border-top: 0;
  border-radius: 0 0 2px 2px;
  clip-path: polygon(0 60%, 28% 60%, 28% 0, 73% 0, 73% 60%, 100% 60%, 100% 100%, 0 100%);
}
.icon-save::before {
  content: "";
  position: absolute;
  top: 0;
  left: 6.5px;
  height: 10px;
  border-left: 1.5px solid currentColor;
}
.icon-save::after {
  content: "";
  position: absolute;
  top: 5.5px;
  left: 4px;
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.btn-again {
  min-height: 2.9rem;
  padding: 0.6rem 1.3rem;
  border: 1px solid rgba(114, 96, 78, 0.42);
  border-radius: 6px;
  background: rgba(250, 245, 234, 0.82);
  color: var(--ink);
  font: 500 0.95rem/1.2 var(--sans);
  transition: background-color 0.16s ease, transform 0.12s ease;
}

.btn-again:hover {
  background: var(--paper);
}
.btn-again:active {
  transform: translateY(1px);
}

/* === ĐIỆN THOẠI (390×844): ƯU TIÊN TỐI ĐA DIỆN TÍCH CHO TỜ GIẤY VÀ BÀN TAY THAO TÁC === */
@media (max-width: 860px) {
  .studio {
    padding: 0 max(0.75rem, env(safe-area-inset-right)) max(0.65rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  }

  .topbar {
    height: 2.85rem;
  }

  .brand {
    font-size: 1.24rem;
    gap: 0.42rem;
  }

  .music-toggle {
    min-height: 2rem;
    padding: 0.22rem 0.68rem;
    font-size: 0.78rem;
    gap: 0.38rem;
  }

  .workbench {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    padding: 0.45rem 0 0.35rem;
  }

  /* Bàn in lên đầu tiên và lớn nhất */
  .press-center {
    order: 1;
    width: 100%;
    gap: 0.42rem;
  }

  .prompt-line {
    font-size: 1.02rem;
    min-height: 1.35rem;
  }

  .press-bed-wrap {
    width: min(94vw, 23.2rem, calc((100svh - 17.2rem) * 0.75));
  }

  .wood-top, .wood-bottom { height: 18px; }
  .wood-left, .wood-right { width: 18px; top: 16px; bottom: 16px; }
  .paper-stack, .paper-sheet, .silk-window { inset: 16px; }
  .pin-tl { top: 5px; left: 5px; }
  .pin-tr { top: 5px; right: 5px; }
  .pin-bl { bottom: 5px; left: 5px; }
  .pin-br { bottom: 5px; right: 5px; }

  .squeegee {
    height: 40px;
  }
  .squeegee-handle {
    height: 22px;
  }

  .press-controls {
    min-height: 2.1rem;
  }

  .action-pill {
    min-height: 2.05rem;
    padding: 0.3rem 0.95rem;
    font-size: 0.84rem;
  }

  /* Hai hũ mực + chọn màu xếp thành 1 dải gọn bên dưới bàn in */
  .ink-station {
    order: 2;
    width: min(100%, 24rem);
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.25rem 0.2rem;
  }

  .ink-jars {
    flex-direction: row;
    gap: 0.6rem;
    flex-shrink: 0;
  }

  .jar-unit {
    gap: 0;
  }

  .ink-jar {
    width: 40px;
    height: 40px;
    box-shadow: 0 0 0 2px #dcd3c2, 4px 6px 10px rgba(55, 40, 25, 0.24);
  }
  .jar-rim { inset: 3px; border-width: 2px; }
  .jar-liquid { inset: 7px; }
  .jar-gloss { top: 10px; left: 11px; width: 9px; height: 5px; }
  .jar-lid { width: 22px; height: 22px; border-width: 1.5px; }
  .jar-lid-1 { top: -5px; right: -8px; }
  .jar-lid-2 { bottom: -4px; left: -8px; }
  .jar-tag { display: none; }

  .palette-bar {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.38rem;
    width: auto;
  }

  .palette-chip {
    width: auto;
    padding: 0.34rem 0.46rem;
    justify-content: center;
  }

  .palette-name {
    display: none;
  }

  /* 3 tờ in thử nhỏ nằm ngang sát mép dưới bàn */
  .proofs-tray {
    order: 3;
    width: min(100%, 24rem);
  }

  .proofs-list {
    flex-direction: row;
    justify-content: center;
    gap: 0.65rem;
  }

  .proof-card {
    width: 5.75rem;
    padding: 4px 4px 5px;
    gap: 0.22rem;
  }

  .proof-name {
    font-size: 0.76rem;
  }

  /* Giá phơi trên điện thoại chiếm phần lớn màn hình */
  .drying-rack {
    gap: 0.85rem;
    padding: 0.35rem 0 0.5rem;
  }

  .rack-poster-wrap {
    width: min(92vw, 24.5rem, calc((100svh - 9.2rem) * 0.75));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
