/* ─── Design Tokens ─────────────────────────────── */
:root {
  color-scheme: light;

  --cream:        #fffbf4;
  --warm-white:   #fffef9;
  --card:         #ffffff;
  --espresso:     #291608;
  --ink:          #3a1f0d;
  --amber:        #b5701a;
  --amber-light:  #d4924a;
  --gold:         #e8a83e;
  --terra:        #b94430;
  --sand:         #f0dfc8;
  --sand-soft:    #f8f0e3;
  --sand-pale:    #fdf6ea;
  --stone:        #8c7260;
  --border:       #e8d4b8;

  --r-sm:   10px;
  --r-md:   18px;
  --r-lg:   28px;
  --r-pill: 9999px;

  --sh-sm:   0 2px 8px rgba(41,22,8,.07);
  --sh-md:   0 8px 28px rgba(41,22,8,.11), 0 2px 8px rgba(41,22,8,.05);
  --sh-lg:   0 24px 72px rgba(41,22,8,.15), 0 6px 18px rgba(41,22,8,.07);
  --sh-warm: 0 24px 72px rgba(181,112,26,.20), 0 6px 18px rgba(181,112,26,.10);
}

/* ─── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input { font: inherit; }
h1, h2, h3, p { letter-spacing: 0; }

/* ─── Base ───────────────────────────────────────── */
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse 90% 55% at 15% -5%,  rgba(181,112,26,.13) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 85% 105%, rgba(185,68,48,.09) 0%, transparent 50%),
    var(--cream);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system,
    "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ─── App shell ──────────────────────────────────── */
.app-shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 36px 32px;
}

/* ─── Upload page grid ───────────────────────────── */
.upload-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}

/* ─── Cards ──────────────────────────────────────── */
.hero-panel,
.stage-panel,
.result-panel,
.login-panel,
.admin-card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  border: none;
  overflow: hidden;
}

/* ─── Hero panel ─────────────────────────────────── */
.hero-panel {
  position: relative;
  padding: 36px 32px 32px;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--espresso), var(--amber), var(--gold), var(--terra));
}

/* Decorative warm blob inside hero */
.hero-panel::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(232,168,62,.18) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 24px;
}

.brand-row {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--espresso);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-mark {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(181,112,26,.22));
}

.kicker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 24px 0 12px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: rgba(181,112,26,.1);
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-topline .kicker {
  margin: 0;
  flex: 0 0 auto;
}

.kicker::before {
  content: "✦";
  font-size: 10px;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 0 0 28px;
  font-size: 52px;
  font-weight: 900;
  line-height: 1.06;
  color: var(--espresso);
  word-break: keep-all;
  letter-spacing: -0.02em;
}

.hero-panel h1 {
  max-width: 7.5em;
}

/* ─── Form ───────────────────────────────────────── */
.upload-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--stone);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.field input,
.url-row input {
  width: 100%;
  min-height: 50px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 16px;
  background: var(--sand-pale);
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

.field input:focus,
.url-row input:focus {
  border-color: var(--amber);
  background: var(--warm-white);
  box-shadow: 0 0 0 4px rgba(181,112,26,.12);
}

.field input::placeholder { color: rgba(140,114,96,.6); }

/* ─── Photo drop ─────────────────────────────────── */
.photo-drop {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 2px dashed rgba(181,112,26,.38);
  border-radius: var(--r-md);
  background: linear-gradient(145deg, var(--sand-pale), rgba(248,240,227,.9));
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.photo-drop:hover {
  border-color: var(--amber);
  background: linear-gradient(145deg, #fef5e4, #fdf0d8);
  box-shadow: var(--sh-warm);
}

.photo-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-placeholder {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
}

.photo-placeholder img {
  width: 72px;
  height: 72px;
  opacity: .85;
  filter: drop-shadow(0 8px 14px rgba(181,112,26,.22));
}

.photo-placeholder strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
  color: var(--espresso);
}

.photo-placeholder small {
  font-size: 13px;
  color: var(--stone);
}

#preview {
  width: 100%;
  height: 280px;
  display: block;
  object-fit: cover;
}

/* ─── Consent row ────────────────────────────────── */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--stone);
  font-size: 13px;
  line-height: 1.6;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--amber);
  flex-shrink: 0;
}

.privacy-consent-block {
  display: grid;
  gap: 10px;
}

.privacy-detail-button {
  appearance: none;
  border: 0;
  padding: 0;
  color: var(--amber);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.privacy-detail-panel {
  margin-left: 28px;
  padding: 14px 16px;
  border: 1.5px solid rgba(232,212,184,.9);
  border-radius: var(--r-md);
  background: linear-gradient(145deg, rgba(255,251,244,.98), rgba(248,240,227,.92));
  color: var(--stone);
  box-shadow: var(--sh-sm);
  font-size: 12px;
  line-height: 1.65;
}

.privacy-detail-panel strong {
  display: block;
  margin-bottom: 8px;
  color: var(--espresso);
  font-size: 13px;
}

.privacy-detail-panel p {
  margin: 0 0 8px;
}

.privacy-detail-panel dl {
  display: grid;
  gap: 7px;
  margin: 0 0 8px;
}

.privacy-detail-panel dl div {
  display: grid;
  gap: 2px;
}

.privacy-detail-panel dt {
  color: var(--espresso);
  font-weight: 900;
}

.privacy-detail-panel dd {
  margin: 0;
}

.privacy-detail-panel .privacy-safe-note {
  margin: 0;
  color: var(--amber);
  font-weight: 800;
}

/* ─── Buttons ────────────────────────────────────── */
.primary-button,
.secondary-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-weight: 900;
  font-size: 15px;
  text-decoration: none;
  transition: filter .18s, transform .18s, box-shadow .18s;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--espresso) 0%, var(--amber) 55%, var(--terra) 100%);
  box-shadow: 0 12px 32px rgba(181,112,26,.34);
  letter-spacing: 0.01em;
}

.primary-button:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(181,112,26,.40);
}

.primary-button:disabled {
  opacity: .6;
  cursor: wait;
  transform: none;
}

.secondary-button {
  padding: 0 22px;
  color: var(--espresso);
  background: var(--sand-pale);
  border: 1.5px solid var(--border);
  font-size: 14px;
}

.secondary-button:hover {
  color: #fff;
  background: var(--amber);
  border-color: var(--amber);
}

.secondary-button.compact {
  min-height: 40px;
  padding: 0 16px;
  font-size: 13px;
}

/* ─── Stage / result panel ───────────────────────── */
.stage-panel,
.result-panel {
  min-height: 560px;
}

.stage-panel {
  display: grid;
  place-items: center;
  padding: 36px;
  background: linear-gradient(145deg, var(--warm-white), var(--sand-pale));
  position: relative;
  overflow: hidden;
}

/* Decorative circles behind postcard */
.stage-panel::before {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,168,62,.12) 0%, transparent 65%);
}

.stage-panel::after {
  content: "";
  position: absolute;
  left: -60px;
  top: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(181,112,26,.08) 0%, transparent 65%);
}

/* ─── Postcard preview ───────────────────────────── */
.postcard-preview {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  min-height: 400px;
  border-radius: var(--r-lg);
  background: var(--warm-white);
  box-shadow: var(--sh-md), inset 0 0 0 1px rgba(232,212,184,.6);
}

.stamp-box {
  position: absolute;
  right: 24px;
  top: 24px;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(185,68,48,.6);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #fff9f2, #fff3e4);
}

.stamp-box img {
  width: 70px;
  height: 70px;
}

.postcard-lines {
  position: absolute;
  left: 28px;
  right: 148px;
  top: 56px;
  display: grid;
  gap: 16px;
}

.postcard-lines span {
  height: 8px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--sand), rgba(232,168,62,.2));
}

.postcard-lines span:nth-child(1) { width: 100%; }
.postcard-lines span:nth-child(2) { width: 80%; }
.postcard-lines span:nth-child(3) { width: 60%; }

.mood-tags {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mood-tags span {
  min-height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--amber);
  background: var(--sand-pale);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 900;
}

/* ─── Result panel ───────────────────────────────── */
.result-panel {
  position: relative;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.result-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--espresso), var(--amber), var(--gold), var(--terra));
  z-index: 1;
}

.result-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 28px 0;
  color: var(--amber);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-top img {
  width: 30px;
  height: 30px;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(160px, .82fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
  flex: 1;
  padding: 16px 28px 28px;
}

.result-photo-card {
  position: relative;
  min-height: 300px;
  margin: 0;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--sand);
  box-shadow: var(--sh-md);
}

.result-photo-card img {
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: block;
  object-fit: cover;
}

.result-photo-card figcaption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  color: var(--terra);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.result-copy {
  display: grid;
  align-content: center;
  gap: 14px;
}

.result-copy h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--espresso);
  word-break: keep-all;
  letter-spacing: -0.01em;
}

.result-copy p {
  margin: 0;
  color: var(--stone);
  font-size: 15px;
  line-height: 1.78;
}

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

.score-card {
  --score-tone: var(--amber);
  min-width: 0;
  padding: 11px 12px;
  border: 1.5px solid rgba(232,212,184,.85);
  border-radius: var(--r-md);
  background: linear-gradient(145deg, rgba(255,251,244,.96), rgba(248,240,227,.82));
  box-shadow: 0 8px 20px rgba(41,22,8,.07);
}

.score-card[data-score-key="happiness"] { --score-tone: #d4924a; }
.score-card[data-score-key="health"] { --score-tone: #2f7f7a; }
.score-card[data-score-key="excitement"] { --score-tone: #b94430; }
.score-card[data-score-key="satisfaction"] { --score-tone: #7b8731; }

.score-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.score-label {
  color: var(--stone);
  font-size: 12px;
  font-weight: 900;
}

.score-value {
  color: var(--espresso);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.score-value::after {
  content: "점";
  margin-left: 2px;
  color: var(--stone);
  font-size: 11px;
  font-weight: 800;
}

.score-track {
  height: 8px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: rgba(232,212,184,.72);
}

.score-fill {
  display: block;
  width: var(--score, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--score-tone);
}

.care-tip {
  color: var(--amber) !important;
  font-weight: 800;
}

.cue-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cue-list li {
  padding: 7px 12px;
  border-radius: var(--r-pill);
  color: #5a3210;
  background: #ffebd0;
  font-size: 13px;
  font-weight: 800;
}

.result-email { font-size: 13px !important; }

.result-panel .secondary-button {
  margin: 0 28px 28px;
  align-self: flex-start;
}

/* ─── Toast ──────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  max-width: min(520px, calc(100vw - 32px));
  padding: 14px 20px;
  border-radius: var(--r-pill);
  transform: translateX(-50%);
  color: #fff;
  background: rgba(41,22,8,.93);
  backdrop-filter: blur(12px);
  box-shadow: var(--sh-lg);
  font-size: 14px;
  font-weight: 700;
}

/* ─── QR body background ─────────────────────────── */
.qr-body {
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%,  rgba(181,112,26,.16) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(185,68,48,.10) 0%, transparent 50%),
    #fff8f0;
}

/* ─── QR screen (legacy, non-live) ──────────────── */
.qr-screen {
  min-height: 100vh;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 40px;
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(360px, .82fr);
  gap: 36px;
  align-items: center;
}

.qr-copy h1 {
  margin-top: 20px;
  font-size: 68px;
  max-width: 8em;
  letter-spacing: -0.02em;
}

.qr-copy p {
  margin: 0;
  color: var(--terra);
  font-size: 28px;
  font-weight: 900;
}

.qr-box {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--sh-lg);
}

.qr-box img {
  width: 86%;
  height: 86%;
  object-fit: contain;
}

.qr-url {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px 20px;
  border-radius: var(--r-md);
  color: var(--espresso);
  background: rgba(255,255,255,.85);
  border: 1.5px solid var(--border);
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
  font-size: 14px;
}

/* ─── Admin shell ────────────────────────────────── */
.admin-shell {
  min-height: 100vh;
}

.login-panel {
  max-width: 420px;
  margin: 12vh auto;
  padding: 36px;
}

.login-panel h1,
.admin-header h1 {
  margin-top: 12px;
  letter-spacing: -0.02em;
}

.admin-app { display: grid; gap: 24px; }

.admin-header,
.panel-top,
.toolbar,
.url-row {
  display: flex;
  align-items: center;
}

.admin-header,
.panel-top {
  justify-content: space-between;
  gap: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.admin-card {
  position: relative;
  padding: 24px;
  background: var(--warm-white);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  border: none;
}

.admin-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, var(--espresso), var(--amber), var(--gold), var(--terra));
}

.qr-frame {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--sh-md);
  border: 1.5px solid var(--border);
}

.qr-frame img {
  width: 90%;
  height: 90%;
  object-fit: contain;
}

.url-row {
  gap: 8px;
  margin-top: 16px;
}

.display-option { margin-top: 16px; }
.display-option input { max-width: 180px; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  color: var(--amber);
  font-weight: 900;
  font-size: 14px;
  text-decoration: none;
}

.text-link:hover { color: var(--espresso); }

.panel-top h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.02em;
  color: var(--espresso);
}

.toolbar { gap: 8px; flex-wrap: wrap; }

.submission-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.submission-item {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--warm-white);
  border: 1.5px solid var(--border);
  transition: box-shadow .18s, border-color .18s;
}

.submission-item:hover {
  box-shadow: var(--sh-md);
  border-color: var(--amber-light);
}

.submission-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--sand);
}

.submission-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 900;
  color: var(--espresso);
}

.submission-meta,
.submission-message {
  margin: 0;
  color: var(--stone);
  font-size: 13px;
  line-height: 1.5;
}

.submission-message { margin-top: 6px; }

.empty-state {
  padding: 32px;
  border-radius: var(--r-md);
  background: var(--sand-pale);
  color: var(--stone);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

/* ─── Live QR screen ─────────────────────────────── */
body.qr-body { overflow: hidden; }

.live-qr-screen {
  width: 100%;
  min-height: 100vh;
  padding: 32px;
  grid-template-columns: minmax(340px, .76fr) minmax(0, 1.24fr);
  gap: 24px;
  align-items: stretch;
}

.qr-anchor-panel,
.floating-results-panel {
  min-height: calc(100vh - 64px);
  border-radius: var(--r-lg);
  border: none;
  box-shadow: var(--sh-lg);
  overflow: hidden;
}

/* Anchor panel — warm dark */
.qr-anchor-panel {
  position: sticky;
  top: 32px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 16px;
  padding: 32px;
  background: linear-gradient(160deg, var(--espresso) 0%, #4a2210 100%);
  color: rgba(255,255,255,.9);
}

.qr-anchor-panel .brand-row {
  color: rgba(255,255,255,.7);
}

.qr-anchor-panel .kicker {
  background: rgba(232,168,62,.18);
  color: var(--gold);
}

.qr-anchor-panel .qr-copy h1 {
  max-width: 7.5em;
  margin: 4px 0 0;
  font-size: 64px;
  color: #fff;
}

.qr-anchor-panel .qr-copy p {
  margin: 0;
  color: var(--gold);
  font-size: 15px;
  font-weight: 900;
}

.qr-anchor-panel .qr-box {
  align-self: center;
  width: min(100%, 480px);
  margin: 0 auto;
  background: rgba(255,255,255,.97);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 6px rgba(232,168,62,.22), var(--sh-lg);
}

.qr-anchor-panel .qr-url {
  grid-column: auto;
  margin: 0;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.8);
  border-color: rgba(255,255,255,.18);
  font-size: 13px;
  border-radius: var(--r-md);
}

/* Results panel */
.floating-results-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    radial-gradient(ellipse 70% 50% at 80% 20%, rgba(232,168,62,.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 20% 80%, rgba(185,68,48,.10) 0%, transparent 50%),
    var(--warm-white);
}

.floating-stage-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 28px 0;
}

.floating-stage-top .kicker { margin: 0; }

.floating-stage-top span {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  color: var(--amber);
  background: var(--sand-pale);
  border: 1.5px solid var(--border);
  font-size: 12px;
  font-weight: 900;
}

.floating-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.floating-stage::before {
  content: "";
  position: absolute;
  inset: 24px;
  border: 1.5px dashed rgba(181,112,26,.2);
  border-radius: var(--r-lg);
  pointer-events: none;
}

.empty-live-results {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--stone);
  text-align: center;
}

.empty-live-results img {
  width: 110px;
  height: 110px;
  opacity: .6;
  filter: drop-shadow(0 10px 0 rgba(181,112,26,.12));
}

.empty-live-results p {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
}

/* ─── Floating result cards ──────────────────────── */
.floating-result-card {
  --card-x: 0px;
  --card-y: 0px;
  --card-r: 0deg;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: 280px;
  min-height: 210px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 16px 16px 14px;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: 0 24px 56px rgba(41,22,8,.16), 0 4px 14px rgba(41,22,8,.08);
  transform-origin: center;
  transform: translate3d(var(--card-x), var(--card-y), 0) rotate(var(--card-r));
  will-change: transform;
  animation: liveCardFadeIn 0.45s ease-out both;
  overflow: hidden;
}

.floating-result-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--espresso), var(--amber), var(--gold), var(--terra));
}

.floating-result-card h2,
.floating-result-card p { margin: 0; }

.floating-card-photo {
  margin: 0;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--sand);
  aspect-ratio: 16 / 9;
}

.floating-card-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.floating-card-mood {
  color: var(--terra);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.floating-result-card h2 {
  color: var(--espresso);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
  word-break: keep-all;
  letter-spacing: -0.01em;
}

.floating-card-message {
  color: var(--stone);
  font-size: 13px;
  line-height: 1.6;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

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

.floating-card-scores span {
  min-width: 0;
  padding: 5px 7px;
  border-radius: var(--r-pill);
  color: var(--espresso);
  background: var(--sand-pale);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.floating-card-footer {
  justify-self: start;
  margin-top: 2px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  color: var(--espresso);
  background: var(--sand-pale);
  font-size: 12px;
  font-weight: 900;
}

.floating-result-card.is-leaving {
  pointer-events: none;
  animation: liveCardOut .5s ease-in forwards;
}

/* ─── Character images ───────────────────────────── */

.welcome-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.welcome-dog {
  width: min(260px, 76%);
  height: auto;
  filter: drop-shadow(0 24px 40px rgba(41,22,8,.18));
  animation: floatDog 3.5s ease-in-out infinite;
}

.welcome-text { text-align: center; }

.welcome-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--espresso);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.welcome-sub {
  font-size: 14px;
  color: var(--stone);
  line-height: 1.7;
  margin: 0;
}

.welcome-badge {
  position: absolute;
  left: 28px;
  bottom: 26px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 9999px;
  background: rgba(41,22,8,.86);
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,.92);
  font-size: 13px;
  font-weight: 800;
  z-index: 3;
  pointer-events: none;
}

.welcome-badge span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

.welcome-peek {
  position: absolute;
  right: -52px;
  bottom: 28px;
  width: 175px;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(-8px 14px 28px rgba(41,22,8,.16));
}

@keyframes floatDog {
  0%, 100% { transform: translateY(0)    rotate(0deg); }
  50%       { transform: translateY(-9px) rotate(1deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.8); }
}

.photo-placeholder .char-img {
  width: 110px;
  height: auto;
  filter: drop-shadow(0 10px 20px rgba(41,22,8,.14));
}

.qr-char {
  display: block;
  width: min(130px, 45%);
  height: auto;
  margin: 0 auto;
  filter: brightness(1.12) drop-shadow(0 8px 20px rgba(0,0,0,.32));
  flex-shrink: 0;
}

.empty-live-results .char-img {
  width: 190px;
  height: auto;
  opacity: 1;
  filter: drop-shadow(0 14px 0 rgba(181,112,26,.14));
  animation: floatDog 3.5s ease-in-out infinite;
}

.login-char {
  display: block;
  width: min(180px, 65%);
  height: auto;
  margin: 0 auto 4px;
  filter: drop-shadow(0 12px 28px rgba(41,22,8,.13));
}

/* ─── Animations ─────────────────────────────────── */
@keyframes liveCardFadeIn {
  from { opacity: 0; filter: blur(2px); }
  to { opacity: 1; filter: blur(0); }
}

@keyframes liveCardOut {
  to { opacity: 0; filter: blur(2px); }
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 980px) {
  .result-grid { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .app-shell { padding: 20px; }

  .upload-shell,
  .admin-grid,
  .qr-screen {
    grid-template-columns: 1fr;
  }

  .upload-shell { align-items: start; }

  .stage-panel,
  .result-panel { min-height: auto; }

  .qr-screen { padding: 24px; }
  .qr-copy h1 { font-size: 48px; }
  .qr-anchor-panel .qr-copy h1 { font-size: 52px; }
  .floating-result-card h2 { font-size: 20px; }

  h1 { font-size: 44px; }
}

@media (max-width: 540px) {
  .app-shell { padding: 16px; }

  .hero-panel,
  .stage-panel,
  .result-panel,
  .login-panel,
  .admin-card {
    border-radius: var(--r-md);
    padding: 20px;
  }

  h1 { font-size: 36px; }
  .hero-panel h1 { max-width: 6.5em; }

  .hero-topline {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
  }

  .photo-drop,
  .photo-placeholder { min-height: 190px; }

  .photo-placeholder img { width: 60px; height: 60px; }
  #preview { height: 230px; }

  .postcard-preview { min-height: 300px; }

  .stamp-box {
    right: 16px;
    top: 16px;
    width: 76px;
    height: 76px;
  }
  .stamp-box img { width: 56px; height: 56px; }

  .postcard-lines {
    left: 18px;
    right: 112px;
    top: 44px;
  }

  .mood-tags { grid-template-columns: 1fr; }
  .result-copy h2 { font-size: 26px; }

  .result-photo-card,
  .result-photo-card img { min-height: 240px; }

  .result-grid { padding: 14px 20px 20px; }
  .result-panel .secondary-button { margin: 0 20px 20px; }
  .result-top { padding: 20px 20px 0; }

  #welcome-panel.stage-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 28px 22px 24px;
  }

  .welcome-body {
    width: 100%;
    gap: 16px;
  }

  .welcome-dog {
    width: min(220px, 64%);
    max-height: 300px;
    object-fit: contain;
  }

  .welcome-title {
    font-size: 22px;
    line-height: 1.25;
  }

  .welcome-sub {
    max-width: 17em;
    margin: 0 auto;
    font-size: 14px;
    line-height: 1.6;
  }

  .welcome-badge {
    position: static;
    margin-top: 18px;
    max-width: 100%;
    justify-content: center;
    align-self: center;
  }

  .welcome-peek {
    display: none;
  }

  .qr-copy h1 { font-size: 38px; }
  .qr-copy p { font-size: 20px; }

  .admin-header,
  .panel-top { align-items: flex-start; }

  .submission-item { grid-template-columns: 68px minmax(0, 1fr); }
  .submission-item img { width: 68px; height: 68px; }
}

@media (max-width: 880px) {
  body.qr-body { overflow: auto; }

  .live-qr-screen {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .qr-anchor-panel,
  .floating-results-panel {
    min-height: auto;
  }

  .qr-anchor-panel {
    position: relative;
    top: auto;
  }

  .floating-stage { min-height: 520px; }
}

@media (max-width: 540px) {
  .live-qr-screen { padding: 12px; }

  .qr-anchor-panel {
    border-radius: var(--r-md);
    padding: 20px;
  }

  .qr-anchor-panel .qr-copy h1 { font-size: 38px; }

  .floating-stage-top {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 18px 0;
  }

  .floating-result-card {
    width: min(74vw, 270px);
    border-radius: var(--r-md);
  }

  .floating-result-card h2 { font-size: 18px; }
}
