/* ==========================================================================
   Magic theme — animated sky backdrop (see assets/js/magic-sky.js),
   the Login page, and the glassy Dashboard skin.
   Theme is driven by <html data-sky="dawn|dusk|twilight|night">.
   ========================================================================== */

:root {
    --mg-ease: cubic-bezier(.22, .8, .24, 1);
    --mg-hand: 'Caveat', 'Bradley Hand', cursive;
}

/* Per-theme palette. Mountains go far (m1) -> near (m5). */
:root, [data-sky="night"] {
    --mg-m1: #2a2d5c; --mg-m2: #1f2250; --mg-m3: #171a40; --mg-m4: #121535; --mg-m5: #0b0d26;
    --mg-accent: #8fe4ff;
    --mg-accent-2: #b59cff;
    --mg-hero-a: #2b2f73; --mg-hero-b: #0d1a3d;
    --mg-ink: #0f1230;
    --mg-sun-op: 0; --mg-moon-op: 1; --mg-moon-top: 9%;
    --mg-aurora: radial-gradient(60% 40% at 70% 10%, rgba(120, 140, 255, .22), transparent 70%),
                 radial-gradient(40% 30% at 15% 25%, rgba(143, 228, 255, .12), transparent 70%);
}
[data-sky="twilight"] {
    --mg-m1: #a597d4; --mg-m2: #8a7bc0; --mg-m3: #6a5ca6; --mg-m4: #574a92; --mg-m5: #3b3172;
    --mg-accent: #e4d6ff;
    --mg-accent-2: #ffd1ec;
    --mg-hero-a: #7b68c8; --mg-hero-b: #3f3488;
    --mg-ink: #2c2466;
    --mg-sun-op: 0; --mg-moon-op: 1; --mg-moon-top: 11%;
    --mg-aurora: radial-gradient(55% 35% at 75% 15%, rgba(255, 255, 255, .25), transparent 70%),
                 radial-gradient(45% 30% at 20% 30%, rgba(255, 200, 235, .18), transparent 70%);
}
[data-sky="dusk"] {
    --mg-m1: #8d4f74; --mg-m2: #6b3a66; --mg-m3: #4c2a56; --mg-m4: #3a2048; --mg-m5: #24132f;
    --mg-accent: #ffc27a;
    --mg-accent-2: #ff8f6b;
    --mg-hero-a: #d9623f; --mg-hero-b: #6b3a78;
    --mg-ink: #3a1d40;
    --mg-sun-op: 1; --mg-moon-op: .45; --mg-moon-top: 8%;
    --mg-aurora: radial-gradient(60% 40% at 50% 85%, rgba(255, 170, 92, .35), transparent 70%),
                 radial-gradient(40% 30% at 85% 20%, rgba(255, 120, 150, .18), transparent 70%);
}
[data-sky="dawn"] {
    --mg-m1: #b0708f; --mg-m2: #8d5a8c; --mg-m3: #6a3f74; --mg-m4: #523062; --mg-m5: #331d45;
    --mg-accent: #ffd18a;
    --mg-accent-2: #ff9d7a;
    --mg-hero-a: #f08a4b; --mg-hero-b: #8a4b8f;
    --mg-ink: #44214e;
    --mg-sun-op: 1; --mg-moon-op: .3; --mg-moon-top: 7%;
    --mg-aurora: radial-gradient(70% 45% at 30% 80%, rgba(255, 190, 110, .4), transparent 70%),
                 radial-gradient(40% 30% at 80% 15%, rgba(255, 150, 120, .2), transparent 70%);
}

/* --------------------------------------------------------------------
   Sky backdrop
   -------------------------------------------------------------------- */
.mg-sky {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background: #0b0d26;
}

.mg-sky__grad {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.8s var(--mg-ease);
}
.mg-sky__grad[data-t="night"]    { background: linear-gradient(180deg, #050816 0%, #0e1838 40%, #1d2a5c 75%, #3a3a7a 100%); }
.mg-sky__grad[data-t="twilight"] { background: linear-gradient(180deg, #4a3d8f 0%, #7d6dbd 38%, #b3a2da 70%, #e2d3ef 100%); }
.mg-sky__grad[data-t="dusk"]     { background: linear-gradient(180deg, #1f1d4a 0%, #5e3474 35%, #c2584a 68%, #f7a24b 100%); }
.mg-sky__grad[data-t="dawn"]     { background: linear-gradient(180deg, #3b2a6b 0%, #8a4b8f 32%, #e0785a 66%, #f9c27a 100%); }

[data-sky="night"]    .mg-sky__grad[data-t="night"],
[data-sky="twilight"] .mg-sky__grad[data-t="twilight"],
[data-sky="dusk"]     .mg-sky__grad[data-t="dusk"],
[data-sky="dawn"]     .mg-sky__grad[data-t="dawn"] { opacity: 1; }

.mg-sky__aurora {
    position: absolute;
    inset: -10%;
    background: var(--mg-aurora);
    filter: blur(10px);
    animation: mg-drift 22s ease-in-out infinite alternate;
}

.mg-sky__canvas {
    position: absolute;
    inset: 0;
}

.mg-sky__moon {
    position: absolute;
    top: var(--mg-moon-top);
    right: 9%;
    width: clamp(90px, 13vw, 170px);
    aspect-ratio: 1;
    opacity: var(--mg-moon-op);
    filter: drop-shadow(0 0 24px rgba(255, 248, 220, .55)) drop-shadow(0 0 70px rgba(255, 248, 220, .25));
    transition: opacity 1.8s var(--mg-ease), top 1.8s var(--mg-ease);
    animation: mg-float 9s ease-in-out infinite;
}
.mg-sky__moon svg { width: 100%; height: 100%; display: block; }

.mg-sky__sun {
    position: absolute;
    left: 50%;
    bottom: 16vh;
    width: min(70vw, 620px);
    aspect-ratio: 1;
    transform: translate(-50%, 50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 236, 190, .95) 0%, rgba(255, 196, 120, .6) 12%, rgba(255, 150, 90, .22) 35%, transparent 65%);
    opacity: var(--mg-sun-op);
    transition: opacity 1.8s var(--mg-ease);
    animation: mg-breathe 7s ease-in-out infinite;
}

.mg-sky__mountains {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: clamp(180px, 34vh, 380px);
}
.mg-sky__mountains > * { transition: fill 1.8s var(--mg-ease); }
.mg-m1 { fill: var(--mg-m1); }
.mg-m2 { fill: var(--mg-m2); }
.mg-m3 { fill: var(--mg-m3); }
.mg-m4 { fill: var(--mg-m4); }
.mg-m5 { fill: var(--mg-m5); }

.mg-sky__mist {
    position: absolute;
    left: -10%;
    right: -10%;
    bottom: 12vh;
    height: 18vh;
    background: radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, .16), transparent 70%);
    filter: blur(8px);
    animation: mg-mist 26s linear infinite alternate;
}

@keyframes mg-float  { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes mg-breathe { 0%, 100% { transform: translate(-50%, 50%) scale(1); } 50% { transform: translate(-50%, 50%) scale(1.05); } }
@keyframes mg-drift  { from { transform: translate3d(-2%, 0, 0); } to { transform: translate3d(2%, 2%, 0); } }
@keyframes mg-mist   { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
@keyframes mg-rise   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes mg-shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes mg-blink  { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .mg-sky *, .mg-rise, .mg-login * { animation: none !important; }
}

/* --------------------------------------------------------------------
   Login
   -------------------------------------------------------------------- */
body.mg-login {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #fff;
    background: #0b0d26;
    -webkit-font-smoothing: antialiased;
}
.mg-login *, .mg-login *::before, .mg-login *::after { box-sizing: border-box; }

.mg-login__wrap {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1.1fr minmax(340px, 440px);
    align-items: center;
    gap: clamp(2rem, 5vw, 5rem);
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem);
    padding-bottom: max(clamp(1.25rem, 4vw, 3rem), env(safe-area-inset-bottom));
}

.mg-brand {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: .01em;
}
.mg-brand__logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--mg-accent), var(--mg-accent-2));
    color: var(--mg-ink);
    box-shadow: 0 0 24px color-mix(in srgb, var(--mg-accent) 55%, transparent);
    font-size: 1rem;
}

.mg-story { min-width: 0; animation: mg-rise .9s var(--mg-ease) both; }
.mg-story__title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: clamp(2rem, 4.4vw, 3.4rem);
    line-height: 1.08;
    margin: 1.6rem 0 .8rem;
    text-shadow: 0 2px 24px rgba(0, 0, 0, .25);
}
.mg-story__title em {
    font-style: italic;
    background: linear-gradient(90deg, var(--mg-accent), var(--mg-accent-2), var(--mg-accent));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: mg-shimmer 6s linear infinite;
}
.mg-story__sub {
    font-size: clamp(.95rem, 1.4vw, 1.08rem);
    line-height: 1.6;
    color: rgba(255, 255, 255, .82);
    max-width: 30rem;
    margin: 0 0 2rem;
}

/* Notebook being written in */
.mg-notebook {
    position: relative;
    width: min(100%, 400px);
    padding: 1.4rem 1.5rem 1.6rem 3.1rem;
    border-radius: 6px 14px 14px 6px;
    background:
        repeating-linear-gradient(to bottom, transparent 0, transparent 2rem, rgba(70, 110, 160, .22) 2rem, rgba(70, 110, 160, .22) calc(2rem + 1px)),
        linear-gradient(180deg, #fffdf6, #f6f0e2);
    background-position: 0 1.15rem, 0 0;
    color: #2b2f4a;
    transform: rotate(-3deg);
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .4) inset;
    animation: mg-float 8s ease-in-out infinite;
}
.mg-notebook::before { /* spiral rings */
    content: '';
    position: absolute;
    left: .55rem;
    top: .8rem;
    bottom: .8rem;
    width: 1.3rem;
    background: radial-gradient(circle at 50% 50%, #1b1d33 0 .32rem, transparent .34rem) 0 0 / 1.3rem 1.45rem repeat-y;
    filter: drop-shadow(1px 1px 0 rgba(255, 255, 255, .5));
}
.mg-notebook::after { /* margin line */
    content: '';
    position: absolute;
    left: 2.5rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(224, 112, 140, .45);
}
.mg-notebook__date,
.mg-notebook__line {
    font-family: var(--mg-hand);
    font-size: 1.55rem;
    line-height: 2rem;
    min-height: 2rem;
}
.mg-notebook__date { color: #3d4470; }
.mg-notebook__line { color: #1f3f8a; }
.mg-notebook__caret {
    display: inline-block;
    width: 2px;
    height: 1.3rem;
    margin-left: 2px;
    vertical-align: -.15rem;
    background: #1f3f8a;
    animation: mg-blink 1s steps(1) infinite;
}
.mg-notebook__pen {
    position: absolute;
    right: -1.4rem;
    bottom: -1rem;
    width: 120px;
    transform: rotate(-35deg);
    filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .35));
    animation: mg-float 3s ease-in-out infinite;
}

/* Glass sign-in card */
.mg-card {
    position: relative;
    padding: clamp(1.5rem, 4vw, 2.25rem);
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .07)), rgba(18, 14, 48, .38);
    border: 1px solid rgba(255, 255, 255, .24);
    box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .06) inset;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    animation: mg-rise .9s .15s var(--mg-ease) both;
}
.mg-card::before { /* soft accent glow on the top edge */
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(140deg, color-mix(in srgb, var(--mg-accent) 80%, transparent), transparent 40%, transparent 65%, color-mix(in srgb, var(--mg-accent-2) 60%, transparent));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}
.mg-card__moon { width: 46px; height: 46px; margin-bottom: .6rem; filter: drop-shadow(0 0 14px rgba(255, 248, 220, .6)); }
.mg-card__moon svg { width: 100%; height: 100%; }
.mg-card h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: 1.7rem;
    margin: 0 0 .3rem;
}
.mg-card__lede { color: rgba(255, 255, 255, .75); font-size: .92rem; margin: 0 0 1.5rem; }

.mg-field { margin-bottom: 1rem; }
.mg-field label {
    display: block;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .78);
    margin-bottom: .45rem;
}
.mg-input {
    position: relative;
    display: flex;
    align-items: center;
}
.mg-input > i {
    position: absolute;
    left: .95rem;
    color: rgba(255, 255, 255, .6);
    font-size: .9rem;
    pointer-events: none;
}
.mg-input input {
    width: 100%;
    font: inherit;
    font-size: 16px; /* prevents iOS zoom on focus */
    color: #fff;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 14px;
    padding: .85rem 2.8rem .85rem 2.6rem;
    outline: none;
    transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.mg-input input::placeholder { color: rgba(255, 255, 255, .45); }
.mg-input input:focus {
    border-color: var(--mg-accent);
    background: rgba(255, 255, 255, .16);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--mg-accent) 25%, transparent);
}
.mg-input input:-webkit-autofill {
    -webkit-text-fill-color: #fff;
    -webkit-box-shadow: 0 0 0 100px rgba(40, 34, 90, .9) inset;
    caret-color: #fff;
}
.mg-input__toggle {
    position: absolute;
    right: .45rem;
    width: 2.3rem;
    height: 2.3rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, .7);
    cursor: pointer;
}
.mg-input__toggle:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.mg-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin: .25rem 0 1.4rem;
    font-size: .86rem;
}
.mg-check { display: inline-flex; align-items: center; gap: .5rem; color: rgba(255, 255, 255, .85); cursor: pointer; }
.mg-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--mg-accent); }
.mg-link { color: var(--mg-accent); text-decoration: none; font-weight: 600; }
.mg-link:hover { text-decoration: underline; }

.mg-btn {
    position: relative;
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: .95rem 1rem;
    font: inherit;
    font-weight: 700;
    font-size: 1rem;
    color: var(--mg-ink);
    background: linear-gradient(110deg, var(--mg-accent), var(--mg-accent-2), var(--mg-accent));
    background-size: 200% 100%;
    box-shadow: 0 12px 30px -10px color-mix(in srgb, var(--mg-accent) 70%, transparent);
    cursor: pointer;
    overflow: hidden;
    transition: transform .2s var(--mg-ease), box-shadow .2s ease, background-position .6s ease;
}
.mg-btn:hover { transform: translateY(-2px); background-position: 100% 0; box-shadow: 0 18px 36px -10px color-mix(in srgb, var(--mg-accent) 80%, transparent); }
.mg-btn:active { transform: translateY(0); }
.mg-btn:disabled { opacity: .7; cursor: wait; transform: none; }

.mg-alert {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .75rem .9rem;
    border-radius: 12px;
    font-size: .88rem;
    margin-bottom: 1.1rem;
}
.mg-alert--error { background: rgba(223, 31, 53, .22); border: 1px solid rgba(255, 140, 150, .45); }
.mg-alert--ok { background: rgba(0, 156, 115, .22); border: 1px solid rgba(120, 230, 190, .45); }

.mg-divider {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin: 1.5rem 0 1.1rem;
    font-size: .82rem;
    color: rgba(255, 255, 255, .65);
}
.mg-divider::before, .mg-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255, 255, 255, .2); }
.mg-signup {
    display: block;
    text-align: center;
    padding: .8rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: background-color .2s ease, border-color .2s ease;
}
.mg-signup:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .45); }

@media (max-width: 900px) {
    .mg-login__wrap {
        grid-template-columns: minmax(0, 1fr);
        align-content: start;
        gap: 1.5rem;
        max-width: 480px;
        padding-top: max(1.25rem, env(safe-area-inset-top));
    }
    .mg-story { text-align: center; }
    .mg-story__title { margin: 1.1rem 0 .5rem; }
    .mg-story__sub { margin: 0 auto 1.2rem; }
    .mg-notebook { margin: 0 auto; width: min(100%, 340px); padding: 1rem 1.2rem 1.1rem 2.9rem; }
    .mg-notebook__pen { width: 90px; right: -.6rem; }
}
@media (max-width: 520px) {
    .mg-story__sub { display: none; }
    .mg-notebook__date, .mg-notebook__line { font-size: 1.3rem; }
    .mg-card h2 { font-size: 1.45rem; }
    .mg-row { flex-wrap: wrap; }
}
@media (max-height: 700px) and (max-width: 900px) {
    .mg-notebook { display: none; }
}

/* --------------------------------------------------------------------
   Dashboard skin (body.db-magic) — glass cards floating over the sky
   -------------------------------------------------------------------- */
body.db-magic { background: #0b0d26; }
body.db-magic .db-main { position: relative; z-index: 1; }

body.db-magic .db-header {
    position: relative;
    z-index: 40;
    background: rgba(12, 10, 40, .28);
    border-bottom-color: rgba(255, 255, 255, .14);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
}
body.db-magic .db-header__name,
body.db-magic .db-header__brand { color: #fff; }
body.db-magic .db-header__logo {
    background: linear-gradient(135deg, var(--mg-accent), var(--mg-accent-2));
    color: var(--mg-ink);
    box-shadow: 0 0 18px color-mix(in srgb, var(--mg-accent) 50%, transparent);
}
body.db-magic .db-header__clock { color: rgba(255, 255, 255, .78); }
body.db-magic .db-nav { background: rgba(255, 255, 255, .12); }
body.db-magic .db-nav__tab { color: rgba(255, 255, 255, .8); }
body.db-magic .db-nav__tab.is-active { background: #fff; color: var(--mg-ink); }
body.db-magic .db-header__logout { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .22); color: #fff; }

body.db-magic .db-card {
    background: rgba(255, 255, 255, .86);
    border-color: rgba(255, 255, 255, .55);
    box-shadow: 0 20px 50px -24px rgba(8, 6, 30, .55);
    backdrop-filter: blur(16px) saturate(1.25);
    -webkit-backdrop-filter: blur(16px) saturate(1.25);
}
body.db-magic a.db-card:hover {
    border-color: color-mix(in srgb, var(--mg-accent) 70%, #fff);
    box-shadow: 0 24px 50px -20px rgba(8, 6, 30, .6), 0 0 0 3px color-mix(in srgb, var(--mg-accent) 35%, transparent);
}
body.db-magic .db-ai-card { background: rgba(255, 255, 255, .9); }
body.db-magic .db-mini-row { background: rgba(255, 255, 255, .75); }

/* Greeting block sits directly on the sky */
.mg-greet { color: #fff; }
.mg-greet__hello { font-size: .95rem; font-weight: 500; color: rgba(255, 255, 255, .82); margin: 0; }
.mg-greet__date {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 600;
    margin: .1rem 0 .2rem;
    text-shadow: 0 2px 20px rgba(0, 0, 0, .25);
}
.mg-greet__line { color: rgba(255, 255, 255, .78); font-size: .9rem; margin: 0; }
.mg-greet .db-label { color: rgba(255, 255, 255, .7); }
.mg-greet .db-heat-cell { background: rgba(255, 255, 255, .16); }
.mg-greet .db-heat-cell.is-active { background: var(--mg-accent); box-shadow: 0 0 6px var(--mg-accent); }

.mg-moonline {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin-top: .7rem;
    font-family: var(--mg-hand);
    font-size: 1.3rem;
    color: var(--mg-accent);
}
.mg-moonline__icon { width: 22px; height: 22px; display: inline-block; }
.mg-moonline__icon svg { width: 100%; height: 100%; }

.mg-stats { display: flex; gap: .6rem; flex-wrap: wrap; }
.mg-stat {
    min-width: 88px;
    padding: .7rem .9rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.mg-stat__num { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.mg-stat .db-label { color: rgba(255, 255, 255, .72); font-size: .6rem; }

/* Theme picker */
.mg-themes {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.mg-themes button {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 0;
    border-radius: 999px;
    padding: .38rem .7rem;
    background: transparent;
    color: rgba(255, 255, 255, .85);
    font: inherit;
    font-size: .74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}
.mg-themes button:hover { background: rgba(255, 255, 255, .14); }
.mg-themes button.is-active { background: #fff; color: var(--mg-ink); }

/* Hero cards */
body.db-magic .db-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b));
    border: 1px solid rgba(255, 255, 255, .25);
    box-shadow: 0 24px 50px -22px rgba(8, 6, 30, .7);
    transition: transform .25s var(--mg-ease), box-shadow .25s ease;
}
body.db-magic .db-hero::after { /* moving sheen */
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .18) 50%, transparent 70%);
    background-size: 250% 100%;
    animation: mg-shimmer 7s linear infinite;
    pointer-events: none;
}
body.db-magic .db-hero:hover { transform: translateY(-4px); box-shadow: 0 30px 60px -20px rgba(8, 6, 30, .75), 0 0 0 3px color-mix(in srgb, var(--mg-accent) 30%, transparent); }
body.db-magic .db-hero > span:last-child { color: var(--mg-accent) !important; }
body.db-magic .db-hero--light {
    background: rgba(255, 255, 255, .14);
    color: #fff;
}
body.db-magic .db-hero--light i,
body.db-magic .db-hero--light p { color: rgba(255, 255, 255, .85) !important; }
body.db-magic .db-hero--light .db-link { color: var(--mg-accent); }
.mg-hero__deco {
    position: absolute;
    right: -10px;
    bottom: -18px;
    font-size: 6rem;
    opacity: .12;
    color: #fff;
    pointer-events: none;
}

.mg-sky-label { color: rgba(255, 255, 255, .85) !important; }
.mg-on-sky { color: rgba(255, 255, 255, .8) !important; }
body.db-magic .db-empty { background: rgba(255, 255, 255, .86); border-radius: 16px; }

.mg-rise { animation: mg-rise .7s var(--mg-ease) both; animation-delay: calc(var(--i, 0) * 70ms); }

body.db-magic .db-fab {
    background: linear-gradient(110deg, var(--mg-accent), var(--mg-accent-2));
    color: var(--mg-ink);
    box-shadow: 0 14px 34px -10px color-mix(in srgb, var(--mg-accent) 75%, transparent);
    bottom: max(1.5rem, env(safe-area-inset-bottom));
}
body.db-magic .db-fab:hover { background: linear-gradient(110deg, var(--mg-accent-2), var(--mg-accent)); }

.db-dash-wrap { max-width: 1120px; margin: 0 auto; padding: 2rem 1.25rem 7rem; }

@media (max-width: 720px) {
    /* Backdrop blur on many cards over an animated canvas is costly on phones */
    body.db-magic .db-card { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(255, 255, 255, .94); }
    .db-dash-wrap { padding: 1.25rem 1rem 6.5rem; }
    .mg-greet-row { gap: 1rem !important; }
    .mg-stats { width: 100%; }
    .mg-stat { flex: 1 1 0; min-width: 0; text-align: center; }
    .mg-themes { width: 100%; justify-content: space-between; }
    .mg-themes button { padding: .38rem .55rem; }
    .mg-themes button span { display: none; }
    body.db-magic .db-fab { right: 1rem; padding: .8rem 1.1rem; }
    .db-header { padding: .6rem .9rem; }
}
@media (max-width: 400px) {
    .db-fab__text { display: none; }
    body.db-magic .db-fab { width: 3.4rem; height: 3.4rem; padding: 0; justify-content: center; font-size: 1.1rem; }
    .db-nav__tab { padding: .35rem .6rem; }
}

@media (max-width: 720px) {
    .mg-stats-col { width: 100%; align-items: stretch !important; }
}

/* ==========================================================================
   Dashboard v2 — bento layout
   ========================================================================== */
.mg-greet {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem 2rem;
    margin: .5rem 0 1.75rem;
}
.mg-greet__side { display: flex; flex-direction: column; align-items: flex-end; gap: .7rem; }

.mg-bento {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
.mg-bento--top { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* Today's page — a sheet of notebook paper */
.mg-today {
    position: relative;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--mg-ink);
    border-radius: 22px;
    padding: 10px;
    background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b));
    box-shadow: 0 30px 60px -28px rgba(8, 6, 30, .8);
    transition: transform .3s var(--mg-ease), box-shadow .3s ease;
}
.mg-today:hover { transform: translateY(-4px) rotate(-.3deg); box-shadow: 0 36px 70px -26px rgba(8, 6, 30, .85), 0 0 0 3px color-mix(in srgb, var(--mg-accent) 35%, transparent); }
.mg-today__paper {
    position: relative;
    flex: 1;
    border-radius: 14px;
    padding: 1.4rem 1.6rem 1.3rem 3.3rem;
    background:
        repeating-linear-gradient(to bottom, transparent 0, transparent 2.1rem, rgba(70, 110, 160, .18) 2.1rem, rgba(70, 110, 160, .18) calc(2.1rem + 1px)),
        linear-gradient(180deg, #fffdf6, #f5eedf);
    background-position: 0 3.2rem, 0 0;
    overflow: hidden;
}
.mg-today__paper::before { /* spiral holes */
    content: '';
    position: absolute;
    left: .8rem;
    top: 1rem;
    bottom: 1rem;
    width: 1.2rem;
    background: radial-gradient(circle, rgba(27, 29, 51, .85) 0 .28rem, transparent .3rem) 0 0 / 1.2rem 1.6rem repeat-y;
}
.mg-today__paper::after { /* red margin line */
    content: '';
    position: absolute;
    left: 2.6rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(224, 112, 140, .45);
}
.mg-today__meta { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.mg-today__chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #7a5a1e;
    background: rgba(240, 180, 41, .18);
    padding: .3rem .65rem;
    border-radius: 999px;
}
.mg-today__date { font-family: var(--mg-hand); font-size: 1.35rem; color: #3d4470; }
.mg-today__prompt {
    font-family: var(--mg-hand);
    font-size: clamp(1.7rem, 3.4vw, 2.3rem);
    line-height: 2.1rem;
    color: #1f3f8a;
    margin: 1.15rem 0 .4rem;
    min-height: 4.2rem;
}
.mg-today__hint { font-size: .82rem; color: #6b7280; margin: 0 0 1rem; }
.mg-today__moods { display: flex; gap: .45rem; flex-wrap: wrap; }
.mg-face {
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    color: var(--c);
    background: color-mix(in srgb, var(--c) 14%, #fff);
    border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
    transition: transform .25s var(--mg-ease);
}
.mg-today:hover .mg-face { animation: mg-bob 1.2s ease-in-out infinite; }
.mg-today:hover .mg-face:nth-child(2) { animation-delay: .1s; }
.mg-today:hover .mg-face:nth-child(3) { animation-delay: .2s; }
.mg-today:hover .mg-face:nth-child(4) { animation-delay: .3s; }
.mg-today:hover .mg-face:nth-child(5) { animation-delay: .4s; }
@keyframes mg-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.mg-today__cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem .6rem .35rem;
    color: #fff;
    font-weight: 700;
    font-size: .92rem;
}
.mg-today__cta i { transition: transform .25s var(--mg-ease); }
.mg-today:hover .mg-today__cta i { transform: translateX(5px); }

/* Streak — dark glass panel on the sky */
.mg-streak {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.3rem;
    border-radius: 22px;
    color: #fff;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.mg-streak__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.mg-streak__num { font-family: 'Source Serif 4', Georgia, serif; font-size: 2.6rem; font-weight: 600; line-height: 1; }
.mg-streak__num i { font-size: 1.6rem; color: var(--mg-accent); filter: drop-shadow(0 0 10px var(--mg-accent)); animation: mg-flicker 2.4s ease-in-out infinite; }
@keyframes mg-flicker { 0%, 100% { transform: scale(1) rotate(0); } 40% { transform: scale(1.08) rotate(-4deg); } 70% { transform: scale(.96) rotate(3deg); } }
.mg-streak__month { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.6rem; font-weight: 600; line-height: 1; }
.mg-streak__label { font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255, 255, 255, .7); margin-top: .3rem; }
.mg-heat { display: flex; gap: 3px; justify-content: space-between; }
.mg-heat__col { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.mg-heat .db-heat-cell { width: 100%; height: auto; aspect-ratio: 1; max-width: 14px; border-radius: 3px; background: rgba(255, 255, 255, .14); }
.mg-heat .db-heat-cell.is-active { background: var(--mg-accent); box-shadow: 0 0 6px color-mix(in srgb, var(--mg-accent) 70%, transparent); }
.mg-streak__link {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .75rem .9rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: .88rem;
    transition: background-color .2s ease;
}
.mg-streak__link:hover { background: rgba(255, 255, 255, .22); }

/* Panels */
.mg-panel { display: flex; flex-direction: column; padding: 1.15rem 1.2rem 1.1rem; border-radius: 20px !important; min-height: 0; }
.mg-panel__head { display: flex; align-items: center; gap: .6rem; margin-bottom: .85rem; }
.mg-ico {
    width: 2.1rem;
    height: 2.1rem;
    flex: 0 0 auto;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: .88rem;
    color: var(--c);
    background: color-mix(in srgb, var(--c) 14%, #fff);
}
.mg-panel__title { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.08rem; font-weight: 600; margin: 0; }
.mg-count {
    min-width: 1.4rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: var(--db-bg);
    color: var(--db-muted-2);
    font-size: .72rem;
    font-weight: 700;
    text-align: center;
}
.mg-total { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; color: var(--db-muted-2); font-size: .95rem; }
.mg-panel__actions { margin-left: auto; display: flex; gap: .3rem; }
.mg-iconbtn {
    width: 1.95rem;
    height: 1.95rem;
    border-radius: 10px;
    border: 1px solid var(--db-border);
    background: #fff;
    color: var(--db-muted-2);
    display: grid;
    place-items: center;
    font-size: .75rem;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s var(--mg-ease);
}
.mg-iconbtn:hover { color: var(--mg-ink); border-color: color-mix(in srgb, var(--mg-hero-a) 50%, #fff); transform: translateY(-1px); }
.mg-iconbtn.is-open { background: var(--mg-ink); color: #fff; border-color: var(--mg-ink); }
.mg-iconbtn.is-open i { transform: rotate(45deg); }
.mg-iconbtn i { transition: transform .2s ease; }

.mg-addform {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    padding: .75rem;
    margin-bottom: .8rem;
    border-radius: 14px;
    background: var(--db-bg);
}
.mg-addform__row { display: flex; gap: .45rem; }
.mg-addform__row > * { flex: 1 1 0; min-width: 0; }
.mg-addform__row > .db-btn { flex: 0 0 auto; }
.mg-addform > .db-btn { align-self: flex-start; }

.mg-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; margin: 0 -.4rem; padding: 0 .4rem; }
.mg-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .5rem;
    border-radius: 12px;
    transition: background-color .15s ease;
}
.mg-item:hover { background: var(--db-bg); }
.mg-item__body { flex: 1; min-width: 0; }
.mg-item__title { font-size: .88rem; font-weight: 600; line-height: 1.35; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-item__sub { font-size: .74rem; color: var(--db-muted-2); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-when { font-size: .7rem; font-weight: 600; color: var(--db-muted-3); white-space: nowrap; }
.mg-when.is-late { color: var(--db-mood-rough); }
.mg-del {
    flex: 0 0 auto;
    width: 1.6rem;
    height: 1.6rem;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--db-muted-3);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease, color .15s ease, background-color .15s ease;
}
.mg-item:hover .mg-del, .mg-del:focus-visible { opacity: 1; }
.mg-del:hover { color: var(--db-mood-rough); background: #fdecee; }
@media (hover: none) { .mg-del { opacity: .7; } }
.mg-datebox {
    flex: 0 0 auto;
    width: 2.6rem;
    padding: .3rem 0;
    border-radius: 10px;
    text-align: center;
    background: linear-gradient(160deg, color-mix(in srgb, #7b68c8 14%, #fff), #fff);
    border: 1px solid color-mix(in srgb, #7b68c8 25%, transparent);
}
.mg-datebox b { display: block; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.02rem; line-height: 1.1; color: #3f3488; }
.mg-datebox small { display: block; font-size: .56rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--db-muted-1); }
.mg-pulse { position: relative; width: .6rem; height: .6rem; flex: 0 0 auto; border-radius: 50%; background: var(--c); margin: 0 .3rem; }
.mg-pulse::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); opacity: 0; animation: mg-ping 2.4s ease-out infinite; }
@keyframes mg-ping { 0% { transform: scale(.5); opacity: .7; } 100% { transform: scale(1.6); opacity: 0; } }
.mg-amount { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.mg-blank { display: flex; align-items: center; gap: .55rem; font-size: .82rem; color: var(--db-muted-3); padding: .6rem .2rem; }
.mg-panel__foot { display: flex; align-items: center; gap: .7rem; margin-top: auto; padding-top: .8rem; font-size: .74rem; color: var(--db-muted-1); white-space: nowrap; }
.mg-progress { flex: 1; height: 6px; border-radius: 999px; background: var(--db-bg); overflow: hidden; }
.mg-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3ba97f, #009c73); transition: width .5s var(--mg-ease); }

.mg-memory__item { display: block; text-decoration: none; color: inherit; padding: .8rem .9rem; border-radius: 14px; background: linear-gradient(160deg, #f7f3ff, #fff); border: 1px solid #ece6fb; transition: transform .2s var(--mg-ease); }
.mg-memory__item:hover { transform: translateY(-2px); }
.mg-memory__date { font-family: var(--mg-hand); font-size: 1.2rem; color: #6a5ca6; }
.mg-memory__text { font-family: 'Source Serif 4', Georgia, serif; font-size: .9rem; line-height: 1.5; color: var(--db-text); margin-top: .15rem; }

.mg-quicknote {
    width: 100%;
    flex: 1;
    min-height: 110px;
    padding: .25rem .2rem;
    border: 0;
    resize: none;
    outline: none;
    font-family: var(--mg-hand);
    font-size: 1.35rem;
    line-height: 1.9rem;
    color: #1f3f8a;
    background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.9rem - 1px), rgba(70, 110, 160, .2) calc(1.9rem - 1px), rgba(70, 110, 160, .2) 1.9rem);
}
.mg-quicknote::placeholder { color: #9aa6b8; }

/* Charts */
.mg-moodpts { position: relative; height: 84px; margin-top: -84px; pointer-events: none; }
.mg-moodpts span { position: absolute; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; transform: translate(-50%, -50%); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); pointer-events: auto; }
.mg-bars { display: flex; align-items: flex-end; gap: 6px; height: 84px; border-bottom: 1px solid var(--db-border); }
.mg-bars__col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.mg-bars__col span { display: block; width: min(100%, 22px); border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--mg-hero-a), var(--mg-hero-b)); transition: height .6s var(--mg-ease); }
.mg-ai-overview { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.05rem; line-height: 1.6; margin: 0 0 1.1rem; }
.mg-ask { display: flex; gap: .5rem; align-items: stretch; }
.mg-ask textarea { flex: 1; min-width: 0; padding: .7rem .85rem; border: 1px solid var(--db-border); border-radius: 14px; font-family: inherit; font-size: .88rem; resize: none; background: #fff; }
.mg-ask textarea:focus { outline: none; border-color: #7b68c8; box-shadow: 0 0 0 3px rgba(123, 104, 200, .15); }
.mg-ask .db-btn { border-radius: 14px; padding: 0 1.1rem; }

/* Recent pages — little paper notes */
.mg-section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 .9rem; }
.mg-section-title { margin: 0; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.3rem; font-weight: 600; color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, .25); }
.mg-section-title i { font-size: .9rem; color: var(--mg-accent); margin-right: .3rem; }
.mg-section-link { color: var(--mg-accent); font-weight: 600; font-size: .85rem; text-decoration: none; }
.mg-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.1rem; }
.mg-page {
    position: relative;
    display: block;
    padding: 1.05rem 1.1rem 1.15rem;
    border-radius: 6px 16px 16px 6px;
    text-decoration: none;
    color: var(--db-text);
    background: linear-gradient(180deg, #fffdf7, #f7f1e3);
    border-left: 5px solid var(--c, #c3d3dc);
    box-shadow: 0 18px 36px -20px rgba(8, 6, 30, .7);
    transform: rotate(var(--tilt, 0deg));
    transition: transform .3s var(--mg-ease), box-shadow .3s ease;
}
.mg-page:hover { transform: rotate(0) translateY(-5px); box-shadow: 0 26px 46px -20px rgba(8, 6, 30, .8), 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); }
.mg-page__date { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-family: var(--mg-hand); font-size: 1.2rem; color: #3d4470; }
.mg-page__mood { font-family: 'Inter', sans-serif; font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); padding: .15rem .5rem; border-radius: 999px; }
.mg-page__title { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.08rem; font-weight: 600; margin: .35rem 0 .3rem; }
.mg-page__text { font-size: .82rem; line-height: 1.5; color: var(--db-muted-2); margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 1024px) {
    .mg-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mg-bento--top { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .mg-bento { grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; }
    .mg-greet { margin-top: 0; }
    .mg-greet__side { width: 100%; align-items: stretch; }
    .mg-today__paper { padding: 1.1rem 1.1rem 1.1rem 2.9rem; }
    .mg-today__paper::after { left: 2.3rem; }
    .mg-today__paper::before { left: .6rem; }
    .mg-list { max-height: none; }
    .mg-del { opacity: .7; }
    /* Recent pages become a swipeable row */
    .mg-pages { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: .9rem; margin: 0 -1rem; padding: .4rem 1rem 1.2rem; }
    .mg-page { flex: 0 0 78%; scroll-snap-align: center; }
}

/* ==========================================================================
   Other app pages on the sky (Diary, To-dos, Events, Reminders, Expenses)
   ========================================================================== */
body.db-magic .db-main > div > h1 { color: #fff; font-size: clamp(1.7rem, 4vw, 2.2rem) !important; text-shadow: 0 2px 18px rgba(0, 0, 0, .3); }
body.db-magic .db-main > div > a.db-link { color: var(--mg-accent); }
body.db-magic .db-main > div > div[x-show="loading"],
body.db-magic .db-main > div > div[x-show="checking"] { color: rgba(255, 255, 255, .85) !important; }
body.db-magic .db-paper {
    background: linear-gradient(180deg, #fffdf7, #f8f3e6);
    border-color: rgba(255, 255, 255, .6);
    box-shadow: 0 30px 60px -30px rgba(8, 6, 30, .8);
}

body.db-magic .mg-subbar {
    background: rgba(12, 10, 40, .22) !important;
    border-bottom-color: rgba(255, 255, 255, .12) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    z-index: 2;
}
body.db-magic .mg-subbar input { background: rgba(255, 255, 255, .92) !important; border-color: transparent !important; }
body.db-magic .mg-subbar .db-nav { background: rgba(255, 255, 255, .14) !important; }
body.db-magic .mg-subbar .db-pill:not(.is-active) { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }
body.db-magic .db-day-btn { color: rgba(255, 255, 255, .85) !important; }
body.db-magic .db-day-btn:hover { background: rgba(255, 255, 255, .12) !important; }
body.db-magic .db-day-btn.is-active { background: #fff !important; color: var(--mg-ink) !important; box-shadow: 0 0 18px color-mix(in srgb, var(--mg-accent) 60%, transparent); }
body.db-magic .db-entry-card.is-selected { border-color: var(--mg-accent) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--mg-accent) 35%, transparent) !important; }

body.db-magic .db-btn-dark { background: var(--mg-ink); }
body.db-magic .db-btn-dark:hover { background: color-mix(in srgb, var(--mg-ink) 75%, var(--mg-hero-a)); }
body.db-magic .db-pill.is-active { background: var(--mg-ink); border-color: var(--mg-ink); }
body.db-magic .db-check.is-checked { background: #3ba97f; border-color: #3ba97f; }

/* Modals / bottom sheets */
body.db-magic .db-overlay {
    background: rgba(8, 6, 30, .5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: mg-fade .25s ease both;
}
body.db-magic .db-sheet {
    background: linear-gradient(180deg, #fffdf7, #fff);
    border-top: 3px solid var(--mg-accent);
    box-shadow: 0 -20px 60px -20px rgba(8, 6, 30, .6);
    animation: mg-sheet .4s var(--mg-ease) both;
}
body.db-magic .db-sheet__header { background: linear-gradient(90deg, color-mix(in srgb, var(--mg-hero-a) 10%, #fff), #fff); }
@media (min-width: 721px) {
    body.db-magic .db-overlay { align-items: center; }
    body.db-magic .db-sheet { border-radius: 22px; }
}
@keyframes mg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mg-sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ==========================================================================
   Write page — a notebook sheet on the sky, with a pen that follows the caret
   ========================================================================== */
.mg-writebar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem 1.25rem;
    color: #fff;
}
.mg-writebar__close { display: inline-flex; align-items: center; gap: .45rem; color: #fff; text-decoration: none; font-weight: 600; font-size: .88rem; }
.mg-writebar__close:hover { color: var(--mg-accent); }
.mg-writebar__words { font-size: .8rem; color: rgba(255, 255, 255, .8); }
.mg-writebar__words i { color: var(--mg-accent); margin-right: .2rem; }
.mg-writebar__right { display: flex; align-items: center; gap: .6rem; }
.mg-fontswitch { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .14); }
.mg-fontswitch button { border: 0; background: none; color: rgba(255, 255, 255, .85); font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: .9rem; padding: .25rem .6rem; border-radius: 999px; cursor: pointer; }
.mg-fontswitch .mg-fontswitch__hand { font-family: var(--mg-hand); font-size: 1.15rem; line-height: 1; }
.mg-fontswitch button.is-active { background: #fff; color: var(--mg-ink); }
.mg-btn-done {
    padding: .5rem 1.1rem;
    border-radius: 999px;
    background: linear-gradient(110deg, var(--mg-accent), var(--mg-accent-2));
    color: var(--mg-ink);
    font-weight: 700;
    font-size: .85rem;
    text-decoration: none;
    box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--mg-accent) 70%, transparent);
}

.mg-write-wrap { max-width: 860px; margin: 0 auto; padding: 1.75rem 1.25rem 6rem; }
.mg-write-error {
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1rem;
    margin-bottom: 1.25rem;
    border-radius: 14px;
    background: #fff1f1;
    border-left: 4px solid var(--db-file-text);
    font-size: .85rem;
    color: #9c2430;
}
.mg-write-error button { flex: 0 0 auto; border: 1px solid #9c2430; background: none; color: #9c2430; border-radius: 8px; padding: .3rem .8rem; font-size: .8rem; font-weight: 600; cursor: pointer; }

.mg-sheet {
    position: relative;
    padding: 2rem 2.2rem 2rem 4.2rem;
    border-radius: 10px 22px 22px 10px;
    background: linear-gradient(180deg, #fffdf7, #f8f2e4);
    box-shadow: 0 40px 80px -36px rgba(8, 6, 30, .85), 0 0 0 1px rgba(255, 255, 255, .5) inset;
}
.mg-sheet::before { /* spiral binding */
    content: '';
    position: absolute;
    left: .9rem;
    top: 1.2rem;
    bottom: 1.2rem;
    width: 1.5rem;
    background:
        radial-gradient(circle at 50% 50%, #2a2c45 0 .34rem, transparent .36rem) 0 0 / 1.5rem 1.8rem repeat-y;
}
.mg-sheet::after { /* margin line */
    content: '';
    position: absolute;
    left: 3.2rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(224, 112, 140, .4);
}
.mg-sheet__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.mg-sheet__day { font-family: var(--mg-hand); font-size: 1.5rem; color: #6a5ca6; line-height: 1; }
.mg-sheet__date { font-family: 'Source Serif 4', Georgia, serif; font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 600; margin: .15rem 0 .2rem; color: var(--db-text); }
.mg-sheet__time { font-size: .8rem; color: var(--db-muted-2); }
.mg-sheet__label { font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--db-muted-1); margin: 0 0 .65rem; }
.mg-chip-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .85rem; border-radius: 999px;
    border: 1px solid #e6dfcd; background: rgba(255, 255, 255, .8);
    color: var(--db-muted-2); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.mg-chip-btn:hover { border-color: color-mix(in srgb, var(--mg-hero-a) 50%, #fff); color: var(--mg-ink); }
.mg-datepick { align-items: center; flex-wrap: wrap; gap: .5rem; margin: -0.5rem 0 1.5rem; padding: .8rem; border-radius: 14px; background: rgba(255, 255, 255, .7); font-size: .78rem; color: var(--db-muted-3); }

.mg-moodpick { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px dashed #e2d9c3; }
.mg-moodpick__row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .55rem; }
.mg-moodbtn {
    display: flex; flex-direction: column; align-items: center; gap: .35rem;
    padding: .8rem .3rem .65rem; border-radius: 16px;
    border: 1.5px solid #ebe4d3; background: rgba(255, 255, 255, .75);
    color: var(--db-muted-2); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
    transition: transform .25s var(--mg-ease), border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.mg-moodbtn i { font-size: 1.6rem; color: var(--c); opacity: .7; transition: transform .3s var(--mg-ease), opacity .2s ease; }
.mg-moodbtn:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--c) 45%, #fff); }
.mg-moodbtn:hover i { opacity: 1; transform: scale(1.12) rotate(-6deg); }
.mg-moodbtn.is-selected {
    border-color: var(--c);
    background: color-mix(in srgb, var(--c) 12%, #fff);
    color: color-mix(in srgb, var(--c) 70%, #000);
    box-shadow: 0 10px 24px -12px var(--c), 0 0 0 4px color-mix(in srgb, var(--c) 15%, transparent);
}
.mg-moodbtn.is-selected i { opacity: 1; animation: mg-pop .5s var(--mg-ease); }
@keyframes mg-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.mg-moodpick__sky { font-family: var(--mg-hand); font-size: 1.15rem; color: #6a5ca6; margin: .6rem 0 0; }
.mg-textbtn { background: none; border: 0; padding: 0; margin-top: .8rem; font: inherit; font-size: .8rem; font-weight: 600; color: #4f62c9; cursor: pointer; }
.mg-textbtn:hover { text-decoration: underline; }
.mg-emoform { flex-direction: column; gap: .5rem; margin-top: .7rem; padding: .9rem; border-radius: 14px; background: rgba(255, 255, 255, .7); }
.mg-intensity { display: flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--db-muted-2); }
.mg-intensity span { margin-right: .3rem; }
.mg-intensity button { width: 1.9rem; height: 1.9rem; border-radius: 50%; border: 1px solid #e6dfcd; background: #fff; font-size: .75rem; font-weight: 700; cursor: pointer; color: var(--db-muted-2); transition: all .15s ease; }
.mg-intensity button.is-on { background: var(--mg-ink); border-color: var(--mg-ink); color: #fff; }
.mg-emotions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .8rem; }
.mg-emotion { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .5rem .35rem .8rem; border-radius: 999px; background: #fff; border: 1px solid #ebe4d3; font-size: .8rem; }
.mg-emotion__dots { display: inline-flex; gap: 2px; }
.mg-emotion__dots i { width: 5px; height: 5px; border-radius: 50%; background: #e6dfcd; }
.mg-emotion__dots i.on { background: #7b68c8; }
.mg-emotion__note { color: var(--db-muted-2); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-emotion button { border: 0; background: none; color: var(--db-muted-3); cursor: pointer; font-size: .75rem; }

/* Saved events as a timeline */
.mg-timeline { position: relative; margin-bottom: 1.25rem; }
.mg-tl { position: relative; display: grid; grid-template-columns: 4.2rem 1rem minmax(0, 1fr) auto; gap: 0 .8rem; padding-bottom: 1.5rem; animation: mg-rise .6s var(--mg-ease) both; }
.mg-tl::before { /* connecting line */
    content: '';
    position: absolute;
    left: calc(4.2rem + .8rem + .5rem - 1px);
    top: 1.1rem;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--mg-hero-a) 40%, transparent), transparent);
}
.mg-tl:last-child::before { display: none; }
.mg-tl__time { font-family: var(--mg-hand); font-size: 1.25rem; color: #6a5ca6; text-align: right; padding-top: .1rem; white-space: nowrap; }
.mg-tl__dot { width: 1rem; height: 1rem; margin-top: .35rem; border-radius: 50%; background: #fff; border: 3px solid var(--mg-hero-a); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mg-hero-a) 18%, transparent); }
.mg-tl__meta { font-size: .75rem; color: var(--db-muted-2); margin-bottom: .2rem; }
.mg-tl__meta i { color: #e0701f; }
.mg-tl__text { font-family: 'Source Serif 4', Georgia, serif; font-size: 1rem; line-height: 1.7; color: var(--db-text); }
.mg-tl__del { align-self: flex-start; border: 0; background: none; color: var(--db-muted-3); cursor: pointer; padding: .3rem; border-radius: 8px; opacity: .5; transition: opacity .15s ease, color .15s ease; }
.mg-tl:hover .mg-tl__del { opacity: 1; }
.mg-tl__del:hover { color: var(--db-mood-rough); }

.mg-addevent {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: .7rem;
    padding: 1rem; border-radius: 16px;
    border: 1.5px dashed #d9cfb6; background: rgba(255, 255, 255, .5);
    font: inherit; font-size: .9rem; font-weight: 600; color: var(--db-muted-2); cursor: pointer;
    transition: all .2s var(--mg-ease);
}
.mg-addevent:hover { border-color: var(--mg-hero-a); color: var(--mg-ink); background: #fff; transform: translateY(-2px); }
.mg-addevent__ico { width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b)); color: #fff; font-size: .75rem; }

/* Composer */
.mg-composer { padding-top: .25rem; }
.mg-composer__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.mg-composer__head .mg-textbtn { margin: 0; }
.mg-title-input {
    width: 100%; border: 0; outline: none; background: transparent;
    font-family: 'Source Serif 4', Georgia, serif; font-size: 1.5rem; font-weight: 600; color: var(--db-text);
    padding: .3rem 0 .6rem; margin-bottom: .4rem; border-bottom: 1px solid #ebe4d3;
}
.mg-title-input::placeholder { color: #c2b9a3; }
.mg-compose { position: relative; }
.mg-compose__area {
    min-height: 220px;
    padding: .2rem .1rem 1.5rem;
    outline: none;
    font-size: 1.02rem;
    color: #1d2647;
    caret-color: #1f3f8a;
}
.mg-composer .db-ruled { background-image: repeating-linear-gradient(to bottom, transparent, transparent 1.7rem, rgba(70, 110, 160, .2) 1.7rem, rgba(70, 110, 160, .2) calc(1.7rem + 1px)); }

/* Handwriting mode */
.mg-hand .mg-compose__area,
.mg-hand .mg-tl__text { font-family: var(--mg-hand); font-size: 1.45rem; line-height: 1.7rem; color: #1f3f8a; }
.mg-hand .mg-tl__text { line-height: 1.9rem; }
.mg-hand .mg-compose__area h1, .mg-hand .mg-tl__text h1 { font-family: var(--mg-hand); font-size: 1.9rem; }
.mg-hand .mg-title-input { font-family: var(--mg-hand); font-size: 2rem; color: #1f3f8a; }

/* The pen: its nib sits at the element's origin, which is moved to the caret */
.mg-pen {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    z-index: 3;
    pointer-events: none;
    transition: transform .16s cubic-bezier(.3, .7, .3, 1), opacity .3s ease;
}
.mg-pen svg {
    position: absolute;
    left: 0;
    top: -6px;
    width: 66px;
    height: 12px;
    transform-origin: 0 50%;
    transform: rotate(-52deg);
    filter: drop-shadow(3px 6px 4px rgba(20, 20, 50, .25));
    transition: transform .3s var(--mg-ease);
}
.mg-pen.is-writing svg { animation: mg-scribble .32s ease-in-out infinite; }
.mg-pen.is-resting {
    /* laid down on the paper at the bottom-right corner */
    transform: translate(calc(100cqw - 80px), 200px);
    opacity: .9;
}
.mg-compose { container-type: inline-size; }
.mg-pen.is-resting svg { transform: rotate(-18deg); }
@keyframes mg-scribble {
    0%   { transform: rotate(-52deg) translate(0, 0); }
    25%  { transform: rotate(-55deg) translate(-1px, 1px); }
    50%  { transform: rotate(-50deg) translate(1px, -1px); }
    75%  { transform: rotate(-54deg) translate(0, 1px); }
    100% { transform: rotate(-52deg) translate(0, 0); }
}
.mg-ink {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #1f3f8a;
    pointer-events: none;
    animation: mg-ink .9s ease-out forwards;
}
@keyframes mg-ink { 0% { transform: scale(1.4); opacity: .8; } 100% { transform: scale(.2) translateY(4px); opacity: 0; } }

.mg-location { display: flex; align-items: center; gap: .55rem; margin-top: .9rem; padding: .55rem .8rem; border-radius: 12px; background: rgba(255, 255, 255, .7); border: 1px solid #ebe4d3; }
.mg-location i { color: #e0701f; font-size: .85rem; }
.mg-location input { flex: 1; border: 0; outline: none; background: transparent; font: inherit; font-size: .88rem; color: var(--db-text); }
.mg-composer__foot { display: flex; justify-content: flex-end; margin-top: 1rem; }
.mg-save {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .8rem 1.4rem; border: 0; border-radius: 14px;
    background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b));
    color: #fff; font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer;
    box-shadow: 0 14px 30px -14px var(--mg-hero-b);
    transition: transform .2s var(--mg-ease), box-shadow .2s ease;
}
.mg-save:hover { transform: translateY(-2px); box-shadow: 0 18px 36px -14px var(--mg-hero-b); }
.mg-save:disabled { opacity: .7; cursor: wait; transform: none; }

@media (max-width: 720px) {
    .mg-writebar { padding: .55rem .9rem; }
    .mg-writebar__close span { display: none; }
    .mg-write-wrap { padding: 1rem .75rem 5rem; }
    .mg-sheet { padding: 1.4rem 1.1rem 1.4rem 2.6rem; border-radius: 8px 18px 18px 8px; }
    .mg-sheet::before { left: .45rem; width: 1.1rem; background-size: 1.1rem 1.6rem; background-image: radial-gradient(circle at 50% 50%, #2a2c45 0 .26rem, transparent .28rem); }
    .mg-sheet::after { left: 2rem; }
    .mg-moodpick__row { gap: .35rem; }
    .mg-moodbtn { padding: .65rem .1rem .5rem; font-size: .68rem; border-radius: 12px; }
    .mg-moodbtn i { font-size: 1.35rem; }
    .mg-tl { grid-template-columns: 1rem minmax(0, 1fr) auto; }
    .mg-tl__time { grid-column: 2 / 4; text-align: left; order: -1; font-size: 1.1rem; }
    .mg-tl__dot { grid-row: 1 / 3; grid-column: 1; }
    .mg-tl::before { left: calc(.5rem - 1px); }
    .mg-pen svg { width: 54px; height: 10px; top: -5px; }
    .mg-pen.is-resting { transform: translate(calc(100cqw - 64px), 200px); }
}

/* ==========================================================================
   Diary book reader (assets/js/diary-book.js)
   ========================================================================== */
.db-diary-book { flex-direction: column; height: 100%; min-height: 540px; gap: .9rem; }
.bk-host { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.bk { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.bk__book {
    position: relative;
    perspective: 2400px;
    transform-style: preserve-3d;
    touch-action: pan-y;
    user-select: text;
}
.bk__book.is-dragging, .bk__book.is-turning { user-select: none; cursor: grabbing; }
.bk__book::before { /* leather cover peeking out around the pages */
    content: '';
    position: absolute;
    inset: -12px -12px -14px;
    border-radius: 16px;
    background:
        radial-gradient(120% 80% at 30% 0%, rgba(255, 255, 255, .12), transparent 60%),
        linear-gradient(135deg, color-mix(in srgb, var(--mg-hero-b) 80%, #000), color-mix(in srgb, var(--mg-hero-b) 50%, #000));
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .08) inset;
    z-index: -1;
}
.bk__book:not(.is-spread)::before { inset: -10px -10px -12px -14px; }

.bk__page, .bk__face {
    position: absolute;
    top: 0;
    bottom: 0;
    overflow: hidden;
    background:
        repeating-linear-gradient(to bottom, transparent 0, transparent 1.85rem, rgba(70, 110, 160, .14) 1.85rem, rgba(70, 110, 160, .14) calc(1.85rem + 1px)),
        linear-gradient(180deg, #fffdf6, #f6efdf);
    background-position: 0 4.6rem, 0 0;
}
.bk__page--left { left: 0; width: 50%; border-radius: 6px 0 0 6px; }
.bk__page--right { left: 50%; width: 50%; border-radius: 0 6px 6px 0; }
.bk__book:not(.is-spread) .bk__page--left { display: none; }
.bk__book:not(.is-spread) .bk__page--right { left: 0; width: 100%; border-radius: 4px 10px 10px 4px; }

/* Gutter shading toward the spine */
.bk-side-l { box-shadow: inset -26px 0 30px -22px rgba(60, 40, 20, .35); }
.bk-side-r { box-shadow: inset 26px 0 30px -22px rgba(60, 40, 20, .35); }
.bk__book:not(.is-spread) .bk-side-r { box-shadow: inset 14px 0 18px -14px rgba(60, 40, 20, .3); }

.bk__spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-1px);
    background: linear-gradient(180deg, rgba(60, 40, 20, .25), rgba(60, 40, 20, .45), rgba(60, 40, 20, .25));
    z-index: 2;
    pointer-events: none;
}
.bk__book:not(.is-spread) .bk__spine { display: none; }

/* Turning leaf */
.bk__leaf { position: absolute; top: 0; bottom: 0; z-index: 6; transform-style: preserve-3d; will-change: transform; pointer-events: none; }
.bk__leaf--right { left: 50%; width: 50%; transform-origin: left center; }
.bk__leaf--left { left: 0; width: 50%; transform-origin: right center; }
.bk__leaf--full { left: 0; width: 100%; transform-origin: left center; }
.bk__face { left: 0; right: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bk__face--back { transform: rotateY(180deg); }
.bk__leaf--right .bk__face--front, .bk__leaf--full .bk__face--front { border-radius: 0 6px 6px 0; }
.bk__leaf--left .bk__face--front { border-radius: 6px 0 0 6px; }
.bk__shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(90deg, rgba(20, 14, 40, .9), rgba(20, 14, 40, .35) 60%, rgba(255, 255, 255, .15));
}
.bk__face--back .bk__shade { background: linear-gradient(270deg, rgba(20, 14, 40, .9), rgba(20, 14, 40, .35) 60%, rgba(255, 255, 255, .15)); }
.bk__cast { position: absolute; top: 0; bottom: 0; z-index: 5; opacity: 0; pointer-events: none; }
.bk__cast--r { left: 50%; width: 50%; background: linear-gradient(90deg, rgba(20, 14, 40, .55), transparent 70%); }
.bk__cast--l { left: 0; width: 50%; background: linear-gradient(270deg, rgba(20, 14, 40, .55), transparent 70%); }
.bk__cast--full { left: 0; width: 100%; background: linear-gradient(90deg, rgba(20, 14, 40, .45), transparent 60%); }

/* Clickable page edges with a curling-corner hint */
.bk__edge {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 44px;
    z-index: 4;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}
.bk__edge--prev { left: 0; }
.bk__edge--next { right: 0; }
.bk__edge::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 0;
    height: 0;
    transition: width .25s var(--mg-ease), height .25s var(--mg-ease);
}
.bk__edge--next::after { right: 0; background: linear-gradient(135deg, transparent 50%, #e9e0c9 50%, #fffaf0 80%); border-radius: 10px 0 6px 0; box-shadow: -3px -3px 8px rgba(0, 0, 0, .12); }
.bk__edge--prev::after { left: 0; background: linear-gradient(225deg, transparent 50%, #e9e0c9 50%, #fffaf0 80%); border-radius: 0 10px 0 6px; box-shadow: 3px -3px 8px rgba(0, 0, 0, .12); }
.bk__edge:hover::after { width: 46px; height: 46px; }
.bk__book.at-start .bk__edge--prev, .bk__book.at-end .bk__edge--next { cursor: default; }
.bk__book.at-start .bk__edge--prev::after, .bk__book.at-end .bk__edge--next::after { display: none; }
.bk__book.is-turning .bk__edge::after { display: none; }
@media (hover: none) { .bk__edge::after { width: 26px; height: 26px; } }

.bk-bump-r { animation: bk-bump-r .35s ease; }
.bk-bump-l { animation: bk-bump-l .35s ease; }
@keyframes bk-bump-r { 30% { transform: translateX(-8px); } 60% { transform: translateX(3px); } }
@keyframes bk-bump-l { 30% { transform: translateX(8px); } 60% { transform: translateX(-3px); } }

/* Page content */
.bk-paper { height: 100%; overflow-y: auto; padding: 1.6rem 2rem 1.4rem; color: #1d2647; overscroll-behavior: contain; }
.bk-side-l .bk-paper { padding-right: 2.4rem; }
.bk-side-r .bk-paper { padding-left: 2.4rem; }
.bk-paper img { -webkit-user-drag: none; user-select: none; }
.bk-paper__head { margin-bottom: 1rem; padding-bottom: .5rem; }
.bk-paper__day { font-family: var(--mg-hand); font-size: 1.5rem; line-height: 1; color: #6a5ca6; }
.bk-paper__date { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.55rem; font-weight: 600; margin: .1rem 0 .35rem; }
.bk-paper__mood { display: inline-block; font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); padding: .18rem .55rem; border-radius: 999px; }
.bk-paper__empty { font-family: var(--mg-hand); font-size: 1.4rem; color: #8b93a8; }
.bk-ev { margin-bottom: 1.3rem; }
.bk-ev__meta { font-family: var(--mg-hand); font-size: 1.2rem; color: #6a5ca6; }
.bk-ev__title { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.15rem; font-weight: 600; margin: .1rem 0 .3rem; }
.bk-ev__body { font-family: 'Source Serif 4', Georgia, serif; font-size: .98rem; line-height: 1.85rem; }
.bk-ev__photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; margin-top: .6rem; }
.bk-ev__photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 4px solid #fff; box-shadow: 0 6px 14px -6px rgba(0, 0, 0, .35); transform: rotate(-1.5deg); }
.bk-ev__photos img:nth-child(even) { transform: rotate(1.5deg); }
.bk-ev__video { width: 100%; border-radius: 8px; background: #000; margin-top: .6rem; }
.bk-ev__tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.bk-paper__note { font-family: var(--mg-hand); font-size: 1.3rem; color: #1f3f8a; white-space: pre-wrap; margin: 0 0 .6rem; }
.bk-paper__foot { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; font-size: .75rem; color: #9a917c; }
.bk-paper__foot a { color: #4f62c9; font-weight: 600; text-decoration: none; }
.bk-paper__foot span { font-family: 'Source Serif 4', Georgia, serif; font-style: italic; }
.bk-paper--blank, .bk-paper--back { display: flex; align-items: center; justify-content: center; text-align: center; }
.bk-paper--blank p { font-family: var(--mg-hand); font-size: 1.6rem; color: #9a917c; }
.bk-paper--back { background: linear-gradient(180deg, #f4ecd9, #ece2ca); }

/* Controls under the book */
.bk-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .75rem;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding: .5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
}
.bk-ctl {
    flex: 0 0 auto;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    border: 0;
    background: #fff;
    color: var(--mg-ink);
    cursor: pointer;
    font-size: .9rem;
    transition: transform .2s var(--mg-ease), box-shadow .2s ease;
}
.bk-ctl:hover { transform: scale(1.08); box-shadow: 0 0 18px color-mix(in srgb, var(--mg-accent) 60%, transparent); }
.bk-controls__mid { flex: 1; min-width: 0; text-align: center; }
.bk-controls__label { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: .95rem; }
.bk-controls__hint { font-size: .7rem; color: rgba(255, 255, 255, .7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-layout { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .14); }
.bk-layout button { border: 0; background: none; color: rgba(255, 255, 255, .85); width: 2.1rem; height: 2.1rem; border-radius: 50%; cursor: pointer; }
.bk-layout button.is-active { background: #fff; color: var(--mg-ink); }
@media (max-width: 819px) {
    .bk-layout { display: none; }
    .db-diary-book { min-height: calc(100dvh - 260px); }
    .bk-paper { padding: 1.2rem 1.1rem 1.1rem 1.6rem; }
    .bk-controls__hint { display: none; }
}

.mg-pentoggle {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .38rem .75rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25);
    background: transparent; color: rgba(255, 255, 255, .75); font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer;
}
.mg-pentoggle.is-on { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .4); }
.mg-pentoggle.is-on i { color: var(--mg-accent); }
@media (max-width: 720px) { .mg-pentoggle span { display: none; } .mg-pentoggle { padding: .38rem .6rem; } }

/* ==========================================================================
   Dashboard v3 — compact; fits one screen on desktop, panels scroll inside
   ========================================================================== */
.dash { max-width: 1480px; margin: 0 auto; padding: 1.1rem 1.5rem 1.5rem; }
.dash__inner { display: flex; flex-direction: column; gap: 1rem; }
.dash__top { display: flex; align-items: center; justify-content: space-between; gap: .8rem 1.5rem; flex-wrap: wrap; color: #fff; }
.dash__hello h1 { margin: 0; font-family: 'Source Serif 4', Georgia, serif; font-size: clamp(1.4rem, 2.2vw, 1.85rem); font-weight: 600; text-shadow: 0 2px 16px rgba(0, 0, 0, .25); }
.dash__hello p { margin: .15rem 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .9rem; font-size: .88rem; color: rgba(255, 255, 255, .8); }
.dash__moon { display: inline-flex; align-items: center; gap: .35rem; font-family: var(--mg-hand); font-size: 1.15rem; color: var(--mg-accent); }
.dash__chips { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.dash-chip { padding: .4rem .75rem; border-radius: 999px; font-size: .76rem; color: rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.dash-chip b { font-family: 'Source Serif 4', Georgia, serif; font-size: .95rem; color: #fff; margin-right: .15rem; }
.dash__chips .mg-themes button { padding: .38rem .55rem; }

.dash__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(300px, 1.05fr);
    grid-template-rows: minmax(250px, .9fr) minmax(280px, 1.1fr);
    grid-template-areas:
        "today today streak pins"
        "plan  spend memory ai";
    gap: 1rem;
}
.dash__grid > :nth-child(1) { grid-area: today; }
.dash__grid > :nth-child(2) { grid-area: streak; }
.dash__grid > :nth-child(3) { grid-area: pins; }
.dash__grid > :nth-child(4) { grid-area: ai; }
.dash__grid > :nth-child(5) { grid-area: plan; }
.dash__grid > :nth-child(6) { grid-area: spend; }
.dash__grid > :nth-child(7) { grid-area: memory; }

/* Desktop: the whole dashboard fits the window; long lists scroll inside their card */
@media (min-width: 1100px) and (min-height: 680px) {
    body.db-magic .db-main:has(.dash) { overflow: hidden; }
    .dash { height: 100%; }
    .dash > .dash__inner, .dash__inner { height: 100%; }
    .dash__grid { flex: 1; min-height: 0; }
    body.db-magic:has(.dash) .db-fab { display: none; }
}

.dash-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-radius: 20px !important; }
.dash-card__head { flex: 0 0 auto; display: flex; align-items: center; gap: .55rem; padding: .85rem 1rem .6rem; }
.dash-card__title { margin: 0; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.05rem; font-weight: 600; }
.dash-card__body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 1rem .8rem; }
.dash-card__foot { flex: 0 0 auto; padding: .6rem 1rem .8rem; border-top: 1px solid var(--db-border); }
.dash-card .mg-item { padding: .45rem .45rem; }

.dash-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--db-bg); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.dash-tabs button { flex: 0 0 auto; border: 0; background: none; padding: .35rem .6rem; border-radius: 9px; font: inherit; font-size: .78rem; font-weight: 600; color: var(--db-muted-2); cursor: pointer; white-space: nowrap; }
.dash-tabs button em { font-style: normal; font-size: .68rem; margin-left: .15rem; padding: 0 .35rem; border-radius: 999px; background: rgba(0, 0, 0, .06); }
.dash-tabs button.is-active { background: #fff; color: var(--mg-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.dash-seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--db-bg); }
.dash-seg button { border: 0; background: none; padding: .28rem .55rem; border-radius: 8px; font: inherit; font-size: .74rem; font-weight: 600; color: var(--db-muted-2); cursor: pointer; }
.dash-seg button.is-active { background: var(--mg-ink); color: #fff; }

/* Today's page */
.dash-today { display: flex; border-radius: 22px; padding: 8px; background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b)); box-shadow: 0 30px 60px -30px rgba(8, 6, 30, .8); min-height: 0; }
.dash-today__paper {
    position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
    border-radius: 15px; padding: 1rem 1.2rem 1rem 3rem;
    background: repeating-linear-gradient(to bottom, transparent 0, transparent 1.9rem, rgba(70, 110, 160, .16) 1.9rem, rgba(70, 110, 160, .16) calc(1.9rem + 1px)), linear-gradient(180deg, #fffdf6, #f5eedf);
    background-position: 0 2.6rem, 0 0;
}
.dash-today__paper::before { content: ''; position: absolute; left: .7rem; top: .9rem; bottom: .9rem; width: 1.1rem; background: radial-gradient(circle, rgba(27, 29, 51, .85) 0 .26rem, transparent .28rem) 0 0 / 1.1rem 1.5rem repeat-y; }
.dash-today__paper::after { content: ''; position: absolute; left: 2.35rem; top: 0; bottom: 0; width: 1px; background: rgba(224, 112, 140, .45); }
.dash-today__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.dash-today__moods { display: flex; gap: .3rem; }
.dash-today__moods .mg-face { width: 1.9rem; height: 1.9rem; font-size: .95rem; text-decoration: none; }
.dash-today__moods .mg-face:hover { transform: translateY(-3px) scale(1.08); }
.dash-today__prompt { font-family: var(--mg-hand); font-size: clamp(1.5rem, 2.3vw, 2rem); line-height: 1.9rem; color: #1f3f8a; margin: .55rem 0 .2rem; }
.dash-today__note {
    flex: 1; min-height: 3.8rem; width: 100%; resize: none; border: 0; outline: none; background: transparent;
    font-family: var(--mg-hand); font-size: 1.3rem; line-height: 1.9rem; color: #1f3f8a; padding: 0;
}
.dash-today__note::placeholder { color: #a3acbd; }
.dash-today__actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.dash-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .95rem; border-radius: 12px; border: 0; font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .2s var(--mg-ease), background-color .2s ease; }
.dash-btn:hover { transform: translateY(-1px); }
.dash-btn:disabled { opacity: .5; cursor: default; transform: none; }
.dash-btn--ghost { background: rgba(255, 255, 255, .8); color: var(--db-muted-2); border: 1px solid #e6dfcd; }
.dash-btn--ink { background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b)); color: #fff; }

/* Streak (dark glass) */
.dash-streak { display: flex; flex-direction: column; gap: .8rem; padding: 1rem 1.1rem; border-radius: 22px; color: #fff; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); min-height: 0; }
.dash-streak .mg-streak__num { font-size: 2.2rem; }
.dash-streak .mg-heat { flex: 1; min-height: 0; align-items: center; }
.dash-streak .mg-heat .db-heat-cell { max-width: 13px; }

/* Insights */
.dash-charts { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .8rem; }
.dash-charts .db-chart-box { padding: .6rem .7rem; }
.dash-ai__overview { font-family: 'Source Serif 4', Georgia, serif; font-size: .98rem; line-height: 1.55; margin: 0 0 .7rem; }
.dash-ai__lists { display: flex; flex-direction: column; gap: .55rem; }
.dash-ai__lists .db-ai-col__title { margin-bottom: .2rem; }
.dash-ai__lists .db-ai-list { font-size: .8rem; line-height: 1.5; }
.dash-ai__history { display: flex; flex-direction: column; gap: .5rem; margin-top: .8rem; }
.dash-qa { padding: .55rem .7rem; border-radius: 12px; background: var(--db-bg); }
.dash-qa__q { display: flex; justify-content: space-between; gap: .4rem; font-size: .8rem; font-weight: 600; }
.dash-qa__a { font-size: .8rem; color: var(--db-muted-2); line-height: 1.5; margin-top: .2rem; }
.dash-range { display: flex; align-items: center; gap: .4rem; margin-bottom: .7rem; font-size: .75rem; color: var(--db-muted-3); }
.dash-ai .mg-ask textarea { padding: .55rem .75rem; min-height: 2.4rem; }

/* Spending */
.dash-total { display: flex; align-items: baseline; gap: .5rem; margin: 0 0 .5rem; }
.dash-total__num { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.7rem; font-weight: 600; }
.dash-total__label { font-size: .74rem; color: var(--db-muted-3); }

/* Recent pages list */
.dash-page { display: flex; align-items: center; gap: .7rem; padding: .5rem .45rem; border-radius: 12px; text-decoration: none; color: inherit; transition: background-color .15s ease; }
.dash-page:hover { background: var(--db-bg); }
.dash-page__date { flex: 0 0 auto; width: 2.5rem; padding: .25rem 0; text-align: center; border-radius: 10px; background: color-mix(in srgb, var(--c, #c3d3dc) 12%, #fff); border-left: 3px solid var(--c, #c3d3dc); }
.dash-page__date b { display: block; font-family: 'Source Serif 4', Georgia, serif; font-size: 1rem; line-height: 1.1; }
.dash-page__date small { display: block; font-size: .55rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--db-muted-1); }
.dash-page__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-page__title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-page__text { font-size: .76rem; color: var(--db-muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tablet: two columns, page scrolls */
@media (max-width: 1099px) {
    .dash__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: none;
        grid-auto-rows: minmax(300px, auto);
        grid-template-areas: "today today" "streak pins" "plan spend" "memory ai";
    }
    .dash-card__body { max-height: 340px; }
}
/* Phone: one column */
@media (max-width: 720px) {
    .dash { padding: .9rem .85rem 6rem; }
    .dash__grid { grid-template-columns: 1fr; grid-auto-rows: auto; grid-template-areas: "today" "pins" "streak" "plan" "spend" "memory" "ai"; }
    .dash__chips { width: 100%; }
    .dash__chips .mg-themes { width: 100%; justify-content: space-between; }
    .dash-today__paper { padding-left: 2.7rem; }
    .dash-today__note { min-height: 5.7rem; }
    .dash-card__body { max-height: none; }
}
.dash-card__head .dash-tabs button { padding: .32rem .45rem; font-size: .74rem; }
.dash-card__head .dash-tabs button em { margin-left: .1rem; padding: 0 .3rem; }

/* ==========================================================================
   Sign up extras + onboarding steps
   ========================================================================== */
.mg-optional { font-weight: 500; letter-spacing: 0; text-transform: none; color: rgba(255, 255, 255, .5); margin-left: .3rem; }
.mg-hint { font-size: .76rem; color: rgba(255, 255, 255, .6); margin: .4rem 0 0; }
.mg-hint--bad { color: #ffb3bb; }
.mg-strength { display: flex; align-items: center; gap: .3rem; margin-top: .55rem; }
.mg-strength span { flex: 1; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .18); transition: background-color .3s ease; }
.mg-strength em { font-style: normal; font-size: .72rem; font-weight: 700; min-width: 4.2rem; text-align: right; color: rgba(255, 255, 255, .75); }
.mg-strength[data-level="1"] span:nth-child(-n+1) { background: #ff6b7d; }
.mg-strength[data-level="2"] span:nth-child(-n+2) { background: #ffc857; }
.mg-strength[data-level="3"] span { background: #5ee0a8; }
.mg-terms { align-items: flex-start; font-size: .84rem; line-height: 1.45; margin: .4rem 0 1.3rem; }
.mg-terms input { margin-top: .15rem; flex: 0 0 auto; }

.mg-onb {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    padding: clamp(1.25rem, 4vw, 3rem) 1rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}
.mg-onb__card { width: min(100%, 620px); }
.mg-onb__progress { display: flex; gap: .4rem; margin-bottom: .6rem; }
.mg-onb__progress span { flex: 1; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .18); transition: background-color .4s var(--mg-ease); }
.mg-onb__progress span.is-done { background: linear-gradient(90deg, var(--mg-accent), var(--mg-accent-2)); box-shadow: 0 0 10px color-mix(in srgb, var(--mg-accent) 60%, transparent); }
.mg-onb__count { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .6); margin: 0 0 1.2rem; }
.mg-onb__loading { text-align: center; padding: 2.5rem 0; color: rgba(255, 255, 255, .75); }
.mg-onb__step { min-height: 260px; }
.mg-onb__step.from-right { animation: mg-step-r .45s var(--mg-ease) both; }
.mg-onb__step.from-left { animation: mg-step-l .45s var(--mg-ease) both; }
@keyframes mg-step-r { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes mg-step-l { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
.mg-onb__icon {
    width: 3rem; height: 3rem; border-radius: 16px; display: grid; place-items: center; margin-bottom: .9rem;
    background: linear-gradient(135deg, var(--mg-accent), var(--mg-accent-2)); color: var(--mg-ink); font-size: 1.2rem;
    box-shadow: 0 0 26px color-mix(in srgb, var(--mg-accent) 50%, transparent);
}
.mg-onb__title { font-family: 'Source Serif 4', Georgia, serif; font-size: clamp(1.6rem, 4vw, 2.1rem); font-weight: 600; margin: 0 0 .35rem; }
.mg-onb__sub { color: rgba(255, 255, 255, .75); font-size: .92rem; margin: 0 0 1.4rem; }
.mg-choices { display: flex; flex-wrap: wrap; gap: .55rem; }
.mg-choices--stack { flex-direction: column; }
.mg-choice {
    display: inline-flex; align-items: center; gap: .55rem;
    padding: .7rem 1rem; border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08);
    color: #fff; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-align: left;
    transition: transform .2s var(--mg-ease), background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.mg-choice i { font-size: .8rem; color: rgba(255, 255, 255, .6); }
.mg-choice:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .45); }
.mg-choice.is-selected {
    background: linear-gradient(110deg, var(--mg-accent), var(--mg-accent-2));
    border-color: transparent; color: var(--mg-ink);
    box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--mg-accent) 70%, transparent);
}
.mg-choice.is-selected i { color: var(--mg-ink); }
.mg-onb__actions { display: flex; align-items: center; gap: .8rem; margin-top: 1.8rem; }
.mg-onb__next { width: auto; margin-left: auto; padding: .85rem 1.5rem; }
.mg-onb__back, .mg-onb__skip { border: 0; background: none; color: rgba(255, 255, 255, .75); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; padding: .5rem 0; }
.mg-onb__back:hover, .mg-onb__skip:hover { color: #fff; }
@media (max-width: 520px) {
    .mg-onb { justify-content: flex-start; padding-top: max(1.25rem, env(safe-area-inset-top)); }
    .mg-choice { flex: 1 1 calc(50% - .3rem); justify-content: center; }
    .mg-choices--stack .mg-choice { justify-content: flex-start; }
    .mg-onb__step { min-height: 0; }
}

/* ==========================================================================
   Book binding: covers, endpapers, page edges, ribbon, open/closed states
   ========================================================================== */
.bk__book { transition: transform .7s var(--mg-ease); }
.bk__book::before { transition: left .7s var(--mg-ease), right .7s var(--mg-ease), inset .7s var(--mg-ease); }

/* Stacked page edges on the outer sides of an open book */
.bk__book.is-spread .bk__page--left { box-shadow: inset -26px 0 30px -22px rgba(60, 40, 20, .35), -2px 1px 0 #ede4cf, -4px 2px 0 #e2d7bd, -6px 3px 0 #ede4cf, -8px 4px 0 #d9cdb1; }
.bk__book.is-spread .bk__page--right { box-shadow: inset 26px 0 30px -22px rgba(60, 40, 20, .35), 2px 1px 0 #ede4cf, 4px 2px 0 #e2d7bd, 6px 3px 0 #ede4cf, 8px 4px 0 #d9cdb1; }
.bk__book:not(.is-spread) .bk__page--right { box-shadow: inset 14px 0 18px -14px rgba(60, 40, 20, .3), 2px 1px 0 #ede4cf, 4px 2px 0 #e2d7bd, 6px 3px 0 #d9cdb1; }

/* Ribbon bookmark hanging from the spine */
.bk__ribbon {
    position: absolute;
    top: -6px;
    left: calc(50% + 18px);
    width: 14px;
    height: calc(100% + 34px);
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(90deg, #8e1f2f, #c23447 45%, #8e1f2f);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 9px), 0 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
    opacity: .92;
    transform-origin: top center;
    animation: bk-sway 6s ease-in-out infinite;
}
.bk__book:not(.is-spread) .bk__ribbon { left: auto; right: 28px; }
.bk__book.is-closed .bk__ribbon { height: calc(100% + 26px); }
.bk__book.is-closed-back.is-spread .bk__ribbon { left: calc(50% - 32px); }
@keyframes bk-sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(.6deg); } }

/* Hidden halves while a cover is moving / the book is shut */
.bk__book.hide-l .bk__page--left { visibility: hidden; }
.bk__book.hide-r .bk__page--right { visibility: hidden; }

/* Closed book: shrink the cover backing to one page and slide it to the centre */
.bk__book.is-spread.is-closed-front { transform: translateX(-25%); }
.bk__book.is-spread.is-closed-back { transform: translateX(25%); }
.bk__book.is-spread.is-closed-front::before { inset: -8px -12px -12px calc(50% - 4px); }
.bk__book.is-spread.is-closed-back::before { inset: -8px calc(50% - 4px) -12px -12px; }
.bk__book.is-spread.is-closed-front .bk__spine,
.bk__book.is-spread.is-closed-back .bk__spine { opacity: 0; }
.bk__book.is-closed .bk__page { box-shadow: 2px 2px 0 #ede4cf, 4px 4px 0 #d9cdb1, 0 30px 60px -20px rgba(0, 0, 0, .7) !important; }
.bk__book.is-closed { cursor: pointer; }
.bk__book.is-closed-front .bk__edge--prev, .bk__book.is-closed-back .bk__edge--next { display: none; }
.bk__book.is-closed .bk__edge::after { display: none; }
/* At the ends the corner curl hints at closing rather than disappearing */
.bk__book.at-start:not(.is-closed) .bk__edge--prev::after,
.bk__book.at-end:not(.is-closed) .bk__edge--next::after { display: block; }
.bk__book.at-start .bk__edge--prev, .bk__book.at-end .bk__edge--next { cursor: pointer; }

/* Leather cover */
.bk-cover {
    position: relative;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #f3d79a;
    background:
        radial-gradient(120% 90% at 30% 15%, rgba(255, 255, 255, .14), transparent 55%),
        radial-gradient(circle at 20% 80%, rgba(0, 0, 0, .25), transparent 50%),
        repeating-radial-gradient(circle at 37% 61%, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px),
        linear-gradient(140deg, color-mix(in srgb, var(--mg-hero-b) 72%, #1a0f0a), color-mix(in srgb, var(--mg-hero-b) 40%, #0b0610));
    user-select: none;
}
.bk-cover--front { border-radius: 4px 12px 12px 4px; box-shadow: inset 14px 0 18px -10px rgba(0, 0, 0, .55), inset -2px 0 0 rgba(255, 255, 255, .06); }
.bk-cover--back { border-radius: 12px 4px 4px 12px; box-shadow: inset -14px 0 18px -10px rgba(0, 0, 0, .55); }
.bk-cover__frame {
    position: absolute;
    inset: 18px 18px 18px 26px;
    border: 1.5px solid rgba(243, 215, 154, .55);
    border-radius: 6px;
    box-shadow: inset 0 0 0 4px rgba(243, 215, 154, .08), 0 0 0 1px rgba(0, 0, 0, .25);
    pointer-events: none;
}
.bk-cover--back .bk-cover__frame { inset: 18px 26px 18px 18px; }
.bk-cover__frame::before, .bk-cover__frame::after { /* gold corner ornaments */
    content: '';
    position: absolute;
    width: 26px;
    height: 26px;
    border: 2px solid rgba(243, 215, 154, .75);
}
.bk-cover__frame::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.bk-cover__frame::after { bottom: 6px; right: 6px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.bk-cover__center { position: relative; text-align: center; padding: 0 2.5rem; }
.bk-cover__emblem {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    border: 1.5px solid rgba(243, 215, 154, .6);
    background: radial-gradient(circle at 35% 30%, rgba(243, 215, 154, .25), rgba(0, 0, 0, .2));
    box-shadow: 0 0 24px rgba(243, 215, 154, .25);
    text-shadow: 0 1px 0 rgba(0, 0, 0, .5);
}
.bk-cover__emblem--small { width: 44px; height: 44px; font-size: 1rem; }
.bk-cover__title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.6rem, 3.2vw, 2.3rem);
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1.15;
    /* embossed gold */
    background: linear-gradient(180deg, #fff1c9, #e3b965 55%, #b58434);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .55)) drop-shadow(0 -1px 0 rgba(255, 255, 255, .12));
}
.bk-cover__rule { width: 90px; height: 1px; margin: .9rem auto; background: linear-gradient(90deg, transparent, rgba(243, 215, 154, .8), transparent); }
.bk-cover__sub { font-family: var(--mg-hand); font-size: 1.35rem; color: rgba(243, 215, 154, .85); }
.bk-cover__end { font-family: var(--mg-hand); font-size: 1.5rem; color: rgba(243, 215, 154, .8); }
.bk-cover__foot { position: absolute; bottom: 34px; font-size: .68rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: rgba(243, 215, 154, .55); }
.bk-cover__hint {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: .75rem;
    color: rgba(255, 255, 255, .7);
    opacity: 0;
}
.bk__page .bk-cover__hint { position: absolute; bottom: 58px; opacity: .8; animation: bk-hint 2.4s ease-in-out infinite; color: rgba(243, 215, 154, .7); }
@keyframes bk-hint { 0%, 100% { opacity: .35; } 50% { opacity: .9; } }

/* Marbled endpaper (inside of the covers) */
.bk-endpaper {
    height: 100%;
    background:
        radial-gradient(60% 40% at 20% 30%, color-mix(in srgb, var(--mg-hero-a) 55%, transparent), transparent 70%),
        radial-gradient(50% 35% at 75% 65%, color-mix(in srgb, var(--mg-accent-2) 45%, transparent), transparent 70%),
        radial-gradient(40% 30% at 60% 15%, color-mix(in srgb, var(--mg-accent) 40%, transparent), transparent 70%),
        repeating-linear-gradient(115deg, rgba(255, 255, 255, .12) 0 2px, transparent 2px 9px),
        linear-gradient(160deg, #f4ead6, #e8dcc2);
}
.bk__face:has(.bk-cover), .bk__page:has(.bk-cover) { background: none; }
/* Closed: ribbon tucked inside, only its tail shows below the book */
.bk__book.is-closed .bk__page { z-index: 1; }
.bk__book.is-closed .bk__ribbon { z-index: 0; }
.bk__book.is-closed-back .bk__page { box-shadow: -2px 2px 0 #ede4cf, -4px 4px 0 #d9cdb1, 0 30px 60px -20px rgba(0, 0, 0, .7) !important; }

/* ==========================================================================
   Extra themes: galaxy, aurora, blossom, forest, candy, clouds
   Each sets UI tokens + its landscape colours. data-scene picks the landscape.
   ========================================================================== */
.mg-scene {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: clamp(180px, 34vh, 380px);
    opacity: 0;
    transition: opacity 1.4s var(--mg-ease);
}
.mg-scene > * { transition: fill 1.8s var(--mg-ease); }
[data-scene="mountains"] .mg-scene--mountains,
[data-scene="snow"] .mg-scene--snow,
[data-scene="ocean"] .mg-scene--ocean,
[data-scene="hills"] .mg-scene--hills,
[data-scene="city"] .mg-scene--city,
[data-scene="clouds"] .mg-scene--clouds { opacity: 1; }
:root:not([data-scene]) .mg-scene--mountains { opacity: 1; }

[data-sky="galaxy"] {
    --mg-accent: #a9bcff; --mg-accent-2: #d7a2ff;
    --mg-hero-a: #4b3fb5; --mg-hero-b: #141b4d; --mg-ink: #141737;
    --mg-sun-op: 0; --mg-moon-op: .9; --mg-moon-top: 8%;
    --mg-sea-a: #2a3f9e; --mg-sea-b: #0b1240;
    --mg-aurora: radial-gradient(50% 35% at 70% 25%, rgba(190, 120, 255, .3), transparent 70%), radial-gradient(45% 30% at 25% 40%, rgba(90, 140, 255, .28), transparent 70%);
}
[data-sky="aurora"] {
    --mg-accent: #7cf5c8; --mg-accent-2: #8fb8ff;
    --mg-hero-a: #1f7a78; --mg-hero-b: #13234a; --mg-ink: #0d1b2a;
    --mg-sun-op: 0; --mg-moon-op: .7; --mg-moon-top: 7%;
    --mg-aurora: radial-gradient(60% 30% at 50% 20%, rgba(80, 255, 190, .12), transparent 70%);
}
[data-sky="blossom"] {
    --mg-accent: #ffe1ec; --mg-accent-2: #ffbf9e;
    --mg-hero-a: #e66f9a; --mg-hero-b: #8a4a8f; --mg-ink: #4a1f3d;
    --mg-sun-op: .7; --mg-moon-op: 0; --mg-moon-top: 9%;
    --mg-aurora: radial-gradient(60% 40% at 30% 20%, rgba(255, 255, 255, .35), transparent 70%);
}
[data-sky="forest"] {
    --mg-accent: #d6f7a8; --mg-accent-2: #ffe08a;
    --mg-hero-a: #3f8f5c; --mg-hero-b: #1d4a3a; --mg-ink: #13301f;
    --mg-sun-op: .65; --mg-moon-op: 0; --mg-moon-top: 9%;
    --mg-aurora: radial-gradient(50% 50% at 75% 10%, rgba(255, 250, 200, .4), transparent 70%);
}
[data-sky="candy"] {
    --mg-accent: #ffe066; --mg-accent-2: #ff9fd0;
    --mg-hero-a: #ff6fae; --mg-hero-b: #5b6cff; --mg-ink: #3b1d5c;
    --mg-sun-op: .5; --mg-moon-op: 0; --mg-moon-top: 9%;
    --mg-aurora: radial-gradient(40% 35% at 50% 60%, rgba(255, 255, 255, .45), transparent 70%);
}
[data-sky="clouds"] {
    --mg-accent: #ffd9ea; --mg-accent-2: #b4ecff;
    --mg-hero-a: #5aa9cc; --mg-hero-b: #d87aa8; --mg-ink: #23415a;
    --mg-sun-op: .45; --mg-moon-op: 0; --mg-moon-top: 9%;
    --mg-aurora: radial-gradient(60% 40% at 50% 30%, rgba(255, 255, 255, .35), transparent 70%);
}

.mg-sky__grad[data-t="galaxy"]  { background: linear-gradient(180deg, #04081f 0%, #160f47 32%, #2b2a86 58%, #3550b5 72%, #0d1546 100%); }
.mg-sky__grad[data-t="aurora"]  { background: linear-gradient(180deg, #01060f 0%, #061c30 45%, #0c3a50 75%, #1a5866 100%); }
.mg-sky__grad[data-t="blossom"] { background: linear-gradient(180deg, #c95f8d 0%, #ec97b6 34%, #f9c9d4 66%, #fff0e6 100%); }
.mg-sky__grad[data-t="forest"]  { background: linear-gradient(180deg, #1c5e5a 0%, #3f9682 38%, #9fd2a0 72%, #eaf5cf 100%); }
.mg-sky__grad[data-t="candy"]   { background: linear-gradient(180deg, #f2649f 0%, #ff9cc6 34%, #b6d3ff 68%, #e9f4ff 100%); }
.mg-sky__grad[data-t="clouds"]  { background: linear-gradient(180deg, #3d97bd 0%, #86c9de 38%, #f5cfe2 72%, #fff3f8 100%); }
[data-sky="galaxy"] .mg-sky__grad[data-t="galaxy"],
[data-sky="aurora"] .mg-sky__grad[data-t="aurora"],
[data-sky="blossom"] .mg-sky__grad[data-t="blossom"],
[data-sky="forest"] .mg-sky__grad[data-t="forest"],
[data-sky="candy"] .mg-sky__grad[data-t="candy"],
[data-sky="clouds"] .mg-sky__grad[data-t="clouds"] { opacity: 1; }

/* Galaxy nebula + milky way band */
.mg-sky__nebula {
    position: absolute;
    inset: -10%;
    opacity: 0;
    transition: opacity 1.8s var(--mg-ease);
    background:
        radial-gradient(30% 22% at 62% 22%, rgba(220, 140, 255, .45), transparent 70%),
        radial-gradient(26% 18% at 45% 34%, rgba(110, 170, 255, .4), transparent 70%),
        radial-gradient(22% 14% at 72% 40%, rgba(255, 170, 230, .25), transparent 70%),
        linear-gradient(120deg, transparent 30%, rgba(200, 210, 255, .12) 45%, rgba(255, 255, 255, .08) 50%, transparent 65%);
    filter: blur(14px);
    animation: mg-drift 30s ease-in-out infinite alternate;
}
[data-sky="galaxy"] .mg-sky__nebula { opacity: 1; }

/* Northern lights ribbons */
.mg-sky__lights { position: absolute; inset: 0; opacity: 0; transition: opacity 2s var(--mg-ease); pointer-events: none; }
[data-sky="aurora"] .mg-sky__lights { opacity: 1; }
.mg-sky__lights i {
    position: absolute;
    left: -20%;
    width: 140%;
    height: 22vh;
    border-radius: 50%;
    filter: blur(22px);
    mix-blend-mode: screen;
    animation: mg-ribbon 14s ease-in-out infinite alternate;
}
.mg-sky__lights i:nth-child(1) { top: 10%; background: linear-gradient(90deg, transparent, rgba(80, 255, 180, .55), rgba(60, 220, 255, .4), transparent); }
.mg-sky__lights i:nth-child(2) { top: 20%; background: linear-gradient(90deg, transparent, rgba(150, 110, 255, .4), rgba(80, 255, 190, .45), transparent); animation-duration: 18s; animation-delay: -4s; }
.mg-sky__lights i:nth-child(3) { top: 4%; height: 14vh; background: linear-gradient(90deg, transparent, rgba(255, 120, 200, .25), rgba(120, 255, 210, .35), transparent); animation-duration: 22s; animation-delay: -9s; }
@keyframes mg-ribbon {
    0% { transform: translateX(-6%) skewY(-4deg) scaleY(.8); }
    50% { transform: translateX(4%) skewY(3deg) scaleY(1.15); }
    100% { transform: translateX(8%) skewY(-2deg) scaleY(.9); }
}

/* Snow scene colours (aurora) */
.mg-s1 { fill: #1d3b52; }
.mg-s-cap { fill: rgba(235, 248, 255, .85); }
.mg-s2 { fill: #13293e; }
.mg-s3 { fill: #0a1726; }

/* Ocean scene (galaxy) */
.mg-horizon { fill: rgba(170, 200, 255, .55); filter: blur(1px); }
.mg-isle { fill: #070c2b; }
.mg-isle--near { fill: #040720; }
.mg-shimmer { fill: rgba(180, 210, 255, .55); animation: mg-shimmer-wave 4s ease-in-out infinite; }
@keyframes mg-shimmer-wave { 0%, 100% { opacity: .15; transform: translateX(0); } 50% { opacity: .8; transform: translateX(10px); } }

/* Hills scene (blossom / forest) */
.mg-h1 { fill: #e3a3bf; } .mg-h2 { fill: #d27fa4; } .mg-h3 { fill: #b8638c; }
.mg-trees circle { fill: #ffc4d8; } .mg-trunk { fill: #8a4d63; }
.mg-flower--0 { fill: #fff; } .mg-flower--1 { fill: #ffe3ef; } .mg-flower--2 { fill: #ffd27a; }
[data-sky="forest"] .mg-h1 { fill: #6fb27e; }
[data-sky="forest"] .mg-h2 { fill: #4a9465; }
[data-sky="forest"] .mg-h3 { fill: #2f7350; }
[data-sky="forest"] .mg-trees circle { fill: #2e6b47; }
[data-sky="forest"] .mg-trunk { fill: #5a4030; }
[data-sky="forest"] .mg-flower--0 { fill: #fff8d0; }
[data-sky="forest"] .mg-flower--1 { fill: #ffd56b; }
[data-sky="forest"] .mg-flower--2 { fill: #ff9f8a; }

/* Candy city */
.mg-bld--0 { fill: #ff8fbf; } .mg-bld--1 { fill: #8fd3ff; } .mg-bld--2 { fill: #ffd27a; } .mg-bld--3 { fill: #b9a0ff; } .mg-bld--4 { fill: #8fe3b8; }
.mg-win { fill: rgba(255, 255, 255, .7); }
.mg-road { fill: #5a4a72; } .mg-road-line { fill: #ffe066; }
.mg-stick { fill: #fff; }
.mg-pop--0 { fill: #ff5f9e; } .mg-pop--1 { fill: #5fc8ff; } .mg-pop--2 { fill: #ffcf3f; } .mg-pop--3 { fill: #a06bff; }
.mg-swirl { fill: none; stroke: rgba(255, 255, 255, .85); stroke-width: 3; }

/* Cotton-candy clouds */
.mg-scene--clouds g { animation: mg-cloud-drift 40s ease-in-out infinite alternate; }
.mg-scene--clouds .mg-c2 { animation-duration: 55s; animation-direction: alternate-reverse; }
.mg-c1 { fill: #f9c4dc; } .mg-c2 { fill: #c5e8f5; } .mg-c3 { fill: #fff3f8; }
@keyframes mg-cloud-drift { from { transform: translateX(-3%); } to { transform: translateX(3%); } }

/* Light themes: keep text on the sky readable */
[data-sky="blossom"] .mg-greet, [data-sky="forest"] .mg-greet, [data-sky="candy"] .mg-greet, [data-sky="clouds"] .mg-greet,
[data-sky="blossom"] .dash__top, [data-sky="forest"] .dash__top, [data-sky="candy"] .dash__top, [data-sky="clouds"] .dash__top { text-shadow: 0 1px 12px rgba(0, 0, 0, .25); }

/* ==========================================================================
   Dashboard: theme picker, sticky note, mood calendar
   ========================================================================== */
.dash-chip--btn { cursor: pointer; font: inherit; font-size: .76rem; font-weight: 600; display: inline-flex; align-items: center; gap: .4rem; color: #fff; transition: background-color .2s ease; }
.dash-chip--btn:hover { background: rgba(255, 255, 255, .22); }
.dash-chip--sticky i { color: #ffe27a; }
.dash-themewrap { position: relative; }
.mg-themepop {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    width: min(92vw, 360px);
    padding: 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, .96);
    color: var(--db-text);
    box-shadow: 0 30px 60px -20px rgba(8, 6, 30, .6);
    text-shadow: none;
}
.mg-themepop__title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 1.05rem; margin-bottom: .6rem; }
.mg-themepop__modes { display: grid; gap: .4rem; margin-bottom: .8rem; }
.mg-themepop__modes button {
    display: flex; align-items: center; gap: .7rem; text-align: left;
    padding: .55rem .7rem; border-radius: 12px; border: 1.5px solid var(--db-border); background: #fff;
    font: inherit; cursor: pointer; color: var(--db-text);
}
.mg-themepop__modes button i { width: 1.9rem; height: 1.9rem; border-radius: 10px; display: grid; place-items: center; background: var(--db-bg); color: var(--mg-hero-a); }
.mg-themepop__modes b { display: block; font-size: .84rem; }
.mg-themepop__modes small { display: block; font-size: .72rem; color: var(--db-muted-2); }
.mg-themepop__modes button.is-active { border-color: var(--mg-hero-a); background: color-mix(in srgb, var(--mg-hero-a) 8%, #fff); }
.mg-themepop__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.mg-swatch { display: flex; flex-direction: column; align-items: center; gap: .3rem; border: 0; background: none; font: inherit; font-size: .66rem; font-weight: 600; color: var(--db-muted-2); cursor: pointer; padding: 0; }
.mg-swatch__art {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, .95);
    font-size: .95rem;
    box-shadow: inset 0 -10px 16px -8px rgba(0, 0, 0, .25);
    transition: transform .2s var(--mg-ease), box-shadow .2s ease;
}
.mg-swatch:hover .mg-swatch__art { transform: translateY(-2px) scale(1.04); }
.mg-swatch.is-active { color: var(--db-text); }
.mg-swatch.is-active .mg-swatch__art { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--mg-hero-a); }
.mg-swatch[data-swatch="dawn"] .mg-swatch__art { background: linear-gradient(180deg, #3b2a6b, #8a4b8f 40%, #e0785a 75%, #f9c27a); }
.mg-swatch[data-swatch="dusk"] .mg-swatch__art { background: linear-gradient(180deg, #1f1d4a, #5e3474 40%, #c2584a 75%, #f7a24b); }
.mg-swatch[data-swatch="twilight"] .mg-swatch__art { background: linear-gradient(180deg, #4a3d8f, #7d6dbd 45%, #b3a2da 80%, #e2d3ef); }
.mg-swatch[data-swatch="night"] .mg-swatch__art { background: linear-gradient(180deg, #050816, #0e1838 45%, #1d2a5c 80%, #3a3a7a); }
.mg-swatch[data-swatch="galaxy"] .mg-swatch__art { background: radial-gradient(60% 40% at 65% 30%, rgba(220, 140, 255, .7), transparent 70%), linear-gradient(180deg, #04081f, #2b2a86 60%, #3550b5 70%, #0d1546); }
.mg-swatch[data-swatch="aurora"] .mg-swatch__art { background: linear-gradient(170deg, transparent 30%, rgba(80, 255, 180, .6) 42%, transparent 55%), linear-gradient(180deg, #01060f, #0c3a50 70%, #1a5866); }
.mg-swatch[data-swatch="blossom"] .mg-swatch__art { background: radial-gradient(circle at 70% 75%, #ffc4d8 0 18%, transparent 19%), linear-gradient(180deg, #c95f8d, #ec97b6 45%, #fff0e6); }
.mg-swatch[data-swatch="forest"] .mg-swatch__art { background: radial-gradient(circle at 30% 80%, #2e6b47 0 20%, transparent 21%), linear-gradient(180deg, #1c5e5a, #3f9682 45%, #eaf5cf); }
.mg-swatch[data-swatch="candy"] .mg-swatch__art { background: radial-gradient(circle at 30% 35%, #ffe066 0 12%, transparent 13%), radial-gradient(circle at 70% 60%, #5fc8ff 0 12%, transparent 13%), linear-gradient(180deg, #f2649f, #ff9cc6 45%, #b6d3ff); }
.mg-swatch[data-swatch="clouds"] .mg-swatch__art { background: radial-gradient(circle at 25% 85%, #fff3f8 0 26%, transparent 27%), radial-gradient(circle at 75% 85%, #f9c4dc 0 24%, transparent 25%), linear-gradient(180deg, #3d97bd, #86c9de 50%, #f5cfe2); }
.mg-themepop__foot { margin: .8rem 0 0; font-size: .7rem; color: var(--db-muted-3); }

/* Today's page — writing only */
.dash-today__sofar {
    display: block; text-decoration: none; color: inherit;
    margin: .5rem 0 0; padding: .5rem .7rem; border-radius: 12px;
    background: rgba(255, 255, 255, .6); border: 1px dashed #e0d5bb;
}
.dash-today__sofar-label { display: block; font-family: var(--mg-hand); font-size: 1.05rem; color: #6a5ca6; line-height: 1; }
.dash-today__sofar b { font-family: 'Source Serif 4', Georgia, serif; font-size: .92rem; }
.dash-today__sofar-text { display: block; font-size: .78rem; color: var(--db-muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-today__paper .dash-today__prompt { flex: 1; }

/* Sticky note dialog */
.mg-sticky-overlay {
    position: fixed; inset: 0; z-index: 80;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    background: rgba(8, 6, 30, .45);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.mg-sticky {
    position: relative;
    width: min(100%, 360px);
    padding: 1.6rem 1.3rem 1.1rem;
    border-radius: 4px 4px 18px 4px;
    background: linear-gradient(170deg, #fff6b8, #ffe887 70%, #ffdc6b);
    color: #4a3b10;
    box-shadow: 0 30px 50px -20px rgba(0, 0, 0, .6), inset 0 -12px 20px -16px rgba(120, 80, 0, .45);
    transform: rotate(-1.5deg);
    animation: mg-sticky-in .45s var(--mg-ease) both;
}
@keyframes mg-sticky-in { from { opacity: 0; transform: rotate(-6deg) translateY(20px) scale(.92); } to { opacity: 1; transform: rotate(-1.5deg); } }
.mg-sticky__pin {
    position: absolute; top: -10px; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ff9a9a, #d62d4b 60%, #8e1f2f);
    box-shadow: 0 4px 6px rgba(0, 0, 0, .35);
}
.mg-sticky h3 { margin: 0 0 .25rem; font-family: var(--mg-hand); font-size: 1.8rem; line-height: 1; }
.mg-sticky__sub { margin: 0 0 .8rem; font-size: .78rem; color: #6b5a22; }
.mg-sticky__sub a { color: #4a3b10; font-weight: 700; }
.mg-sticky textarea {
    width: 100%; min-height: 130px; resize: none; border: 0; outline: none; background:
        repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.9rem - 1px), rgba(120, 90, 20, .22) calc(1.9rem - 1px), rgba(120, 90, 20, .22) 1.9rem);
    font-family: var(--mg-hand); font-size: 1.35rem; line-height: 1.9rem; color: #3a2e08;
}
.mg-sticky textarea::placeholder { color: rgba(74, 59, 16, .45); }
.mg-sticky__actions { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; }
.mg-sticky__saved { font-size: .78rem; font-weight: 700; color: #2f7a3b; margin-right: auto; }
.mg-sticky__cancel { margin-left: auto; border: 0; background: none; font: inherit; font-size: .82rem; font-weight: 600; color: #6b5a22; cursor: pointer; }
.mg-sticky__save { border: 0; border-radius: 10px; padding: .55rem 1rem; background: #4a3b10; color: #fff6b8; font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; }
.mg-sticky__save:disabled { opacity: .5; cursor: default; }

/* Mood calendar (dark glass card on the sky) */
.dash-cal {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    padding: .9rem 1rem .8rem;
    border-radius: 22px;
    color: #fff;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    min-height: 0;
}
.dash-cal__head { display: flex; align-items: center; gap: .35rem; }
.dash-cal__month { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 1rem; min-width: 0; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-cal__nav { width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; font-size: .7rem; }
.dash-cal__nav:disabled { opacity: .3; cursor: default; }
.dash-cal__streak { display: inline-flex; align-items: center; gap: .3rem; margin-left: .2rem; padding: .25rem .55rem; border-radius: 999px; background: rgba(255, 255, 255, .14); font-size: .8rem; }
.dash-cal__streak i { color: var(--mg-accent); }
.dash-cal__dow, .dash-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dash-cal__dow span { text-align: center; font-size: .6rem; font-weight: 700; letter-spacing: .08em; color: rgba(255, 255, 255, .55); }
.dash-cal__grid { flex: 1; min-height: 0; grid-auto-rows: 1fr; }
.dash-cal__day {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 24px;
    border-radius: 10px;
    font-size: .76rem;
    font-weight: 600;
    color: rgba(255, 255, 255, .8);
    text-decoration: none;
    transition: transform .18s var(--mg-ease), background-color .2s ease, box-shadow .2s ease;
}
.dash-cal__day:not(.is-blank):hover, .dash-cal__day:focus-visible { transform: scale(1.12); background: rgba(255, 255, 255, .18); outline: none; z-index: 1; }
.dash-cal__day.is-blank { pointer-events: none; }
.dash-cal__day.is-future { color: rgba(255, 255, 255, .35); }
.dash-cal__day.has-entry { background: rgba(255, 255, 255, .2); color: #fff; }
.dash-cal__day.has-mood { background: var(--c); color: #fff; box-shadow: 0 0 10px -2px var(--c); text-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.dash-cal__day.has-mood:hover { background: var(--c); box-shadow: 0 0 16px 0 var(--c); }
.dash-cal__day.is-today { box-shadow: 0 0 0 2px var(--mg-accent), 0 0 12px var(--mg-accent); }
.dash-cal__legend { display: flex; justify-content: center; flex-wrap: wrap; gap: .3rem .7rem; font-size: .6rem; color: rgba(255, 255, 255, .7); }
.dash-cal__legend > span { display: inline-flex; align-items: center; gap: .25rem; }
.dash-cal__legend i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.dash-cal__tip {
    position: absolute;
    z-index: 20;
    padding: .75rem .85rem .7rem;
    border-radius: 16px;
    background: linear-gradient(180deg, #fffdf7, #f6efdf);
    color: var(--db-text);
    box-shadow: 0 24px 44px -16px rgba(8, 6, 30, .75), 0 0 0 1px rgba(255, 255, 255, .5);
    pointer-events: none;
    text-shadow: none;
}
.dash-cal__tip-date { font-family: var(--mg-hand); font-size: 1.2rem; color: #6a5ca6; line-height: 1.1; margin-bottom: .2rem; }
.dash-cal__tip-mood { display: inline-block; font-size: .58rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c); background: color-mix(in srgb, var(--c) 14%, #fff); padding: .15rem .5rem; border-radius: 999px; margin-bottom: .3rem; }
.dash-cal__tip-title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: .95rem; margin-bottom: .2rem; }
.dash-cal__tip-text { font-size: .78rem; line-height: 1.45; color: var(--db-muted-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.dash-cal__tip-open { margin-top: .4rem; font-size: .7rem; font-weight: 700; color: #4f62c9; }
@media (hover: hover) { .dash-cal__tip-open { display: none; } }
@media (max-width: 720px) { .dash-cal__grid { grid-auto-rows: 38px; } .mg-themepop { right: auto; left: 0; } }
/* Keep the top bar (theme picker popover) above the animated cards */
.dash__top { position: relative; z-index: 30; }

/* ==========================================================================
   Flowing book pages (assets/js/diary-paginate.js)
   ========================================================================== */
.bk-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }
.bk-measure .bk__page { position: relative; left: 0; }
.bk-paper--flow { overflow: hidden; position: relative; padding-bottom: 2.6rem; }
.bk-flow > :first-child { margin-top: 0; }
.bk-flow p { margin: 0 0 .55rem; }
.bk-flow .bk-li { margin: 0; padding-left: 1.4rem; }
.bk-flow .bk-li + :not(.bk-li) { margin-top: .5rem; }
.bk-flow h1 { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.3rem; margin: .4rem 0 .3rem; }
.bk-flow h2 { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--db-muted-1); margin: .6rem 0 .25rem; }
.bk-flow, .bk-flow p, .bk-flow li { font-family: 'Source Serif 4', Georgia, serif; font-size: .98rem; line-height: 1.85rem; color: #1d2647; }
.bk-ev__head { margin-top: .7rem; }
.bk-cont { font-family: var(--mg-hand); font-size: 1.1rem; color: #8b7fbf; margin-bottom: .35rem; }
.bk-more { position: absolute; right: 1.5rem; bottom: .75rem; font-family: var(--mg-hand); font-size: 1.05rem; color: #6a5ca6; }
.bk-more i { font-size: .7rem; }
.bk-pnum {
    position: absolute;
    left: 0;
    right: 0;
    bottom: .8rem;
    text-align: center;
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: .75rem;
    color: #a39a84;
    pointer-events: none;
}
.bk-photo { margin: .7rem 0; text-align: center; }
.bk-photo img {
    display: inline-block;
    max-width: 100%;
    width: auto;
    height: auto;
    border: 6px solid #fff;
    border-radius: 4px;
    box-shadow: 0 10px 22px -10px rgba(0, 0, 0, .45);
    transform: rotate(-.8deg);
}
.bk-photo:nth-of-type(even) img { transform: rotate(.8deg); }
.bk-flow .bk-ev__video { display: block; width: 100%; margin: .6rem 0; }
.bk-audio { display: block; width: 100%; margin: .6rem 0; }
.bk-doc { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; padding: .5rem .7rem; border-radius: 10px; background: #fff; border: 1px solid #ebe4d3; color: var(--db-text); text-decoration: none; font-family: 'Inter', sans-serif; font-size: .82rem; }
.bk-doc span { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--db-file-bg); color: var(--db-file-text); font-size: .6rem; font-weight: 700; }
.bk-endday { display: flex; justify-content: space-between; align-items: center; margin-top: .8rem; font-family: 'Inter', sans-serif; font-size: .74rem; color: #b5ab92; }
.bk-endday a { color: #4f62c9; font-weight: 600; text-decoration: none; }
.bk-flow .bk-paper__note { font-family: var(--mg-hand); font-size: 1.3rem; line-height: 1.85rem; color: #1f3f8a; }

/* ---- Dashboard fixes: no overflow between cards, clearer calendar, chat bubbles ---- */
.dash__grid > * { min-width: 0; }
.dash-today, .dash-today__paper { min-width: 0; }
.dash-today__sofar { min-width: 0; overflow: hidden; }
.dash-today__sofar-text { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dash-today__sofar b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Darker glass so mood colours read the same on light and dark themes */
.dash-cal { background: rgba(14, 10, 40, .5); border-color: rgba(255, 255, 255, .16); }
.dash-cal__day.has-mood { color: #fff; font-weight: 700; }
.dash-cal__day.is-today:not(.has-mood) { background: rgba(255, 255, 255, .12); color: #fff; }

/* To-do and list titles may wrap to two lines instead of cutting off */
.dash-card .mg-item__title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dash-card .mg-when { margin-left: auto; }

/* Insights Q&A as chat bubbles */
.dash-ai__history { gap: .7rem; }
.dash-qa { padding: 0; background: none; display: flex; flex-direction: column; gap: .35rem; }
.dash-qa__q {
    align-self: flex-end;
    display: flex; align-items: flex-start; gap: .3rem;
    max-width: 88%;
    padding: .55rem .8rem;
    border-radius: 16px 16px 4px 16px;
    background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b));
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.4;
}
.dash-qa__q .mg-del { color: rgba(255, 255, 255, .7); width: 1.2rem; height: 1.2rem; font-size: .7rem; order: 2; }
.dash-qa__q .mg-del:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.dash-qa:hover .mg-del { opacity: 1; }
.dash-qa__a {
    align-self: flex-start;
    display: flex; gap: .5rem; align-items: flex-start;
    max-width: 92%;
    padding: .6rem .8rem;
    border-radius: 16px 16px 16px 4px;
    background: var(--db-bg);
    border: 1px solid var(--db-border);
    font-size: .82rem;
    line-height: 1.5;
    color: var(--db-text);
}
.dash-qa__bot { flex: 0 0 auto; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font-size: .65rem; color: #fff; background: linear-gradient(135deg, #22b2d6, var(--db-navy)); }
.dash-ai .dash-card__foot { background: rgba(255, 255, 255, .6); }
.dash-ai .mg-ask textarea { border-radius: 999px; padding: .6rem 1rem; }
.dash-ai .mg-ask .db-btn { border-radius: 50%; width: 2.6rem; height: 2.6rem; padding: 0; flex: 0 0 auto; }

/* ==========================================================================
   Canvas — a board of sticky notes and task cards
   ========================================================================== */
.cv { max-width: 1280px; margin: 0 auto; padding: 1.6rem 1.5rem 5rem; }
.cv__head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.6rem; color: #fff; }
.cv__title { margin: 0; font-family: 'Source Serif 4', Georgia, serif; font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 600; text-shadow: 0 2px 16px rgba(0, 0, 0, .25); }
.cv__sub { margin: .2rem 0 0; color: rgba(255, 255, 255, .8); font-size: .92rem; }
.cv__tools { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cv-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cv-seg button { border: 0; background: none; color: rgba(255, 255, 255, .85); font: inherit; font-size: .8rem; font-weight: 600; padding: .4rem .8rem; border-radius: 999px; cursor: pointer; }
.cv-seg button em { font-style: normal; opacity: .7; margin-left: .2rem; }
.cv-seg button.is-active { background: #fff; color: var(--mg-ink); }
.cv-add { display: inline-flex; align-items: center; gap: .45rem; border: 0; border-radius: 999px; padding: .55rem 1rem; font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer; transition: transform .2s var(--mg-ease); }
.cv-add:hover { transform: translateY(-2px); }
.cv-add--note { background: #ffe27a; color: #4a3b10; box-shadow: 0 10px 22px -10px rgba(255, 210, 80, .8); }
.cv-add--task { background: #fff; color: var(--mg-ink); }

.cv-board { columns: 4 250px; column-gap: 1.4rem; }
.cv-card {
    position: relative;
    break-inside: avoid;
    margin: 0 0 1.6rem;
    padding: 1.3rem 1.1rem .8rem;
    transform: rotate(var(--tilt, 0deg));
    transition: transform .25s var(--mg-ease), box-shadow .25s ease;
    animation: mg-rise .5s var(--mg-ease) both;
}
.cv-card:hover { transform: rotate(0) translateY(-4px) scale(1.02); z-index: 2; }

/* Sticky note */
.cv-note {
    background: linear-gradient(170deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c) 75%);
    color: #3b3220;
    border-radius: 3px 3px 16px 3px;
    box-shadow: 0 8px 14px -8px rgba(0, 0, 0, .4), inset 0 -10px 14px -12px rgba(0, 0, 0, .2);
    min-height: 150px;
}
.cv-note__text { margin: 0; font-family: var(--mg-hand); font-size: 1.45rem; line-height: 1.75rem; white-space: pre-wrap; word-break: break-word; cursor: text; }
.cv-note__edit {
    width: 100%; min-height: 120px; resize: vertical; border: 0; outline: none; background: rgba(255, 255, 255, .35); border-radius: 6px;
    font-family: var(--mg-hand); font-size: 1.45rem; line-height: 1.75rem; color: #3b3220; padding: .3rem .4rem;
}
.cv-note__label, .cv-task__label { font-size: .64rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .6; margin-bottom: .4rem; }
.cv-card__foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .8rem; font-size: .72rem; }
.cv-card__date { color: inherit; opacity: .7; text-decoration: none; font-weight: 600; }
.cv-card__date:hover { opacity: 1; text-decoration: underline; }
.cv-card__icons { display: flex; gap: .2rem; opacity: 0; transition: opacity .2s ease; }
.cv-card:hover .cv-card__icons, .cv-card:focus-within .cv-card__icons { opacity: 1; }
@media (hover: none) { .cv-card__icons { opacity: .75; } }
.cv-card__icons button { width: 1.8rem; height: 1.8rem; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .45); color: inherit; cursor: pointer; font-size: .72rem; }
.cv-card__icons button:hover { background: rgba(255, 255, 255, .8); }
.cv-card__actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .7rem; }
.cv-btn { border: 0; border-radius: 10px; padding: .5rem .9rem; font: inherit; font-size: .8rem; font-weight: 700; background: #3b3220; color: #fff; cursor: pointer; }
.cv-btn:disabled { opacity: .5; }
.cv-btn--ghost { background: transparent; color: inherit; }

/* Push pin and tape */
.cv-pin { position: absolute; top: -9px; left: 50%; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff9a9a, #d62d4b 60%, #8e1f2f); box-shadow: 0 4px 6px rgba(0, 0, 0, .35); }
.cv-tape { position: absolute; top: -12px; left: 50%; width: 86px; height: 24px; margin-left: -43px; transform: rotate(-3deg); background: rgba(255, 255, 255, .55); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); backdrop-filter: blur(2px); }

/* Task card (index card) */
.cv-task {
    background: repeating-linear-gradient(to bottom, #fff 0, #fff 1.6rem, #dfe9f5 1.6rem, #dfe9f5 calc(1.6rem + 1px));
    background-position: 0 2.3rem;
    border-top: 3px solid #f08a9b;
    border-radius: 4px;
    color: var(--db-text);
    box-shadow: 0 8px 14px -8px rgba(0, 0, 0, .4);
}
.cv-task__row { display: flex; align-items: flex-start; gap: .6rem; cursor: pointer; }
.cv-task__row .db-check { margin-top: .2rem; }
.cv-task__title { font-family: var(--mg-hand); font-size: 1.45rem; line-height: 1.6rem; color: #1f3f8a; word-break: break-word; }
.cv-task.is-done .cv-task__title { text-decoration: line-through; color: #9aa6b8; }
.cv-task.is-done { opacity: .75; }
.cv-card__due { font-weight: 700; color: var(--db-muted-2); }
.cv-card__due.is-late { color: var(--db-mood-rough); }
.cv-task__input { width: 100%; border: 0; outline: none; background: transparent; font-family: var(--mg-hand); font-size: 1.45rem; color: #1f3f8a; }
.cv-task__due { display: inline-flex; align-items: center; gap: .4rem; margin-top: .6rem; font-size: .75rem; color: var(--db-muted-2); }
.cv-task__due input { border: 1px solid var(--db-border); border-radius: 8px; padding: .25rem .4rem; font: inherit; }
.cv-task .cv-card__icons button { background: var(--db-bg); }

.cv-note--new, .cv-task--new { box-shadow: 0 0 0 3px rgba(255, 255, 255, .6), 0 22px 32px -18px rgba(0, 0, 0, .55); }

.cv-empty { text-align: center; color: #fff; padding: 3rem 1rem; }
.cv-empty__art { width: 84px; height: 84px; margin: 0 auto 1rem; border-radius: 6px 6px 22px 6px; display: grid; place-items: center; font-size: 2rem; background: #ffe27a; color: #4a3b10; transform: rotate(-6deg); box-shadow: 0 20px 30px -14px rgba(0, 0, 0, .5); }
.cv-empty__title { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.4rem; font-weight: 600; }
.cv-empty p { color: rgba(255, 255, 255, .8); }

@media (max-width: 720px) {
    .cv { padding: 1rem .9rem 5rem; }
    .cv__tools { width: 100%; }
    .cv-seg { width: 100%; justify-content: space-between; }
    .cv-add { flex: 1; justify-content: center; }
    .cv-board { columns: 2 150px; column-gap: .9rem; }
    .cv-card { padding: 1.1rem .8rem .6rem; margin-bottom: 1.2rem; }
    .cv-note__text, .cv-task__title { font-size: 1.25rem; line-height: 1.5rem; }
}
@media (max-width: 380px) { .cv-board { columns: 1; } }
/* Keep each card (and its pin/tape above it) in one column fragment */
.cv-card { display: inline-block; width: 100%; vertical-align: top; margin-top: 12px; }

/* ==========================================================================
   Mobile polish: writing + reading
   ========================================================================== */
.mg-reader-back { display: none; }
@media (max-width: 959px) {
    /* Split view on phones: list first, the reader opens as a full-screen page */
    .db-diary-shell.mode-split .db-diary-reader { display: none; }
    .db-diary-shell.mode-split .db-diary-list { overflow: visible !important; }
    .db-diary-shell.mode-split .db-diary-reader.is-mobile-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 70;
        overflow-y: auto;
        padding: 0 .75rem calc(1.5rem + env(safe-area-inset-bottom));
        background: rgba(8, 6, 30, .55);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        animation: mg-step-r .35s var(--mg-ease) both;
    }
    .db-diary-reader.is-mobile-open .mg-reader-back {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        position: sticky;
        top: 0;
        z-index: 2;
        margin: 0 -.75rem .8rem;
        width: calc(100% + 1.5rem);
        padding: calc(.85rem + env(safe-area-inset-top)) 1rem .85rem;
        border: 0;
        background: rgba(12, 10, 40, .7);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        color: #fff;
        font: inherit;
        font-weight: 600;
        cursor: pointer;
    }
    .db-diary-reader.is-mobile-open .db-paper { border-radius: 14px; }
    /* Tag filters scroll sideways in one row instead of wrapping */
    .mg-subbar > div > div:last-child { flex-wrap: nowrap !important; overflow-x: auto; justify-content: flex-start !important; scrollbar-width: none; }
    .mg-subbar > div > div:last-child::-webkit-scrollbar { display: none; }
    .mg-subbar .db-pill { flex: 0 0 auto; }
}
@media (max-width: 720px) {
    .db-entry-card { padding: .8rem .85rem; border-radius: 14px !important; }
    .db-entry-card h4 { font-size: 1rem !important; }

    /* Writing: compact header, sticky full-width save bar */
    .mg-sheet__head { flex-wrap: nowrap; align-items: flex-start; }
    .mg-chip-btn span { display: none; }
    .mg-chip-btn { padding: .55rem .65rem; }
    .mg-title-input { font-size: 1.3rem; }
    .mg-compose__area { min-height: 180px; font-size: 1rem; }
    .mg-composer__foot {
        position: sticky;
        bottom: 0;
        z-index: 5;
        margin: 1rem -1.1rem -1.4rem -2.6rem;
        padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, rgba(248, 242, 228, 0), #f8f2e4 35%);
        border-radius: 0 0 18px 8px;
    }
    .mg-save { width: 100%; justify-content: center; padding: .9rem 1rem; font-size: 1rem; }
    .mg-moodpick__sky { font-size: 1rem; }
    .mg-tl__text { font-size: .98rem; }
}
@media (max-width: 959px) {
    body.db-magic .db-main:has(.is-mobile-open) { z-index: 90; }
}
/* Reading view: book typography */
.db-diary-reader .db-body, .db-diary-scroll .db-paper p { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.02rem !important; line-height: 1.8 !important; color: #1d2647; }

/* ==========================================================================
   Settings panel (header gear)
   ========================================================================== */
.mg-settings-overlay {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    background: rgba(8, 6, 30, .5);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.mg-settings {
    width: min(100%, 440px);
    max-height: min(90vh, 640px);
    display: flex; flex-direction: column;
    padding: 1.2rem 1.2rem 1rem;
    border-radius: 22px;
    background: linear-gradient(180deg, #fffdf7, #fff);
    color: var(--db-text);
    box-shadow: 0 40px 80px -30px rgba(8, 6, 30, .8);
    animation: mg-sheet .35s var(--mg-ease) both;
}
.mg-settings__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.mg-settings__head h2 { margin: 0; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.3rem; font-weight: 600; }
.mg-settings__head h2 i { font-size: 1rem; color: var(--mg-hero-a); margin-right: .3rem; }
.mg-settings__close { width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--db-border); background: #fff; color: var(--db-muted-2); cursor: pointer; }
.mg-settings__label { font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--db-muted-1); }
.mg-settings__hint { font-size: .78rem; color: var(--db-muted-3); margin: .15rem 0 .6rem; }
.mg-settings__search { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 12px; background: var(--db-bg); margin-bottom: .5rem; }
.mg-settings__search i { color: var(--db-muted-3); font-size: .8rem; }
.mg-settings__search input { flex: 1; border: 0; outline: none; background: none; font: inherit; font-size: 16px; }
.mg-settings__list { flex: 1; min-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -.3rem; padding: 0 .3rem; }
.mg-cur { display: flex; align-items: center; gap: .7rem; padding: .5rem .55rem; border: 0; border-radius: 12px; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--db-text); }
.mg-cur:hover { background: var(--db-bg); }
.mg-cur.is-active { background: color-mix(in srgb, var(--mg-hero-a) 10%, #fff); }
.mg-cur__sym { flex: 0 0 auto; min-width: 2.4rem; height: 2.1rem; padding: 0 .3rem; border-radius: 10px; display: grid; place-items: center; background: var(--db-bg); font-weight: 700; font-size: .85rem; }
.mg-cur.is-active .mg-cur__sym { background: var(--mg-ink); color: #fff; }
.mg-cur__name { flex: 1; min-width: 0; font-size: .86rem; color: var(--db-muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-cur__name b { color: var(--db-text); margin-right: .25rem; }
.mg-cur > i { color: var(--mg-hero-a); }
.mg-settings__preview { margin-top: .7rem; padding: .6rem .8rem; border-radius: 12px; background: var(--db-bg); font-size: .82rem; color: var(--db-muted-2); }
.mg-settings__preview b { font-family: 'Source Serif 4', Georgia, serif; font-size: 1rem; color: var(--db-text); }
.mg-settings__error { margin-top: .5rem; font-size: .8rem; color: var(--db-mood-rough); }
.mg-settings__actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .9rem; }
.mg-settings__cancel { border: 0; background: none; font: inherit; font-weight: 600; color: var(--db-muted-2); cursor: pointer; padding: .55rem .8rem; }
.mg-settings__save { border: 0; border-radius: 12px; padding: .6rem 1.4rem; font: inherit; font-weight: 700; color: #fff; cursor: pointer; background: linear-gradient(135deg, var(--mg-hero-a), var(--mg-hero-b)); }
.mg-settings__save:disabled { opacity: .6; }
@media (max-width: 520px) {
    .mg-settings-overlay { align-items: flex-end; padding: 0; }
    .mg-settings { width: 100%; max-height: 85vh; border-radius: 22px 22px 0 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

/* ==========================================================================
   Diary page: single slim toolbar, bigger reading area
   ========================================================================== */
.dv-bar { flex: 0 0 auto; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.dv-bar__inner { max-width: 1280px; margin: 0 auto; padding: .45rem 1.25rem; display: flex; align-items: center; gap: .5rem; }
.dv-search { flex: 1 1 auto; max-width: 420px; min-width: 0; display: flex; align-items: center; gap: .5rem; height: 2.3rem; padding: 0 .4rem 0 .85rem; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--db-muted-3); cursor: text; }
.dv-search i { font-size: .8rem; }
.dv-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font: inherit; font-size: .88rem; color: var(--db-text); }
.dv-search button { width: 1.6rem; height: 1.6rem; border: 0; border-radius: 50%; background: var(--db-bg); color: var(--db-muted-2); cursor: pointer; font-size: .7rem; }
.dv-tags { position: relative; flex: 0 0 auto; }
.dv-tags__btn { display: inline-flex; align-items: center; gap: .35rem; height: 2.3rem; padding: 0 .8rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .12); color: #fff; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; max-width: 11rem; }
.dv-tags__btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-tags__btn.is-active { background: #fff; color: var(--mg-ink); }
.dv-tags__chev { font-size: .55rem; opacity: .7; }
.dv-tags__menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 180px; max-height: 320px; overflow-y: auto; padding: .35rem; border-radius: 14px; background: #fff; box-shadow: 0 20px 40px -14px rgba(8, 6, 30, .6); display: flex; flex-direction: column; }
.dv-tags__menu button { text-align: left; border: 0; background: none; padding: .5rem .7rem; border-radius: 10px; font: inherit; font-size: .84rem; color: var(--db-text); cursor: pointer; }
.dv-tags__menu button:hover { background: var(--db-bg); }
.dv-tags__menu button.is-active { background: var(--mg-ink); color: #fff; }
.dv-views { margin-left: auto; flex: 0 0 auto; display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); }
.dv-views button { display: inline-flex; align-items: center; gap: .35rem; height: 1.95rem; padding: 0 .75rem; border: 0; border-radius: 999px; background: none; color: rgba(255, 255, 255, .85); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; }
.dv-views button i { font-size: .8rem; }
.dv-views button.is-active { background: #fff; color: var(--mg-ink); }
.dv-wrap { max-width: 1280px; margin: 0 auto; padding: .8rem 1.25rem; height: 100%; }
/* Wider reading measure now that there's room */
.db-diary-shell.mode-page .db-diary-reader .db-paper { max-width: 860px !important; }
@media (max-width: 1100px) { .dv-views button span { display: none; } .dv-views button { padding: 0 .65rem; } }
@media (max-width: 720px) {
    .dv-bar__inner { padding: .45rem .75rem; gap: .4rem; }
    .dv-tags__btn { padding: 0 .7rem; }
    .dv-tags__btn span, .dv-tags__chev { display: none; }
    .dv-tags__menu { left: auto; right: 0; }
    .dv-views button { padding: 0 .55rem; }
    .dv-wrap { padding: .6rem .6rem; }
    .db-diary-book { min-height: calc(100dvh - 170px); }
}

/* ---- Canvas v2: tasks column (left) + stickies board (right) ---- */
.cv-layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 2rem; align-items: start; }
.cv-layout.show-notes { grid-template-columns: minmax(0, 1fr); }
.cv-layout.show-notes .cv-col--tasks, .cv-layout.show-tasks .cv-col--notes { display: none; }
.cv-layout.show-tasks { grid-template-columns: minmax(0, 520px); }
.cv-col__title { display: flex; align-items: center; gap: .5rem; margin: 0 0 1.1rem; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.1rem; font-weight: 600; color: #fff; text-shadow: 0 1px 10px rgba(0, 0, 0, .25); }
.cv-col__title i { color: var(--mg-accent); font-size: .9rem; }
.cv-col__title em { font-style: normal; font-family: 'Inter', sans-serif; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: rgba(255, 255, 255, .16); }
.cv-col__empty { color: rgba(255, 255, 255, .75); font-size: .85rem; }
.cv-col--tasks { position: sticky; top: 0; }
.cv-col--tasks .cv-card { margin-bottom: 1.2rem; }
.cv-col--notes .cv-board { columns: 3 220px; column-gap: 1.3rem; }

/* Sticky text is a borderless textarea: click to type, no edit mode */
.cv-note__text {
    display: block; width: 100%; min-height: 3.5rem; overflow: hidden; resize: none;
    border: 0; outline: none; background: transparent; padding: 0; margin: 0;
    font-family: var(--mg-hand); font-size: 1.45rem; line-height: 1.75rem; color: #3b3220;
    white-space: pre-wrap; word-break: break-word; cursor: text;
}
.cv-note__text--edit { min-height: 7rem; background: rgba(255, 255, 255, .3); border-radius: 6px; padding: .2rem .35rem; }
.cv-note.is-editing { transform: rotate(0) scale(1.03); z-index: 3; box-shadow: 0 0 0 3px rgba(255, 255, 255, .75), 0 30px 40px -18px rgba(0, 0, 0, .6); }
.cv-note.is-editing .cv-note__text { background: rgba(255, 255, 255, .25); border-radius: 6px; }
.cv-note.is-saving { opacity: .85; }
.cv-card__saved { font-size: .7rem; font-weight: 700; color: #2f7a3b; }

/* Colour dots: appear on hover / while editing */
.cv-colors { display: flex; gap: .3rem; margin-top: .6rem; opacity: 0; max-height: 0; overflow: hidden; transition: opacity .2s ease, max-height .2s ease; }
.cv-note:hover .cv-colors, .cv-note.is-editing .cv-colors, .cv-note--new .cv-colors, .cv-note:focus-within .cv-colors { opacity: 1; max-height: 2rem; }
@media (hover: none) { .cv-colors { opacity: 1; max-height: 2rem; } }
.cv-colors button { width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .12); background: var(--c); cursor: pointer; padding: 0; transition: transform .15s ease; }
.cv-colors button:hover { transform: scale(1.15); }
.cv-colors button.is-active { border-color: #3b3220; box-shadow: 0 0 0 2px rgba(255, 255, 255, .8); }

@media (max-width: 900px) {
    .cv-layout { grid-template-columns: 1fr; gap: 1.4rem; }
    .cv-col--tasks { position: static; }
    .cv-col--notes { order: -1; }
    .cv-col--notes .cv-board { columns: 2 150px; column-gap: .9rem; }
}
@media (max-width: 380px) { .cv-col--notes .cv-board { columns: 1; } }

/* Dashboard stickies tab */
.dash-stickies { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; padding-top: .2rem; }
.dash-sticky { position: relative; padding: .55rem .6rem .4rem; border-radius: 3px 3px 12px 3px; background: linear-gradient(170deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c)); box-shadow: 0 8px 14px -8px rgba(0, 0, 0, .4); transform: rotate(-.6deg); transition: transform .2s var(--mg-ease); }
.dash-sticky:nth-child(even) { transform: rotate(.7deg); }
.dash-sticky:focus-within { transform: rotate(0) scale(1.03); box-shadow: 0 0 0 2px #fff, 0 12px 20px -8px rgba(0, 0, 0, .45); z-index: 1; }
.dash-sticky textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 0; font-family: var(--mg-hand); font-size: 1.1rem; line-height: 1.3rem; color: #3b3220; }
.dash-sticky__date { display: block; font-size: .62rem; font-weight: 600; color: rgba(59, 50, 32, .6); }
.dash-sticky__all { display: inline-flex; align-items: center; gap: .35rem; margin-top: .7rem; font-size: .76rem; font-weight: 600; color: #4f62c9; text-decoration: none; }
.dash-tabs button em { font-style: normal; }

/* Today card: prompt with a small shuffle icon, one main button */
.dash-today__promptrow { flex: 1; display: flex; align-items: flex-start; gap: .5rem; }
.dash-today__promptrow .dash-today__prompt { flex: 1; }
.dash-today__shuffle { flex: 0 0 auto; margin-top: .75rem; width: 2rem; height: 2rem; border-radius: 50%; border: 1px dashed #d8ccb0; background: rgba(255, 255, 255, .6); color: #8a7a55; cursor: pointer; font-size: .75rem; transition: transform .3s var(--mg-ease); }
.dash-today__shuffle:hover { transform: rotate(180deg); color: var(--mg-ink); }

/* Write page autosave indicator */
.mg-sync { display: inline-flex; align-items: center; gap: .35rem; margin-left: .7rem; font-size: .74rem; color: rgba(255, 255, 255, .75); }
.mg-sync.is-saved i { color: #5ee0a8; }
.mg-sync.is-pending i { color: var(--mg-accent); }
.mg-sync.is-error { color: #ffb3bb; }
@media (max-width: 720px) { .mg-sync span { display: none; } .mg-sync { margin-left: .4rem; } }
/* Pen on: the pen marks the spot, so hide the blinking text cursor */
.mg-compose__area.is-pen { caret-color: transparent; }

/* ==========================================================================
   Share sheet (assets/js/share-card.js)
   ========================================================================== */
.shr-overlay { position: fixed; inset: 0; z-index: 120; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(8, 6, 30, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.shr-overlay.is-open { display: flex; animation: mg-fade .2s ease both; }
.shr { width: min(100%, 440px); max-height: 94vh; overflow-y: auto; padding: 1.1rem; border-radius: 22px; background: #fffdf7; color: var(--db-text); box-shadow: 0 40px 80px -30px rgba(8, 6, 30, .8); animation: mg-sheet .35s var(--mg-ease) both; font-family: 'Inter', sans-serif; }
.shr__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.shr__head h2 { margin: 0; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.2rem; font-weight: 600; }
.shr__head h2 i { color: var(--mg-hero-a, #7b68c8); font-size: .95rem; margin-right: .3rem; }
.shr__close { width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid #e6dfcd; background: #fff; color: #667; cursor: pointer; }
.shr__preview { position: relative; aspect-ratio: 4 / 5; border-radius: 16px; overflow: hidden; background: #eee6d6; box-shadow: 0 16px 30px -18px rgba(0, 0, 0, .5); }
.shr__preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shr__spin { position: absolute; inset: 0; display: none; place-items: center; color: #8a7a55; font-size: 1.3rem; }
.shr__preview.is-loading .shr__spin { display: grid; }
.shr__actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .9rem; }
.shr__btn { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .6rem .2rem; border: 1px solid #ebe4d3; border-radius: 14px; background: #fff; font: inherit; font-size: .72rem; font-weight: 600; color: #4a4a5a; cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.shr__btn i { font-size: 1.15rem; color: #6a5ca6; }
.shr__btn:hover { transform: translateY(-2px); border-color: #cfc4a8; }
.shr__btn--main { grid-column: 1 / -1; flex-direction: row; justify-content: center; padding: .8rem; font-size: .92rem; color: #fff; border: 0; background: linear-gradient(135deg, var(--mg-hero-a, #7b68c8), var(--mg-hero-b, #3f3488)); }
.shr__btn--main i { color: #fff; font-size: 1rem; }
.shr__btn--wa i { color: #25d366; }
.shr__note { min-height: 1.1rem; margin: .6rem 0 0; font-size: .8rem; font-weight: 600; color: #2f7a3b; text-align: center; }
.shr__privacy { margin: .2rem 0 0; font-size: .7rem; color: #9a917c; text-align: center; }
@media (max-width: 520px) {
    .shr-overlay { align-items: flex-end; padding: 0; }
    .shr { width: 100%; border-radius: 22px 22px 0 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
    .shr__preview { max-height: 46vh; aspect-ratio: auto; height: 46vh; }
    .shr__preview img { object-fit: contain; }
}

.mg-share-btn { margin-left: 1rem; border: 1px solid var(--db-border); background: #fff; border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .8rem; font-weight: 600; color: #4f62c9; cursor: pointer; }
.mg-share-btn:hover { border-color: #4f62c9; }
.bk-share { border: 0; background: none; padding: 0; font: inherit; font-size: .74rem; font-weight: 600; color: #4f62c9; cursor: pointer; }
.bk-ctl--share { width: 2.3rem; height: 2.3rem; font-size: .85rem; background: rgba(255, 255, 255, .16); color: #fff; }
.bk-ctl--share:hover { background: #fff; color: var(--mg-ink); }
.bk-ctl--share:disabled { opacity: .35; cursor: default; transform: none; box-shadow: none; }
.bk-ctl--share { width: auto; border-radius: 999px; padding: 0 .9rem; display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .8rem; font-weight: 700; }
@media (max-width: 819px) { .bk-ctl--share span { display: none; } .bk-ctl--share { width: 2.3rem; padding: 0; justify-content: center; } }

/* Edit buttons */
.mg-tl__tools { display: flex; flex-direction: column; gap: .2rem; align-self: flex-start; }
.mg-tl__edit { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid #e6dfcd; background: rgba(255, 255, 255, .8); border-radius: 999px; padding: .3rem .65rem; font: inherit; font-size: .72rem; font-weight: 700; color: #4f62c9; cursor: pointer; }
.mg-tl__edit:hover { border-color: #4f62c9; background: #fff; }
.mg-tl__tools .mg-tl__del { opacity: .6; text-align: center; }
@media (max-width: 720px) { .mg-tl__edit span { display: none; } .mg-tl__edit { padding: .4rem .5rem; } }
.mg-ev-head { display: flex; align-items: flex-start; gap: .6rem; }
.mg-ev-head h3 { flex: 1; }
.mg-ev-edit { margin-left: auto; flex: 0 0 auto; font-size: .74rem; font-weight: 700; color: #4f62c9; text-decoration: none; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--db-border); opacity: .75; }
.mg-ev-edit:hover { opacity: 1; border-color: #4f62c9; }
.mg-edit-btn { margin-left: 0; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }

/* ==========================================================================
   StreakWrite brand
   ========================================================================== */
.mg-brand__img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; box-shadow: 0 0 22px rgba(243, 196, 90, .35), 0 6px 16px -6px rgba(0, 0, 0, .5); }
.mg-brand { font-size: 1.25rem; letter-spacing: .005em; }
.db-header__logo--img { width: 32px; height: 32px; border-radius: 9px; object-fit: cover; background: none; padding: 0; box-shadow: 0 0 14px rgba(243, 196, 90, .3); }
.db-header__name em { font-family: 'Source Serif 4', Georgia, serif; font-style: italic; font-weight: 600; color: #f3c45a; }
body.db-magic .db-header__logo--img { background: none; }
.mg-brand em { font-family: 'Source Serif 4', Georgia, serif; font-style: italic; color: #f3c45a; }

/* ==========================================================================
   Stickies pinned to the dashboard
   ========================================================================== */
.dash-pins {
    position: fixed;
    left: 0;
    right: 0;
    top: 56px;            /* below the header */
    bottom: 0;
    z-index: 45;
    pointer-events: none;
}
.pin-note {
    position: absolute;
    width: 190px;
    pointer-events: auto;
    border-radius: 3px 3px 16px 3px;
    background: linear-gradient(170deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c) 75%);
    color: #3b3220;
    box-shadow: 0 18px 30px -14px rgba(0, 0, 0, .55), inset 0 -12px 18px -14px rgba(0, 0, 0, .25);
    transform: rotate(var(--tilt, 0deg));
    transition: transform .2s var(--mg-ease), box-shadow .2s ease;
    animation: pin-in .45s var(--mg-ease) both;
}
@keyframes pin-in { from { opacity: 0; transform: translateY(-14px) rotate(-8deg) scale(.9); } to { opacity: 1; transform: rotate(var(--tilt, 0deg)); } }
.pin-note:hover, .pin-note:focus-within { transform: rotate(0) scale(1.02); z-index: 2; }
.pin-note.is-dragging { transform: rotate(2deg) scale(1.06); box-shadow: 0 30px 44px -14px rgba(0, 0, 0, .6); z-index: 3; transition: none; }
.pin-note__bar { position: relative; display: flex; align-items: center; gap: .3rem; height: 26px; padding: 0 .3rem 0 .6rem; cursor: grab; touch-action: none; user-select: none; }
.pin-note.is-dragging .pin-note__bar { cursor: grabbing; }
.pin-note__pin { position: absolute; top: -9px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff9a9a, #d62d4b 60%, #8e1f2f); box-shadow: 0 3px 5px rgba(0, 0, 0, .35); }
.pin-note__peek { flex: 1; min-width: 0; font-family: var(--mg-hand); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-note__tools { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .15s ease; }
.pin-note:hover .pin-note__tools, .pin-note:focus-within .pin-note__tools, .pin-note.is-folded .pin-note__tools { opacity: 1; }
.pin-note__tools button { width: 22px; height: 22px; border: 0; border-radius: 6px; background: rgba(255, 255, 255, .45); color: #3b3220; cursor: pointer; font-size: .62rem; }
.pin-note__tools button:hover { background: rgba(255, 255, 255, .85); }
.pin-note textarea { display: block; width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 0 .7rem .7rem; font-family: var(--mg-hand); font-size: 1.2rem; line-height: 1.45rem; color: #3b3220; }
.pin-note.is-folded { width: 150px; border-radius: 3px 3px 10px 3px; }

/* Pin toggles */
.dash-sticky { position: relative; }
.dash-sticky__pin { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border: 0; border-radius: 6px; background: rgba(255, 255, 255, .4); color: rgba(59, 50, 32, .45); cursor: pointer; font-size: .62rem; z-index: 1; }
.dash-sticky__pin.is-on { color: #d62d4b; background: rgba(255, 255, 255, .8); }
.dash-sticky__pin:hover { color: #d62d4b; }
.cv-card__icons button.is-on { color: #d62d4b; background: rgba(255, 255, 255, .85); }
.mg-sticky__pinopt { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; font-size: .8rem; font-weight: 600; color: #6b5a22; cursor: pointer; }
.mg-sticky__pinopt i { color: #d62d4b; font-size: .75rem; }

/* Phones: pinned notes become a swipeable row under the greeting */
@media (max-width: 720px) {
    .dash-pins { position: static; display: flex; gap: .7rem; overflow-x: auto; padding: .7rem .1rem .9rem; margin-bottom: .2rem; scroll-snap-type: x mandatory; scrollbar-width: none; }
    .dash-pins::-webkit-scrollbar { display: none; }
    .pin-note { position: relative; left: auto !important; top: auto !important; flex: 0 0 160px; scroll-snap-align: start; }
    .pin-note__bar { cursor: default; }
    .pin-note__tools { opacity: 1; }
}
@media (max-width: 720px) { .pin-note.is-folded { flex-basis: 130px; align-self: flex-start; } .pin-note:not(.is-folded) .pin-note__bar { height: 22px; } }
.shr__preview.is-spread { aspect-ratio: 8 / 5; }
.shr:has(.shr__preview.is-spread) { width: min(100%, 720px); }

/* Reading in handwriting (Diary toolbar Aa switch) */
.dv-font { flex: 0 0 auto; }
html.read-hand .db-diary-reader .db-body,
html.read-hand .db-diary-reader .db-body p,
html.read-hand .db-diary-reader .db-body li,
html.read-hand .db-diary-scroll .db-paper p,
html.read-hand .bk-flow, html.read-hand .bk-flow p, html.read-hand .bk-flow li {
    font-family: var(--mg-hand) !important;
    font-size: 1.45rem !important;
    line-height: 1.85rem !important;
    color: #1f3f8a !important;
}
html.read-hand .db-diary-reader .db-body h1, html.read-hand .bk-flow h1 { font-family: var(--mg-hand) !important; font-size: 1.9rem; }
@media (max-width: 720px) { .dv-font button { padding: .25rem .45rem; } }

/* ==========================================================================
   Phones: galaxy look for sign in / sign up / onboarding
   ========================================================================== */
@media (max-width: 720px) {
    body.mg-login { background: #04061a; }
    /* Twinkling star field + a slow rotating galaxy swirl behind everything */
    body.mg-login::before {
        content: '';
        position: fixed;
        inset: -30%;
        z-index: 0;
        pointer-events: none;
        background:
            radial-gradient(1.5px 1.5px at 20% 30%, #fff, transparent),
            radial-gradient(1px 1px at 70% 20%, #fff, transparent),
            radial-gradient(1.2px 1.2px at 40% 70%, #cfe0ff, transparent),
            radial-gradient(1px 1px at 85% 60%, #fff, transparent),
            radial-gradient(1.4px 1.4px at 10% 85%, #ffd9f5, transparent),
            radial-gradient(1px 1px at 55% 45%, #fff, transparent),
            conic-gradient(from 0deg at 55% 40%, transparent 0deg, rgba(150, 110, 255, .18) 60deg, transparent 120deg, rgba(80, 200, 255, .14) 200deg, transparent 260deg, rgba(255, 120, 220, .12) 320deg, transparent 360deg);
        background-size: 140px 140px, 190px 190px, 230px 230px, 170px 170px, 260px 260px, 120px 120px, 100% 100%;
        animation: mg-galaxy-spin 120s linear infinite;
        opacity: .9;
    }
    @keyframes mg-galaxy-spin { to { transform: rotate(360deg); } }
    /* hide the landscape so it feels like open space */
    body.mg-login .mg-scene, body.mg-login .mg-sky__mist, body.mg-login .mg-sky__sun { display: none; }
    body.mg-login .mg-sky__moon { top: 3%; right: 6%; width: 74px; opacity: .85; }

    /* Glass card with a violet / cyan glow */
    body.mg-login .mg-card {
        background: linear-gradient(160deg, rgba(120, 90, 255, .22), rgba(40, 120, 255, .08) 60%, rgba(255, 110, 210, .12)), rgba(8, 10, 40, .55);
        border-color: rgba(170, 160, 255, .35);
        box-shadow: 0 0 40px -6px rgba(140, 110, 255, .45), 0 30px 60px -24px rgba(0, 0, 0, .8);
    }
    body.mg-login .mg-input input { background: rgba(10, 14, 50, .55); border-color: rgba(170, 160, 255, .3); }
    body.mg-login .mg-input input:focus { border-color: #8fd8ff; box-shadow: 0 0 0 4px rgba(120, 200, 255, .2); }
    body.mg-login .mg-btn { background: linear-gradient(110deg, #8fd8ff, #b59cff, #ff9fe0); color: #120c33; box-shadow: 0 12px 30px -10px rgba(150, 120, 255, .8); }
    body.mg-login .mg-story__title em { background-image: linear-gradient(90deg, #8fd8ff, #c7a6ff, #ff9fe0, #8fd8ff); }
    body.mg-login .mg-brand__img { box-shadow: 0 0 22px rgba(150, 120, 255, .6); }
    body.mg-login .mg-link { color: #9fdcff; }
    body.mg-login .mg-choice.is-selected { background: linear-gradient(110deg, #8fd8ff, #c7a6ff); }
    body.mg-login .mg-onb__progress span.is-done { background: linear-gradient(90deg, #8fd8ff, #c7a6ff); }
    body.mg-login .mg-notebook { display: none; }
}

/* ==========================================================================
   Diary customisation: cover colours, own cover photo, paper styles, panel
   ========================================================================== */
/* Cover colours — on <html data-cover> (the book) and on preview/swatches */
[data-cover="leather"] { --bk-cover-a: #6b3d24; --bk-cover-b: #3a1e10; }
[data-cover="navy"]    { --bk-cover-a: #1d2e5c; --bk-cover-b: #0b1430; }
[data-cover="forest"]  { --bk-cover-a: #2d5a3f; --bk-cover-b: #13301f; }
[data-cover="plum"]    { --bk-cover-a: #5e2b5f; --bk-cover-b: #2c0f2e; }
[data-cover="rose"]    { --bk-cover-a: #a8546d; --bk-cover-b: #5a2135; }
[data-cover="charcoal"]{ --bk-cover-a: #3a3a40; --bk-cover-b: #17171b; }
[data-cover="sand"]    { --bk-cover-a: #b89a6a; --bk-cover-b: #6e5530; }
[data-cover]:not([data-cover="theme"]) .bk-cover:not(.has-photo),
.dc__preview[data-cover]:not([data-cover="theme"]) .bk-cover:not(.has-photo) {
    background:
        radial-gradient(120% 90% at 30% 15%, rgba(255, 255, 255, .14), transparent 55%),
        repeating-radial-gradient(circle at 37% 61%, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px),
        linear-gradient(140deg, var(--bk-cover-a), var(--bk-cover-b));
}
html[data-cover]:not([data-cover="theme"]) .bk__book::before {
    background: radial-gradient(120% 80% at 30% 0%, rgba(255, 255, 255, .12), transparent 60%), linear-gradient(135deg, var(--bk-cover-a), var(--bk-cover-b));
}
.bk-cover.has-photo { background-size: cover; background-position: center; }
.bk-cover.has-photo .bk-cover__emblem { background: rgba(0, 0, 0, .35); }
.bk-cover.has-photo .bk-cover__title { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .8)); }

/* Paper styles — book pages, the hidden measuring page and the reader */
html[data-paper="white"] :is(.bk__page, .bk__face):not(:has(.bk-cover, .bk-endpaper)) {
    background: repeating-linear-gradient(to bottom, transparent 0, transparent 1.85rem, rgba(70, 110, 160, .14) 1.85rem, rgba(70, 110, 160, .14) calc(1.85rem + 1px)), #fff;
    background-position: 0 4.6rem, 0 0;
}
html[data-paper="plain"] :is(.bk__page, .bk__face):not(:has(.bk-cover, .bk-endpaper)) { background: linear-gradient(180deg, #fffdf6, #f6efdf); }
html[data-paper="dots"] :is(.bk__page, .bk__face):not(:has(.bk-cover, .bk-endpaper)) {
    background: radial-gradient(circle, rgba(70, 90, 130, .28) 1px, transparent 1.4px) 0 0 / 1.1rem 1.1rem, #fffdf8;
}
html[data-paper="kraft"] :is(.bk__page, .bk__face):not(:has(.bk-cover, .bk-endpaper)) {
    background: repeating-linear-gradient(to bottom, transparent 0, transparent 1.85rem, rgba(90, 60, 30, .14) 1.85rem, rgba(90, 60, 30, .14) calc(1.85rem + 1px)), linear-gradient(180deg, #e3cfa8, #d6bd8f);
    background-position: 0 4.6rem, 0 0;
}
html[data-paper="white"] :is(.db-diary-reader, .db-diary-scroll) .db-paper { background: #fff; }
html[data-paper="dots"] :is(.db-diary-reader, .db-diary-scroll) .db-paper { background: radial-gradient(circle, rgba(70, 90, 130, .22) 1px, transparent 1.4px) 0 0 / 1.1rem 1.1rem, #fffdf8; }
html[data-paper="kraft"] :is(.db-diary-reader, .db-diary-scroll) .db-paper { background: linear-gradient(180deg, #e3cfa8, #d6bd8f); }

/* Toolbar button */
.dv-custom-btn { flex: 0 0 auto; }
@media (max-width: 1100px) { .dv-custom-btn span { display: none; } }

/* Panel (right drawer on desktop, bottom sheet on phones) */
.dc-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(8, 6, 30, .5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); display: flex; justify-content: flex-end; }
.dc { width: min(100%, 420px); height: 100%; display: flex; flex-direction: column; background: #fffdf7; color: var(--db-text); box-shadow: -30px 0 60px -30px rgba(8, 6, 30, .8); animation: dc-in .35s var(--mg-ease) both; }
@keyframes dc-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.dc__head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem .6rem; }
.dc__head h2 { margin: 0; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.25rem; font-weight: 600; }
.dc__head h2 i { font-size: .95rem; color: var(--mg-hero-a); margin-right: .3rem; }
.dc__body { flex: 1; overflow-y: auto; padding: .2rem 1.2rem 1rem; }
.dc__preview { width: 170px; height: 230px; margin: .3rem auto 1rem; border-radius: 6px 14px 14px 6px; overflow: hidden; box-shadow: 0 20px 34px -16px rgba(0, 0, 0, .55); }
.dc__preview .bk-cover { height: 100%; transform-origin: center; }
.dc__preview .bk-cover__title { font-size: 1.05rem; }
.dc__preview .bk-cover__emblem { width: 36px; height: 36px; font-size: .9rem; margin-bottom: .5rem; }
.dc__preview .bk-cover__sub { font-size: .9rem; }
.dc__preview .bk-cover__frame { inset: 9px 9px 9px 13px; }
.dc__preview .bk-cover__frame::before, .dc__preview .bk-cover__frame::after { width: 12px; height: 12px; }
.dc__preview .bk-cover__rule { margin: .45rem auto; width: 50px; }
.dc__preview .bk-cover__foot { bottom: 16px; font-size: .5rem; }
.dc__preview .bk-cover__hint { display: none; }
.dc__preview .bk-cover__center { padding: 0 1rem; }
.dc__label { display: block; margin: 1rem 0 .45rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--db-muted-1); }
.dc__input { width: 100%; padding: .65rem .8rem; border-radius: 12px; border: 1px solid #e6dfcd; background: #fff; font: inherit; font-size: 16px; }
.dc__input:focus { outline: none; border-color: var(--mg-hero-a); }
.dc__swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.dc__swatch, .dc__paper { display: flex; flex-direction: column; align-items: center; gap: .3rem; border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
.dc__swatch span { width: 100%; height: 38px; border-radius: 10px; background: linear-gradient(140deg, var(--bk-cover-a), var(--bk-cover-b)); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.dc__swatch[data-cover="theme"] span { background: linear-gradient(140deg, var(--mg-hero-a), var(--mg-hero-b)); }
.dc__swatch small, .dc__paper small { font-size: .68rem; font-weight: 600; color: var(--db-muted-2); }
.dc__swatch.is-active span, .dc__paper.is-active span { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--mg-hero-a); }
.dc__chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.dc__paper span { width: 100%; aspect-ratio: 3 / 4; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.dc__paper[data-paper="cream"] span { background: repeating-linear-gradient(to bottom, #fffdf6 0 7px, rgba(70, 110, 160, .3) 7px 8px); }
.dc__paper[data-paper="white"] span { background: repeating-linear-gradient(to bottom, #fff 0 7px, rgba(70, 110, 160, .3) 7px 8px); }
.dc__paper[data-paper="plain"] span { background: #fbf6ea; }
.dc__paper[data-paper="dots"] span { background: radial-gradient(circle, rgba(70, 90, 130, .45) 1px, transparent 1.3px) 0 0 / 6px 6px, #fffdf8; }
.dc__paper[data-paper="kraft"] span { background: repeating-linear-gradient(to bottom, #dcc59a 0 7px, rgba(90, 60, 30, .3) 7px 8px); }
.dc__row { display: flex; gap: .5rem; flex-wrap: wrap; }
.dc__btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem; border-radius: 12px; border: 1px solid #e6dfcd; background: #fff; font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; color: var(--db-text); }
.dc__btn--ghost { color: var(--db-mood-rough); }
.dc__hint { font-size: .78rem; margin: .4rem 0 0; }
.dc__grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.dc__seg { display: flex; padding: 3px; border-radius: 12px; background: #f1ede2; }
.dc__seg button { flex: 1; border: 0; background: none; padding: .5rem .3rem; border-radius: 9px; font: inherit; font-size: .8rem; font-weight: 600; color: var(--db-muted-2); cursor: pointer; white-space: nowrap; }
.dc__seg button.is-active { background: #fff; color: var(--mg-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.dc__error { margin: 0; padding: 0 1.2rem; font-size: .8rem; color: var(--db-mood-rough); }
.dc__foot { display: flex; align-items: center; gap: .4rem; padding: .8rem 1.2rem calc(.9rem + env(safe-area-inset-bottom)); border-top: 1px solid #ece5d3; }
.dc__reset { margin-right: auto; border: 0; background: none; font: inherit; font-size: .8rem; font-weight: 600; color: var(--db-muted-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 520px) {
    .dc-overlay { align-items: flex-end; }
    .dc { height: 88vh; width: 100%; border-radius: 22px 22px 0 0; animation-name: mg-sheet; }
    .dc__chips { grid-template-columns: repeat(5, 1fr); }
}

/* ==========================================================================
   Canvas drag & drop + trash
   ========================================================================== */
.cv-card { position: relative; }
.cv-grip {
    position: absolute; top: .35rem; right: .35rem; z-index: 2;
    width: 1.6rem; height: 1.6rem; border: 0; border-radius: 7px;
    background: rgba(255, 255, 255, .45); color: rgba(0, 0, 0, .4);
    cursor: grab; touch-action: none; font-size: .7rem; opacity: 0; transition: opacity .15s ease;
}
.cv-card:hover .cv-grip { opacity: 1; }
@media (hover: none) { .cv-grip { opacity: .8; } }
.cv-note, .cv-task { cursor: grab; }
.cv-note textarea, .cv-task input { cursor: text; }
body.cv-is-dragging, body.cv-is-dragging * { cursor: grabbing !important; user-select: none !important; }
.cv-card.is-placeholder { opacity: .3; transform: none !important; box-shadow: none !important; outline: 2px dashed rgba(255, 255, 255, .8); outline-offset: 3px; transition: opacity .15s ease; }
.cv-ghost {
    position: fixed !important; left: 0; top: 0; z-index: 200; margin: 0 !important;
    pointer-events: none; opacity: .97;
    box-shadow: 0 14px 22px -10px rgba(0, 0, 0, .45) !important;
    animation: none !important; transition: none !important;
    will-change: transform;
}
.cv-ghost .cv-grip { opacity: 1; }

.cv-trash {
    position: fixed; right: 1.4rem; bottom: calc(1.4rem + env(safe-area-inset-bottom)); z-index: 60;
    width: 64px; height: 64px; border-radius: 20px; border: 1px solid rgba(255, 255, 255, .3);
    background: rgba(14, 10, 40, .55); color: #fff; font-size: 1.35rem; cursor: pointer;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 16px 30px -14px rgba(0, 0, 0, .6);
    transition: transform .25s var(--mg-ease), background-color .2s ease, width .25s var(--mg-ease), height .25s var(--mg-ease);
}
.cv-trash:hover { transform: translateY(-2px); background: rgba(14, 10, 40, .75); }
.cv-trash > i { position: relative; z-index: 1; }
.cv-trash__lid { position: absolute; left: 50%; top: 14px; width: 26px; height: 4px; margin-left: -13px; border-radius: 3px; background: transparent; transform-origin: left center; transition: transform .25s var(--mg-ease); }
.cv-trash__count { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #ff6b7d; color: #fff; font: 700 .72rem/22px 'Inter', sans-serif; box-shadow: 0 0 0 2px rgba(14, 10, 40, .8); }
.cv-trash__hint { position: absolute; right: 0; bottom: calc(100% + 10px); white-space: nowrap; padding: .35rem .7rem; border-radius: 999px; background: rgba(14, 10, 40, .85); font: 600 .75rem 'Inter', sans-serif; }
.cv-trash.is-ready { width: 84px; height: 84px; border-radius: 26px; border-style: dashed; border-color: rgba(255, 255, 255, .7); animation: cv-wiggle 1.2s ease-in-out infinite; }
.cv-trash.is-over { background: #e2364f; border-color: #fff; transform: scale(1.12); animation: none; }
.cv-trash.is-over > i { transform: rotate(-12deg); transition: transform .2s ease; }
.cv-trash.is-bump { animation: cv-bump .5s var(--mg-ease); }
@keyframes cv-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes cv-bump { 30% { transform: scale(1.18); } 60% { transform: scale(.94); } }

.cv-toast { position: fixed; left: 50%; bottom: calc(1.4rem + env(safe-area-inset-bottom)); z-index: 70; transform: translateX(-50%); display: flex; align-items: center; gap: .9rem; padding: .7rem .9rem .7rem 1.1rem; border-radius: 14px; background: rgba(14, 10, 40, .92); color: #fff; font-size: .88rem; box-shadow: 0 16px 30px -12px rgba(0, 0, 0, .6); animation: mg-sheet .3s var(--mg-ease) both; }
.cv-toast button { border: 0; background: none; color: var(--mg-accent); font: inherit; font-weight: 700; cursor: pointer; }

.cv-trash__empty { text-align: center; padding: 2.5rem 1rem; color: var(--db-muted-2); }
.cv-trash__empty i { font-size: 2.2rem; color: #d8cfb9; }
.cv-trash__empty p { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.1rem; color: var(--db-text); margin: .7rem 0 .3rem; }
.cv-trashrow { display: flex; align-items: center; gap: .6rem; padding: .6rem; margin-bottom: .5rem; border-radius: 14px; background: #fff; border: 1px solid #ece5d3; }
.cv-trashrow__kind { flex: 0 0 auto; width: 2.2rem; height: 2.2rem; border-radius: 10px; display: grid; place-items: center; font-size: .85rem; }
.cv-trashrow__kind.is-note { background: var(--c, #fff1a8); color: #6b5a22; }
.cv-trashrow__kind.is-task { background: #fde4e8; color: #c23447; }
.cv-trashrow__body { flex: 1; min-width: 0; }
.cv-trashrow__text { font-family: var(--mg-hand); font-size: 1.15rem; line-height: 1.25rem; color: #3b3220; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cv-trashrow__meta { font-size: .7rem; color: var(--db-muted-3); margin-top: .15rem; }
.cv-trashrow .dc__btn { padding: .4rem .65rem; font-size: .76rem; }
.cv-trashrow__del { flex: 0 0 auto; width: 2rem; height: 2rem; border: 0; border-radius: 8px; background: none; color: var(--db-muted-3); cursor: pointer; }
.cv-trashrow__del:hover { color: var(--db-mood-rough); background: #fdecee; }

.cv-confirm-overlay { position: fixed; inset: 0; z-index: 210; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(8, 6, 30, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.cv-confirm { width: min(100%, 360px); padding: 1.4rem 1.3rem 1.1rem; border-radius: 22px; background: #fffdf7; text-align: center; box-shadow: 0 40px 70px -30px rgba(0, 0, 0, .8); animation: mg-sheet .3s var(--mg-ease) both; }
.cv-confirm__icon { width: 3.2rem; height: 3.2rem; margin: 0 auto .7rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.2rem; background: #efeaff; color: #6a5ca6; }
.cv-confirm__icon.is-danger { background: #fde4e8; color: #e2364f; }
.cv-confirm h3 { margin: 0 0 .35rem; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.2rem; color: var(--db-text); }
.cv-confirm p { margin: 0 0 1.1rem; font-size: .88rem; color: var(--db-muted-2); line-height: 1.45; word-break: break-word; }
.cv-confirm__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.cv-confirm__no, .cv-confirm__yes { padding: .75rem; border-radius: 14px; font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; }
.cv-confirm__no { border: 1px solid #e6dfcd; background: #fff; color: var(--db-text); }
.cv-confirm__yes { border: 0; background: var(--mg-ink); color: #fff; }
.cv-confirm__yes.is-danger { background: #e2364f; }
@media (max-width: 720px) { .cv-trash { right: 1rem; width: 56px; height: 56px; } .cv-trash.is-ready { width: 72px; height: 72px; } }

/* ==========================================================================
   Photo slider (media-embed.js daybookSliderHtml)
   ========================================================================== */
.db-photos { margin-top: .7rem; }
.db-photo { margin: .6rem 0; text-align: center; }
.db-photo img { max-width: 100%; border-radius: 10px; display: inline-block; }
.db-slider { margin: .7rem 0; user-select: none; }
.db-slider__stage { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 460px; border-radius: 12px; overflow: hidden; background: #1a1830; box-shadow: 0 12px 26px -14px rgba(0, 0, 0, .5); touch-action: pan-y; }
.db-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .35s ease, transform .35s ease; transform: scale(1.02); }
.db-slide.is-on { opacity: 1; transform: none; }
.db-slide img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
.db-slider__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 2.2rem; height: 2.2rem; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .9); color: #1d2647; cursor: pointer; font-size: .8rem; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); opacity: .85; transition: opacity .15s ease, transform .15s ease; }
.db-slider__nav:hover { opacity: 1; transform: translateY(-50%) scale(1.08); }
.db-slider__nav.is-prev { left: .6rem; }
.db-slider__nav.is-next { right: .6rem; }
.db-slider__count { position: absolute; right: .6rem; bottom: .6rem; padding: .2rem .55rem; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font: 600 .72rem 'Inter', sans-serif; }
.db-slider__dots { display: flex; justify-content: center; gap: 6px; margin-top: .5rem; }
.db-slider__dot { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; background: rgba(60, 60, 90, .25); cursor: pointer; transition: width .2s ease, background-color .2s ease; }
.db-slider__dot.is-on { width: 18px; border-radius: 999px; background: var(--mg-hero-a, #7b68c8); }
.bk-flow .db-slider__stage { aspect-ratio: auto; height: 260px; }
.bk-flow .db-slider { margin: .5rem 0; }

/* ==========================================================================
   Cover designs (pattern layer over the cover colour / photo)
   ========================================================================== */
.bk-cover[data-design]::before { content: ''; position: absolute; inset: 0; pointer-events: none; }
.bk-cover[data-design="stars"]::before {
    background:
        radial-gradient(1.4px 1.4px at 12% 18%, rgba(255, 240, 200, .9), transparent),
        radial-gradient(1px 1px at 72% 12%, #fff, transparent),
        radial-gradient(1.6px 1.6px at 85% 40%, rgba(255, 240, 200, .9), transparent),
        radial-gradient(1px 1px at 30% 62%, #fff, transparent),
        radial-gradient(1.2px 1.2px at 55% 84%, rgba(255, 240, 200, .8), transparent),
        radial-gradient(1px 1px at 18% 88%, #fff, transparent),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><path d='M30 20l2 6 6 2-6 2-2 6-2-6-6-2 6-2z M92 70l1.5 4.5 4.5 1.5-4.5 1.5L92 82l-1.5-4.5L86 76l4.5-1.5z' fill='%23f3d79a' fill-opacity='.55'/></svg>"),
        radial-gradient(60% 40% at 70% 20%, rgba(150, 130, 255, .25), transparent 70%);
    background-size: auto, auto, auto, auto, auto, auto, 120px 120px, auto;
}
.bk-cover[data-design="floral"]::before {
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64'><g fill='none' stroke='%23f3d79a' stroke-opacity='.4' stroke-width='1.1'><g transform='translate(16 16)'><circle cy='-5' r='3.5'/><circle cx='4.8' cy='-1.5' r='3.5'/><circle cx='3' cy='4' r='3.5'/><circle cx='-3' cy='4' r='3.5'/><circle cx='-4.8' cy='-1.5' r='3.5'/></g><g transform='translate(48 48)'><circle cy='-5' r='3.5'/><circle cx='4.8' cy='-1.5' r='3.5'/><circle cx='3' cy='4' r='3.5'/><circle cx='-3' cy='4' r='3.5'/><circle cx='-4.8' cy='-1.5' r='3.5'/></g><path d='M40 18c4-2 8 0 8 4M10 46c3 3 8 3 10 0'/></g><circle cx='16' cy='16' r='1.6' fill='%23f3d79a' fill-opacity='.6'/><circle cx='48' cy='48' r='1.6' fill='%23f3d79a' fill-opacity='.6'/></svg>") 0 0 / 64px 64px;
}
.bk-cover[data-design="deco"]::before {
    background:
        conic-gradient(from 180deg at 50% 46%, transparent 0 calc(var(--r, 0) * 1deg), rgba(243, 215, 154, .14) 0 4deg, transparent 0 12deg) 0 0 / 100% 100%,
        repeating-conic-gradient(from 0deg at 50% 46%, rgba(243, 215, 154, .12) 0 2deg, transparent 2deg 12deg),
        repeating-linear-gradient(45deg, transparent 0 22px, rgba(243, 215, 154, .14) 22px 23px),
        repeating-linear-gradient(-45deg, transparent 0 22px, rgba(243, 215, 154, .14) 22px 23px);
    -webkit-mask: radial-gradient(circle at 50% 46%, #000 0 55%, rgba(0,0,0,.5) 75%, #000 100%);
}
.bk-cover[data-design="waves"]::before {
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='24'><path d='M0 12 Q 12 0 24 12 T 48 12' fill='none' stroke='%23f3d79a' stroke-opacity='.38' stroke-width='1.3'/></svg>") 0 0 / 48px 24px;
    -webkit-mask: linear-gradient(180deg, transparent 0, #000 55%);
    mask: linear-gradient(180deg, transparent 0, #000 55%);
}
.bk-cover[data-design="botanical"]::before {
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><g fill='%23f3d79a' fill-opacity='.42'><path d='M10 190 C 60 150, 90 110, 110 50' fill='none' stroke='%23f3d79a' stroke-opacity='.55' stroke-width='2'/><path d='M40 160c-10-18 4-34 22-30-2 18-10 28-22 30z'/><path d='M62 136c-18-6-20-26-6-36 8 14 10 26 6 36z'/><path d='M76 112c4-20 24-26 34-14-14 8-24 14-34 14z'/><path d='M88 88c-14-12-8-32 8-34 2 16-2 26-8 34z'/><path d='M100 66c8-16 28-16 32-2-14 4-24 4-32 2z'/></g></svg>") left bottom / 62% auto no-repeat,
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><g fill='%23f3d79a' fill-opacity='.32' transform='rotate(180 100 100)'><path d='M10 190 C 60 150, 90 110, 110 50' fill='none' stroke='%23f3d79a' stroke-opacity='.45' stroke-width='2'/><path d='M40 160c-10-18 4-34 22-30-2 18-10 28-22 30z'/><path d='M62 136c-18-6-20-26-6-36 8 14 10 26 6 36z'/><path d='M76 112c4-20 24-26 34-14-14 8-24 14-34 14z'/></g></svg>") right top / 46% auto no-repeat;
}
.bk-cover[data-design="marble"]::before {
    background:
        linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .22) 40%, transparent 42%),
        linear-gradient(160deg, transparent 58%, rgba(255, 255, 255, .16) 59.5%, transparent 61%),
        linear-gradient(80deg, transparent 18%, rgba(243, 215, 154, .25) 19%, transparent 20.5%),
        linear-gradient(135deg, transparent 72%, rgba(255, 255, 255, .12) 74%, transparent 77%),
        radial-gradient(60% 40% at 30% 30%, rgba(255, 255, 255, .18), transparent 70%),
        radial-gradient(50% 35% at 75% 75%, rgba(0, 0, 0, .25), transparent 70%);
    filter: blur(.4px);
}
.bk-cover[data-design="minimal"] .bk-cover__frame { display: none; }
.bk-cover[data-design="minimal"] .bk-cover__emblem { border: 0; background: none; box-shadow: none; }
.bk-cover[data-design="minimal"] .bk-cover__title { letter-spacing: .08em; font-weight: 500; }
.bk-cover[data-design="minimal"]::before { background: linear-gradient(90deg, transparent 0 12%, rgba(243, 215, 154, .5) 12% calc(12% + 2px), transparent 0); }
.bk-cover[data-design="deco"] .bk-cover__frame { border-width: 3px; border-style: double; border-radius: 2px; }
.bk-cover[data-design="botanical"] .bk-cover__frame, .bk-cover[data-design="floral"] .bk-cover__frame { border-radius: 40px 4px 40px 4px; }
.bk-cover > :not(.bk-cover__frame) { position: relative; z-index: 1; }

/* Design picker tiles */
.dc__designs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; }
.dc__design { display: flex; flex-direction: column; align-items: center; gap: .3rem; border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
.dc__design small { font-size: .68rem; font-weight: 600; color: var(--db-muted-2); }
.dc-mini { position: relative; display: grid !important; place-items: center; width: 100%; aspect-ratio: 3 / 4; height: auto !important; border-radius: 3px 8px 8px 3px; overflow: hidden; color: #f3d79a; font-size: .8rem; }
.dc-mini .bk-cover__frame { inset: 5px 5px 5px 7px; border-width: 1px; }
.dc-mini .bk-cover__frame::before, .dc-mini .bk-cover__frame::after { width: 6px; height: 6px; border-width: 1px; }
.dc__design.is-active .dc-mini { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--mg-hero-a); }
.dc__designs[data-cover="theme"] .dc-mini { background: linear-gradient(140deg, color-mix(in srgb, var(--mg-hero-b) 72%, #1a0f0a), color-mix(in srgb, var(--mg-hero-b) 40%, #0b0610)); }
.dc__designs:not([data-cover="theme"]) .dc-mini { background: linear-gradient(140deg, var(--bk-cover-a), var(--bk-cover-b)); }
.bk-cover > .bk-cover__foot, .bk-cover > .bk-cover__hint { position: absolute; }
.bk-cover[data-design="floral"]::before { background-size: 110px 110px; opacity: .85; }
.dc-mini[data-design="floral"]::before { background-size: 40px 40px; }

/* ==========================================================================
   Public pages: top nav, footer, Features and FAQ (see partials/public-nav.php)
   ========================================================================== */
.mg-nav {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem 1.5rem;
    max-width: 1180px;
    margin: 0 auto;
    padding: max(1rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 3rem) 0;
}
.mg-nav__links { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; }
.mg-nav__links a {
    color: rgba(255, 255, 255, .82);
    text-decoration: none;
    font-weight: 500;
    font-size: .92rem;
    padding: .5rem .8rem;
    border-radius: 999px;
    transition: background-color .2s ease, color .2s ease;
}
.mg-nav__links a:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.mg-nav__links a.is-active { color: #fff; background: rgba(255, 255, 255, .14); }
.mg-nav__links a.mg-nav__cta {
    margin-left: .35rem;
    color: var(--mg-ink);
    font-weight: 600;
    background: linear-gradient(110deg, var(--mg-accent), var(--mg-accent-2));
}
.mg-nav__links a.mg-nav__cta:hover { color: var(--mg-ink); filter: brightness(1.08); }

/* The sign-in / sign-up grid fills the screen minus the nav */
.mg-nav ~ .mg-login__wrap { min-height: calc(100dvh - 4.5rem); padding-top: clamp(1rem, 3vw, 2rem); }
.mg-nav ~ .mg-login__wrap .mg-story__title { margin-top: 0; }

.mg-foot {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem clamp(1rem, 4vw, 3rem) max(1.5rem, env(safe-area-inset-bottom));
    text-align: center;
    font-size: .85rem;
    color: rgba(255, 255, 255, .65);
}
.mg-foot nav { display: flex; justify-content: center; flex-wrap: wrap; gap: .4rem 1.4rem; margin-bottom: .6rem; }
.mg-foot a { color: rgba(255, 255, 255, .85); text-decoration: none; }
.mg-foot a:hover { color: #fff; text-decoration: underline; }
.mg-foot p { margin: 0; }

.mg-pub {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 0 auto;
    padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 3rem) 1rem;
}
.mg-pub--narrow { max-width: 760px; }
.mg-pub__hero { text-align: center; margin-bottom: clamp(2rem, 5vw, 3.5rem); animation: mg-rise .9s var(--mg-ease) both; }
.mg-pub__hero .mg-story__title { margin: 0 0 1rem; }
.mg-pub__lede {
    max-width: 38rem;
    margin: 0 auto 1.6rem;
    font-size: clamp(1rem, 1.5vw, 1.12rem);
    line-height: 1.65;
    color: rgba(255, 255, 255, .85);
}
.mg-pub__btn { display: inline-flex; align-items: center; justify-content: center; width: auto; padding-inline: 1.6rem; text-decoration: none; }
.mg-pub__h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2rem);
    text-align: center;
    margin: 0 0 1.4rem;
}

/* Glass panel, same family as the sign-in card but near-opaque so long
   text stays readable whatever the sky is doing behind it */
.mg-panel {
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02)), rgba(10, 12, 38, .86);
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 24px 60px -28px rgba(0, 0, 0, .6);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.mg-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 1rem;
    margin-bottom: clamp(2.5rem, 6vw, 4rem);
}
.mg-feature { padding: 1.4rem 1.4rem 1.2rem; }
.mg-feature__icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    margin-bottom: .9rem;
    color: var(--mg-ink);
    background: linear-gradient(135deg, var(--mg-accent), var(--mg-accent-2));
}
.mg-feature h3, .mg-steps h3 { margin: 0 0 .4rem; font-size: 1.05rem; font-weight: 600; }
.mg-feature p, .mg-steps p { margin: 0; font-size: .93rem; line-height: 1.6; color: rgba(255, 255, 255, .88); }

.mg-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 clamp(2.5rem, 6vw, 4rem);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: 1rem;
}
.mg-steps li { padding: 1.4rem; }
.mg-steps b {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    margin-bottom: .8rem;
    border: 1px solid var(--mg-accent);
    color: var(--mg-accent);
    font-family: 'Source Serif 4', Georgia, serif;
}

.mg-pub__cta { text-align: center; padding: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: 1rem; }
.mg-pub__cta h2 { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: clamp(1.4rem, 3vw, 1.8rem); margin: 0 0 .5rem; }
.mg-pub__cta p { margin: 0 0 1.3rem; color: rgba(255, 255, 255, .82); line-height: 1.6; }

.mg-faq { display: grid; gap: .75rem; margin-bottom: clamp(2rem, 5vw, 3rem); }
.mg-faq__item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.3rem;
    cursor: pointer;
    list-style: none;
}
.mg-faq__item summary::-webkit-details-marker { display: none; }
.mg-faq__item summary h2 { margin: 0; font-size: 1.02rem; font-weight: 600; }
.mg-faq__item summary i { flex: 0 0 auto; font-size: .8rem; color: var(--mg-accent); transition: transform .25s var(--mg-ease); }
.mg-faq__item[open] summary i { transform: rotate(180deg); }
.mg-faq__item p { margin: 0; padding: 0 1.3rem 1.2rem; line-height: 1.65; color: rgba(255, 255, 255, .85); }

@media (max-width: 640px) {
    .mg-nav { justify-content: center; }
    .mg-nav__links { justify-content: center; }
    .mg-nav__links a { padding: .45rem .7rem; font-size: .88rem; }
    .mg-nav ~ .mg-login__wrap { min-height: 0; }
}
@media (max-width: 720px) {
    body.mg-login .mg-panel {
        background: linear-gradient(160deg, rgba(120, 90, 255, .14), rgba(40, 120, 255, .04) 60%, rgba(255, 110, 210, .07)), rgba(8, 10, 34, .88);
        border-color: rgba(170, 160, 255, .3);
    }
}

/* Privacy Policy / Terms of Service body text */
.mg-legal { padding: clamp(1.4rem, 4vw, 2.4rem); margin-bottom: 1rem; line-height: 1.7; color: rgba(255, 255, 255, .92); font-size: .97rem; }
.mg-legal h2 { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 1.25rem; color: #fff; margin: 1.8rem 0 .5rem; }
.mg-legal p { margin: 0 0 .9rem; }
.mg-legal ul { margin: 0 0 .9rem; padding-left: 1.2rem; }
.mg-legal li { margin-bottom: .45rem; }
.mg-legal b { color: #fff; }
.mg-legal .mg-link { overflow-wrap: anywhere; }

/* Hero text sits straight on the sky, so give it a soft shadow for contrast */
.mg-pub__hero .mg-pub__lede { color: rgba(255, 255, 255, .92); text-shadow: 0 1px 12px rgba(0, 0, 0, .55); }

/* Journaling guides */
.mg-guide-card { display: block; color: #fff; text-decoration: none; transition: transform .2s var(--mg-ease), border-color .2s ease; }
.mg-guide-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--mg-accent) 60%, transparent); }
.mg-guide-card h2, .mg-guide-card h3 { margin: 0 0 .4rem; font-size: 1.1rem; font-weight: 600; }
.mg-guide-card .mg-link { display: inline-block; margin-top: .8rem; font-size: .9rem; }
.mg-crumbs { font-size: .85rem; color: rgba(255, 255, 255, .7); margin-bottom: 1.2rem; text-align: center; }
.mg-crumbs a { color: rgba(255, 255, 255, .88); text-decoration: none; }
.mg-crumbs a:hover { text-decoration: underline; }
.mg-article { margin-bottom: clamp(2rem, 5vw, 3rem); }
.mg-article h3 { font-size: 1.05rem; font-weight: 600; color: #fff; margin: 1.3rem 0 .35rem; }
.mg-article ol { margin: 0 0 .9rem; padding-left: 1.4rem; }
.mg-article li::marker { color: var(--mg-accent); }
.mg-article__example {
    margin: 0 0 1rem;
    padding: 1.2rem 1.4rem;
    border-radius: 14px;
    border-left: 3px solid var(--mg-accent);
    background: rgba(255, 255, 255, .06);
}
.mg-article__example p:last-child { margin-bottom: 0; }
.mg-article .mg-btn { margin-top: .6rem; }

/* ==========================================================================
   Dashboard: pinned-notes card (top right) above a compact Insights card
   ========================================================================== */
.dash-pinboard__icon { width: 1.9rem; height: 1.9rem; border-radius: 9px; display: grid; place-items: center; background: #ffe9a8; color: #d62d4b; font-size: .8rem; }
.dash-pinboard__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 1rem .7rem; padding: .7rem .1rem .3rem; align-items: start; }
.dash-pinboard .pin-note,
.dash-pinboard .pin-note.is-folded {
    position: relative; left: auto !important; top: auto !important; width: auto; flex: none;
    box-shadow: 0 6px 12px -7px rgba(0, 0, 0, .4), inset 0 -10px 14px -12px rgba(0, 0, 0, .2);
    animation: none;
}
.dash-pinboard .pin-note:hover, .dash-pinboard .pin-note:focus-within { transform: rotate(0) translateY(-2px); }
.dash-pinboard .pin-note__bar { cursor: default; height: 22px; }
.dash-pinboard .pin-note__pin { top: -8px; width: 15px; height: 15px; margin-left: -7.5px; }
.dash-pinboard .pin-note textarea { font-size: 1.1rem; line-height: 1.3rem; padding: 0 .55rem .55rem; }
.dash-pinboard__empty { margin: .4rem 0 0; display: flex; gap: .6rem; align-items: flex-start; font-size: .8rem; line-height: 1.5; color: var(--db-muted-2); }
.dash-pinboard__empty i { color: #d62d4b; margin-top: .2rem; }

/* Compact Insights: smaller type and charts so it fits the bottom slot */
.dash-ai .dash-card__head { padding: .7rem .9rem .45rem; flex-wrap: wrap; }
.dash-ai .dash-card__body { padding: 0 .9rem .6rem; }
.dash-ai .dash-charts { gap: .45rem; margin-bottom: .55rem; }
.dash-ai .dash-ai__overview { font-size: .88rem; line-height: 1.5; }
.dash-ai .dash-card__foot { padding: .45rem .9rem .55rem; }
.dash-ai .mg-ask .db-btn { width: 2.2rem; height: 2.2rem; }
.dash-ai .mg-ask textarea { padding: .45rem .9rem; min-height: 2.2rem; }
@media (max-width: 1099px) { .dash-ai .dash-card__body { max-height: 300px; } }
@media (max-width: 720px) { .dash-pinboard__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash-pinboard .pin-note__tools { opacity: 1; } }

/* ==========================================================================
   Community (public/community.php) and the "Post to community" sheet
   ========================================================================== */
.cm-compose, .cm-join, .cm-post, .cm-empty, .cm-about { padding: clamp(1rem, 3vw, 1.4rem); margin-bottom: 1rem; }
.cm-compose__title { margin: 0 0 .8rem; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.15rem; font-weight: 600; }
.cm-compose__title i { color: var(--mg-accent); margin-right: .3rem; font-size: .95rem; }
.cm-input {
    display: block; width: 100%; margin-bottom: .6rem; padding: .7rem .85rem;
    border-radius: 12px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .07);
    color: #fff; font: inherit; font-size: 16px; outline: none; transition: border-color .15s ease, background-color .15s ease;
}
.cm-input::placeholder { color: rgba(255, 255, 255, .5); }
.cm-input:focus { border-color: var(--mg-accent); background: rgba(255, 255, 255, .1); }
.cm-input--area { resize: vertical; min-height: 6rem; line-height: 1.55; }
.cm-compose__row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.cm-actions { display: flex; gap: .4rem; align-items: center; margin-left: auto; }
.cm-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); max-width: 100%; }
.cm-seg button { border: 0; background: none; color: rgba(255, 255, 255, .78); font: inherit; font-size: .82rem; font-weight: 600; padding: .4rem .8rem; border-radius: 999px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 11rem; }
.cm-seg button.is-on { background: #fff; color: var(--mg-ink); }
.cm-btn { width: auto; padding: .6rem 1.4rem; margin: 0; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.cm-ghost { border: 1px solid rgba(255, 255, 255, .3); background: none; color: #fff; font: inherit; font-size: .88rem; font-weight: 600; padding: .55rem 1rem; border-radius: 12px; cursor: pointer; text-decoration: none; }
.cm-ghost:hover { background: rgba(255, 255, 255, .1); }
.cm-danger { border: 0; background: #e2364f; color: #fff; font: inherit; font-size: .85rem; font-weight: 700; padding: .5rem .9rem; border-radius: 10px; cursor: pointer; }
.cm-note { margin: .7rem 0 0; font-size: .78rem; color: rgba(255, 255, 255, .65); }
.cm-error { margin: .5rem 0 0; font-size: .85rem; color: #ff9aa8; }
.cm-muted { margin: .4rem 0; font-size: .85rem; color: rgba(255, 255, 255, .65); }
.cm-center { text-align: center; }
.cm-join p { margin: 0 0 .9rem; line-height: 1.6; color: rgba(255, 255, 255, .88); }
.cm-join__actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.cm-post__head { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.cm-avatar { flex: 0 0 auto; width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--mg-ink); background: linear-gradient(135deg, var(--mg-accent), var(--mg-accent-2)); text-transform: uppercase; }
.cm-avatar.is-anon { background: rgba(255, 255, 255, .14); color: #fff; }
.cm-post__who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cm-post__who b { font-size: .95rem; }
.cm-post__who > span { font-size: .76rem; color: rgba(255, 255, 255, .62); }
.cm-mood { flex: 0 0 auto; font-size: .7rem; font-weight: 700; text-transform: capitalize; padding: .2rem .6rem; border-radius: 999px; color: #fff; background: color-mix(in srgb, var(--c) 55%, transparent); border: 1px solid var(--c); }
.cm-menu { position: relative; flex: 0 0 auto; }
.cm-icon { width: 2rem; height: 2rem; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; }
.cm-icon:hover { background: rgba(255, 255, 255, .16); }
.cm-menu__pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; min-width: 9rem; padding: .3rem; border-radius: 12px; background: #fff; box-shadow: 0 16px 30px -12px rgba(0, 0, 0, .5); }
.cm-menu__pop button { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .55rem .7rem; border: 0; border-radius: 8px; background: none; font: inherit; font-size: .85rem; color: var(--mg-ink); cursor: pointer; text-align: left; }
.cm-menu__pop button:hover { background: #f1eefb; }
.cm-menu__pop .is-danger { color: #d0233c; }
.cm-confirm { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .8rem; padding: .6rem .8rem; border-radius: 12px; background: rgba(226, 54, 79, .15); border: 1px solid rgba(255, 140, 155, .4); font-size: .85rem; }
.cm-confirm span { flex: 1; min-width: 10rem; }
.cm-post__title { margin: 0 0 .4rem; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.2rem; font-weight: 600; }
.cm-post__body { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.7; font-size: .97rem; color: rgba(255, 255, 255, .92); }
.cm-post__body.is-clamped { display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.cm-more { margin-top: .3rem; border: 0; background: none; padding: 0; color: var(--mg-accent); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.cm-post__foot { margin-top: .9rem; padding-top: .7rem; border-top: 1px solid rgba(255, 255, 255, .12); }
.cm-toggle { display: inline-flex; align-items: center; gap: .45rem; border: 0; background: none; color: rgba(255, 255, 255, .85); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; padding: .2rem 0; }
.cm-toggle__chev { font-size: .7rem; transition: transform .2s var(--mg-ease); }
.cm-toggle__chev.is-open { transform: rotate(180deg); }

.cm-thread { margin-top: .7rem; }
.cm-comment { padding: .65rem .8rem; border-radius: 12px; background: rgba(255, 255, 255, .06); margin-bottom: .55rem; }
.cm-comment__head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .82rem; }
.cm-comment__head time { color: rgba(255, 255, 255, .55); font-size: .75rem; }
.cm-comment p { margin: .25rem 0 0; white-space: pre-wrap; word-break: break-word; line-height: 1.55; font-size: .9rem; color: rgba(255, 255, 255, .9); }
.cm-badge { font-size: .62rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: .1rem .45rem; border-radius: 999px; background: var(--mg-accent); color: var(--mg-ink); }
.cm-comment__tools { display: flex; gap: .8rem; margin-top: .35rem; }
.cm-comment__tools button { border: 0; background: none; padding: 0; color: rgba(255, 255, 255, .62); font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer; }
.cm-comment__tools button:hover { color: #fff; }
.cm-replies { margin: .5rem 0 0 1.1rem; padding-left: .8rem; border-left: 2px solid rgba(255, 255, 255, .14); }
.cm-replies:empty { display: none; }
.cm-comment--reply { background: rgba(255, 255, 255, .04); padding: .55rem .7rem; }
.cm-reply { display: flex; gap: .45rem; align-items: center; }
.cm-reply .cm-input { margin: 0; padding: .55rem .8rem; }
.cm-reply--new { margin-top: .4rem; }
.cm-send { flex: 0 0 auto; width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 0; cursor: pointer; color: var(--mg-ink); background: linear-gradient(135deg, var(--mg-accent), var(--mg-accent-2)); }
.cm-send:disabled { opacity: .45; cursor: default; }
.cm-empty { text-align: center; color: rgba(255, 255, 255, .8); }
.cm-empty i { font-size: 1.8rem; color: var(--mg-accent); }
.cm-about { margin-top: 1.5rem; }
.cm-about h2 { margin-top: 0; }

/* Poster sheet (light, inside the app) */
.cm-poster { width: min(100%, 520px); max-height: min(92vh, 760px); }
.cm-poster__body { overflow-y: auto; margin: 0 -.3rem; padding: 0 .3rem; }
.cm-poster__pick { display: flex; gap: .4rem; flex-wrap: wrap; margin: .35rem 0 .8rem; }
.cm-poster__pick button { display: inline-flex; align-items: center; gap: .4rem; max-width: 100%; border: 1px solid var(--db-border); background: #fff; color: var(--db-muted-2); border-radius: 999px; padding: .4rem .8rem; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.cm-poster__pick button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem; }
.cm-poster__pick button.is-on { background: var(--mg-ink); border-color: var(--mg-ink); color: #fff; }
.cm-poster__input { display: block; width: 100%; margin: .35rem 0 .8rem; padding: .6rem .75rem; border-radius: 12px; border: 1px solid var(--db-border); background: var(--db-bg); font: inherit; font-size: 16px; color: var(--db-text); outline: none; }
.cm-poster__input:focus { border-color: var(--mg-hero-a); background: #fff; }
.cm-poster__text { resize: vertical; line-height: 1.55; min-height: 8rem; }
.cm-poster__done { text-align: center; padding: 1rem 0 .4rem; }
.cm-poster__done > i { font-size: 2.4rem; color: #009c73; }
.cm-poster__done p { margin: .7rem 0 .4rem; font-size: .95rem; }

@media (max-width: 520px) {
    .cm-compose__row { flex-direction: column; align-items: stretch; }
    .cm-seg { width: 100%; }
    .cm-seg button { flex: 1; max-width: none; }
    .cm-actions { margin-left: 0; justify-content: flex-end; }
    .cm-compose .cm-btn { width: 100%; }
    .cm-replies { margin-left: .4rem; padding-left: .6rem; }
    .cm-mood { display: none; }
}

/* App header: five tabs (Home, Read, Write, Canvas, Community) scroll sideways on small phones */
@media (max-width: 640px) {
    .db-nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
    .db-nav::-webkit-scrollbar { display: none; }
}
@media (max-width: 480px) {
    .db-nav__tab { padding: .35rem .5rem; font-size: .76rem; }
}

/* Sprinkles celebration (assets/js/sprinkles.js) */
.sprk-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 300; pointer-events: none; }
.sprk-msg {
    position: fixed; left: 50%; top: max(1.2rem, env(safe-area-inset-top)); z-index: 301;
    max-width: calc(100vw - 2rem); padding: .75rem 1.3rem; border-radius: 999px;
    font: 700 .98rem/1.3 'Inter', sans-serif; color: #120c33; text-align: center;
    background: linear-gradient(110deg, #8fd8ff, #c7a6ff, #ff9fe0);
    box-shadow: 0 16px 40px -12px rgba(120, 90, 255, .7);
    pointer-events: none; opacity: 0; transform: translate(-50%, -16px) scale(.96);
    transition: opacity .35s ease, transform .45s cubic-bezier(.22, .8, .24, 1);
}
.sprk-msg.is-in { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ==========================================================================
   Notifications bell (header.php)
   ========================================================================== */
.nt { position: relative; flex: 0 0 auto; }
.nt__bell { position: relative; }
.nt__badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #ff5a72; color: #fff; font: 700 .64rem/18px 'Inter', sans-serif; text-align: center; box-shadow: 0 0 0 2px rgba(14, 10, 40, .7); }
.nt__panel {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 90;
    width: min(360px, calc(100vw - 1.5rem)); max-height: min(70vh, 520px);
    display: flex; flex-direction: column; overflow: hidden;
    border-radius: 18px; background: #fffdf7; color: var(--db-text);
    box-shadow: 0 30px 60px -20px rgba(8, 6, 30, .7);
}
.nt__head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1rem .6rem; border-bottom: 1px solid var(--db-border); }
.nt__head b { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.05rem; }
.nt__link { border: 0; background: none; padding: 0; font: inherit; font-size: .8rem; font-weight: 600; color: #4f62c9; cursor: pointer; }
.nt__list { flex: 1; overflow-y: auto; padding: .35rem; }
.nt__item { display: flex; gap: .7rem; padding: .65rem .6rem; border-radius: 12px; text-decoration: none; color: inherit; }
.nt__item:hover { background: var(--db-bg); }
.nt__item.is-unread { background: color-mix(in srgb, #7b68c8 9%, #fff); }
.nt__icon { flex: 0 0 auto; width: 2.1rem; height: 2.1rem; border-radius: 10px; display: grid; place-items: center; font-size: .85rem; background: #ece7fb; color: #6a56c4; }
.nt__icon[data-type^="event"] { background: #e3f1fb; color: #2f7fb8; }
.nt__icon[data-type^="community"] { background: #fde9f2; color: #c2457a; }
.nt__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; font-size: .84rem; line-height: 1.4; }
.nt__text b { font-weight: 600; }
.nt__text > span { color: var(--db-muted-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nt__text time { font-size: .72rem; color: var(--db-muted-3); }
.nt__empty { margin: 0; padding: 1.4rem 1rem; text-align: center; font-size: .84rem; line-height: 1.5; color: var(--db-muted-2); }
.nt__empty i { display: block; font-size: 1.5rem; margin-bottom: .5rem; color: #c9bfe8; }
.nt__foot { padding: .6rem 1rem .75rem; border-top: 1px solid var(--db-border); font-size: .78rem; color: var(--db-muted-2); }
.nt__toast {
    position: fixed; right: 1rem; top: 4.4rem; z-index: 95; max-width: min(340px, calc(100vw - 2rem));
    display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; border-radius: 14px; cursor: pointer;
    background: #fffdf7; color: var(--db-text); font-size: .86rem; font-weight: 600;
    box-shadow: 0 20px 40px -14px rgba(8, 6, 30, .7);
}
.nt__toast i { color: #6a56c4; }
@media (max-width: 520px) {
    .nt { position: static; }
    .nt__panel { position: fixed; left: .75rem; right: .75rem; top: 3.8rem; width: auto; }
}

/* "Continue with Google" (partials/google-signin.php) */
.mg-google__btn { display: flex; justify-content: center; min-height: 44px; }
.mg-google__error { margin: .6rem 0 0; font-size: .84rem; color: #ffb3bd; text-align: center; }
.mg-google .mg-divider { margin: 1.1rem 0 1rem; }

/* ==========================================================================
   Public content pages (body.mg-public: features, guides, FAQ, community,
   privacy, terms) in the diary's look: the app's own sky with cream paper
   cards and ink text, like the dashboard. Headings on the sky stay white.
   ========================================================================== */
body.mg-public {
    --pp-paper: #fffdf7;
    --pp-ink: #1d2647;
    --pp-text: #3a4560;
    --pp-muted: #6b7690;
    --pp-line: #ece5d3;
    --pp-soft: #f6f1e4;
    --pp-link: #4f62c9;
}
body.mg-public .mg-pub__hero .mg-story__title,
body.mg-public .mg-pub__h2,
body.mg-public .mg-crumbs { text-shadow: 0 2px 18px rgba(8, 6, 30, .45); }
body.mg-public .mg-pub__hero .mg-pub__lede { text-shadow: 0 1px 14px rgba(8, 6, 30, .6); }

/* Paper cards */
body.mg-public .mg-panel,
body.mg-login.mg-public .mg-panel {
    background: linear-gradient(180deg, var(--pp-paper), #fbf6ea);
    color: var(--pp-text);
    border: 1px solid rgba(255, 255, 255, .6);
    box-shadow: 0 20px 50px -24px rgba(8, 6, 30, .55);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
body.mg-public .mg-panel h2,
body.mg-public .mg-panel h3,
body.mg-public .mg-panel b,
body.mg-public .mg-legal h2,
body.mg-public .mg-legal b { color: var(--pp-ink); }
body.mg-public .mg-panel p,
body.mg-public .mg-legal,
body.mg-public .mg-feature p,
body.mg-public .mg-steps p,
body.mg-public .mg-pub__cta p,
body.mg-public .mg-faq__item p { color: var(--pp-text); }
body.mg-public .mg-panel .mg-link { color: var(--pp-link); }
body.mg-public .mg-feature__icon { color: #fff; background: linear-gradient(135deg, var(--mg-hero-a, #7b68c8), var(--mg-hero-b, #3f3488)); }
body.mg-public .mg-steps b { border-color: var(--mg-hero-a, #7b68c8); color: var(--mg-hero-a, #7b68c8); }
body.mg-public .mg-article li::marker { color: var(--mg-hero-a, #7b68c8); }
body.mg-public .mg-article__example { background: var(--pp-soft); border-left-color: #e0708c; font-family: var(--mg-hand); font-size: 1.3rem; line-height: 1.55; color: #1f3f8a; }
body.mg-public .mg-article__example p, body.mg-public .mg-article__example b { color: #1f3f8a; }
body.mg-public .mg-faq__item summary i { color: var(--mg-hero-a, #7b68c8); }
body.mg-public .mg-guide-card { color: var(--pp-ink); }
body.mg-public .mg-guide-card:hover { border-color: #fff; box-shadow: 0 24px 50px -20px rgba(8, 6, 30, .6), 0 0 0 3px color-mix(in srgb, var(--mg-accent) 45%, transparent); }
body.mg-public .mg-panel .mg-btn { color: #fff; background: linear-gradient(135deg, var(--mg-hero-a, #7b68c8), var(--mg-hero-b, #3f3488)); box-shadow: 0 12px 26px -12px rgba(8, 6, 30, .6); }

/* Community on paper */
body.mg-public .mg-panel .cm-input { background: var(--pp-soft); border-color: var(--pp-line); color: var(--pp-ink); }
body.mg-public .mg-panel .cm-input::placeholder { color: #a39c88; }
body.mg-public .mg-panel .cm-input:focus { background: #fff; border-color: var(--mg-hero-a, #7b68c8); }
body.mg-public .cm-compose__title i { color: var(--mg-hero-a, #7b68c8); }
body.mg-public .mg-panel .cm-seg { background: var(--pp-soft); border-color: var(--pp-line); }
body.mg-public .mg-panel .cm-seg button { color: var(--pp-muted); }
body.mg-public .mg-panel .cm-seg button.is-on { background: var(--pp-ink); color: #fff; }
body.mg-public .mg-panel .cm-ghost { border-color: var(--pp-line); color: var(--pp-ink); background: #fff; }
body.mg-public .mg-panel .cm-ghost:hover { background: var(--pp-soft); }
body.mg-public .mg-panel .cm-note, body.mg-public .mg-panel .cm-muted, body.mg-public .cm-post__who > span, body.mg-public .cm-comment__head time { color: var(--pp-muted); }
body.mg-public .mg-panel .cm-error { color: #c42a40; }
body.mg-public .cm-avatar { color: #fff; background: linear-gradient(135deg, var(--mg-hero-a, #7b68c8), var(--mg-hero-b, #3f3488)); }
body.mg-public .cm-avatar.is-anon { background: #e7e1d1; color: var(--pp-ink); }
body.mg-public .cm-mood { color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
body.mg-public .cm-icon { background: var(--pp-soft); color: var(--pp-ink); }
body.mg-public .cm-icon:hover { background: var(--pp-line); }
body.mg-public .cm-confirm { background: #fdecef; border-color: #f5c2cb; color: #8c1d2f; }
body.mg-public .cm-post__body { color: var(--pp-text); }
body.mg-public .cm-more { color: var(--pp-link); }
body.mg-public .cm-post__foot { border-top-color: var(--pp-line); }
body.mg-public .cm-toggle { color: var(--pp-ink); }
body.mg-public .cm-comment { background: var(--pp-soft); }
body.mg-public .cm-comment--reply { background: #fff; border: 1px solid var(--pp-line); }
body.mg-public .cm-comment p { color: var(--pp-text); }
body.mg-public .cm-comment__tools button { color: var(--pp-muted); }
body.mg-public .cm-comment__tools button:hover { color: var(--pp-ink); }
body.mg-public .cm-replies { border-left-color: var(--pp-line); }
body.mg-public .cm-badge { background: var(--mg-hero-a, #7b68c8); color: #fff; }
body.mg-public .cm-send { color: #fff; background: linear-gradient(135deg, var(--mg-hero-a, #7b68c8), var(--mg-hero-b, #3f3488)); }
body.mg-public .cm-empty { color: var(--pp-text); }
body.mg-public .cm-empty i { color: var(--mg-hero-a, #7b68c8); }

/* Phones: keep the app's landscape sky instead of the sign-in galaxy */
@media (max-width: 720px) {
    body.mg-login.mg-public { background: #0b0d26; }
    body.mg-login.mg-public::before { display: none; }
    body.mg-login.mg-public .mg-scene,
    body.mg-login.mg-public .mg-sky__mist,
    body.mg-login.mg-public .mg-sky__sun { display: block; }
    body.mg-login.mg-public .mg-sky__moon { top: var(--mg-moon-top); right: 9%; width: clamp(90px, 13vw, 170px); opacity: var(--mg-moon-op); }
}

/* Text that sits on the sky gets the header's frosted glass, so it reads on
   pale skies (blossom, candy, clouds) as well as dark ones */
body.mg-public .mg-pub__hero {
    padding: clamp(1.2rem, 3.5vw, 2rem) clamp(1rem, 3vw, 2rem);
    border-radius: 24px;
    background: rgba(12, 10, 40, .3);
    border: 1px solid rgba(255, 255, 255, .14);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
body.mg-public .mg-pub__h2 {
    display: table;
    margin-inline: auto;
    padding: .35rem 1.2rem;
    border-radius: 999px;
    background: rgba(12, 10, 40, .32);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
body.mg-public .mg-crumbs { display: table; margin-inline: auto; padding: .3rem .9rem; border-radius: 999px; background: rgba(12, 10, 40, .3); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
body.mg-public .mg-foot {
    max-width: min(1180px, calc(100% - 2rem));
    margin: 1rem auto max(1rem, env(safe-area-inset-bottom));
    border-radius: 20px;
    background: rgba(12, 10, 40, .4);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
body.mg-public .cm-center > .cm-ghost { background: rgba(12, 10, 40, .35); }

/* ==========================================================================
   Sign-up: one screen, compact two-column form (signup.php)
   ========================================================================== */
.mg-login__wrap--signup { grid-template-columns: minmax(0, 1fr) minmax(520px, 600px); gap: clamp(1.5rem, 4vw, 3.5rem); }
.mg-nav ~ .mg-login__wrap--signup { padding-top: clamp(.6rem, 2vw, 1.2rem); padding-bottom: clamp(.8rem, 2vw, 1.4rem); }
.mg-card--compact { padding: clamp(1.2rem, 3vw, 1.7rem) clamp(1.2rem, 3vw, 1.9rem); }
.mg-card--compact h2 { font-size: 1.5rem; margin-bottom: .15rem; }
.mg-card--compact .mg-card__lede { margin-bottom: 1rem; }
.mg-card--compact .mg-alert { margin-bottom: .8rem; }
.mg-card--compact .mg-google .mg-divider { margin: .8rem 0 .8rem; }
.mg-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; align-items: start; margin-bottom: 1rem; }
.mg-form-grid .mg-field { margin: 0; min-width: 0; }
.mg-card--compact .mg-field label { font-size: .68rem; margin-bottom: .35rem; }
.mg-card--compact .mg-input input { padding-top: .7rem; padding-bottom: .7rem; }
.mg-card--compact .mg-strength { margin-top: .4rem; }
.mg-card--compact .mg-hint { font-size: .72rem; margin-top: .3rem; }
/* Terms sit beside the phone field, lined up with its input */
.mg-form-grid .mg-terms { margin: 0; align-self: end; min-height: 2.9rem; display: flex; align-items: center; font-size: .8rem; }
.mg-card--compact .mg-btn { padding: .85rem 1rem; }
.mg-switch { margin: .9rem 0 0; text-align: center; font-size: .88rem; color: rgba(255, 255, 255, .78); }

/* Short laptop screens: drop the decorative notebook so the form fits */
@media (min-width: 901px) and (max-height: 760px) {
    .mg-login__wrap--signup .mg-notebook { display: none; }
    .mg-login__wrap--signup .mg-story__sub { margin-bottom: 0; }
}
/* Tablets: story above, form below, still two columns */
@media (max-width: 900px) {
    .mg-login__wrap--signup { grid-template-columns: minmax(0, 1fr); max-width: 600px; }
}
/* Phones: one column */
@media (max-width: 560px) {
    .mg-form-grid { grid-template-columns: 1fr; gap: .7rem; }
    .mg-form-grid .mg-terms { min-height: 0; }
}
