:root {
  --paper: #fbf5e9;
  --paper-edge: #e6d6b8;
  --ink: #3b2a1e;
  --ink-soft: #7a6450;
  --red: #a8322a;
  --gold: #d6a23c;
  --green: #2f6b4c;
  --shadow: 0 6px 24px rgba(10, 8, 30, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1030; color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; }
#app canvas { display: block; touch-action: none; }

.card { background: var(--paper); border: 1px dashed var(--paper-edge); border-radius: 10px;
  box-shadow: var(--shadow); outline: 4px solid rgba(251,245,233,.55); outline-offset: -1px; }

#title { position: fixed; top: max(16px, env(safe-area-inset-top)); left: 16px; padding: 10px 14px; max-width: calc(100% - 32px); }
#title .kicker { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; }
#title h1 { font-family: "Fraunces", Georgia, serif; font-size: 22px; margin: 2px 0 2px; line-height: 1.15; }
#status { font-family: "Fraunces", Georgia, serif; font-style: italic; font-size: 14px; color: var(--red); }

.bar { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
#bar-left { left: 16px; }
#bar-right { right: 16px; }
.btn { font: 700 14px "Nunito", system-ui, sans-serif; color: var(--ink); background: var(--paper);
  border: 1px dashed var(--paper-edge); border-radius: 10px; padding: 10px 14px; min-height: 44px;
  box-shadow: var(--shadow); cursor: pointer; }
.btn:hover { background: #fff9ee; }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#zoom { position: fixed; right: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 60px); display: flex; flex-direction: column; gap: 6px; }
#zoom .btn { width: 44px; height: 44px; padding: 0; font-size: 20px; line-height: 1; }
#toast { position: fixed; left: 50%; top: 96px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s; padding: 10px 16px; max-width: calc(100% - 32px); text-align: center;
  font-family: "Fraunces", Georgia, serif; font-size: 15px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#hint { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); color: #fff; opacity: .85;
  font-size: 13px; text-shadow: 0 1px 4px rgba(0,0,0,.6); transition: opacity 1s; text-align: center;
  width: calc(100% - 32px); pointer-events: none; }

.overlay { position: fixed; inset: 0; background: rgba(8, 10, 30, .45); display: flex; align-items: center;
  justify-content: center; padding: 16px; z-index: 10; }
.overlay[hidden] { display: none; }
.sheet { width: 100%; max-width: 460px; max-height: calc(100% - 32px); overflow: auto; padding: 22px 22px 20px; position: relative; }
.sheet h2 { font-family: "Fraunces", Georgia, serif; margin: 0 0 6px; font-size: 24px; line-height: 1.2; }
.sheet p { line-height: 1.55; margin: 0 0 10px; font-size: 16px; }
.close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; background: transparent;
  font-size: 20px; cursor: pointer; color: var(--ink-soft); border-radius: 8px; }
.close:hover { background: rgba(0,0,0,.05); }
.daynum { font-family: "Fraunces", Georgia, serif; font-size: 54px; line-height: 1; color: var(--red); font-weight: 700; }
.foot { margin-top: 12px; font-size: 13px; color: var(--ink-soft); font-style: italic; font-family: "Fraunces", Georgia, serif; }

.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 12px; }
.grid button { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--paper-edge); background: #fff;
  font: 700 17px "Fraunces", Georgia, serif; color: var(--ink); cursor: pointer; min-height: 40px; }
.grid button.locked { color: #b8a993; background: #f4ecdc; }
.grid button.today { background: var(--gold); color: #fff; border-color: var(--gold); }
.grid button.opened { background: var(--green); color: #fff; border-color: var(--green); }
.legend { font-size: 13px; color: var(--ink-soft); margin-top: 10px; }

.secret-list { list-style: none; padding: 0; margin: 12px 0 0; }
.secret-list li { padding: 10px 0; border-top: 1px dashed var(--paper-edge); }
.secret-list li strong { font-family: "Fraunces", Georgia, serif; font-size: 16px; }
.secret-list li.hidden-secret { color: var(--ink-soft); font-style: italic; }
.secret-list li span { display: block; font-size: 14px; line-height: 1.45; margin-top: 2px; }

.btn-media { display: block; width: 100%; margin-top: 6px; font: 700 16px "Fraunces", Georgia, serif; color: #fff;
  background: var(--red); border: 2px dashed rgba(255,255,255,.6); outline: 3px solid var(--red); border-radius: 10px;
  padding: 12px 14px; min-height: 48px; cursor: pointer; }
.btn-media:hover { filter: brightness(1.08); }
.btn-media:focus-visible { outline-color: var(--gold); }
#ov-media { background: rgba(5, 6, 18, .88); z-index: 15; }
#ov-media .close { color: #fff; position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; background: rgba(255,255,255,.12); }
.media-box { width: 100%; max-width: 960px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.media-stage { position: relative; width: 100%; display: flex; align-items: center; justify-content: center; }
.media-stage img, .media-stage video { max-width: 100%; max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); border-radius: 8px; display: block; background: #000; }
.media-stage iframe { width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); border: 0; border-radius: 8px; background: #000; }
.media-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(251,245,233,.9); color: var(--ink); font-size: 22px; cursor: pointer; box-shadow: var(--shadow); }
.media-nav.prev { left: 8px; } .media-nav.next { right: 8px; }
.media-nav[hidden] { display: none; }
.media-cap { color: #f3ead8; font-family: "Fraunces", Georgia, serif; font-size: 15px; text-align: center; min-height: 1.4em; }
.media-dots { display: flex; gap: 6px; }
.media-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.3); }
.media-dots span.on { background: var(--gold); }

#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff;
  font-family: "Fraunces", Georgia, serif; font-size: 20px; background: #0b1030; transition: opacity .8s; z-index: 20; text-align: center; padding: 16px; }

@media (max-width: 520px) {
  #title h1 { font-size: 18px; }
  #title { padding: 8px 12px; }
  .btn { padding: 8px 10px; font-size: 13px; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  #hint { bottom: 76px; font-size: 12px; }
}
@media (max-width: 400px) { .lbl { display: none; } }

/* Länk ut (t.ex. fotoalbum) i en lucka */
.btn-lank { display: block; width: 100%; margin-top: 8px; font: 700 15px "Nunito", system-ui, sans-serif; color: var(--ink);
  background: #fff; border: 2px dashed var(--paper-edge); border-radius: 10px; padding: 11px 14px; min-height: 46px;
  cursor: pointer; text-align: center; text-decoration: none; }
.btn-lank:hover { background: #fff9ee; }
.btn-lank:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Hälsning och namnruta */
#hej { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
#hej button { font: inherit; color: var(--ink-soft); background: none; border: 0; padding: 0; text-decoration: underline dotted; cursor: pointer; }
#hej[hidden] { display: none; }
.namn-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.namn-form input { font: 500 17px "Nunito", system-ui, sans-serif; padding: 11px 12px; border: 1px solid var(--paper-edge);
  border-radius: 8px; background: #fff; color: var(--ink); min-height: 46px; }
.namn-form input:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.namn-form .btn-media { margin-top: 0; }
.namn-info { font-size: 13px; line-height: 1.45; color: var(--ink-soft); margin-top: 12px; }
#ov-namn { z-index: 16; }

/* Dolda knappar ska vara dolda, även när klassen sätter display */
.btn-media[hidden], .btn-lank[hidden] { display: none !important; }
