:root {
  --paper: #f7efe6;
  --cream: #fffaf4;
  --ink: #1c1410;
  --muted: #6b5348;
  --spark: #b76e79;
  --sage: #5e8f6a;
  --ab: #6b8cff;
  --fd: #c9a227;
  --shadow: 28, 20, 16;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #e8d8c8; }
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--ink);
  background: #e8d8c8;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-t)) 16px calc(28px + var(--safe-b));
}
.bar { min-height: 44px; display: flex; align-items: center; }
.brand {
  margin: 0;
  font-style: italic;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.03em;
}
#view { display: flex; flex-direction: column; gap: 16px; }
button { -webkit-tap-highlight-color: transparent; appearance: none; border: 0; font: inherit; cursor: pointer; }
.card {
  background: rgba(255, 250, 244, 0.78);
  border-radius: 22px;
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 10px 24px rgba(var(--shadow), .08);
}
.hint { margin: 0; color: var(--muted); font-size: 15px; }
.upload {
  display: grid;
  place-items: center;
  min-height: 168px;
  border-radius: 18px;
  background: rgba(255,250,244,.55);
  box-shadow: inset 0 0 0 1.5px rgba(28,20,16,.08);
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 20px;
}
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload.has img { width: 100%; height: 168px; object-fit: cover; display: block; }
.upload p { margin: 0; font-style: italic; font-size: 20px; }
.sizes { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.size {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,250,244,.7);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.size.on { background: var(--ink); color: #fffaf4; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row label { font-size: 15px; color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--spark); }
.toggle { display: flex; gap: 8px; }
.toggle button {
  flex: 1;
  min-height: 44px;
  border-radius: 999px;
  background: rgba(255,250,244,.7);
  font-weight: 600;
}
.toggle button.on { background: var(--ink); color: #fffaf4; }
.go, .ghost, .sheet-btn {
  min-height: 52px;
  border-radius: 999px;
  width: 100%;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.go, .sheet-btn { background: var(--spark); color: #fff; }
.ghost { background: rgba(255,250,244,.7); }
.meta { margin: 0; font-size: 14px; color: var(--muted); }
#preview-wrap {
  border-radius: 16px;
  overflow: hidden;
  background: #1c1410;
  box-shadow: 0 12px 28px rgba(var(--shadow), .16);
}
#preview {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.legend { display: flex; flex-direction: column; gap: 8px; }
.swatch {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: rgba(255,250,244,.7);
  border-radius: 14px;
  padding: 8px 10px;
  width: 100%;
}
.swatch i {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: block;
  box-shadow: inset 0 0 0 1px rgba(28,20,16,.08);
}
.swatch b { display: block; font-size: 15px; }
.swatch small { color: var(--muted); font-size: 12px; }
.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(28,20,16,.08);
}
.tag.ab { background: #dfe6ff; color: #2a3d9c; }
.tag.fd { background: #f3e4a8; color: #6a5208; }
.list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.list li { display: flex; justify-content: space-between; gap: 8px; }
.foot { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

.modal-back {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(28,20,16,.36);
  display: flex; align-items: flex-start; justify-content: center;
  padding: calc(14px + var(--safe-t)) 16px 8px;
  opacity: 0; transition: opacity .3s var(--ease);
}
.modal-back.in { opacity: 1; }
.who {
  width: min(392px, 100%);
  background: rgba(255,250,244,.86);
  backdrop-filter: blur(18px);
  border-radius: 28px;
  padding: 24px 22px 22px;
  display: grid; gap: 12px;
}
.who h2 { margin: 0; font-style: italic; font-size: 32px; text-align: center; }
input[type="password"] {
  width: 100%; border: 0; border-radius: 16px;
  padding: 15px 16px; font-size: 16px;
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 0 0 1.5px rgba(28,20,16,.08);
}
input[type="password"]:focus { outline: none; box-shadow: inset 0 0 0 1.5px rgba(183,110,121,.5); }
.shake { animation: shake .42s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.busy { opacity: .6; pointer-events: none; }
