/* Celestial field notes. Warm paper belongs to the personal archive;
   the astronomical image viewer keeps a dark, light-sensitive surround. */
:root {
    --life-paper: #faf9f5;
    --life-paper-soft: #faf9f5;
    --life-ink: #29384c;
    --life-ink-soft: #5f6b78;
    --life-ink-faint: #65717c;
    --life-blue: #486581;
    --life-blue-soft: #eaf0f3;
    --life-blue-pale: #f2f5f5;
    --life-pink: #8c7050;
    --life-pink-soft: #f3eee5;
    --life-rule: #dce0dd;
    --life-rule-soft: #e8e9e3;
    --life-brass: #a18a64;
    --life-panel-shadow: 0 28px 90px #01071352, 0 4px 18px #02091329, inset 0 1px 0 #ffffff;
}

.portal-panel {
    --paper: var(--life-paper);
    --paper-soft: var(--life-paper-soft);
    --ink: var(--life-ink);
    --ink-soft: var(--life-ink-soft);
    --ink-faint: var(--life-ink-faint);
    --rule: var(--life-rule);
    border: 1px solid #e7e7dc;
    border-top: 2px solid #c2b496;
    border-radius: 8px;
    background: var(--life-paper);
    color: var(--life-ink);
    box-shadow: var(--life-panel-shadow);
    backdrop-filter: none;
}

/* A quiet title plate, with the geometry of an engraved celestial chart. */
html[lang] .portal-panel .portal-panel-header {
    padding: 28px 88px 24px 34px;
    border-bottom: 1px solid var(--life-rule);
    background:
        radial-gradient(circle at 100% 0, transparent 69px, #a18a641f 70px, transparent 71px,
            transparent 101px, #a18a6414 102px, transparent 103px),
        linear-gradient(110deg, #eef2f2, #f8f7f2 72%);
}

.portal-panel-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 34px;
    width: 42px;
    height: 2px;
    background: var(--life-brass);
    pointer-events: none;
}

html[lang] .portal-panel .portal-panel-title {
    color: var(--life-ink);
    font-size: clamp(1.85rem, 2.2vw, 2.3rem);
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

html:lang(zh) .portal-panel .portal-panel-title { letter-spacing: 0.04em; }
html[lang] .portal-panel .portal-panel-names {
    margin-top: 9px;
    color: var(--life-ink-soft);
    font-size: 0.8125rem;
    line-height: 1.6;
    letter-spacing: 0.08em;
}
html:lang(zh) .portal-panel .portal-panel-names { font-size: 0.9375rem; letter-spacing: 0.08em; }

.portal-panel .portal-close {
    top: 27px;
    right: 28px;
    width: 42px;
    height: 42px;
    border: 1px solid #b6c0c773;
    border-radius: 50%;
    background: #ffffff59;
    color: var(--life-blue);
    box-shadow: inset 0 1px 0 #ffffffb3;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}
.portal-panel .portal-close::before,
.portal-panel .portal-close::after {
    content: '';
    position: absolute;
    width: 13px;
    height: 1px;
    background: currentColor;
    transform: rotate(45deg);
}
.portal-panel .portal-close::after { transform: rotate(-45deg); }
.portal-panel .portal-close:hover {
    transform: none;
    color: var(--life-ink);
    border-color: #8c9ba8;
    background: #e5edf1;
}

html[lang] .portal-panel .portal-panel-body {
    padding: 30px 34px 36px;
    scrollbar-color: #b8c1c5 transparent;
    scrollbar-gutter: stable;
}
.portal-panel-body::-webkit-scrollbar-thumb { background: #b8c1c5; }

/* Keep metadata legible, but quieter than the writing and photographs. */
html[lang] .portal-panel :is(.portal-moment-meta, .thought-date) {
    color: #65717c;
    font-size: 0.75rem;
    line-height: 1.65;
    letter-spacing: 0.035em;
}
html:lang(zh) .portal-panel :is(.portal-moment-meta, .thought-date) { font-size: 0.875rem; letter-spacing: 0.015em; }
.portal-panel .portal-moments { gap: 36px; }
.portal-panel .portal-moment + .portal-moment { padding-top: 32px; border-top-color: var(--life-rule); }
html[lang] .portal-panel .portal-moment-header { margin-bottom: 20px; }
html[lang] .portal-panel :is(.portal-moment h3, .shelf-title, .reading-collection-header h3) {
    color: var(--life-ink);
    font-weight: 400;
    line-height: 1.4;
}

/* Photographs are mounted, rather than presented as app tiles. */
.portal-panel .gallery-grid { gap: 12px; }
.portal-panel .gallery-item {
    padding: 5px;
    border: 1px solid #d9ddd9;
    border-radius: 4px;
    background: #fffefb;
    box-shadow: 0 3px 9px #26394a0a;
}
.portal-panel .gallery-item img { border-radius: 1px; }
.portal-panel .gallery-caption { inset-inline: 5px; bottom: 5px; padding: 30px 12px 10px; }
.portal-panel .shelf-still { padding: 6px; }
.portal-panel .shelf-still img { height: auto; }
.portal-panel .shelf-image-credit { color: #707a82; }
.portal-panel .shelf-screen { gap: 22px; padding-bottom: 30px; }
.portal-panel .shelf-screen + .shelf-screen { padding-top: 20px; }
.portal-panel .shelf-quotation {
    padding: 16px 0 16px 20px;
    border-left: 2px solid #c4b597;
}
.portal-panel .shelf-links-grid { padding-top: 20px; border-top: 1px solid var(--life-rule-soft); }
.portal-panel :is(.shelf-subsection h4, .shelf-links-grid h4) { color: #647c8e; }

/* Shared action language: ink, hairline borders and a clear pressed state. */
.portal-panel :is(.pub-btn, .project-link, .wishlist-button, .home-route-launch, .home-route-cancel),
.footprints-map-open, .footprints-map-view-toggle, .footprints-map-retry {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid #c6d0d5;
    border-radius: 5px;
    background: #f3f6f6;
    color: var(--life-blue);
    box-shadow: inset 0 1px 0 #ffffffa3;
    text-decoration: none;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}
.portal-panel :is(.pub-btn, .project-link, .wishlist-button, .home-route-cancel):hover:not(:disabled),
:is(.footprints-map-open, .footprints-map-view-toggle, .footprints-map-retry):hover {
    border-color: #8da1af;
    background: #e6edf0;
    color: #263e53;
    filter: none;
}
.portal-panel :is(.pub-btn, .project-link, .wishlist-button):active:not(:disabled) { box-shadow: inset 0 2px 4px #29384c12; }
.portal-panel :is(.pub-btn, .project-link):disabled { opacity: 0.48; cursor: not-allowed; }
.portal-panel :is(.wishlist-button-primary, .home-route-launch) {
    border-color: #38556e;
    background: #38556e;
    color: #fffef8;
    box-shadow: inset 0 1px 0 #ffffff1a, 0 2px 5px #20334712;
}
.portal-panel :is(.wishlist-button-primary, .home-route-launch):hover:not(:disabled) {
    border-color: #29445d;
    background: #29445d;
    color: #fffef8;
}
.portal-panel :is(.pub-actions, .project-links) { flex-wrap: wrap; gap: 8px; }
.portal-panel .thought-toggle {
    min-height: 40px;
    padding: 6px 0;
    color: var(--life-blue);
    border-bottom: 1px solid #a0b1bd;
}
.portal-panel .thought-toggle:hover { color: var(--life-ink); border-bottom-color: var(--life-brass); }
.portal-panel .thought-item { padding-block: 4px 28px; }
.portal-panel .thought-item + .thought-item { padding-top: 16px; }

/* An archive index, with a crisp reading column inside each collection. */
html[lang] .portal-panel .reading-collection {
    padding: 26px 24px 10px;
    border: 1px solid var(--life-rule);
    border-top: 2px solid #bac6cc;
    border-radius: 4px;
    background: #fffefa;
}
.portal-panel .reading-intro { padding-bottom: 28px; }
.portal-panel .reading-crown { color: var(--life-brass); }
.portal-panel .reading-badge {
    border-color: #b8c8c8;
    border-radius: 3px;
    background: #eff3f0;
    color: #52706b;
}
.portal-panel .reading-article { border-top-color: var(--life-rule-soft); }
.portal-panel .reading-article-trigger:hover .reading-article-title { color: #486581; }
.portal-panel .reading-open { padding-bottom: 2px; border-bottom: 1px solid #bdcbd3; }
.portal-panel .reading-original { color: var(--life-blue); }

/* The invitation has the proportions and edges of a correspondence card. */
.portal-panel .wishlist-invitation {
    padding: 26px;
    border: 1px solid #dcded4;
    border-top: 3px double #c2b496;
    border-radius: 3px;
    background: linear-gradient(135deg, #fffefa, #f5f4ed);
    box-shadow: 0 4px 14px #29384c06;
}
.portal-panel .wishlist-draft textarea { border-radius: 3px; background: #fffefb; }
.portal-panel .wishlist-number { color: #8c7050; }
.portal-panel .wishlist-item { padding-bottom: 26px; margin-bottom: 26px; }

/* Recipe notes, an atlas and a personal calling card each have their own rhythm. */
.portal-panel .wine-recipe {
    padding: 22px;
    border: 1px solid #dadfdc;
    border-radius: 4px;
    background: #f0f3f0;
}
.portal-panel .wine-entry h4 { color: #496b74; }
.portal-panel .wine-ingredients > div { padding-block: 10px; border-bottom-color: #dce2db; }
.portal-panel .wine-ingredients > div:last-child { border-bottom: 0; }
.portal-panel .wine-adjustment {
    margin-top: 30px;
    padding: 20px 22px;
    border-left: 2px solid #b39a70;
    border-radius: 0 3px 3px 0;
    background: #f2eee4;
}
.portal-panel .wine-adjustment h4 { color: #846c48; }
.portal-panel .profile-intro { gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--life-rule); }
.portal-panel .profile-portrait img { border: 4px solid #fffefb; box-shadow: 0 0 0 1px #c4c9c3, 0 5px 14px #29384c12; }
.portal-panel .personal-profile h4 { color: #6f735e; }
.portal-panel .profile-links { gap: 8px 24px; }
.portal-panel .profile-links a { text-decoration: underline; text-decoration-color: #bdc7cb; text-underline-offset: 5px; }
.portal-panel .friend-link {
    padding: 17px 20px;
    border: 1px solid #dce1df;
    border-radius: 4px;
    background: #ffffff80;
    color: var(--life-blue);
    box-shadow: 0 2px 5px #29384c04;
}
.portal-panel .friend-link:hover { border-color: #9dafba; background: #edf2f3; color: var(--life-ink); box-shadow: 0 4px 12px #29384c0a; }
.portal-panel .friends-list { gap: 12px; }
.portal-panel .handwriting-toggle { border-radius: 5px; background: #f1f4f2; }

.footprints-map-card, .footprints-map-viewer {
    border-color: #d1d8d3;
    border-radius: 5px;
    background: var(--life-paper);
    color: var(--life-ink);
}
.footprints-map-card { box-shadow: 0 4px 14px #203b3c0a; }
.footprints-map-card .map-card-title { border-color: var(--life-rule); background: #f4f4ee; color: var(--life-ink); }
.footprints-map-number { color: #8c7050; }
.footprints-viewer-header h2 { color: var(--life-ink); }
.footprints-map-controls { border-color: #cdd6d5; background: #fafaf5ed; }
.footprints-map-control, .footprints-viewer-close {
    border-color: #cdd6d5;
    background: #eef3f2;
    color: #48646d;
}
:is(.footprints-map-control, .footprints-viewer-close):is(:hover, :focus-visible) { border-color: #8ea6ac; background: #e0e9e8; color: #294751; }
.footprints-map-view-toggle[aria-pressed='true'] { border-color: #b5a180; background: #eee6d7; color: #6b5737; }
.footprints-map-zoom, .footprints-map-hint { color: var(--life-ink-soft); }

/* Astronomical footnotes are deliberately subordinate to the personal entry. */
.portal-panel .constellation-meaning {
    padding: 24px 0 0;
    border-top: 1px solid #cdd4d3;
    background: none;
}
.portal-panel .constellation-meaning-kicker { color: #887451; }
.portal-panel .constellation-meaning h3 { color: #4e6072; }
html[lang] .portal-panel .constellation-meaning p { font-size: var(--type-small); line-height: 1.85; }
.portal-panel .star-reader {
    margin-top: 26px;
    padding: 18px 20px;
    border: 1px solid #dce3e2;
    border-left: 2px solid #a7b7bf;
    border-radius: 3px;
    background: #edf2f180;
    box-shadow: none;
    color: var(--life-ink-soft);
}
.portal-panel .star-reader-kicker { color: #887451; }
.portal-panel .star-reader-title { color: var(--life-blue); }
.portal-panel :is(.star-reader-meta, .star-reader-description, .star-reader-status) { color: var(--life-ink-soft); }
.portal-panel .star-reader.is-overview,
.portal-panel .star-reader.is-empty { border-top: 1px solid #dce3e2; }
.portal-panel .star-reader.is-overview .star-reader-status,
.portal-panel .star-reader.is-empty .star-reader-status { padding-left: 0; border-left: 0; color: var(--life-ink-soft); }
.portal-panel .home-route-preview { border-color: #ccd6db; background: linear-gradient(135deg, #edf2f3, #f5f3ed); }
body.route-preview-active .portal-panel .star-reader { margin: 0; padding: 0; border: 0; background: none; }

/* Legacy academic entries use the same quiet paper if shown here. */
.portal-content.homepage-parity {
    --bg-alt: #fffefa;
    --text: var(--life-ink);
    --text-secondary: var(--life-ink-soft);
    --text-muted: var(--life-ink-faint);
    --border: var(--life-rule);
    --border-light: var(--life-rule-soft);
    --shadow: 0 3px 12px #20334709;
    --shadow-hover: 0 6px 18px #20334712;
}
.portal-panel .news-item { padding: 14px 16px; border: 1px solid var(--life-rule); border-radius: 4px; background: #f0f4f3; flex-wrap: wrap; gap: 4px 16px; }
.portal-panel .news-date, .portal-panel .pub-venue { color: #6a7f8b; }
.portal-panel .pub-list { gap: 16px; }
.portal-panel .pub-item, .portal-panel .project-card { border: 1px solid var(--life-rule); border-radius: 4px; background: #fffefa; }

/* The long-form reader shares the paper and ink, while retaining its
   horizontal / traditional vertical typesetting and bamboo illustration. */
.thought-reader {
    --reader-ink: #2d3b4b;
    --reader-muted: #68747b;
    --reader-rule: #dce0d8;
    border: 1px solid #dedfd5;
    border-top: 2px solid #b8aa8e;
    border-radius: 6px;
    background: #fcfbf7;
    box-shadow: 0 35px 120px #00081466, inset 0 1px 0 #fff;
}
.thought-reader::before { opacity: 0.48; filter: saturate(0.45); }
.thought-reader::backdrop { background: #070f1dc9; }
.thought-reader .thought-reader-mode { color: #52697a; }
.thought-reader .thought-reader-progress { color: #677886; }
.thought-reader :is(.thought-reader-language, .thought-reader-close, .thought-reader-pagination button) {
    border-color: #cdd6d6;
    border-radius: 4px;
    background: #fffefa;
    transition: background 180ms ease, border-color 180ms ease;
}
.thought-reader :is(.thought-reader-close, .thought-reader-pagination button):enabled:hover { border-color: #9aafb8; background: #edf2f2; }
.thought-reader .thought-reader-scroll { scrollbar-color: #b9c4c5 transparent; }
.thought-reader.is-reading a { color: #486581; }

/* Image observations stay dark so the eye can move between image and text
   without a bright panel overwhelming the nebula or galaxy. */
.deep-sky-card {
    --ink: #e5e7e6;
    --ink-soft: #b4bdc6;
    --ink-faint: #a3afbc;
    --rule: #ffffff24;
    border: 1px solid #c3cfd822;
    border-top: 2px solid #a18a6480;
    border-radius: 5px;
    background: linear-gradient(145deg, #142030f5, #0a121ff5 75%);
    color: #e5e7e6;
    padding: 38px clamp(26px, 3vw, 52px) 38px;
    scrollbar-color: #506075 transparent;
    box-shadow: 0 22px 60px #00000040, inset 0 1px 0 #ffffff06;
}
.deep-sky-card h1 { color: #f1ede2; }
.deep-sky-card .deep-sky-category { color: #b7a480; }
.deep-sky-card :is(.deep-sky-catalogue, .deep-sky-source-kicker) { color: #a5b7ca; }
.deep-sky-card :is(.deep-sky-description, .deep-sky-observation) { color: #bcc5cf; }
.deep-sky-card :is(.deep-sky-facts dt, .deep-sky-credit) { color: #a4b1c1; }
.deep-sky-card .deep-sky-facts dd { color: #e4e8eb; }
.deep-sky-card :is(.deep-sky-facts, .deep-sky-provenance) { border-color: #9baec329; }
.deep-sky-card .deep-sky-source-links a { color: #b8d1e4; }
.deep-sky-card .deep-sky-source-links a:hover { color: #f1e1bd; }
.deep-sky-card .deep-sky-description { max-width: 42ch; }

:is(.portal-panel, .thought-reader, .footprints-map-viewer) :is(button, a, summary, textarea, select, [tabindex]):focus-visible {
    outline: 2px solid #6f8fa6;
    outline-offset: 3px;
}
.deep-sky-card :is(button, a, [tabindex]):focus-visible { outline: 2px solid #c5d9e9; outline-offset: 4px; }
:is(.portal-panel, .thought-reader) ::selection { background: #a9c6d54a; }
.deep-sky-card ::selection { background: #b5cde438; }

@media (min-width: 901px) {
    .deep-sky-card { right: 24px; bottom: 24px; width: calc(38% - 24px); }
}
@media (max-width: 900px) {
    .deep-sky-card { width: calc(100% - 28px); margin: 14px; padding: 30px 26px 36px; }
}
@media (max-aspect-ratio: 3/2), (max-width: 1024px) and (max-aspect-ratio: 16/9) {
    .portal-panel:has(#profile:not([hidden])) { max-height: calc(100dvh - 112px); }
}
@media (max-width: 680px) {
    .portal-panel { border-radius: 7px; }
    html[lang] .portal-panel .portal-panel-header { padding: 20px 74px 18px 22px; }
    html[lang] .portal-panel .portal-panel-title { font-size: 1.75rem; }
    html[lang] .portal-panel .portal-panel-names { margin-top: 5px; font-size: 0.8125rem; }
    html:lang(zh) .portal-panel .portal-panel-names { font-size: 0.875rem; }
    .portal-panel-header::after { left: 22px; width: 34px; }
    .portal-panel .portal-close { top: 20px; right: 20px; width: 40px; height: 40px; }
    html[lang] .portal-panel .portal-panel-body { padding: 24px 22px 30px; }
    html[lang] .portal-panel .reading-collection { padding: 20px 16px 6px; }
    .portal-panel .wishlist-invitation { padding: 20px; }
    .portal-panel .star-reader { padding: 16px; }
    .portal-panel .wine-recipe { padding: 18px; }
}
@media (max-width: 640px) {
    .thought-reader { border: 0; border-radius: 0; }
}
@media (max-width: 600px) {
    .footprints-map-viewer { border: 0; border-radius: 0; }
}
@media (max-width: 380px) {
    html[lang] .portal-panel .portal-panel-header { padding-left: 18px; }
    html[lang] .portal-panel .portal-panel-body { padding-inline: 17px; }
    .portal-panel-header::after { left: 18px; }
    .portal-panel .wishlist-invitation { padding: 17px; }
    .portal-panel .wine-adjustment { padding: 17px; }
}
@media (prefers-reduced-motion: reduce) {
    .portal-panel *, .thought-reader * { transition-duration: 0.001ms !important; }
}

/* Reading leaves space for its constellation; visual collections get a wider mount. */
@media (min-width: 1025px) and (min-aspect-ratio: 3/2) and (min-height: 600px) {
    .portal-panel {
        top: max(88px, calc(env(safe-area-inset-top) + 72px));
        right: max(36px, env(safe-area-inset-right));
        bottom: max(42px, env(safe-area-inset-bottom));
        width: clamp(420px, 39vw, 580px);
    }
    .portal-panel.is-left { left: max(36px, env(safe-area-inset-left)); right: auto; }
    .portal-panel:has(:is(#gallery, #footprints):not([hidden])) { width: clamp(440px, 43vw, 650px); }
    body.route-preview-active .portal-panel { width: clamp(320px, 30vw, 370px); }
}
