/* Chronicle — the Diary surface is isolated from the rest of the Lull shell. */
#view-diary.diary-view {
    position: fixed;
    z-index: 210;
    inset: 0;
    display: none;
    width: 100%;
    height: 100dvh;
    align-items: stretch;
    justify-content: stretch;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    background: #f4f2eb;
}
#view-diary.diary-view.active { display: flex; animation: none; }
#app-content:has(#view-diary.active) { padding-bottom: 0 !important; overflow: hidden; }
body.diary-immersive-active #app-content { padding-bottom: 0 !important; overflow: hidden; }
#bottom-nav.diary-nav-hidden { display: none !important; }

.diary-device {
    --bg: #f4f2eb;
    --bg-letter: #fdfcf7;
    --ink: #1f1e1b;
    --ink-sub: #5c5b56;
    --ink-muted: #9e9c94;
    --line: #dfddd5;
    --line-subtle: #eceae4;
    --seal-red: #944837;
    --aura-clear: #8a9a86;
    --aura-calm: #788585;
    --aura-glow: #b8976c;
    --aura-deep: #4a535e;
    --aura-frost: #a89f91;
    --serif: "Noto Serif SC", "LXGW WenKai", Georgia, serif;
    --en-serif: "Cinzel", "Times New Roman", serif;
    position: relative;
    width: 100%;
    max-width: none;
    height: 100%;
    overflow: hidden;
    border-radius: 0;
    background: var(--bg);
    box-shadow: none;
    color: var(--ink);
    font-family: var(--serif);
    -webkit-font-smoothing: antialiased;
    transition: background .35s ease;
}

.diary-device,
.diary-device * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.diary-device button,
.diary-device input,
.diary-device textarea { font: inherit; }
.diary-device button { border: 0; outline: 0; cursor: pointer; }
.diary-device button:focus-visible,
.diary-device [role="button"]:focus-visible,
.diary-device input:focus-visible,
.diary-device textarea:focus-visible { outline: 1px solid var(--seal-red); outline-offset: 3px; }

.diary-device .scroll-body {
    height: 100%;
    overflow-y: auto;
    padding: 0 28px calc(90px + env(safe-area-inset-bottom, 0px));
    scrollbar-width: none;
}
.diary-device .scroll-body::-webkit-scrollbar { display: none; }
.diary-device .page-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: calc(31px + env(safe-area-inset-top, 0px)) 0 38px;
}
.diary-device .space-title {
    padding: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--en-serif);
    font-size: 13px;
    letter-spacing: .25em;
    line-height: 1;
}
.diary-device .mode {
    padding: 0;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    font-size: 11px;
    letter-spacing: .05em;
}
.diary-device .view-stage { display: none; }
.diary-device .view-stage.active { display: block; animation: diary-fade-in .25s ease; }
@keyframes diary-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 纪事 */
.diary-device .day { margin-bottom: 52px; }
.diary-device .day-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-bottom: 9px;
    border-bottom: .5px solid var(--line);
}
.diary-device .date { display: flex; align-items: baseline; gap: 8px; }
.diary-device .date-number {
    font-family: var(--en-serif);
    font-size: 27px;
    line-height: 1;
}
.diary-device .date-info {
    color: var(--ink-muted);
    font-size: 10.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.diary-device .day-mood {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--ink-muted);
    font-size: 10.5px;
}
.diary-device .mood-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.diary-device .pages { padding-top: 22px; }
.diary-device .page { position: relative; cursor: pointer; }
.diary-device .page + .page { margin-top: 29px; }
.diary-device .page.mine { padding-right: 28px; }
.diary-device .page-owner {
    margin-bottom: 8px;
    color: var(--ink-muted);
    font-size: 9.5px;
    letter-spacing: .14em;
}
.diary-device .page-title {
    margin-bottom: 7px;
    color: var(--ink);
    font-size: 16.5px;
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1.5;
}
.diary-device .page-preview {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ink-sub);
    font-size: 12.8px;
    font-weight: 300;
    line-height: 1.85;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.diary-device .page-foot {
    margin-top: 9px;
    color: var(--ink-muted);
    font-family: var(--en-serif);
    font-size: 9px;
    letter-spacing: .08em;
}
.diary-device .page.theirs {
    margin-left: 34px;
    padding-left: 17px;
    border-left: 1px solid var(--line);
}
.diary-device .page.theirs .page-title,
.diary-device .page.theirs .page-foot { text-align: right; }
.diary-device .page.theirs .page-preview { text-align: justify; }
.diary-device .today .date-number,
.diary-device .today .date-info { color: var(--seal-red); }
.diary-device .unwritten { padding: 3px 0; }
.diary-device .unwritten-title { margin-bottom: 7px; color: var(--ink-sub); font-size: 14px; }
.diary-device .write-link {
    color: var(--seal-red);
    font-size: 11px;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* 人物切换 */
.diary-device .character-switcher {
    position: relative;
    z-index: 15;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}
.diary-device .character-current {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0 3px 8px;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    font-size: 9.5px;
    letter-spacing: .14em;
}
.diary-device .character-menu {
    position: absolute;
    top: 25px;
    right: -5px;
    width: 142px;
    padding: 5px 0;
    border: 1px solid var(--line);
    background: var(--bg-letter);
    box-shadow: 0 12px 35px rgba(0, 0, 0, .1);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-5px);
    transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
    visibility: hidden;
}
.diary-device .character-switcher.open .character-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    visibility: visible;
}
.diary-device .character-menu::before {
    position: absolute;
    top: -4px;
    right: 20px;
    width: 7px;
    height: 7px;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    background: var(--bg-letter);
    content: "";
    transform: rotate(45deg);
}
.diary-device .character-option {
    position: relative;
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px 9px 16px;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
}
.diary-device .character-option:hover { background: var(--line-subtle); }
.diary-device .option-name { font-size: 11px; letter-spacing: .08em; }
.diary-device .option-mood { font-size: 9px; }
.diary-device .character-option.active::before {
    position: absolute;
    top: 6px;
    left: 7px;
    content: "·";
    font-size: 15px;
}
.diary-device .character-diary-content { transition: opacity .15s ease, transform .15s ease; }
.diary-device .character-diary-content.changing { opacity: 0; transform: translateY(3px); }

/* 锁定与留白 */
.diary-device .locked-page {
    margin-top: 29px;
    margin-left: 34px;
    padding: 4px 0 4px 17px;
    border-left: 1px solid var(--line);
}
.diary-device .lock-line { width: 42px; height: 1px; margin: 13px 0 11px auto; background: var(--line); }
.diary-device .lock-title { margin-bottom: 5px; color: var(--ink-sub); font-size: 12.5px; text-align: right; }
.diary-device .lock-sub { color: var(--ink-muted); font-size: 10.5px; line-height: 1.7; text-align: right; }
.diary-device .exchange-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 25px;
    color: var(--ink-muted);
    font-size: 9px;
    letter-spacing: .14em;
}
.diary-device .exchange-mark::before,
.diary-device .exchange-mark::after { flex: 1; height: .5px; background: var(--line); content: ""; }
.diary-device .missed-mine { padding: 4px 28px 4px 0; opacity: .66; }
.diary-device .blank-line { width: 30px; height: 1px; margin: 14px 0 10px; background: var(--ink-muted); }
.diary-device .blank-text { color: var(--ink-muted); font-size: 11.5px; font-style: italic; }
.diary-device .blank-foot { margin-top: 7px; color: var(--ink-muted); font-size: 9.5px; line-height: 1.7; }
.diary-device .theirs-empty { cursor: default; }
.diary-device .theirs-empty .empty-content { opacity: .66; text-align: right; }
.diary-device .theirs-empty .blank-line { margin-left: auto; }

/* 心迹 */
.diary-device .resonance-page { padding: 2px 0 28px; }
.diary-device .resonance-heading { padding-bottom: 25px; border-bottom: .5px solid var(--line); }
.diary-device .resonance-month { margin-bottom: 12px; color: var(--seal-red); font-family: var(--en-serif); font-size: 10px; letter-spacing: .2em; }
.diary-device .resonance-title { color: var(--ink); font-size: 23px; font-weight: 600; letter-spacing: .035em; line-height: 1.55; }
.diary-device .resonance-title::after { display: block; width: 24px; height: 1px; margin-top: 17px; background: var(--line); content: ""; }
.diary-device .resonance-copy { max-width: 255px; margin-top: 18px; color: var(--ink-muted); font-size: 11.5px; font-weight: 300; line-height: 1.95; }
.diary-device .month-mood { padding: 36px 0 38px; }
.diary-device .trace-label { color: var(--ink-muted); font-size: 9.5px; letter-spacing: .15em; }
.diary-device .mood-ribbon { display: flex; width: 100%; height: 3px; margin-top: 20px; }
.diary-device .mood-ribbon span { display: block; height: 100%; }
.diary-device .mood-ribbon .clear { width: 40%; background: var(--aura-clear); }
.diary-device .mood-ribbon .calm { width: 30%; background: var(--aura-calm); }
.diary-device .mood-ribbon .glow { width: 20%; background: var(--aura-glow); }
.diary-device .mood-ribbon .deep { width: 10%; background: var(--aura-deep); }
.diary-device .mood-names { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 18px; margin-top: 17px; }
.diary-device .mood-name { display: flex; align-items: center; gap: 6px; color: var(--ink-muted); font-size: 10px; }
.diary-device .mood-name::before { width: 4px; height: 4px; border-radius: 50%; background: var(--mood); content: ""; }
.diary-device .mood-name.clear { --mood: var(--aura-clear); }
.diary-device .mood-name.calm { --mood: var(--aura-calm); }
.diary-device .mood-name.glow { --mood: var(--aura-glow); }
.diary-device .mood-name.deep { --mood: var(--aura-deep); }
.diary-device .mood-name.frost { --mood: var(--aura-frost); }
.diary-device .month-trace { padding-top: 25px; border-top: .5px solid var(--line); }
.diary-device .trace-head { display: flex; align-items: baseline; justify-content: space-between; }
.diary-device .trace-note { color: var(--ink-muted); font-size: 8.5px; }
.diary-device .trace-days { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 30px; }
.diary-device .trace-days::before { position: absolute; top: 8px; right: 7%; left: 7%; height: .5px; background: var(--line); content: ""; }
.diary-device .trace-day { position: relative; z-index: 1; text-align: center; }
.diary-device .trace-point { display: flex; width: 17px; height: 17px; align-items: center; justify-content: center; margin: 0 auto 9px; background: var(--bg); }
.diary-device .trace-point::after { width: 3px; height: 3px; border-radius: 50%; background: var(--line); content: ""; }
.diary-device .trace-day.opened .trace-point::after { width: 5px; height: 5px; background: var(--seal-red); }
.diary-device .trace-day.missed { opacity: .38; }
.diary-device .trace-day.missed .trace-point::after { width: 7px; height: 1px; border-radius: 0; background: var(--ink-muted); transform: rotate(-35deg); }
.diary-device .trace-day.current .trace-point { border: 1px solid var(--seal-red); border-radius: 50%; }
.diary-device .trace-day.current .trace-point::after { width: 0; height: 0; }
.diary-device .trace-date { color: var(--ink-muted); font-family: var(--en-serif); font-size: 9px; }
.diary-device .trace-day.opened .trace-date { color: var(--ink-sub); }
.diary-device .trace-day.current .trace-date { color: var(--seal-red); }
.diary-device .trace-months { display: flex; justify-content: space-between; margin-top: 21px; color: var(--ink-muted); font-family: var(--en-serif); font-size: 8px; letter-spacing: .14em; }

/* 弹窗 */
.diary-device .modal-overlay {
    position: absolute;
    z-index: 100;
    inset: 0;
    display: flex;
    align-items: flex-end;
    background: rgba(25, 24, 21, .28);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease, visibility .28s ease;
    visibility: hidden;
}
.diary-device .modal-overlay.show { opacity: 1; pointer-events: auto; visibility: visible; }
.diary-device .modal-sheet {
    width: 100%;
    height: 92%;
    overflow: hidden;
    border-radius: 22px 22px 0 0;
    background: var(--bg-letter);
    box-shadow: 0 -18px 55px rgba(0, 0, 0, .08);
    transform: translateY(100%);
    transition: transform .42s cubic-bezier(.22, .8, .24, 1), background .35s ease;
}
.diary-device .modal-overlay.show .modal-sheet { transform: translateY(0); }
.diary-device .sheet-body { height: 100%; overflow-y: auto; padding: 39px 29px calc(52px + env(safe-area-inset-bottom)); scrollbar-width: none; }
.diary-device .sheet-body::-webkit-scrollbar { display: none; }
.diary-device .sheet-meta-row { display: flex; min-height: 28px; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.diary-device .sheet-date-stamp { color: var(--ink-muted); font-family: var(--en-serif); font-size: 9px; letter-spacing: .15em; }
.diary-device .sheet-close,
.diary-device .write-close { display: flex; width: 28px; height: 28px; align-items: center; justify-content: center; margin-right: -7px; background: transparent; color: var(--ink-muted); cursor: pointer; font-family: Georgia, serif; font-size: 18px; }
.diary-device .sheet-title { max-width: 92%; margin-bottom: 30px; color: var(--ink); font-size: 22px; font-weight: 600; letter-spacing: .025em; line-height: 1.55; }
.diary-device .sheet-title::after { display: block; width: 22px; height: 1px; margin-top: 21px; background: var(--line); content: ""; }
.diary-device .sheet-content { color: var(--ink-sub); font-size: 14px; font-weight: 300; line-height: 2.15; text-align: justify; }
.diary-device .sheet-content p { margin: 0 0 21px; text-indent: 2em; }
.diary-device .sheet-content p:first-child { text-indent: 0; }
.diary-device .sheet-seal-mark { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 15px; border-top: .5px solid var(--line-subtle); color: var(--ink-muted); font-size: 9px; }

/* 落墨 */
.diary-device .write-sheet { height: 94%; }
.diary-device .write-paper { height: 100%; overflow-y: auto; padding: 39px 30px calc(34px + env(safe-area-inset-bottom)); scrollbar-width: none; }
.diary-device .write-paper::-webkit-scrollbar { display: none; }
.diary-device .write-meta { display: flex; min-height: 28px; align-items: center; justify-content: space-between; margin-bottom: 35px; }
.diary-device .write-date { color: var(--ink-muted); font-family: var(--en-serif); font-size: 9px; letter-spacing: .15em; }
.diary-device .write-mood { display: flex; min-height: 22px; align-items: center; margin-bottom: 29px; }
.diary-device .write-mood-label { flex-shrink: 0; margin-right: 19px; color: var(--ink-muted); font-size: 9px; letter-spacing: .14em; }
.diary-device .mood-options { display: flex; flex: 1; align-items: center; justify-content: space-between; }
.diary-device .mood-option { position: relative; padding: 3px 0; background: transparent; color: var(--ink-muted); cursor: pointer; font-size: 10.5px; opacity: .52; transition: color .2s ease, opacity .2s ease, transform .2s ease; }
.diary-device .mood-option[data-mood="晴空"] { --mood-color: var(--aura-clear); }
.diary-device .mood-option[data-mood="远山"] { --mood-color: var(--aura-calm); }
.diary-device .mood-option[data-mood="暮色"] { --mood-color: var(--aura-glow); }
.diary-device .mood-option[data-mood="幽夜"] { --mood-color: var(--aura-deep); }
.diary-device .mood-option[data-mood="霜雪"] { --mood-color: var(--aura-frost); }
.diary-device .mood-option.active { color: var(--mood-color); opacity: 1; transform: translateY(-1px); }
.diary-device .mood-option.active::before { position: absolute; top: -7px; left: 50%; width: 4px; height: 4px; border-radius: 50%; background: var(--mood-color); content: ""; transform: translateX(-50%); }
.diary-device .writer-title { width: 100%; margin-bottom: 17px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 23px; font-weight: 600; letter-spacing: .025em; line-height: 1.55; }
.diary-device .writer-title::placeholder { color: var(--ink-muted); font-weight: 400; opacity: .48; }
.diary-device .title-mark { width: 22px; height: 1px; margin-bottom: 26px; background: var(--line); }
.diary-device .writer-content { width: 100%; min-height: 300px; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink-sub); font-size: 14px; font-weight: 300; letter-spacing: .015em; line-height: 2.15; }
.diary-device .writer-content::placeholder { color: var(--ink-muted); opacity: .45; }
.diary-device .writer-count { margin-top: 15px; color: var(--ink-muted); font-family: var(--en-serif); font-size: 8.5px; letter-spacing: .1em; text-align: right; }
.diary-device .write-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 23px; padding-top: 17px; border-top: .5px solid var(--line-subtle); }
.diary-device .intent-options { display: flex; align-items: center; gap: 16px; }
.diary-device .intent-item { position: relative; color: var(--ink-muted); cursor: pointer; font-size: 10px; }
.diary-device .intent-item.active { color: var(--ink); }
.diary-device .intent-item.active::after { position: absolute; bottom: -7px; left: 50%; width: 3px; height: 3px; border-radius: 50%; background: var(--seal-red); content: ""; transform: translateX(-50%); }
.diary-device .seal-btn { padding: 4px 0; background: transparent; color: var(--seal-red); cursor: pointer; font-size: 11px; letter-spacing: .08em; }
.diary-device .seal-btn::after { content: " →"; }
.diary-device .seal-btn:disabled { cursor: wait; opacity: .5; }

/* 底栏 */
.diary-device .bottom-lens-nav { position: absolute; right: 0; bottom: 0; left: 0; z-index: 20; display: flex; height: calc(64px + env(safe-area-inset-bottom, 0px)); align-items: center; justify-content: space-around; padding: 0 75px env(safe-area-inset-bottom, 0px); border-top: 1px solid var(--line); background: var(--bg); }
.diary-device .lens-btn { color: var(--ink-muted); cursor: pointer; font-size: 12.5px; letter-spacing: .1em; }
.diary-device .lens-btn.active { color: var(--ink); font-weight: 600; }

/* 深色 */
.diary-device[data-theme="dark"] {
    --bg: #131312;
    --bg-letter: #1a1a19;
    --ink: #e0ded7;
    --ink-sub: #9e9c93;
    --ink-muted: #66635c;
    --line: #292927;
    --line-subtle: #242422;
    --seal-red: #bd5b47;
    --aura-clear: #82967d;
    --aura-calm: #758687;
    --aura-glow: #c6a474;
    --aura-deep: #758394;
    --aura-frost: #a89f91;
}
.diary-device[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, .38); }

@media (max-width: 420px) {
    #view-diary.diary-view { padding: 0 !important; background: #f4f2eb; }
    .diary-device { max-width: none; height: 100%; border-radius: 0; box-shadow: none; }
}
