:root {
  --paper: #eadfcd;
  --paper-deep: #d8c9b0;
  --ink: #1c1712;
  --ink-soft: #5a5146;
  --brass: #a0783a;
  --brass-bright: #c49a54;
  --desk: #f7f1e6;
  --line: rgba(28, 23, 18, 0.14);
  --shadow: 0 24px 50px rgba(48, 32, 12, 0.16);
  --display: "Noto Serif SC", "Cormorant Garamond", serif;
  --body: "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: var(--app-height, 100dvh);
}

body {
  color: var(--ink);
  background: #cbb896;
  font-family: var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.grain,
.shaft {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.grain {
  z-index: 3;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.shaft {
  z-index: 0;
  background: linear-gradient(
    118deg,
    transparent 18%,
    rgba(255, 244, 214, 0.28) 38%,
    rgba(255, 236, 196, 0.55) 46%,
    transparent 62%
  );
  animation: drift 18s ease-in-out infinite;
}

@keyframes drift {
  0%,
  100% {
    transform: translateX(-4%) rotate(0.2deg);
  }
  50% {
    transform: translateX(3%) rotate(-0.6deg);
  }
}

.frame {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(280px, 38%) 1fr;
  gap: 0;
  height: var(--app-height, 100dvh);
  max-width: 1280px;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.atelier {
  position: relative;
  padding: 48px 44px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.seat {
  margin: 0 0 28px;
  letter-spacing: 0.28em;
  font-size: 11px;
  color: var(--brass);
  text-transform: uppercase;
}

.atelier h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(64px, 8vw, 92px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 0.08em;
}

.atelier-en {
  margin: 10px 0 0;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 22px;
  color: var(--ink-soft);
}

.lede {
  margin: 36px 0 0;
  max-width: 28ch;
  font-size: 15px;
  line-height: 1.9;
  color: var(--ink-soft);
}

.meta {
  margin: 40px 0 0;
  display: grid;
  gap: 16px;
}

.meta div {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.meta dt {
  font-size: 12px;
  color: var(--brass);
}

.meta dd {
  margin: 0;
  font-size: 14px;
}

.config-pill {
  margin: 48px 0 0;
  width: fit-content;
  padding: 6px 10px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}

.config-pill.ok {
  color: #3f5c38;
  border-color: rgba(63, 92, 56, 0.28);
}

.config-pill.warn {
  color: #8a4b1f;
  border-color: rgba(138, 75, 31, 0.3);
}

.desk {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--desk);
  min-width: 0;
  min-height: 0;
}

.desk-bar {
  display: flex;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.transcript {
  overflow: auto;
  min-height: 0;
  padding: 28px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.bubble {
  max-width: 82%;
  padding: 14px 16px;
  line-height: 1.7;
  font-size: 14px;
  animation: rise 420ms ease both;
}

.bubble.studio {
  align-self: flex-start;
  background: transparent;
  border-left: 2px solid var(--brass);
  padding-left: 14px;
}

.bubble.guest {
  align-self: flex-end;
  background: #fffaf1;
  border: 1px solid var(--line);
}

.thumb {
  width: 148px;
  height: 186px;
  object-fit: cover;
  display: block;
  border: 8px solid #fffaf1;
  box-shadow: 0 10px 24px rgba(48, 32, 12, 0.16);
}

.prints {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 100%;
}

.print {
  background: #fffaf1;
  padding: 12px 12px 16px;
  box-shadow: 0 16px 32px rgba(48, 32, 12, 0.14);
  animation: rise 700ms ease both;
}

.print img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #d9d3c6;
}

.print figcaption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.print a {
  color: var(--brass);
  text-decoration: none;
}

.composer {
  padding: 8px 20px 20px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chips button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.chips button:hover,
.icon-btn:hover,
.send:hover,
.ghost:hover,
.chips button:active,
.icon-btn:active,
.send:active,
.ghost:active {
  border-color: var(--brass);
  color: var(--brass);
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.72);
}

.icon-btn,
.send,
.ghost {
  font: inherit;
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

#textInput {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  min-width: 0;
}

.send,
.ghost {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--desk);
  padding: 10px 16px;
}

.ghost {
  background: transparent;
  color: var(--ink);
}

.camera-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(92vw, 420px);
}

.camera-dialog::backdrop {
  background: rgba(28, 23, 18, 0.55);
}

.camera-body {
  background: var(--ink);
  padding: 12px;
}

#cameraVideo {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #111;
}

.camera-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 0 4px;
}

.busy {
  display: flex;
  gap: 6px;
  padding: 6px 0;
}

.busy i {
  width: 6px;
  height: 6px;
  background: var(--brass);
  border-radius: 50%;
  animation: blink 1.1s infinite;
}

.busy i:nth-child(2) {
  animation-delay: 0.15s;
}

.busy i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

button:focus-visible,
input:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .shaft {
    display: none;
  }

  .grain {
    opacity: 0.1;
  }

  .frame {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    max-width: none;
    box-shadow: none;
    min-height: var(--app-height, 100dvh);
  }

  .atelier {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .atelier h1 {
    font-size: 28px;
    letter-spacing: 0.16em;
    line-height: 1;
  }

  .seat,
  .atelier-en,
  .lede,
  .meta {
    display: none;
  }

  .config-pill {
    margin: 0;
    flex-shrink: 0;
    font-size: 11px;
    padding: 5px 8px;
  }

  .desk-bar {
    padding: 10px 16px;
    font-size: 11px;
  }

  .transcript {
    padding: 16px 16px 8px;
    gap: 12px;
  }

  .bubble {
    max-width: 92%;
    padding: 12px 14px;
    font-size: 15px;
  }

  .thumb {
    width: 112px;
    height: 140px;
    border-width: 6px;
  }

  .prints {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .print {
    padding: 8px 8px 12px;
  }

  .composer {
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    position: sticky;
    bottom: 0;
    background: var(--desk);
    z-index: 2;
  }

  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .chips::-webkit-scrollbar {
    display: none;
  }

  .chips button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .composer-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    grid-template-areas:
      "album camera camera"
      "input input send";
    gap: 8px;
    padding: 8px;
    align-items: stretch;
  }

  #captureInput {
    display: none;
  }

  .icon-btn:has(#fileInput) {
    grid-area: album;
  }

  #cameraBtn {
    grid-area: camera;
  }

  #textInput {
    grid-area: input;
    font-size: 16px;
    min-height: 44px;
    padding: 0 8px;
  }

  .send {
    grid-area: send;
  }

  .icon-btn {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--line);
  }

  .icon-btn[data-label]::after {
    content: attr(data-label);
    font-size: 13px;
    letter-spacing: 0.04em;
  }

  #textInput {
    font-size: 16px;
    min-height: 44px;
  }

  .send,
  .ghost {
    min-height: 44px;
    padding: 10px 14px;
    flex-shrink: 0;
  }

  .camera-dialog {
    max-width: none;
    width: 100vw;
    height: var(--app-height, 100dvh);
    margin: 0;
  }

  .camera-body {
    min-height: var(--app-height, 100dvh);
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top, 0px) 12px env(safe-area-inset-bottom, 0px);
  }

  #cameraVideo {
    flex: 1;
    width: 100%;
    aspect-ratio: auto;
    min-height: 0;
  }
}

@media (max-width: 420px) {
  .prints {
    grid-template-columns: 1fr;
  }

  .send {
    padding-inline: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shaft,
  .bubble,
  .print,
  .busy i {
    animation: none;
  }
}
