:root {
  color-scheme: light;
  --ink: #34483f;
  --muted: #77847a;
  --glass: rgba(251, 250, 242, 0.76);
  --line: rgba(63, 80, 64, 0.16);
  --gold: #a28048;
  --button: #435b49;
  --bg: #e4ebe2;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font:
    13px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  transition:
    background 1s,
    color 1s;
}
body.night {
  color-scheme: dark;
  --ink: #f1e4c9;
  --muted: #b6a9be;
  --glass: rgba(40, 29, 52, 0.8);
  --line: rgba(239, 218, 176, 0.2);
  --gold: #d4b476;
  --button: #a9864d;
  --bg: #241a35;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  border-radius: 10px;
  padding: 11px 15px;
  min-height: 44px;
  transition:
    background 0.2s,
    transform 0.2s;
}
button:hover {
  background: rgba(155, 154, 126, 0.14);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}
button.primary {
  background: var(--button);
  color: #fff9eb;
  border-color: transparent;
}
button[aria-pressed="true"] {
  background: rgba(174, 151, 93, 0.18);
}
[hidden] {
  display: none !important;
}
#scene {
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse at 52% 44%,
    #faf9eb 0%,
    #e5ece3 48%,
    #cedbcf 100%
  );
  transition: background 1s;
}
body.night #scene {
  background: radial-gradient(
    ellipse at 53% 44%,
    #4f3b57 0%,
    #2c203c 48%,
    #191624 100%
  );
}
#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 110px #2339270a;
}
header {
  position: fixed;
  top: max(40px, env(safe-area-inset-top));
  left: 5%;
  pointer-events: none;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  gap: 12px;
  align-items: center;
}
.eyebrow:before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--gold);
}
h1 {
  font-family: "Snell Roundhand", "URW Chancery L", "Apple Chancery", cursive;
  font-size: clamp(34px, 3.5vw, 56px);
  font-weight: 400;
  line-height: 1.2;
  margin: 16px 0 10px;
  max-width: 340px;
}
body.night h1 {
  text-shadow: 0 0 26px #f8d9a831;
}
header p {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
  margin: 0;
}
.top-right {
  position: fixed;
  right: 4%;
  top: 40px;
  text-align: right;
}
.edition {
  font-family: Georgia, serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 12px;
}
#status {
  font-size: 10px;
  color: var(--muted);
}
#galleryToggle {
  margin-top: 14px;
  background: var(--glass);
  border-radius: 30px;
  font-size: 12px;
}
.bottom {
  position: fixed;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  max-width: calc(100% - 24px);
}
.hint {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1.5px;
  white-space: nowrap;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow:
    0 8px 40px #1422170c,
    inset 0 1px #ffffff30;
  backdrop-filter: blur(20px);
  padding: 7px;
  border-radius: 18px;
  white-space: nowrap;
}
.toolbar button {
  border: 0;
  font-size: 12px;
}
.toolbar .primary {
  padding-inline: 20px;
}
.icon {
  font-size: 17px;
  vertical-align: -1px;
  margin-right: 7px;
}
.sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
}
#moreMenu {
  position: absolute;
  right: 0;
  bottom: 84px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 8px;
  width: 205px;
  box-shadow: 0 10px 40px #0001;
}
#moreMenu button {
  display: block;
  width: 100%;
  border: 0;
  text-align: left;
}
.corner {
  position: fixed;
  left: 5%;
  bottom: 37px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  pointer-events: none;
}
.corner span {
  display: block;
  font-family: Georgia, serif;
  font-size: 18px;
  letter-spacing: 0;
  color: var(--gold);
  margin-bottom: 3px;
}
#focusBar {
  position: fixed;
  right: 4%;
  top: 50%;
  transform: translateY(-50%);
  width: 220px;
  padding: 24px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(20px);
}
#focusBar .label {
  letter-spacing: 2px;
  color: var(--gold);
  font-size: 10px;
}
#focusCaption {
  font-family: Georgia, "Songti SC", serif;
  font-size: 20px;
  margin: 12px 0 18px;
  overflow-wrap: anywhere;
}
#focusBar button {
  font-size: 12px;
}
#focusBar .row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
#focusBar .row button {
  flex: 1;
  padding: 9px;
}
#back {
  width: 100%;
  margin-top: 18px;
}
#gallery {
  position: fixed;
  right: 4%;
  top: 155px;
  width: 285px;
  max-height: calc(100dvh - 280px);
  overflow: auto;
  padding: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(20px);
  z-index: 4;
}
#gallery .gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
#thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
#thumbs button {
  padding: 4px;
  border-radius: 5px;
  aspect-ratio: 0.82;
  position: relative;
  background: #f6f1e4;
  color: #6b765f;
}
#thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
#thumbs small {
  font-size: 9px;
}
#thumbs .empty {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 19px;
  color: #a29b83;
}
#toast {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  padding: 12px 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  z-index: 20;
  max-width: min(90vw, 580px);
  box-shadow: 0 10px 30px #0001;
  backdrop-filter: blur(20px);
}
dialog {
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  box-shadow: 0 24px 120px #0004;
}
dialog::backdrop {
  background: #171d2266;
  backdrop-filter: blur(8px);
}
dialog h2 {
  font-family: Georgia, "Songti SC", serif;
  font-size: 23px;
  font-weight: 400;
  margin: 0 0 8px;
}
dialog p {
  color: var(--muted);
  font-size: 12px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
#cropCanvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border: 8px solid #faf7ef;
  touch-action: none;
  cursor: grab;
}
label {
  display: block;
  font-size: 12px;
  margin-top: 14px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}
input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  background: var(--glass);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}
#dropZone {
  position: fixed;
  inset: 16px;
  z-index: 15;
  border: 2px dashed var(--gold);
  border-radius: 25px;
  background: var(--glass);
  display: grid;
  place-items: center;
  font-size: 22px;
  pointer-events: none;
}
#loading {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--bg);
  gap: 12px;
}
#loading strong {
  font:
    italic 30px Georgia,
    serif;
}
#loading p {
  color: var(--muted);
}
#fallback {
  position: fixed;
  inset: 200px 5% 160px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
}
#fallback button {
  background: var(--glass);
}
#fallback img {
  width: 100%;
  display: block;
}
body.fallback .hint {
  white-space: normal;
  text-align: center;
}
body.focusing header {
  opacity: 0.45;
}
@media (max-width: 700px) {
  header {
    top: max(25px, env(safe-area-inset-top));
    left: 25px;
  }
  h1 {
    font-size: 35px;
    margin-top: 10px;
    max-width: 240px;
  }
  header p {
    font-size: 10px;
    letter-spacing: 1px;
  }
  .eyebrow {
    font-size: 8px;
    letter-spacing: 2px;
  }
  .top-right {
    top: 28px;
    right: 20px;
  }
  .edition {
    display: none;
  }
  #status {
    max-width: 90px;
    font-size: 9px;
  }
  #galleryToggle {
    font-size: 10px;
    padding: 7px 10px;
  }
  .bottom {
    bottom: max(15px, env(safe-area-inset-bottom));
    gap: 10px;
    width: calc(100% - 24px);
  }
  .toolbar {
    width: 100%;
    justify-content: space-between;
    gap: 0;
    padding: 6px;
    border-radius: 16px;
  }
  .toolbar button {
    padding: 9px 8px;
    font-size: 10px;
    min-width: 42px;
  }
  .toolbar .primary {
    padding-inline: 10px;
  }
  .icon {
    display: block;
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
  }
  .sep {
    margin: 0 2px;
  }
  .hint {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .corner {
    display: none;
  }
  #focusBar {
    top: auto;
    bottom: 115px;
    left: 12px;
    right: 12px;
    transform: none;
    width: auto;
    padding: 12px 15px;
  }
  #focusBar .label {
    font-size: 9px;
  }
  #focusCaption {
    font-size: 16px;
    margin: 4px 0;
  }
  #focusBar .row {
    display: inline-flex;
    margin: 5px 3px 0 0;
  }
  #focusBar .row button {
    min-height: 38px;
    padding: 7px 12px;
  }
  #back {
    width: auto;
    float: right;
    margin-top: 5px;
    min-height: 38px;
    padding: 7px 10px;
  }
  #gallery {
    top: 130px;
    right: 12px;
    width: calc(100% - 24px);
    max-height: calc(100dvh - 250px);
  }
  #thumbs {
    grid-template-columns: repeat(4, 1fr);
  }
  #thumbs button {
    max-height: 110px;
  }
  #thumbs img {
    height: 65px;
    aspect-ratio: auto;
    object-fit: cover;
  }
  body.focusing header {
    opacity: 0;
  }
  #fallback {
    inset: 165px 12px 130px;
  }
  dialog {
    padding: 20px;
  }
  #cropCanvas {
    max-height: 42dvh;
    object-fit: contain;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.live-tag {
  font: 9px sans-serif;
  letter-spacing: 1.5px;
  color: var(--gold);
}
#liveControls {
  margin-top: 12px;
}
#liveControls button {
  width: 100%;
  margin-top: 6px;
}
#message {
  position: fixed;
  bottom: 115px;
  left: 5%;
  max-width: 240px;
  font:
    italic 15px Georgia,
    serif;
  color: var(--muted);
  pointer-events: none;
}
#liveStatus {
  font-size: 11px;
  color: var(--muted);
  margin-top: 7px;
}
#sound[aria-pressed="true"] {
  background: var(--button);
  color: white;
}
#fallback {
  z-index: 1;
}
body.focusing #message {
  display: none;
}
.live-thumb {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 4px;
  background: #23392acc;
  color: #fff;
  font-size: 8px;
  border-radius: 3px;
}
.toolbar button {
  min-width: 48px;
}
@media (max-width: 700px) {
  #message {
    display: none;
  }
  #liveControls {
    display: flex;
    gap: 5px;
    margin: 4px 0;
  }
  #liveControls button {
    width: auto;
    font-size: 11px;
    margin: 0;
    padding: 8px 12px;
  }
  #liveStatus {
    font-size: 10px;
    margin: 3px 0;
  }
  #focusBar {
    bottom: 112px;
  }
  #focusBar .row {
    margin: 3px 0;
  }
  #focusCaption {
    margin: 2px 0;
    font-size: 14px;
    max-height: 65px;
    overflow: auto;
  }
}
