:root{
  --bg: #b9c5c8;
  --surface: #e7e5de;
  --surface-alt: #d9e0df;
  --primary: #60777a;
  --primary-dark: #303a3b;
  --primary-pale: #b8c8c9;
  --accent: #718287;
  --text: #343b3b;
  --text-muted: #68777a;
  --text-faint: #859296;
  --border: #9eacae;
  --shadow: 0 8px 30px rgba(63, 106, 100, 0.08);
  --shadow-soft: 0 2px 12px rgba(63, 106, 100, 0.06);
  --radius: 18px;
  --serif: 'Noto Serif SC', serif;
  --sans: 'Noto Sans SC', sans-serif;
}

*{ box-sizing: border-box; margin:0; padding:0; }
html, body{
  height: 100%;
  overflow: hidden;
}
body{
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background-color .42s ease, color .42s ease;
}
a{ color: inherit; text-decoration: none; }
.content-link{
  color: var(--primary-dark);
  text-decoration: underline;
  text-underline-offset: .2em;
  overflow-wrap: anywhere;
}
.content-link:hover{ color: var(--primary); }
.wavy-underline{
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}
button{ font-family: inherit; }

::selection{ background: var(--primary-pale); color: var(--primary-dark); }

/* ---------- Welcome ---------- */
.site-content{
  height: 100%;
  opacity: 1;
  visibility: visible;
  transition: opacity .82s cubic-bezier(.22, 1, .36, 1) .12s;
}
body.welcome-pending .site-content{
  opacity: 0;
  visibility: hidden;
}
.welcome-screen{
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #b9c5c8;
  color: #465557;
  transition:
    opacity .62s cubic-bezier(.22, 1, .36, 1),
    visibility 0s linear .64s;
}
.welcome-screen.is-leaving{
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.welcome-content{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2.4vw, 24px);
  max-width: 100%;
  transition: opacity .38s ease, transform .52s cubic-bezier(.22, 1, .36, 1);
}
.welcome-screen.is-leaving .welcome-content{
  opacity: 0;
  transform: translateY(-5px) scale(.985);
}
.welcome-message{
  font-family: var(--serif);
  font-size: clamp(1.02rem, 2.1vw, 1.34rem);
  font-weight: 400;
  letter-spacing: .08em;
  text-align: center;
}
.fingerprint-entry{
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  padding: 7px;
  border: 0;
  background: transparent;
  color: rgba(75, 99, 101, .72);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fingerprint-entry::before{
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 119, 122, .12), transparent 68%);
  opacity: .2;
  transform: scale(.76);
  animation: fingerprintHint 2.8s ease-in-out infinite;
}
.fingerprint-entry svg{
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  fill: currentColor;
  transition: color .25s ease, transform .25s ease, opacity .25s ease;
}
.fingerprint-entry:hover svg,
.fingerprint-entry:focus-visible svg{
  color: rgba(48, 69, 71, .9);
  transform: scale(1.055);
}
.fingerprint-entry:focus-visible{
  outline: 1px dotted rgba(48, 69, 71, .72);
  outline-offset: 3px;
}
@keyframes fingerprintHint{
  0%, 100%{ opacity: .14; transform: scale(.74); }
  50%{ opacity: .68; transform: scale(1.08); }
}

/* ---------- Passage ---------- */
.passage-screen{
  position: fixed;
  z-index: 900;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #b9c5c8;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .52s ease, visibility 0s linear .52s;
}
.passage-screen.is-active{
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}
.passage-screen.is-leaving{
  opacity: 0;
  visibility: hidden;
  transition: opacity .72s ease, visibility 0s linear .72s;
}
.passage-screen[hidden]{
  display: none;
}
.passage-person{
  position: relative;
  width: 70px;
  height: 190px;
  transform: translateY(30px);
}
.passage-person span{
  position: absolute;
  display: block;
  background: #000;
  opacity: 0;
}
.passage-head{
  top: 0;
  left: 15px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transform: scale(.72);
}
.passage-body{
  top: 50px;
  left: 30px;
  width: 10px;
  height: 70px;
  transform: scaleY(0);
  transform-origin: center top;
}
.passage-leg{
  top: 115px;
  width: 10px;
  height: 70px;
  transform: scaleY(0);
  transform-origin: center top;
}
.passage-leg-left{ left: 27px; }
.passage-leg-right{ left: 33px; }
.passage-screen.is-active .passage-head{
  animation: passageHeadReveal .4s cubic-bezier(.22, 1, .36, 1) .25s forwards;
}
.passage-screen.is-active .passage-body{
  animation: passageLineReveal .5s cubic-bezier(.22, 1, .36, 1) .55s forwards;
}
.passage-screen.is-active .passage-leg-left{
  animation: passageLineReveal .5s cubic-bezier(.22, 1, .36, 1) .85s forwards;
}
.passage-screen.is-active .passage-leg-right{
  animation: passageLineReveal .5s cubic-bezier(.22, 1, .36, 1) .98s forwards;
}
@keyframes passageHeadReveal{
  from{ opacity: 0; transform: scale(.72); }
  to{ opacity: 1; transform: scale(1); }
}
@keyframes passageLineReveal{
  from{ opacity: 0; transform: scaleY(0); }
  to{ opacity: 1; transform: scaleY(1); }
}

body.welcome-entered #home .minimal-boy{
  animation: welcomeFigureReveal .65s cubic-bezier(.22, 1, .36, 1) .2s both;
}
body.welcome-entered #home .minimal-text{
  animation: welcomeTextReveal .72s cubic-bezier(.22, 1, .36, 1) .48s both;
}
body.welcome-entered #home .hidden-door{
  animation: welcomeQuietReveal .6s ease .68s both;
}
body.welcome-entered #siteHeader{
  animation: welcomeHeaderReveal .65s cubic-bezier(.22, 1, .36, 1) .78s both;
}

@keyframes welcomeFigureReveal{
  from{ opacity: 0; }
  to{ opacity: 1; }
}
@keyframes welcomeTextReveal{
  from{ opacity: 0; transform: translateY(7px); }
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes welcomeQuietReveal{
  from{ opacity: 0; }
  to{ opacity: 1; }
}
@keyframes welcomeHeaderReveal{
  from{ opacity: 0; transform: translateY(-7px); }
  to{ opacity: 1; transform: translateY(0); }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar{ width: 10px; }
::-webkit-scrollbar-track{ background: var(--bg); }
::-webkit-scrollbar-thumb{ background: var(--primary-pale); border-radius: 10px; }

/* ---------- Header ---------- */
#siteHeader{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 5vw;
  background: rgba(185, 197, 200, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: background-color .42s ease, border-color .4s ease, box-shadow .4s ease;
}
body[data-page-theme="reading"] #siteHeader{ background: rgba(217, 208, 194, .92); }
body[data-page-theme="articles"] #siteHeader{ background: rgba(216, 209, 220, .92); }
body[data-page-theme="swim"] #siteHeader{ background: rgba(74, 112, 153, .94); }
body[data-page-theme="ai"] #siteHeader{ background: rgba(203, 211, 200, .92); }
body[data-page-theme="reading"]{ background: #d9d0c2; }
body[data-page-theme="articles"]{ background: #d8d1dc; }
body[data-page-theme="swim"]{ background: #547eab; }
body[data-page-theme="ai"]{ background: #cbd3c8; }
#siteHeader.scrolled{
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}
.brand{
  display:flex; align-items:center; gap:10px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: .04em;
  transition: color .36s ease;
}
nav.mainnav{ display:flex; gap: 4px; }
nav.mainnav button{
  background: none; border:none; cursor:pointer;
  padding: 9px 16px;
  font-size: .92rem;
  color: var(--primary-dark);
  border-radius: 999px;
  transition: color .3s ease, background-color .3s ease;
  white-space: nowrap;
}
nav.mainnav button:hover{ color: var(--primary-dark); background: var(--surface-alt); }
nav.mainnav button.active{ color: #fff; background: var(--primary); font-weight:500; }
nav.mainnav button[data-target="reading"].active{ background: #846f58; }
nav.mainnav button[data-target="articles"].active{ background: #7d6d83; }
nav.mainnav button[data-target="swim"].active{ background: #3f76a8; }
nav.mainnav button[data-target="ai"].active{ background: #687b6b; }
body[data-page-theme="reading"] .brand,
body[data-page-theme="reading"] nav.mainnav button{ color: #4e4235; }
body[data-page-theme="articles"] .brand,
body[data-page-theme="articles"] nav.mainnav button{ color: #4b3f50; }
body[data-page-theme="ai"] .brand,
body[data-page-theme="ai"] nav.mainnav button{ color: #35463a; }
body[data-page-theme="swim"] .brand,
body[data-page-theme="swim"] nav.mainnav button{ color: #f2f6f8; }
body[data-page-theme="reading"] nav.mainnav button.active{ color: #fffdf8; }
body[data-page-theme="articles"] nav.mainnav button.active{ color: #fcf9fc; }
body[data-page-theme="ai"] nav.mainnav button.active{ color: #f3f2ec; }
body[data-page-theme="reading"] nav.mainnav button:not(.active):hover{ background: rgba(238, 232, 220, .72); }
body[data-page-theme="articles"] nav.mainnav button:not(.active):hover{ background: rgba(236, 232, 237, .72); }
body[data-page-theme="ai"] nav.mainnav button:not(.active):hover{ background: rgba(230, 227, 218, .72); }
body[data-page-theme="swim"] nav.mainnav button:not(.active):hover{ background: rgba(235, 243, 247, .15); }
body[data-page-theme="swim"] nav.mainnav button.active{
  color: #244766;
  background: #e1edf3;
}

.nav-toggle{ display:none; background:none; border:none; cursor:pointer; padding: 6px; }
.nav-toggle span{ display:block; width:22px; height:2px; background: var(--primary-dark); margin:5px 0; border-radius:2px; transition: background-color .3s ease, transform .3s ease; }
body[data-page-theme="reading"] .nav-toggle span{ background: #4e4235; }
body[data-page-theme="articles"] .nav-toggle span{ background: #4b3f50; }
body[data-page-theme="ai"] .nav-toggle span{ background: #35463a; }
body[data-page-theme="swim"] .nav-toggle span{ background: #f2f6f8; }

/* ---------- Layout shell ---------- */
main{ padding-top: 74px; }
.section{ display:none; min-height: 100vh; }
.section.active{
  display:block;
  animation: sectionReveal .42s ease both;
}
@keyframes sectionReveal{
  from{ opacity: 0; }
  to{ opacity: 1; }
}
@keyframes fadein{
  from{ opacity: 0; transform: translateY(3px); }
  to{ opacity: 1; transform: translateY(0); }
}

/* ---------- Home page ---------- */
/* ---------- Minimal Home ---------- */


.home-page{
    min-height:100vh;
    display:flex;
    justify-content:center;
    align-items:center;
    background:#b9c5c8;
}


.minimal-hero{

    position:relative;

    width:100%;

    height:100vh;

    display:flex;

    flex-direction:column;

    justify-content:center;

    align-items:center;

}



/* 人 */

.minimal-boy{

    position:relative;

    width:70px;

    height:190px;

    margin-bottom:50px;

}



.minimal-boy .head{
    position:absolute;
    top:0;
    left:15px;
    width:40px;
    height:40px;
    border-radius:50%;
    background: #000;
}

.minimal-boy .body{
    position:absolute;
    top:50px;
    left:30px;
    width:10px;
    height:70px;
    background: #000;
}

.minimal-boy .leg{
    position:absolute;
    top:115px;
    width:10px;
    height:70px;
    background: #000;
}


.minimal-boy .left{

    left:27px;

}


.minimal-boy .right{

    left:33px;

}



.minimal-text{
    text-align:center;
}

.minimal-text p{
    margin-top: 0;
    font-size: 1.3rem;
    font-family: var(--serif);
    font-weight: 400;
    font-style: italic;
    color: #000;
    letter-spacing: 0.3em;
    line-height: 1.8;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    animation: textFadeIn 1.5s ease-out forwards;
}

/* ---------- Ending ---------- */
.ending-page{
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #b9c5c8;
}

.ending-hero{
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.ending-boy{
    width: 44px;
    height: 118px;
    margin-bottom: 34px;
    opacity: .64;
}

.ending-boy .head{
    left: 10px;
    width: 24px;
    height: 24px;
}

.ending-boy .body{
    top: 30px;
    left: 19px;
    width: 6px;
    height: 45px;
}

.ending-boy .leg{
    top: 72px;
    width: 6px;
    height: 43px;
    transform-origin: center top;
}

.ending-boy .left{
    left: 18px;
    transform: rotate(4deg);
}

.ending-boy .right{
    left: 23px;
    transform: rotate(-5deg);
}

.ending-text{
    text-align: center;
    max-width: min(88vw, 720px);
}

.ending-text p{
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    color: rgba(0, 0, 0, .64);
    font-family: var(--serif);
    font-size: 1.08rem;
    font-weight: 400;
    letter-spacing: .16em;
    line-height: 1.8;
}

.ending-text span{
    display: block;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid transparent;
    animation-name: endingTypeLine, endingTypingCaret;
    animation-duration: 1.5s, 1.5s;
    animation-timing-function: steps(10, end), linear;
    animation-fill-mode: forwards, forwards;
    animation-delay: var(--typing-delay), var(--typing-delay);
}

.ending-text span:nth-child(1){ --typing-delay: .35s; }
.ending-text span:nth-child(2){ --typing-delay: 2.05s; }
.ending-text span:nth-child(3){ --typing-delay: 3.75s; }

@keyframes endingTypeLine{
    from{ width: 0; }
    to{ width: 100%; }
}

@keyframes endingTypingCaret{
    0%, 92%{ border-right-color: rgba(0, 0, 0, .5); }
    100%{ border-right-color: transparent; }
}

.hidden-door{
    position: absolute;
    right: clamp(22px, 4vw, 56px);
    bottom: clamp(20px, 4vh, 44px);
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 9px;
    padding: 6px 4px;
    border: 0;
    background: transparent;
    color: rgba(0, 0, 0, .48);
    cursor: pointer;
    font-family: var(--serif);
    transition: color .3s ease, transform .3s ease;
}
.door-figure{
    position: relative;
    top: -25px;
    display: block;
    width: 54px;
    height: 76px;
    transition: transform .35s ease;
}
.door-figure::before,
.door-figure::after{
    content: '';
    position: absolute;
    border: 1px solid #111;
    border-bottom: 0;
    pointer-events: none;
}
.door-figure::before{
    z-index: 0;
    top: 1px;
    left: 4px;
    width: 46px;
    height: 72px;
}
.door-figure::after{
    z-index: 0;
    top: 5px;
    left: 9px;
    width: 36px;
    height: 68px;
}
.door-leaf{
    position: absolute;
    z-index: 1;
    top: 8px;
    left: 10px;
    display: block;
    width: 35px;
    height: 62px;
    background: #111;
    clip-path: polygon(0 0, 100% 9%, 100% 88%, 0 100%);
    transform-origin: left center;
    transition: transform .35s ease;
}
.door-leaf::before{
    content: '';
    position: absolute;
    inset: 1px;
    background: var(--bg);
    clip-path: polygon(0 0, 100% 9%, 100% 88%, 0 100%);
}
.door-leaf::after{
    content: none;
}
.door-knob{
    position: absolute;
    z-index: 2;
    top: 48%;
    right: 5px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    border: 1px solid #111;
    background: var(--bg);
}
.door-caption{
    font-size: .66rem;
    letter-spacing: .16em;
    white-space: nowrap;
}
.hidden-door:hover{
    color: rgba(0, 0, 0, .78);
    transform: translateY(-2px);
}
.hidden-door:hover .door-figure,
.hidden-door:focus-visible .door-figure{
    transform: translateY(-1px);
}
.hidden-door:hover .door-leaf,
.hidden-door:focus-visible .door-leaf{
    transform: translateX(-2px) scaleX(1.03);
}
.hidden-door:focus-visible{
    color: rgba(0, 0, 0, .78);
    outline: 1px solid rgba(0, 0, 0, .42);
    outline-offset: 3px;
}

/* ---------- Other side ---------- */
body.other-side-open #siteHeader{
  display: none;
}
body.other-side-open main{
  padding-top: 0;
}
.other-side-page{
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #303837;
  color: #cbd1ce;
}
.other-side-empty-text{
  margin-left: .32em;
  color: rgba(220, 225, 222, .68);
  font-family: var(--serif);
  font-size: clamp(1rem, 2vw, 1.24rem);
  font-weight: 400;
  letter-spacing: .32em;
}
.other-side-return{
  position: absolute;
  z-index: 2;
  top: clamp(18px, 4vh, 38px);
  left: clamp(16px, 3vw, 34px);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(220, 225, 222, .48);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: .72;
  transition: opacity .2s ease;
}
.other-side-return:hover{
  opacity: 1;
}
.other-side-return:focus-visible{
  opacity: 1;
  outline: 1px dotted rgba(220, 225, 222, .58);
  outline-offset: 2px;
}

@keyframes textFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* ---------- Reading layout ---------- */
.reading-layout{
  --surface: #eee8dc;
  --border: #b8ac99;
  --primary: #846f58;
  --primary-dark: #4e4235;
  --primary-pale: #d0c2ae;
  --text: #403a32;
  --text-muted: #756b5e;
  --text-faint: #938778;
  padding: 0 2vw;
  margin: 0 auto;
  background: linear-gradient(180deg, #d9d0c2 0%, #cec3b3 100%);
  min-height: 100vh;
}
.reading-content{
  display: grid;
  grid-template-columns: 1fr 4fr;
  gap: 20px;
  padding: 10px 0 20px;
  min-height: calc(100vh - 60px);
}
.reading-sidebar{
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  min-height: calc(100vh - 80px);
}
.reading-category{
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  font: inherit;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--text-muted);
  transition: all .3s ease;
  border: 1px solid transparent;
  text-align: center;
}
.reading-category:hover{
  background: #e1d8c9;
  color: #665847;
  border-color: #c7baa6;
}
.reading-category.active{
  background: var(--primary);
  color: #fffdf8;
  border-color: var(--primary);
}
.reading-main{
  min-height: calc(100vh - 80px);
}
.reading-placeholder{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 40px 20px;
  color: var(--text-faint);
}
.reading-svg{
  width: min(220px, 50%);
  height: auto;
  margin-bottom: 20px;
  color: var(--primary);
  opacity: 0.5;
}
.reading-placeholder p{
  font-size: .95rem;
  font-weight: 300;
}
.reading-tab-content{
  display: none;
}
.reading-tab-content.active{
  display: block;
  animation: fadein .4s ease;
}
.reading-content-view{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 25px;
  line-height: 1.65;
  height: calc(100vh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-pale) transparent;
  -webkit-overflow-scrolling: touch;
}
.reading-content-view h3{
  font-family: var(--serif);
  font-size: 1.05rem;
  color: #5d5040;
  margin: 16px 0 8px;
  padding-left: 10px;
  border-left: 3px solid #aa9577;
}
.reading-content-view h3:first-child{
  margin-top: 0;
}
.reading-content-view p{
  font-size: .94rem;
  color: var(--text);
  margin-bottom: 10px;
  text-align: justify;
}
.mao-directory,
.mao-article-reader{
  width: min(100%, 860px);
  margin: 0 auto;
}
.mao-directory{
  padding: clamp(8px, 2vw, 18px) clamp(2px, 2vw, 18px);
}
.mao-directory-heading{
  padding: 8px 0 clamp(26px, 5vh, 46px);
  border-bottom: 1px solid var(--border);
}
.mao-directory-heading > span{
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: .72rem;
  letter-spacing: .18em;
}
.mao-directory-heading h2{
  margin-bottom: 8px;
  color: var(--primary-dark);
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4vw, 2.45rem);
  font-weight: 600;
  letter-spacing: .08em;
}
.mao-directory-heading p{
  margin: 0;
  color: var(--text-muted);
  font-size: .88rem;
  text-align: left;
}
.mao-directory-list button{
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  width: 100%;
  min-height: 78px;
  padding: 18px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: color .2s ease, padding-left .2s ease, background .2s ease;
}
.mao-directory-list button:hover{
  padding-left: 12px;
  background: rgba(137, 116, 93, .08);
  color: var(--primary-dark);
}
.mao-directory-list button:focus-visible{
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.mao-directory-list button > span:first-child{
  color: var(--text-faint);
  font-family: Georgia, serif;
  font-size: .72rem;
  letter-spacing: .08em;
}
.mao-directory-list button > span:last-child{
  color: var(--text-muted);
  font-size: .76rem;
}
.mao-directory-list strong{
  font-family: var(--serif);
  font-size: clamp(.98rem, 2vw, 1.08rem);
  font-weight: 500;
  line-height: 1.65;
}
.mao-article-toolbar{
  position: sticky;
  z-index: 2;
  top: 0;
  margin-bottom: 24px;
  padding: 4px 0 12px;
  background: linear-gradient(180deg, var(--surface) 72%, rgba(238, 232, 220, 0));
}
.mao-article-toolbar button{
  min-height: 40px;
  padding: 7px 4px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
  letter-spacing: .04em;
}
.mao-article-toolbar button:hover{ color: var(--primary-dark); }
.mao-article-toolbar button:focus-visible{
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.reading-content-view .mao-article > h3{
  max-width: 30em;
  margin: 0 0 clamp(24px, 4vh, 38px);
  padding: 0 0 20px;
  border-left: 0;
  border-bottom: 1px solid var(--border);
  color: var(--primary-dark);
  font-size: clamp(1.42rem, 3vw, 2rem);
  line-height: 1.55;
}
.reading-content-view .mao-article > p{
  max-width: 76ch;
  margin: 0;
  font-size: .98rem;
  line-height: 2;
}
.reading-content-view::-webkit-scrollbar,
.notes-content-view::-webkit-scrollbar{ width: 8px; }
.reading-content-view::-webkit-scrollbar-track,
.notes-content-view::-webkit-scrollbar-track{ background: transparent; }
.reading-content-view::-webkit-scrollbar-thumb,
.notes-content-view::-webkit-scrollbar-thumb{
  background: var(--primary-pale);
  border-radius: 999px;
}

/* ---------- Article layout ---------- */
.notes-layout{
  padding: 0 2vw;
  margin: 0 auto;
  background: linear-gradient(180deg, #dfe4e2 0%, #d4dddc 100%);
  min-height: 100vh;
}
.notes-content{
  display: grid;
  grid-template-columns: 1fr 4fr;
  gap: 20px;
  padding: 10px 0 20px;
  min-height: calc(100vh - 60px);
}
.notes-sidebar{
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  min-height: calc(100vh - 80px);
}
.notes-category{
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  font: inherit;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--text-muted);
  transition: all .3s ease;
  border: 1px solid transparent;
  text-align: center;
}
.notes-category:hover{
  background: #dce4e1;
  color: #556a6b;
  border-color: #b6c6c4;
}
.notes-category.active{
  background: #718789;
  color: #fff;
  border-color: #718789;
}
.notes-main{ min-height: calc(100vh - 80px); }
.notes-placeholder{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 40px 20px;
  color: var(--text-faint);
}
.notes-placeholder p{ font-size: .95rem; font-weight: 300; }
.notes-tab-content{ display: none; }
.notes-tab-content.active{ display: block; animation: fadein .4s ease; }
.notes-content-view{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 25px;
  height: calc(100vh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-pale) transparent;
  -webkit-overflow-scrolling: touch;
}
.notes-content-view p{
  font-size: .94rem;
  color: var(--text);
  margin-bottom: 10px;
  text-align: justify;
}

/* ---------- Articles: soft lavender-grey palette ---------- */
.articles-layout{
  --surface: #ece8ed;
  --border: #b9afbe;
  --primary: #7d6d83;
  --primary-dark: #4b3f50;
  --primary-pale: #cec3d2;
  --text: #413a44;
  --text-muted: #6f6374;
  --text-faint: #8f8394;
  background: linear-gradient(180deg, #d8d1dc 0%, #cbc3d0 100%);
}
.articles-layout .notes-category:hover{
  border-color: #c6bccb;
  background: #e2dce5;
  color: var(--primary-dark);
}
.articles-layout .notes-category.active{
  border-color: var(--primary);
  background: var(--primary);
  color: #fcf9fc;
}
.articles-layout ::selection{
  background: var(--primary-pale);
  color: var(--primary-dark);
}

.article-content-view{
  padding: clamp(24px, 4vw, 46px);
}
.article-category-title{
  margin-bottom: clamp(30px, 5vh, 52px);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  font-weight: 400;
  letter-spacing: .14em;
}
.article-category-title:empty{
  display: none;
}
.article-entry{
  max-width: 78ch;
  margin: 0 auto;
  padding-bottom: clamp(34px, 6vh, 64px);
}
.article-entry + .article-entry{
  padding-top: clamp(30px, 5vh, 52px);
  border-top: 1px solid var(--border);
}
.article-entry h3{
  margin-bottom: 18px;
  color: var(--primary-dark);
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  font-weight: 600;
  line-height: 1.55;
}
.article-entry h3:empty,
.article-entry p:empty{
  display: none;
}
.article-entry p{
  margin-bottom: 1.15em;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 2;
}

/* ---------- AI: reading layout with a calm sage palette ---------- */
.ai-layout{
  --surface: #e6e3da;
  --border: #a2ada3;
  --primary: #687b6b;
  --primary-dark: #35463a;
  --primary-pale: #b2beb3;
  --text: #343d36;
  --text-muted: #5d6b61;
  --text-faint: #7c897f;
  background: linear-gradient(180deg, #cbd3c8 0%, #bdc8bc 100%);
}
.ai-layout .reading-category{
  color: var(--text-muted);
}
.ai-layout .reading-category:hover{
  border-color: #a6b1a7;
  background: #d4dad1;
  color: var(--primary-dark);
}
.ai-layout .reading-category.active{
  border-color: var(--primary);
  background: var(--primary);
  color: #f3f2ec;
}
.ai-layout .reading-placeholder{
  color: var(--text-faint);
}
.ai-layout .reading-svg{
  color: #718475;
}
.ai-layout .reading-content-view{
  border-color: var(--border);
  background: var(--surface);
  scrollbar-color: var(--primary-pale) transparent;
}
.ai-layout .reading-content-view h3{
  border-left-color: #87998a;
  color: var(--primary-dark);
}
.ai-layout .reading-content-view p{
  color: var(--text);
}
.ai-layout .reading-content-view::-webkit-scrollbar-thumb{
  background: var(--primary-pale);
}
.ai-layout ::selection{
  background: var(--primary-pale);
  color: var(--primary-dark);
}
.ai-article > h3,
.ai-article > p,
.ai-article-section-title{
  width: min(100%, 860px);
  margin-left: auto;
  margin-right: auto;
}
.ai-article > p{
  line-height: 1.9;
}
.ai-article-section-title{
  margin-top: 2.7em;
  margin-bottom: 1.2em;
  padding-bottom: .72em;
  border-bottom: 1px solid rgba(104, 123, 107, .32);
  color: var(--primary-dark);
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-align: center;
  text-indent: .16em;
}
.ai-context-flow{
  display: block;
  width: min(100%, 520px);
  margin: 1.35em auto;
  padding: 14px 18px;
  border: 1px solid rgba(104, 123, 107, .24);
  border-radius: 12px;
  background: rgba(104, 123, 107, .075);
  color: var(--primary-dark);
  line-height: 1.72;
  text-align: center;
}
.ai-article > h3:empty,
.ai-article > p:empty{
  display: none;
}

/* ---------- Swim layout ---------- */
.swim-layout{
  padding: 0 2vw;
  margin: 0 auto;
  background: linear-gradient(180deg, #547eab 0%, #1a1d21 100%);
  min-height: 100vh;
  --surface: #e6e1d6;
  --border: #98a296;
  --text: #343b35;
  --text-muted: #6f796f;
  --text-faint: #879087;
}
.swim-content{
  display: grid;
  grid-template-columns: 1fr 4fr;
  gap: 20px;
  padding: 10px 0 20px;
  min-height: calc(100vh - 60px);
}
.swim-sidebar{
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  min-height: calc(100vh - 80px);
}
.swim-category{
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  font: inherit;
  font-size: .9rem;
  line-height: 1.5;
  color: #edf4f7;
  transition: all .3s ease;
  border: 1px solid transparent;
  text-align: center;
}
.swim-category:hover{
  background: #d5e8f4;
  color: #244766;
  border-color: #91b8d3;
}
.swim-category.active{
  background: #2f6fa8;
  color: #fff;
  border-color: #2f6fa8;
}
.reading-category:focus-visible,
.notes-category:focus-visible,
.swim-category:focus-visible{
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.reading-category,
.notes-category,
.swim-category{
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}
.swim-main{
  min-height: calc(100vh - 80px);
}
.swim-placeholder{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 40px 20px;
  color: var(--text-faint);
}
.swim-svg{
  width: min(220px, 50%);
  height: auto;
  margin-bottom: 20px;
  color: #4A90D9;
  opacity: 0.5;
}
.swim-placeholder p{
  font-size: .95rem;
  font-weight: 300;
}
.swim-tab-content{
  display: none;
}
.swim-tab-content.active{
  display: block;
  animation: fadein .4s ease;
}
.swim-content-view{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 25px;
  line-height: 1.65;
  height: calc(100vh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #4A90D9 transparent;
  -webkit-overflow-scrolling: touch;
}
.swim-content-view h3{
  font-family: var(--serif);
  font-size: 1.05rem;
  color: #2E5A9E;
  margin: 16px 0 8px;
  padding-left: 10px;
  border-left: 3px solid #4A90D9;
}
.swim-content-view h3:first-child{
  margin-top: 0;
}
.swim-content-view p{
  font-size: .94rem;
  color: var(--text);
  margin-bottom: 10px;
  text-align: justify;
}
.swim-content-view::-webkit-scrollbar{ width: 8px; }
.swim-content-view::-webkit-scrollbar-track{ background: transparent; }
.swim-content-view::-webkit-scrollbar-thumb{
  background: #4A90D9;
  border-radius: 999px;
}

/* ---------- Content overflow safety ---------- */
.reading-content,
.notes-content,
.swim-content,
.reading-main,
.notes-main,
.swim-main{
  min-width: 0;
}
.reading-content-view,
.notes-content-view,
.swim-content-view{
  overflow-wrap: anywhere;
}
.content-load-error{
  display: grid;
  place-items: center;
  min-height: 100%;
  color: var(--text-faint);
}
.content-load-error p{
  margin: 0;
  font-size: .9rem;
  font-weight: 300;
  text-align: center;
}
.reading-content-view img,
.notes-content-view img,
.swim-content-view img,
.reading-content-view video,
.notes-content-view video,
.swim-content-view video{
  display: block;
  max-width: 100%;
  height: auto;
}
.reading-content-view iframe,
.notes-content-view iframe,
.swim-content-view iframe{
  display: block;
  max-width: 100%;
}
.reading-content-view table,
.notes-content-view table,
.swim-content-view table,
.reading-content-view pre,
.notes-content-view pre,
.swim-content-view pre{
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px), (orientation: landscape) and (max-height: 500px) and (max-width: 1024px){
  html, body{
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  #siteHeader{
    min-height: 64px;
    padding: 10px 5vw;
  }
  .brand{ font-size: 1rem; }
  main{ padding-top: 64px; }
  .section{
    min-height: calc(100vh - 64px);
    min-height: calc(100svh - 64px);
  }
  .home-page,
  .ending-page,
  .minimal-hero,
  .ending-hero{
    min-height: calc(100vh - 64px);
    min-height: calc(100svh - 64px);
    height: calc(100vh - 64px);
    height: calc(100svh - 64px);
  }
  .minimal-boy{
    transform: scale(.86);
    margin-bottom: 26px;
  }
  .passage-person{
    transform: scale(.86);
  }
  .ending-page .ending-boy{
    transform: none;
    margin-bottom: 24px;
  }
  .minimal-text p{
    padding: 0 24px;
    font-size: 1.05rem;
    letter-spacing: .18em;
  }
  .ending-text p{
    font-size: .95rem;
    letter-spacing: .1em;
    line-height: 1.9;
  }
  .hidden-door{
    right: 12px;
    bottom: 16px;
    gap: 7px;
    padding: 5px;
  }
  .door-figure{ top: -22px; width: 46px; height: 65px; transform: scale(.86); transform-origin: center bottom; }
  .hidden-door:hover .door-figure,
  .hidden-door:focus-visible .door-figure{ transform: scale(.86) translateY(-1px); }
  .door-caption{ font-size: .62rem; }
  .reading-layout,
  .notes-layout,
  .swim-layout{
    height: calc(100vh - 64px);
    height: calc(100svh - 64px);
    min-height: 0;
    padding: 0 14px 16px;
    overflow: hidden;
  }
  .reading-content,
  .notes-content,
  .swim-content{
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    height: 100%;
    min-height: 0;
    padding: 8px 0 0;
  }
  .reading-sidebar,
  .notes-sidebar,
  .swim-sidebar{
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 8px;
    min-height: auto;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 1px;
    padding: 2px 12px 5px 1px;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }
  .reading-sidebar::-webkit-scrollbar,
  .notes-sidebar::-webkit-scrollbar,
  .swim-sidebar::-webkit-scrollbar{
    display: none;
    width: 0;
    height: 0;
  }
  .reading-sidebar.has-more-right,
  .notes-sidebar.has-more-right,
  .swim-sidebar.has-more-right{
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
  }
  .reading-category,
  .notes-category,
  .swim-category{
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    margin-bottom: 0;
    padding: 9px 13px;
    font-size: .86rem;
    scroll-snap-align: start;
    white-space: nowrap;
  }
  .reading-main,
  .notes-main,
  .swim-main{
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }
  .reading-placeholder,
  .notes-placeholder,
  .swim-placeholder{
    height: 100%;
    min-height: 0;
    padding: 24px 18px;
  }
  .reading-tab-content.active,
  .notes-tab-content.active,
  .swim-tab-content.active{ height: 100%; }
  .reading-content-view,
  .notes-content-view,
  .swim-content-view{
    height: 100%;
    min-height: 0;
    padding: 18px;
    border-radius: 14px;
    line-height: 1.8;
  }
  .reading-content-view p,
  .swim-content-view p{ font-size: .98rem; }
  .ai-layout{
    padding: 0 10px 12px;
  }
  .ai-layout .reading-content{
    gap: 6px;
  }
  .ai-layout .reading-content-view.ai-article{
    padding: 20px 16px 42px;
    line-height: 1.9;
    scrollbar-gutter: auto;
  }
  .ai-article > h3{
    margin-bottom: 18px;
    padding-left: 11px;
    font-size: 1.28rem;
    line-height: 1.45;
  }
  .ai-article > p{
    font-size: 1rem;
    line-height: 1.92;
    letter-spacing: .01em;
    text-align: left;
    word-break: normal;
  }
  .ai-article-section-title{
    margin-top: 2.35em;
    margin-bottom: 1.1em;
    padding-bottom: .65em;
    font-size: 1.04rem;
    line-height: 1.5;
  }
  .ai-context-flow{
    margin: 1.25em auto;
    padding: 12px 10px;
    border-radius: 10px;
    font-size: .94rem;
    line-height: 1.7;
  }
  .article-entry p{ font-size: 1rem; }
  .mao-directory{ padding: 4px 0; }
  .mao-directory-list button{
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    min-height: 70px;
    padding: 14px 2px;
  }
  .mao-directory-list button:hover{ padding-left: 7px; }
  .mao-directory-list button > span:last-child{ display: none; }
  .reading-content-view .mao-article > h3{
    font-size: 1.35rem;
  }
  .mao-article-toolbar button{
    min-height: 44px;
  }
  nav.mainnav{
    position: fixed; top: 64px; left:0; right:0;
    background: rgba(231, 229, 222, .98);
    flex-direction: column;
    padding: 8px 5vw 16px;
    border-bottom: 1px solid var(--border);
    transform: translateY(-115%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .35s ease, opacity .25s ease, visibility 0s linear .35s;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 64px);
    max-height: calc(100svh - 64px);
    overflow-y: auto;
  }
  body[data-page-theme="reading"] nav.mainnav{ background: rgba(238, 232, 220, .98); }
  body[data-page-theme="articles"] nav.mainnav{ background: rgba(236, 232, 237, .98); }
  body[data-page-theme="ai"] nav.mainnav{ background: rgba(230, 227, 218, .98); }
  body[data-page-theme="swim"] nav.mainnav{ background: rgba(49, 72, 94, .98); }
  nav.mainnav.open{
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }
  nav.mainnav button{
    min-height: 44px;
    text-align:left;
    padding: 10px 12px;
  }
  .nav-toggle{ display:block; min-width:44px; min-height:44px; }
}

@media (orientation: landscape) and (max-height: 350px) and (max-width: 1024px){
  .minimal-boy{
    transform: scale(.72);
    margin-bottom: -4px;
  }
  .minimal-text p{
    font-size: 1rem;
    letter-spacing: .15em;
  }
}

@media (prefers-reduced-motion: reduce){
  .site-content,
  .welcome-screen,
  .fingerprint-entry svg{
    transition-duration: .01ms;
  }
  .fingerprint-entry::before{ animation: none; }
  *{ animation: none !important; transition: none !important; }
  .ending-text span{
    width: 100%;
    border-right: 0;
  }
  .passage-person span{ opacity: 1; }
  .passage-head{ transform: scale(1); }
  .passage-body,
  .passage-leg{ transform: scaleY(1); }
}
