/* Shared paper, illustration and typography in both reading contexts. */
@font-face{font-family:SnackMemoModu;src:url('/main-site/assets/gangwon-modu-bold.woff2') format('woff2');font-weight:700;font-style:normal;font-display:swap}
.memo-letter,#stories .daily-finished.memo-letter{box-sizing:border-box;isolation:isolate;position:relative;width:100%;max-width:760px;margin:0 auto;padding:26px clamp(18px,5%,38px) 30px;border:1px solid #ded2b8;border-radius:3px;color:#4b4c3c;background:radial-gradient(ellipse at 0 0,#eadcc459,transparent 65%),repeating-linear-gradient(0deg,#b79c7210 0,#b79c7210 1px,transparent 1px,transparent 4px),#fcf7e9;box-shadow:0 3px 12px #715d3620,inset 0 0 35px #b89f6420;overflow-wrap:anywhere}
.memo-letter .memo-letter-heading{display:block;margin:0 0 20px;padding:0 0 17px;border:0;border-bottom:1px solid #cbbb9866;background:none}
.memo-letter .memo-letter-heading small{font:11px/1.6 Arial,'Apple SD Gothic Neo',sans-serif;color:#8b8068}
.memo-letter .memo-letter-heading h3{font:700 21px/1.5 SnackMemoModu,serif;color:#425344;margin:10px 0 0;word-break:keep-all}
.memo-letter .memo-letter-body p{font:700 14.5px/2.05 SnackMemoModu,'Apple SD Gothic Neo',sans-serif;letter-spacing:-.15px;font-synthesis:none;margin:0 0 1.2em;padding:0;white-space:normal;word-break:normal;color:#4b4c3c}
.memo-letter .memo-letter-body p{text-align:justify;text-align-last:start}
.memo-letter-source{text-decoration:underline;text-decoration-color:#aa9676;text-decoration-thickness:1px;text-underline-offset:4px}
.memo-letter-source.is-mine{background:#e5ecd690;text-decoration-color:#5f7d58;text-decoration-thickness:2px;border-radius:2px}
.memo-letter .memo-letter-signoff{display:block;margin:22px 0 0;padding:14px 0 0;border:0;border-top:1px solid #cbbb9866;font:11px/1.7 Arial,'Apple SD Gothic Neo',sans-serif;color:#8b8068;background:none}
/* The room grid and feed dialog surround the exact same paper. */
#stories .daily-finished.memo-letter,#stories .daily-finished.memo-letter{grid-column:1/-1;justify-self:center}
dialog.memo-letter-dialog{padding:14px;background:#f3eddf}
dialog.memo-letter-dialog .dialog-head{background:none;margin-bottom:12px;padding-bottom:10px}
dialog.memo-letter-dialog .participants{margin-top:16px}
@media(max-width:600px){.memo-letter,#stories .daily-finished.memo-letter{padding:21px 18px 24px}.memo-letter .memo-letter-heading h3{font-size:20px}dialog.memo-letter-dialog{width:calc(100% - 16px);padding:10px;max-height:calc(100dvh - 24px)}}

#relay.room-system .relay-completed-reading{flex:none;width:100%;min-width:0;max-width:760px;align-self:center}
#relay.room-system .relay-completed-participants{display:flex;flex-wrap:wrap;gap:6px 10px;margin-top:16px;padding-top:14px;border-top:1px solid #cbbb9866;font:11px/1.6 Arial,'Apple SD Gothic Neo',sans-serif;color:#6d7f67}
#relay.room-system .relay-completed-participants small{width:100%;font-size:11px}
#relay.room-system .relay-completed-participants a{color:inherit;text-underline-offset:3px}
/* Buttons belong below the sentence; only the ordinal occupies the narrow column. */
#relay.room-system .sentence>.sentence-number{grid-column:1;grid-row:1}
#relay.room-system .sentence>.sentence-content{grid-column:2;grid-row:1;min-width:0;width:100%}
#relay.room-system .sentence-content .sentence-credit{padding-right:0}
#relay.room-system .sentence-reactions{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-top:7px}
#relay.room-system .sentence-reactions .line-like{position:static!important;inset:auto!important;flex:none;margin:0}
#relay.room-system .sentence-reactions .daily-comment{position:static;flex:none;width:auto;margin:0;padding:4px 8px;min-height:28px;font:11px/1.4 Arial,'Apple SD Gothic Neo',sans-serif}

/* Completed relay: a stable number column keeps wrapped lines aligned. */
.memo-letter .memo-letter-body .memo-letter-relay-line{display:grid;grid-template-columns:30px minmax(0,1fr);column-gap:6px;align-items:start;margin:0 0 12px}
.memo-letter .memo-letter-line-number{box-sizing:border-box;display:flex;align-items:center;justify-content:center;width:30px;height:22px;margin-top:4px;border:1px solid #a3b5b0;border-radius:4px;background:#e8efeb;color:#486460;font:600 10px/1 Arial,'Apple SD Gothic Neo',sans-serif;letter-spacing:0;white-space:nowrap}
.memo-letter .memo-letter-line-text{display:block;min-width:0;overflow-wrap:anywhere}
/* The board viewport owns both ongoing and completed-story scrolling. An auto overflow box with
   overscroll containment inside it would swallow wheel/touch at its own zero edge. */
#relay.room-system .guestbook-viewport>.guestbook.relay-prose{overflow:visible;overscroll-behavior:auto}
/* Closed works show a compact excerpt; full artwork opens only on request. */
:is(#stories,#relay).room-system .daily-work-preview{box-sizing:border-box;width:100%;max-width:760px;margin:0 auto 18px;padding:20px 22px;background:#fffdf6;border:1px solid #e0dac9;border-radius:12px;box-shadow:inset 0 1px #fff,0 2px 4px #554b400d;color:#45554a}
.daily-work-preview>small{font:11px/1.5 system-ui;color:#879085}
:is(#stories,#relay).room-system .daily-work-preview>h3{font:700 20px/1.5 SnackMemoModu,serif;margin:8px 0 12px;color:#3e5549}
:is(#stories,#relay).room-system .daily-work-preview .daily-work-excerpt{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;font:700 14px/1.9 SnackMemoModu,serif;margin:0 0 16px;word-break:normal;overflow-wrap:anywhere}
.daily-work-read{display:block;width:100%;padding:10px 12px;border:1px solid #d8ddce;border-radius:8px;background:linear-gradient(155deg,#fffffa,#edf0e5);color:#45604c;box-shadow:inset 0 1px #fff,0 1px 2px #554b4010;font:600 12px/1.4 system-ui;cursor:pointer}
.daily-dialog:has(>.memo-letter){width:min(820px,calc(100vw - 24px));max-height:calc(100dvh - 32px);overflow-y:auto;overscroll-behavior:contain}
@media(max-width:760px){:is(#stories,#relay).room-system .daily-work-preview{padding:16px}.daily-work-preview>h3{font-size:18px}}

/* Each credit stays with its own sentence, including wrapped mobile lines. */
.memo-letter .memo-letter-line-author{grid-column:2;display:block;margin-top:3px;color:#7b817b;font:11px/1.5 Arial,'Apple SD Gothic Neo',sans-serif;letter-spacing:0;overflow-wrap:anywhere}

.memo-letter .memo-letter-cover{
 width:112px;
 aspect-ratio:2/3;
 margin:0 auto 22px;
 border-radius:2px;
}
.memo-letter-cover img{display:block;width:100%;height:100%;object-fit:cover}
.edition-cover{position:relative;overflow:hidden;container-type:inline-size}
.edition-cover .edition-cover-title{
 position:absolute;
 inset:7% 7% auto;
 max-block-size:76%;
 overflow:hidden;
 padding:3% 2%;
 font:700 clamp(7px,12cqi,14px)/1.16 system-ui,sans-serif!important;
 text-align:center;
 text-wrap:balance;
 white-space:normal;
 word-break:keep-all;
 overflow-wrap:anywhere;
 color:#2e4037;
 text-shadow:0 0 3px #fff8e6,0 1px 2px #fff8e6;
}
.edition-cover .edition-cover-title[data-size="medium"]{font-size:clamp(7px,10cqi,12px)!important}
.edition-cover .edition-cover-title[data-size="long"]{font-size:clamp(6px,8cqi,10px)!important}
.edition-cover-dusk .edition-cover-title{color:#fff0d6;text-shadow:0 0 3px #2d2924,0 1px 2px #2d2924}

.memo-letter-operator{display:inline-block;margin-top:8px;color:#47614e;font:600 12px/1.4 system-ui;text-underline-offset:3px}

.memo-letter .memo-letter-cover:has(+ .memo-letter-genre){margin-bottom:8px}
.memo-letter .memo-letter-genre{
 display:flex;width:fit-content;align-items:center;gap:6px;margin:0 auto 18px;padding:3px 9px;
 border:1px solid #aebfb8;border-radius:6px;background:#edf3ef;color:#34584e;font:11px/1.45 system-ui,sans-serif;
}
.memo-letter-genre span{color:#526d63}

/* The completed work dialog owns scrolling while it is open. */
html:has(dialog[open] > .memo-letter),
body:has(dialog[open] > .memo-letter),
body:has(dialog[open] > .memo-letter) #community-scroll,
body:has(dialog[open] > .memo-letter) .room-system :is(.memo-viewport, .guestbook-viewport) {
  overflow: hidden !important;
  scrollbar-width: none;
}

dialog#community-dialog:has(> .memo-letter),
dialog#daily-room-dialog:has(> .memo-letter) {
  box-sizing: border-box;
  width: min(840px, calc(100% - 16px));
  max-width: none;
  max-height: calc(100dvh - 20px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

dialog:is(#community-dialog, #daily-room-dialog).memo-letter-scrolling:has(> .memo-letter) {
  scrollbar-color: #a3ada3 transparent;
}

@media (max-width: 600px) {
  dialog#community-dialog:has(> .memo-letter),
  dialog#daily-room-dialog:has(> .memo-letter) {
    padding-inline: 8px !important;
  }

  dialog > .memo-letter {
    padding-inline: 8px;
  }

  dialog > .memo-letter .memo-letter-body .memo-letter-relay-line {
    grid-template-columns: 24px minmax(0, 1fr);
    column-gap: 4px;
    font-size: clamp(10.5px, 2.85vw, 14px);
  }

  dialog > .memo-letter .memo-letter-line-number {
    width: 24px;
  }
}


@layer compact-corrections {
  html:root:has(body[data-room-view] dialog[open] > .memo-letter),
  html body[data-room-view]:has(dialog[open] > .memo-letter) {
    overflow: hidden !important;
  }
}

#relay.room-system .relay-waiting > p {
  font: 700 14px/1.6 SnackMemoModu, system-ui, sans-serif;
}

:is(#stories,#relay).room-system .memo-archive-preview {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: start;
  max-width: none;
  padding: 18px 0;
}

.memo-archive-info {
  padding: 0 14px 0 22px;
  border-inline-end: 1px solid #d8dfd0;
}
.memo-archive-topic-label {
  display: table;
  margin-top: 5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e4eadc;
  color: #344b39;
  font: 650 12px/1.5 system-ui, sans-serif;
}
.memo-archive-detail {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: start;
  gap: clamp(14px, 1.8vw, 28px);
  padding-inline-end: 22px;
}
.memo-archive-detail:has(.memo-archive-people) {
  grid-template-columns: 112px minmax(0, 1fr) minmax(105px, .3fr);
}

.memo-archive-preview .memo-letter-cover {
  width: 100%;
  height: auto;
  margin: 0;
  aspect-ratio: 2 / 3;
}

.memo-archive-info h3 { margin: 5px 0; }
.memo-archive-info :is(p, small) { font: 12px/1.5 system-ui, sans-serif; }

.memo-archive-preview .memo-archive-excerpt {
  margin: 0 0 12px;
  padding: 0;
  min-height: 0;
  font: 700 15px/1.85 SnackMemoModu, serif;
  text-align: justify;
  text-align-last: left;
  word-break: normal;
  overflow-wrap: anywhere;
}

:is(#stories,#relay).room-system .memo-archive-preview .daily-work-read { width: auto; }
.memo-archive-people h4 { margin: 0 0 8px; font: 600 12px/1.4 system-ui; }
.memo-archive-people ul { display: flex; flex-wrap: wrap; gap: 5px; list-style: none; padding: 0; margin: 0; }
.memo-archive-people li { padding: 3px 7px; border-radius: 4px; background: #edf0e6; font: 12px/1.4 system-ui; }

@media (max-width: 1050px) {
  :is(#stories,#relay).room-system .memo-archive-preview { padding: 14px; }
  .memo-archive-info { grid-column: 1 / -1; padding: 0 0 10px; border: 0; }
  .memo-archive-detail,
  .memo-archive-detail:has(.memo-archive-people) {
    grid-column: 1 / -1;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    padding: 0;
  }
  .memo-archive-people { grid-column: 2; }
}

:is(#stories,#relay).room-system .memo-archive-preview .memo-archive-excerpt { font: 700 15px/1.85 SnackMemoModu, serif; }

:is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 6px;
}
:is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info :is(small, h3, p) {
  margin: 0;
  font: 500 13px/1.5 system-ui, sans-serif;
}
:is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info > :is(small, p) {
  color: #000;
}
:is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info h3 {
  font-size: 17px;
  font-weight: 700;
  word-break: keep-all;
}
:is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info p {
  margin-top: auto;
}
.memo-archive-info .memo-archive-topic-label { margin: 0; }

@media (min-width: 1251px) {
  :is(#stories,#relay).room-system .memo-archive-preview {
    grid-template-rows: auto;
    align-items: stretch;
  }
  .memo-archive-preview .memo-archive-detail,
  .memo-archive-preview .memo-archive-detail:has(.memo-archive-people) {
    grid-template-columns: subgrid;
    column-gap: normal;
    padding: 0;
    align-items: stretch;
  }
  .memo-archive-preview .memo-letter-cover {
    align-self: end;
    width: 112px;
    grid-column: 1;
    grid-row: 1;
  }
  .memo-archive-preview .memo-archive-copy {
    grid-column: 1 / 4;
    grid-row: 1;
    margin-left: calc(112px + clamp(14px, 1.8vw, 28px));
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }
  .memo-archive-preview .memo-archive-excerpt { width: 100%; }
  .memo-archive-preview .daily-work-read { margin-top: auto; margin-bottom: 0; }
  .memo-archive-preview .memo-archive-people { grid-column: 4; grid-row: 1; padding-right: 16px; }
}

:is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info h3 {
  min-block-size: 3em;
}

.memo-archive-topic {
  display: grid;
  justify-items: start;
  gap: 9px;
}

@media (min-width: 1251px) {
  :is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info {
    display: grid;
    grid-template-rows: auto auto auto;
    align-content: center;
    gap: 14px;
  }
  .memo-archive-info > small { grid-row: 1; }
  .memo-archive-topic { grid-row: 2; }
  .memo-archive-info > p { grid-row: 3; }
  :is(#stories,#relay).room-system .memo-archive-preview .memo-archive-excerpt {
    font-size: 16px;
    line-height: 2.15;
  }
  .memo-archive-preview .memo-archive-people h4 {
    line-height: 34.4px;
    margin-bottom: 3px;
  }
}

@media (max-width: 760px) {
  .memo-archive-preview .memo-archive-detail,
  .memo-archive-preview .memo-archive-detail:has(.memo-archive-people) {
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: stretch;
  }
  .memo-archive-preview .memo-archive-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }
  :is(#stories,#relay).room-system .memo-archive-preview .memo-archive-excerpt {
    width: 100%;
    margin-block-end: 6px;
    line-height: 1.55;
  }
  :is(#stories,#relay).room-system .memo-archive-preview .daily-work-read {
    margin-top: auto;
    margin-bottom: 3px;
    padding: 6px 9px;
  }
  .memo-archive-preview .memo-archive-people {
    grid-column: 1 / -1;
    border-top: 1px solid #d8dfd0;
    padding-top: 10px;
  }
}

@media (min-width: 1251px) {
  .memo-archive-preview .memo-archive-copy {
    position: relative;
    padding-inline-end: clamp(14px, 1.8vw, 28px);
  }
  .memo-archive-preview .memo-archive-copy::after {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-end: -1px;
    border-inline-start: 1px solid #d8dfd0;
    pointer-events: none;
  }
}

@media (min-width: 1251px) {
  :is(#stories,#relay).room-system .memo-archive-preview .memo-archive-info > small {
    align-self: start;
    line-height: 1.5;
  }
}

/* Full 101 reading view: metadata, wrapped cover, original contributions. */
.memo-letter.memo-letter-reading{max-width:none;padding:24px 28px;background:#fffdf7;border:0;box-shadow:none}
.memo-letter-reading .memo-letter-heading{padding:0 0 22px;margin:0 0 26px;border-bottom:1px solid #dddcd1}
.memo-reading-meta{display:grid;grid-template-columns:1fr 1fr;gap:32px;font-family:Arial,"Noto Sans KR",sans-serif;color:#283c34}
.memo-reading-topic{display:grid;gap:9px}.memo-reading-topic small{font-size:13px}.memo-reading-topic>span{font-size:12px;color:#73786c}.memo-reading-topic strong{font-size:17px;line-height:1.5}
.memo-reading-people strong{font-size:15px}.memo-reading-people p{font-size:14px;line-height:1.8;margin:10px 0 0;word-break:keep-all}
.memo-letter-reading .memo-letter-body{display:flow-root}
.memo-letter-reading .memo-letter-cover{float:left;width:152px;margin:0 26px 18px 0;aspect-ratio:2/3}
.memo-letter-reading .memo-reading-title{font:700 26px/1.4 Arial,sans-serif;margin:0 0 18px;color:#243d33}
.memo-letter-reading .memo-letter-body p{font-size:17px;line-height:1.95;text-align:justify;text-align-last:left;text-indent:1.5em;margin:0}
.memo-reading-originals{clear:both;border-top:1px solid #d4d9ce;margin-top:30px;padding-top:22px}
.memo-reading-originals h4{font:700 16px/1.5 Arial,sans-serif;margin:0 0 16px}
.memo-reading-originals p{display:flex;align-items:baseline;gap:20px;justify-content:space-between;margin:0;padding:8px 0;font:15px/1.65 SnackMemoModu,sans-serif}
.memo-reading-originals small{flex-shrink:0;font:12px/1.6 Arial,sans-serif;color:#72786e}
.memo-letter-reading .memo-letter-signoff{display:none}
@media(max-width:600px){.memo-letter.memo-letter-reading{padding:16px 12px}.memo-reading-meta{grid-template-columns:1fr;gap:16px}.memo-letter-reading .memo-letter-cover{width:96px;margin-right:16px}.memo-letter-reading .memo-reading-title{font-size:21px;min-height:0;margin-bottom:12px}.memo-letter-reading .memo-letter-body p{clear:none;font-size:16px;line-height:1.9}.memo-reading-originals p{gap:12px;font-size:14px}.memo-reading-originals small{font-size:11px}}

dialog:has(.memo-letter-reading)>h2{display:none}

/* Keep the reader close control above the isolated paper while scrolling. */
body dialog#daily-room-dialog:has(> .memo-letter) > .daily-close {
 position:sticky!important;top:0!important;right:auto!important;float:right!important;z-index:10!important;
 display:flex;align-items:center;justify-content:center;
 width:40px;height:40px;min-width:40px;min-height:40px;
 margin:0 0 8px 8px;padding:0;border:1px solid #cbd4cd;
 border-radius:50%;background:#fffdf7;color:#294637;
 font:400 26px/1 Arial,sans-serif;box-shadow:0 2px 5px #243d331a;
}
body dialog#daily-room-dialog:has(> .memo-letter) > .memo-letter {clear:both}
body dialog#community-dialog:has(> .memo-letter) > .dialog-head {
 position:sticky;top:0;z-index:10;background:#fffdf7;
}

/* Relay previews have no memo-wall columns to inherit. */
#relay.room-system .memo-archive-preview {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-block-end: 20px;
}
@media (min-width: 1051px) and (max-width: 1250px) {
  #relay.room-system .memo-archive-preview { grid-template-columns: minmax(145px, 1fr) minmax(0, 4fr); }
}

#relay.room-system .guestbook:has(> .memo-archive-preview) {
  padding: 0;
  background: transparent;
  box-shadow: none;
}
#relay.room-system .guestbook > .memo-archive-preview {
  margin: 0;
}
@media (min-width: 761px) {
  #relay.room-system .guestbook-viewport:has(.memo-archive-preview) {
    padding: 28px 4px 16px;
    background: transparent;
    box-shadow: none;
  }
  #relay.room-system .guestbook:has(> .memo-archive-preview) { gap: 42px; }
}
@media (min-width: 1251px) {
  #relay.room-system .memo-archive-preview { column-gap: clamp(14px, 1.6vw, 22px); }
}

@media (max-width: 600px) {
  dialog > .memo-letter:has(.memo-letter-relay-line) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 14px 12px 18px;
  }
  dialog > .memo-letter:has(.memo-letter-relay-line) > :not(.memo-letter-cover, .memo-letter-genre) {
    grid-column: 1 / -1;
  }
  dialog > .memo-letter:has(.memo-letter-relay-line) > .memo-letter-heading { margin: 0; padding-bottom: 9px; }
  dialog:is(#community-dialog, #daily-room-dialog) > .memo-letter:has(.memo-letter-relay-line) > .memo-letter-heading h3 { display: none; }
  dialog > .memo-letter:has(.memo-letter-relay-line) > .memo-letter-cover { width: 72px; margin: 0; }
  dialog > .memo-letter:has(.memo-letter-relay-line) > .memo-letter-genre {
    justify-self: start;
    margin: 0;
  }
  dialog > .memo-letter .memo-letter-body .memo-letter-relay-line {
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 7px;
    font-size: 15px;
    line-height: 1.55;
  }
  dialog > .memo-letter .memo-letter-line-number { width: 28px; }
}
