:root{font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color-scheme:dark;--green:#102c2b;--deep:#081b1b;--light:#f8efd9;--gold:#e9c48e;--text:#f6f1e6;--muted:#b6c6bd;--red:#aa4645}
*{box-sizing:border-box}html{background:var(--deep);scroll-behavior:smooth}body{margin:0;min-height:100dvh;color:var(--text);background:radial-gradient(ellipse 100% 60% at 50% -13%,#31554a 0%,transparent 75%),linear-gradient(170deg,#0d2726 0%,#0a1e1d 100%)}
body::before{content:"✣  ·   ✧   ·   ✦   ·   ✣   ·   ✧   ·   ✦";position:absolute;top:100px;left:0;right:0;overflow:hidden;text-align:center;letter-spacing:18px;font-size:13px;color:#e6dbb71e;pointer-events:none}.snow-glow{position:fixed;inset:0;pointer-events:none;background-image:radial-gradient(#f6e8c844 1px,transparent 1.5px),radial-gradient(#eddec31f 1px,transparent 1.5px);background-position:7px 32px,41px 60px;background-size:91px 93px,139px 173px;opacity:.45}
.page{position:relative;z-index:1;max-width:760px;margin:0 auto;padding:max(19px,env(safe-area-inset-top)) 18px max(24px,env(safe-area-inset-bottom))}.app-header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:4px 2px 23px;border-bottom:1px solid #d6b98839}.brand{display:flex;align-items:center;gap:10px}.brand-icon{width:40px;height:40px;border:1px solid #e9c48e99;color:var(--gold);border-radius:50%;display:grid;place-items:center;font-size:27px}.brand-name{display:block;font-family:Georgia,serif;font-size:19px;letter-spacing:.12em;font-weight:bold;color:#f4dab0}.brand-tagline{display:block;font-size:10px;color:#c3d0be;letter-spacing:.045em;margin-top:3px}.year-pill{font-size:10px;letter-spacing:.13em;border:1px solid #8c9e8480;border-radius:999px;padding:9px 10px;color:#dfd7b7;white-space:nowrap}
.nav-tabs{display:grid;grid-template-columns:1fr 1fr;gap:4px;background:#ffffff0a;border:1px solid #ffffff13;border-radius:13px;padding:4px;margin:20px 0 32px}.tab{background:transparent;color:#c0cfc5;border:0;padding:12px 4px;border-radius:9px;font:inherit;font-size:13px;font-weight:650;cursor:pointer}.tab.active{color:#132c27;background:#e5c691;box-shadow:0 2px 15px #050d0a44}
.eyebrow{display:block;text-transform:uppercase;letter-spacing:.18em;color:#e1c396;font-size:10px;font-weight:750;line-height:1.8}.welcome{text-align:center;max-width:500px;margin:0 auto;padding:12px 6px 30px}.welcome-ornament{margin:12px auto 26px;border:1px solid #c5a56a7b;background:radial-gradient(circle at 50% 25%,#46684e,#1b3630 72%);width:104px;height:104px;border-radius:50%;display:grid;place-items:center;font-size:49px;box-shadow:0 0 0 9px #e8c5900a,0 15px 38px #010f0f88}.welcome h1,.calendar-intro h1,.editor-intro h1{font-family:Georgia,"Times New Roman",serif;font-size:clamp(34px,7.9vw,51px);font-weight:400;line-height:1.16;letter-spacing:-.04em;margin:12px 0 17px}.welcome h1 em,.calendar-intro h1 em,.editor-intro h1 em{font-style:italic;color:#e7c58f}.welcome p,.editor-intro p,.calendar-intro p{color:#c0cbbd;line-height:1.7;font-size:14px;margin:0 auto 26px;max-width:450px}.primary,.secondary,.outline,.text-button,.subtle-danger{font-family:inherit;font-weight:750;cursor:pointer;touch-action:manipulation}.primary,.secondary{width:100%;border-radius:11px;min-height:54px;padding:13px 19px;font-size:14px;display:flex;align-items:center;justify-content:space-between;gap:15px}.primary{background:#ebc995;color:#21392f;border:1px solid #f3daac;box-shadow:0 5px 24px #00000035}.secondary{margin-top:12px;background:transparent;border:1px solid #d7be9390;color:#eacb9c}.text-button{margin-top:22px;background:transparent;border:0;color:#cdd0b5;font-size:12px;padding:9px}.outline{border:1px solid #abac9080;background:#ffffff09;border-radius:9px;color:#eee8d4;padding:12px 14px;font-size:12px}.subtle-danger{border:0;background:transparent;color:#dba6a2;font-size:12px;padding:9px 0}
.calendar-intro{text-align:center;padding:0 0 12px}.calendar-intro h1{margin-top:10px;margin-bottom:5px}.calendar-intro p.dedication{font-family:Georgia,serif;font-style:italic;font-size:16px;color:#ebccab;margin-bottom:13px}.thin-divider{display:flex;align-items:center;gap:11px;color:var(--gold);max-width:200px;margin:15px auto}.thin-divider:before,.thin-divider:after{content:"";display:block;flex:1;height:1px;background:#dfc08c75}.calendar-intro .calendar-hint{margin:9px auto 20px;font-size:12px}.calendar-switch{margin-bottom:19px;display:flex;align-items:center;gap:12px;justify-content:center}.calendar-switch label{font-size:12px;color:#d5c6a5}.calendar-switch select{max-width:65%;border:1px solid #ffffff3d;background:#173c35;color:#f8edd4;padding:10px;border-radius:8px}.door-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px}.door{aspect-ratio:.78;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:0;border:2px solid #d3aa6b;border-radius:9px;color:#ffedcf;background:linear-gradient(135deg,#6e302e,#8b3b37 45%,#592a2b);cursor:pointer;box-shadow:inset 0 0 0 3px #fff3ca14,0 6px 14px #0005;overflow:hidden;touch-action:manipulation;transition:transform .13s ease,filter .13s ease}.door:nth-child(4n+2){background:linear-gradient(135deg,#28534a,#306655,#173b36)}.door:nth-child(4n+3){background:linear-gradient(125deg,#254946,#32645d,#143a36)}.door:nth-child(4n){background:linear-gradient(135deg,#823c42,#a04a4b,#60272e)}.door::before{content:"";position:absolute;inset:5px;border:1px dashed #e5c59266;border-radius:5px;pointer-events:none}.door::after{content:"✧";position:absolute;right:8px;top:6px;font-size:12px;color:#dfc58d80}.door:active{transform:scale(.96)}.door .door-date{font-family:Georgia,serif;font-size:clamp(30px,7vw,52px);line-height:1.08;color:#f8dba5;text-shadow:0 2px 2px #0004}.door .door-month{font-size:9px;letter-spacing:.14em;margin-top:7px;text-transform:uppercase;color:#f7deb9}.door .door-state{position:absolute;bottom:7px;font-size:11px;color:#f9e8ca}.door.locked{filter:saturate(.64) brightness(.67)}.door.opened{background:linear-gradient(130deg,#e3c990,#faedcd);border-color:#f9e9c0;color:#476052}.door.opened .door-date{color:#355c4d;text-shadow:none}.door.opened .door-month,.door.opened .door-state{color:#456451}.door.opened:after{color:#5c7764}.progress-caption{text-align:center;color:#d1c0a2;font-size:12px;margin:22px 0}.view-actions{display:flex;gap:10px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin-top:20px}
.editor-intro{text-align:center;margin:5px 0 25px}.editor-intro h1{margin:9px 0}.editor-intro p{margin-bottom:0}.editor-card{border:1px solid #c2aa7d52;background:#102d2aba;border-radius:17px;padding:19px;margin:13px 0 20px;box-shadow:0 10px 30px #051a1740}.editor-card h2{font-family:Georgia,serif;color:#f8e4bc;font-size:21px;font-weight:400;display:flex;align-items:center;gap:11px;margin:0 0 22px}.step{width:30px;height:30px;border:1px solid #dfc28c;border-radius:50%;font:600 13px system-ui;display:inline-grid;place-items:center;flex:none;color:#f1d59f}.field-grid{display:grid;grid-template-columns:1fr 1fr;gap:11px}.field{display:flex;flex-direction:column;margin-bottom:14px;min-width:0}.field label{font-size:12px;color:#e3dbca;font-weight:650;margin-bottom:7px}.field input,.field select,.message-editor textarea{border:1px solid #8da6965c;border-radius:9px;background:#071d1abf;color:#fff0d8;font:inherit;font-size:14px;width:100%;padding:13px 11px;min-height:46px;outline:none}.field input:focus,.field select:focus,.message-editor textarea:focus{border-color:#efcf94;box-shadow:0 0 0 3px #e3bc8230}.field input::placeholder{color:#aab3b8}.message-editor textarea::placeholder{color:#abb4b9;font-style:italic;opacity:1}.field select{font-size:13px}.field option{background:#173b32}.year-row{grid-template-columns:.58fr 1.42fr}.field-help{color:#9eaf9f;font-size:11px;line-height:1.6;margin:0}.section-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.section-head h2{margin-bottom:11px}.filled-pill{background:#e0c48b1d;border:1px solid #ddc59e45;padding:6px 10px;border-radius:20px;color:#efdaae;font-size:11px;white-space:nowrap}.muted{color:#b7c7ba;line-height:1.65;font-size:13px}.small{font-size:12px;margin:0 0 20px}.edit-door-grid{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:6px;margin-bottom:20px}.edit-day{aspect-ratio:1;border:1px solid #a2ae9970;border-radius:7px;background:#214137;color:#e7e3ce;cursor:pointer;font-size:12px;font-weight:700;position:relative;touch-action:manipulation}.edit-day.filled::after{content:"";position:absolute;width:4px;height:4px;bottom:4px;left:calc(50% - 2px);background:#f0d198;border-radius:50%}.edit-day.selected{background:#e9c792;color:#1b332c;border-color:#f7e8bf;box-shadow:0 0 0 2px #f0cf9e47}.edit-day.selected.filled:after{background:#406150}.message-editor{background:#ffffff06;border:1px solid #ffffff19;border-radius:10px;padding:13px}.message-top{display:flex;justify-content:space-between;gap:15px;align-items:center;margin-bottom:10px}.message-top label{font-size:13px;color:#f1d9ae;font-weight:700}.message-top span{font-size:10px;color:#a4b5a8}.message-editor textarea{resize:vertical;min-height:130px;line-height:1.65}.editor-navigation{display:grid;grid-template-columns:1fr 1.25fr 1fr;gap:7px;margin-top:10px}.outline.compact{padding:10px 3px;font-size:11px}.export-card h2{margin-bottom:9px}.export-info{color:#ecc994;font-weight:750;font-size:13px;margin:14px 0}.export-card .field-help{margin-top:12px}.export-card code{color:#f4daad}
footer{text-align:center;color:#aaac8f;font-family:Georgia,serif;font-size:12px;letter-spacing:.03em;padding:40px 0 14px}footer span{padding:0 6px;color:#e4c895}
.letter-dialog{border:0;border-radius:16px;padding:0;background:transparent;color:#263b32;width:calc(100% - 36px);max-width:500px;max-height:90dvh;box-shadow:0 30px 80px #000b}.letter-dialog::backdrop{background:#031511d9;backdrop-filter:blur(7px)}.letter-shell{position:relative;max-height:90dvh;overflow-y:auto;text-align:center;padding:39px 26px 31px;background:linear-gradient(140deg,#fffcf0,#eedbbc);border:7px solid #f8ebd1;border-radius:16px;box-shadow:inset 0 0 0 1px #bb976057}.close-dialog{position:absolute;top:10px;right:12px;border:0;background:transparent;color:#63786a;font-size:30px;cursor:pointer;padding:5px 11px}.eyebrow.gold-letter{color:#927446}.letter-number{font-family:Georgia,serif;font-size:68px;color:#a0443e;margin:8px 0 -9px}.heart-divider{font-family:Georgia,serif;color:#a84e4d;font-size:27px}.letter-shell h2{font-family:Georgia,serif;font-size:24px;font-weight:400;margin:10px 0 20px}.letter-message{white-space:pre-wrap;overflow-wrap:anywhere;font-family:Georgia,serif;font-size:clamp(18px,5vw,23px);line-height:1.6;margin:18px auto 20px;max-width:360px}.letter-from{font-family:Georgia,serif;color:#815e4a;font-style:italic;font-size:16px}.letter-decoration{color:#a77e49;font-size:18px;letter-spacing:10px;margin-top:23px}.toast{pointer-events:none;opacity:0;position:fixed;z-index:5;left:50%;bottom:calc(23px + env(safe-area-inset-bottom));transform:translate(-50%,12px);min-width:min(320px,calc(100vw - 40px));max-width:calc(100vw - 40px);border:1px solid #d7ba83;border-radius:10px;padding:15px 20px;color:#f5e6ca;background:#204139;box-shadow:0 15px 40px #0008;text-align:center;font-size:13px;line-height:1.5;transition:opacity .2s,transform .2s}.toast.show{opacity:1;transform:translate(-50%,0)}
[hidden]{display:none!important}button:focus-visible{outline:3px solid #e9c48e;outline-offset:3px}
@media(min-width:620px){.page{padding-left:28px;padding-right:28px}.door-grid{grid-template-columns:repeat(6,minmax(0,1fr));gap:13px}.editor-card{padding:25px}.nav-tabs{max-width:440px;margin-left:auto;margin-right:auto}}
@media(max-width:380px){.page{padding-left:13px;padding-right:13px}.brand-name{font-size:16px}.brand-tagline{font-size:9px}.year-pill{font-size:9px;padding:7px}.door-grid{gap:7px}.door .door-month{font-size:8px}.edit-door-grid{grid-template-columns:repeat(6,1fr)}.editor-navigation{grid-template-columns:1fr 1fr}.editor-navigation button:nth-child(2){grid-row:2;grid-column:1/-1}.field-grid{grid-template-columns:1fr}.year-row{grid-template-columns:.65fr 1.35fr}}

/* Privat-modus: låst skjerm og passorddialog. */
#lockedView, #draftGate { margin-top: 28px; }
#lockedView .primary, #draftGate .primary { margin: 18px 0 10px; }
#lockedView .outline { margin: 10px 0; }
.security-dialog { width: min(92vw, 420px); max-height: 90dvh; overflow:auto; border: 1px solid #b89f79; border-radius: 22px; padding: 0; background:#fdf5e9; color: #1f312b; box-shadow:0 20px 70px #001e1a55; }
.security-dialog::backdrop { background: #061a18b9; backdrop-filter: blur(4px); }
.security-shell { padding: 27px 22px 24px; position:relative; }
.security-shell h2 { font-size:24px; line-height:1.2; margin:13px 25px 8px 0; }
.security-shell .muted, .security-shell .field-help { color:#57685e; }
.security-shell input { width:100%; min-height:49px; padding:11px; color:#18302a; background:white; border:1px solid #d1cabf; border-radius:11px; font:inherit; }
.security-shell .field { margin: 14px 0; }
.security-shell .primary { width:100%; margin:17px 0 12px; }
.security-shell .close-dialog { position:absolute; top:9px; right:10px; }
.security-error { padding:11px; border-radius:8px; color:#8b1921; background:#ffe0dd; font-size:14px; }
#saveIndicator { text-align:center; }

/* Eksempler vises tydelig som grå, ikke-lagret veiledning. */
.example-caption{font-size:11px;line-height:1.5;color:#b6bec2;font-style:italic;margin:8px 2px 0}.example-caption[hidden]{display:none}.lock-explainer{margin-top:10px;line-height:1.65}.view-actions .lock-explainer{margin-top:-2px;margin-bottom:8px}.lock-explainer strong{color:#e8d8b9}

/* Flere private utkast – ingen endring i resten av designet. */
.existing-drafts{border-top:1px solid #c2aa7d52;margin-top:22px;padding-top:19px}
.existing-drafts label{display:block;color:#e3dbca;font-size:12px;font-weight:650;margin-bottom:8px}
.existing-drafts select{width:100%;min-height:46px;padding:12px;background:#071d1a;border:1px solid #8da6965c;border-radius:9px;color:#fff0d8;font:inherit}
.existing-drafts .outline,.existing-drafts .subtle-danger{margin-top:12px;width:100%}
.existing-drafts .field-help{margin-top:9px}
#draftGate #newDraft{margin-top:15px}
#newDraftFromEditor{margin-top:10px}

/* Åpnede luker: et utdrag på luken og alle hele meldinger nedenfor. */
.door.opened{justify-content:flex-start;padding:12px 5px 9px;gap:2px}
.door.opened .door-date{font-size:clamp(21px,5.6vw,36px)}
.door.opened .door-month{margin-top:1px}
.door.opened .door-state{position:static;margin:1px 0 0}
.door-preview{font-size:10px;line-height:1.3;color:#345245;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;max-width:100%;margin:2px 3px 0}
.opened-messages{margin:26px 0 20px}
.opened-messages h2{font-family:Georgia,serif;font-weight:400;font-size:24px;color:#efd7ad;text-align:center;margin:0 0 6px}
.opened-messages-info{font-size:12px;color:#b6c9bb;text-align:center;line-height:1.6;margin:0 auto 20px;max-width:420px}
.opened-message-list{display:grid;gap:13px}
.opened-message-card{background:#f8efdd;color:#263b31;padding:20px 19px;border-radius:13px;border:1px solid #dcc59e;box-shadow:0 4px 16px #0003}
.opened-message-card h3{font-size:15px;color:#94503f;margin:0 0 9px;font-family:Georgia,serif}
.opened-message-text{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6;font-size:16px;margin:0;font-family:Georgia,serif}
.letter-shell{overscroll-behavior:contain}

/* Datoperiode i kalenderoppretteren, med full bredde for mobilens datovelgere. */
.period-fields{margin-top:6px}.period-fields input[type="date"]{color-scheme:dark;min-width:0;min-height:52px}.period-apply{display:block;margin:12px 0 0;width:100%;font-size:13px}.period-apply:disabled{opacity:.4;cursor:not-allowed}#periodHelp{min-height:17px}

#saveIndicator:empty { display:none; }

/* Bilde til tekstluke – tilpasset mobil, uten utklipp av lange bilder. */
.photo-editor{border-top:1px solid #e3bd8e3a;margin-top:16px;padding-top:15px}
.photo-label{display:block;font-size:13px;font-weight:750;color:#f1d9ae;margin-bottom:10px}
.photo-actions{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.photo-actions button{font-size:13px;min-height:45px;white-space:normal}
.photo-actions button:disabled,.edit-photo-area button:disabled{opacity:.45}
.edit-photo-area{padding:12px 0 5px;display:flex;flex-direction:column;align-items:flex-start;gap:10px}
.edit-photo-area img{display:block;max-width:100%;width:auto;max-height:310px;object-fit:contain;border-radius:9px;border:1px solid #c2a97f66}
.photo-editor .field-help{margin-top:8px}
.letter-photo{max-width:100%;height:auto;max-height:56dvh;object-fit:contain;border-radius:12px;display:block;margin:18px auto 12px;box-shadow:0 4px 15px #0002}
.letter-photo[hidden]{display:none}
.opened-message-photo{display:block;max-width:100%;width:auto;max-height:430px;object-fit:contain;border-radius:9px;margin:12px 0 14px}
.door-thumb{width:85%;height:25%;object-fit:cover;border-radius:3px;margin:3px auto 0;min-height:0}
.door.opened:has(.door-thumb) .door-preview{-webkit-line-clamp:1;margin-top:0}
@media(max-width:360px){.photo-actions{grid-template-columns:1fr}}

/* v14: Kameraet bruker ikke lenger Androids eksterne kamera-app.
   Videoen er kun en direkte forhåndsvisning og blir aldri lagret på server. */
.camera-dialog{border:0;border-radius:16px;width:calc(100% - 24px);max-width:540px;max-height:calc(100dvh - 24px);padding:0;overflow:auto;color:#f7e9cf;background:#0b2321;box-shadow:0 25px 80px #000d}
.camera-dialog::backdrop{background:#020d0dbf;backdrop-filter:blur(5px)}
.camera-shell{padding:16px;display:flex;flex-direction:column;gap:12px;max-height:calc(100dvh - 24px)}
.camera-header{display:flex;align-items:center;justify-content:space-between;font-family:Georgia,serif;font-size:21px;color:#f4dab0}
.camera-close{border:1px solid #ebcb9c77;border-radius:9px;color:#f4dab0;background:#ffffff0a;font-size:26px;line-height:1;min-height:40px;min-width:44px}
#cameraPreview{display:block;width:100%;max-height:min(63dvh,570px);min-height:210px;object-fit:contain;border-radius:10px;background:#030808}
.camera-status{margin:0;min-height:1.5em;text-align:center;font-size:12px;color:#bacbbf}
.camera-actions button{justify-content:center;min-height:53px}
.camera-actions button:disabled{opacity:.5}

/* V16: Norsk/English without altering the existing calendar design. */
.header-right{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.language-switch{display:inline-flex;border:1px solid #bba1788f;border-radius:9px;overflow:hidden;background:#102925}
.lang-button{min-width:38px;padding:9px 9px;background:transparent;color:#ebd8b6;border:0;font:700 12px system-ui;cursor:pointer}
.lang-button+ .lang-button{border-left:1px solid #bba17860}
.lang-button.active{background:#ecc891;color:#19392f}
.lang-button:focus-visible{outline:2px solid #e7d29e;outline-offset:-2px}
@media(max-width:420px){.header-right{gap:5px}.lang-button{min-width:32px;padding:7px}.year-pill{font-size:9px;padding:7px}}

.backup-tools{margin:20px auto 0;max-width:650px;background:#0e2723;border:1px solid #baaa7857;padding:14px 18px;border-radius:12px;font-size:13px}
.backup-tools summary{cursor:pointer;color:#e9d4ab;font-weight:700}
.backup-tools p{color:#b9c5b7;line-height:1.65}
.backup-actions{display:flex;gap:10px;flex-wrap:wrap;margin:10px 0}
.backup-actions button{flex:1;min-width:190px}
/* Tilbakeknapp som virker i nettleser og som PWA. */
.site-return{display:flex;justify-content:flex-start;margin:14px 0 -7px}
.site-return-link{display:inline-flex;align-items:center;min-height:40px;padding:7px 12px;color:#efd4a2;border:1px solid #d5b37b77;border-radius:9px;background:#ffffff0c;font-size:12px;font-weight:650;text-decoration:none;line-height:1.3}
.site-return-link:hover{background:#ffffff18;color:#fff3d8}
.site-return-link:focus-visible{outline:3px solid #e9c48e;outline-offset:3px}

/* Inn og ut av appen: to tydelige navigasjonslenker på mobil. */
.site-return{flex-wrap:wrap;gap:8px}

/* Frivillig lokal opplåsing, som aldri er forhåndsvalgt. */
.remember-device-option{display:flex;align-items:flex-start;gap:12px;cursor:pointer;padding:12px 5px;color:#253c30;font-size:13px;font-weight:700;line-height:1.35}
.remember-device-option input{width:21px;min-width:21px;height:21px;min-height:21px;accent-color:#28563d;margin:0}
.remember-device-option small{display:block;font-weight:400;font-size:11px;color:#5c695e;margin-top:5px}
