:root {
  --purple: #5b57a6;
  --purple-dark: #3f3b85;
  --green: #1ab26b;
  --green-dark: #128a52;
  --ink: #231f20;
  --muted: #6b6672;
  --line: #e4e1ee;
  --bg: #f4f3f9;
  --card: #ffffff;
  --radius: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar .logo { height: 24px; width: auto; flex: none; }
.bar h1 {
  flex: 1; min-width: 0; margin: 0; font-size: 1.1rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lang {
  width: auto; margin: 0; padding: 6px 8px; border-radius: 10px; border: 1.5px solid var(--line);
  font: inherit; font-size: .85rem; font-weight: 700; background: #fff; color: var(--ink);
}
.icon-btn {
  flex: none; background: var(--bg); color: var(--ink); border: 0; width: 40px; height: 40px;
  border-radius: 50%; font-size: 1.3rem; cursor: pointer;
}
.wrap {
  max-width: 560px; margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}
.card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 1px 2px rgba(35,31,32,.06), 0 8px 24px rgba(63,59,133,.08); margin-bottom: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 1.4rem; color: var(--purple-dark); }
.card h3 { margin: 16px 0 4px; font-size: 1rem; }
label { display: block; font-weight: 600; margin: 12px 0; font-size: .95rem; }
input, textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-weight: 400;
  border: 1.5px solid #d6d2e3; border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--purple); border-color: var(--purple); }
.btn {
  display: inline-block; width: 100%; padding: 14px 18px; border: 0; border-radius: 12px;
  background: var(--purple); color: #fff; font: inherit; font-weight: 700; cursor: pointer; text-align: center;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.green { background: var(--green); }
.btn.secondary { background: #ebe9f3; color: var(--ink); }
.btn.danger { background: #fff; color: #b3261e; border: 1.5px solid #f0c9c6; }
.btn[disabled] { opacity: .6; }
.error { color: #b3261e; min-height: 1.2em; margin: 8px 0; font-weight: 600; }
.hint { background: #eef9f3; border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.small { color: var(--muted); font-size: .85rem; }

/* Lågen */
.door-scene { perspective: 1200px; margin-bottom: 16px; }
.door {
  position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 68vh; margin: 0 auto;
  border: 0; padding: 0; background: none; cursor: pointer; display: block;
}
.door-front {
  position: absolute; inset: 0; border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(160deg, var(--purple), var(--purple-dark));
  border: 4px solid var(--green); box-shadow: 0 14px 40px rgba(63,59,133,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff;
  transform-origin: left center; transition: transform .9s cubic-bezier(.3,.7,.3,1), opacity .9s;
}
.door-front .num { font-size: clamp(6rem, 35vw, 11rem); font-weight: 800; line-height: 1; text-shadow: 0 4px 0 rgba(0,0,0,.18); }
.door-front .date { margin-top: 4px; font-weight: 600; opacity: .9; }
.door-front .tap { margin-top: 18px; font-weight: 700; background: var(--green); color: #fff; padding: 8px 16px; border-radius: 999px; }
.door-front .knob { position: absolute; right: 18px; top: 50%; width: 16px; height: 16px; border-radius: 50%; background: var(--green); }
.door.open .door-front { transform: rotateY(-105deg); opacity: 0; pointer-events: none; }

.door-content { animation: fadeIn .5s ease both; }
.door-content .day-label { color: var(--green-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; margin: 0 0 4px; }
.door-content h2 { font-size: 1.6rem; }
.door-content .body { white-space: pre-wrap; line-height: 1.55; font-size: 1.05rem; }
.door-content img { display: block; width: 100%; height: auto; border-radius: 12px; margin: 12px 0; }
.door-content .btn { margin-top: 8px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.center { text-align: center; }
.big { font-size: 3.4rem; margin: 4px 0; }
.countdown { font-size: 3.2rem; font-weight: 800; color: var(--purple); margin: 4px 0; }

.messages { list-style: none; margin: 0; padding: 0; }
.messages li { border-top: 1px solid var(--line); padding: 12px 0; }
.messages li:first-child { border-top: 0; }
.messages .meta { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.messages .text { white-space: pre-wrap; }

.toggle { display: flex; align-items: center; gap: 12px; font-weight: 500; cursor: pointer; }
.toggle input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--green); }

@media (prefers-reduced-motion: reduce) {
  .door-front { transition: none; }
  .door-content { animation: none; }
}

/* Svar via Messenger */
.answer { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.answer .small { margin: 0 0 8px; }
.btn.messenger { display: flex; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(90deg, #0a7cff, #a033ff 60%, #ff5c87); }
.m-icon { width: 22px; height: 22px; flex: none; background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M12 2C6.36 2 2 6.13 2 11.7c0 2.91 1.19 5.44 3.14 7.17.16.14.26.35.27.57l.05 1.78a.8.8 0 0 0 1.12.71l1.98-.87c.17-.08.36-.09.53-.04.91.25 1.88.38 2.91.38 5.64 0 10-4.13 10-9.7S17.64 2 12 2zm6 7.46-2.94 4.66a1.5 1.5 0 0 1-2.17.4l-2.34-1.75a.6.6 0 0 0-.72 0l-3.16 2.4c-.42.32-.97-.18-.69-.63l2.94-4.66a1.5 1.5 0 0 1 2.17-.4l2.34 1.75a.6.6 0 0 0 .72 0l3.16-2.4c.42-.32.97.18.69.63z'/%3E%3C/svg%3E"); }

/* Forside */
.today-card { text-align: center; }
.today-card .day-label { color: var(--green-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; margin: 0; }
.today-num { font-size: 6rem; font-weight: 800; line-height: 1; color: var(--purple); margin: 8px 0 0; }
.today-date { margin: 4px 0 16px; color: var(--muted); font-weight: 600; }
.badge-ok { display: inline-block; margin: 0 0 14px; padding: 6px 14px; border-radius: 999px; background: #dff5ea; color: var(--green-dark); font-weight: 700; }
#toFront { margin-top: 4px; }

/* Svar i appen */
.answer-form textarea { margin: 8px 0 12px; resize: vertical; }
.answer-form .btn { margin-top: 8px; }
.answer-form label.btn { margin: 0; font-weight: 700; }
.answer-preview img, .answer-done img { display: block; width: 100%; height: auto; border-radius: 12px; margin-top: 12px; }
.answer-form .link-btn { margin-top: 8px; }
.answer-done { text-align: center; }
.answer-done .body { white-space: pre-wrap; text-align: left; background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.link-btn { border: 0; background: none; color: var(--purple); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.next-today { text-align: center; margin: 0 0 16px; }
