@import url('https://fonts.googleapis.com/css2?family=Cormorant+SC:wght@500;600;700&family=Noto+Serif+KR:wght@400;500;600;700&display=swap');

/* Griun KimTang: official free webfont, unmodified. */
@font-face {
  font-family: "Griun KimTang";
  src: url("assets/Griun_KimTang-Rg.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #181612;
  --muted-ink: #615d54;
  --paper: #e8e2d2;
  --paper-dark: #c9c0ab;
  --night: #090a0a;
  --accent: #9e1d1d;
  --book-w: min(84vw, 430px);
  --book-h: min(78vh, 610px);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  color: #e9e6dc;
  background:
    radial-gradient(circle at 50% 34%, rgba(78, 77, 67, .16), transparent 36%),
    linear-gradient(155deg, #121313 0%, #070808 55%, #101111 100%);
  font-family: "Noto Serif KR", Georgia, serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.scene {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 28px clamp(20px, 4vw, 68px) 22px;
  isolation: isolate;
}

.atmosphere { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.atmosphere span { position: absolute; border: 1px solid rgba(255,255,255,.035); border-radius: 50%; }
.atmosphere span:nth-child(1) { width: 62vw; height: 62vw; left: -30vw; top: 4vh; }
.atmosphere span:nth-child(2) { width: 42vw; height: 42vw; right: -22vw; top: 18vh; }
.atmosphere span:nth-child(3) { width: 18vw; height: 18vw; right: 8vw; bottom: -9vw; }

.masthead, .controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1180px, 100%);
  margin-inline: auto;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #88877f;
}

.eyebrow, .status, .controls p { margin: 0; }
.status { display: flex; align-items: center; gap: 9px; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: #575951; box-shadow: 0 0 0 4px rgba(255,255,255,.025); }
.open .status i { background: #899178; box-shadow: 0 0 12px rgba(137,145,120,.7); }

.book-stage {
  position: relative;
  width: min(1180px, 100%);
  min-height: 660px;
  margin: 8px auto;
  perspective: 1900px;
  display: grid;
  place-items: center;
}

.book-shadow {
  position: absolute;
  width: min(48vw, 470px);
  height: 68px;
  top: calc(50% + min(36vh, 280px));
  border-radius: 50%;
  background: rgba(0,0,0,.85);
  filter: blur(28px);
  transform: translateZ(-40px);
  transition: width 1s ease, opacity 1s ease;
}

.book-stage.open .book-shadow { width: min(90vw, 920px); opacity: .92; }

.cover {
  appearance: none;
  border: 0;
  position: absolute;
  z-index: 8;
  left: calc(50% - (var(--book-w) / 2));
  top: 50%;
  width: var(--book-w);
  height: var(--book-h);
  padding: 0;
  border-radius: 5px 11px 11px 5px;
  cursor: default;
  transform: translateY(-50%) rotateY(0deg);
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: left 1.15s cubic-bezier(.64,.02,.18,1), transform 1.15s cubic-bezier(.64,.02,.18,1), filter .4s ease;
  background:
    radial-gradient(ellipse at 86% 8%, rgba(255,255,255,.06), transparent 32%),
    linear-gradient(90deg, rgba(255,255,255,.04), transparent 4%, transparent 95%, rgba(0,0,0,.42)),
    #111212;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.06),
    inset 8px 0 12px rgba(255,255,255,.025),
    inset -8px 0 16px rgba(0,0,0,.5),
    1px 3px 1px #292824,
    5px 8px 0 #aaa28d,
    10px 14px 32px rgba(0,0,0,.64);
  backface-visibility: hidden;
}

.cover:hover { filter: brightness(1.04); }
.cover, .cover > * { -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.cover > * { transition: opacity .18s .23s ease; }
.book-stage.open .cover { left: 50%; transform: translateY(-50%) rotateY(-179deg); pointer-events: none; }
.book-stage.open .cover > * { opacity: 0; }

.cover-grain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  opacity: .48;
  background-image:
    repeating-linear-gradient(105deg, transparent 0 2px, rgba(255,255,255,.025) 3px, transparent 4px 8px),
    repeating-linear-gradient(15deg, transparent 0 3px, rgba(0,0,0,.13) 4px 5px);
}

.cover-edge { position: absolute; left: 12px; top: 0; bottom: 0; width: 2px; background: linear-gradient(90deg, #050505, #2d2d2c, #090909); box-shadow: 3px 0 8px #000; }
.cover-title { position: absolute; left: 0; right: 0; top: 36%; color: #eae9e4; font: 600 clamp(30px, 4.2vw, 48px)/1 "Cormorant SC", Georgia, serif; letter-spacing: .09em; text-align: center; text-shadow: 1px 0 #777, -1px 0 #777; transform: translateY(-50%); }
.cover-title::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: -16px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent); }
.cover-mark { position: absolute; left: 34px; bottom: 29px; font: 600 10px "Cormorant SC", serif; letter-spacing: .24em; color: #656562; }
.lock-clasp { position: absolute; z-index: 5; right: -31px; top: 44%; width: 58px; height: 72px; padding: 0; border: 1px solid #393a37; border-radius: 5px 10px 10px 5px; cursor: pointer; background: linear-gradient(145deg, #222321, #090a0a 58%, #292a27); box-shadow: inset 0 0 0 2px #070707, 8px 10px 22px rgba(0,0,0,.55); transition: filter .2s, border-color .2s; }
.lock-clasp:hover, .lock-clasp:focus-visible { filter: brightness(1.35); border-color: #77756d; outline: none; }
.lock-clasp::before, .lock-clasp::after { content: ""; position: absolute; left: 8px; width: 11px; height: 8px; border: 1px solid #494a45; border-radius: 2px; background: #121312; }
.lock-clasp::before { top: 12px; } .lock-clasp::after { bottom: 12px; }
.lock-clasp span { position: absolute; right: 9px; top: 50%; width: 14px; height: 14px; border: 1px solid #6d6a61; border-radius: 50%; transform: translateY(-50%); box-shadow: inset 0 0 0 3px #111; }
.lock-panel { position: absolute; z-index: 6; right: -246px; top: 50%; width: 216px; padding: 17px 14px 13px; opacity: 0; visibility: hidden; pointer-events: none; transform: translate(14px,-50%) scale(.96); border: 1px solid #4d4d47; border-radius: 3px; background: linear-gradient(145deg, rgba(31,32,30,.99), rgba(7,8,8,.99)); box-shadow: 10px 16px 34px rgba(0,0,0,.62), inset 0 0 0 1px rgba(255,255,255,.025); transition: opacity .2s ease, transform .24s ease, visibility 0s .24s; }
.lock-panel.visible { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(0,-50%) scale(1); transition-delay: 0s; }
.lock-panel::before { content: ""; position: absolute; left: -8px; top: 50%; width: 14px; height: 14px; border-left: 1px solid #4d4d47; border-bottom: 1px solid #4d4d47; background: #171816; transform: translateY(-50%) rotate(45deg); }
.lock-panel p { margin: 0 0 9px; color: #a5a196; font: 500 9px/1.45 "Noto Serif KR", serif; letter-spacing: .04em; }
.lock-input-row { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 7px; }
.lock-icon { display: grid; place-items: center; width: 24px; height: 26px; border: 1px solid #4a4a45; color: #9f9b90; font-size: 14px; }
.lock-panel input { width: 72px; height: 28px; padding: 4px 2px 3px 8px; border: 1px solid #4c4c47; border-radius: 0; background: #080909; color: #e4dfd2; font: 600 14px/1 "Cormorant SC", monospace; letter-spacing: .32em; caret-color: #b5ad99; box-shadow: inset 0 2px 8px #000; }
.lock-panel input::placeholder { color: #67675f; letter-spacing: .18em; }
.lock-panel input:focus { border-color: #a7a092; box-shadow: inset 0 2px 8px #000, 0 0 0 1px #a7a092; }
.lock-panel button { border: 1px solid #55544e; background: #1d1e1c; color: #d5d0c4; font: 600 8px "Cormorant SC", serif; letter-spacing: .1em; cursor: pointer; }
.lock-panel #unlockButton { height: 28px; padding: 0 7px; }
.lock-panel button:hover { background: #30312e; border-color: #858177; }
.lock-close { position: absolute; right: 5px; top: 4px; width: 22px; height: 22px; padding: 0; border: 0 !important; background: transparent !important; color: #77766f !important; font: 16px/1 Arial, sans-serif !important; }
.reset-lock { margin-top: 9px; padding: 2px 0; border: 0 !important; background: transparent !important; color: #74736c !important; font-family: "Noto Serif KR", serif !important; letter-spacing: 0 !important; }
.lock-panel.error { animation: lockShake .38s ease; }
.lock-panel.error input { border-color: #8d3030; }
.lock-panel.success input { border-color: #7f8a6c; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.spread {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(88vw, 860px);
  height: var(--book-h);
  display: grid;
  grid-template-columns: 1fr 1fr;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%) scale(.82);
  transition: opacity .42s .36s ease, transform .8s .32s cubic-bezier(.2,.7,.1,1), visibility 0s .9s;
  filter: drop-shadow(0 18px 22px rgba(0,0,0,.45));
}

.book-stage.open .spread { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); transition-delay: .3s, .26s, 0s; }
.page { position: relative; overflow: hidden; color: var(--ink); background-color: var(--paper); }
.page-left { border-radius: 6px 2px 2px 8px; background-image: linear-gradient(90deg, rgba(0,0,0,.04), transparent 14%, transparent 88%, rgba(0,0,0,.12)); box-shadow: inset -12px 0 28px rgba(63,50,30,.12); }
.page-right { border-radius: 2px 7px 8px 2px; background-image: linear-gradient(90deg, rgba(0,0,0,.14), transparent 14%, transparent 92%, rgba(0,0,0,.04)); box-shadow: inset 12px 0 28px rgba(63,50,30,.13); }
.page::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 31px, rgba(73,83,93,.14) 32px, transparent 33px); background-position: 0 118px; pointer-events: none; }
.page::after { content: ""; position: absolute; top: 0; bottom: 0; width: 14px; opacity: .3; background: repeating-linear-gradient(0deg, #d4ccb9 0 1px, transparent 1px 3px); }
.page-left::after { left: 0; } .page-right::after { right: 0; }
.paper-noise { position: absolute; inset: 0; opacity: .2; mix-blend-mode: multiply; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E"); }
.spine { position: absolute; z-index: 4; left: 50%; top: 0; bottom: 0; width: 22px; transform: translateX(-50%); pointer-events: none; background: linear-gradient(90deg, transparent, rgba(58,47,32,.24), rgba(255,255,255,.16), rgba(58,47,32,.24), transparent); box-shadow: 0 0 26px rgba(50,39,25,.2); }

.page-content { position: relative; height: 100%; padding: clamp(28px, 4.2vw, 52px); z-index: 2; }
.page-label { margin: 0 0 19px; font: 600 9px "Cormorant SC", Georgia, serif; letter-spacing: .22em; color: #756d60; }
.page h1, .page h2 { margin: 0; font-family: "Noto Serif KR", Georgia, serif; font-weight: 600; line-height: 1.08; letter-spacing: -.04em; }
.page h1 { font-size: clamp(28px, 3.2vw, 38px); }
.page h2 { font-size: clamp(25px, 2.8vw, 34px); }

form { display: grid; gap: 5px; }
label { margin-top: 8px; font: 600 11px "Noto Serif KR", serif; letter-spacing: .12em; color: #5f584c; }
input, textarea { width: 100%; border: 0; border-bottom: 1px solid rgba(46,40,32,.38); border-radius: 0; padding: 7px 3px 6px; color: #201d18; outline: none; resize: none; background: transparent; font: 21px/1.3 "Griun KimTang", "Noto Serif KR", cursive; }
textarea { min-height: 120px; }
input::placeholder, textarea::placeholder { color: #918979; opacity: .7; }
input:focus, textarea:focus { border-color: #211e18; box-shadow: 0 1px 0 #211e18; }
.form-footer { margin-top: 13px; display: flex; align-items: center; justify-content: space-between; }
#charCount { font: 600 9px "Cormorant SC", serif; color: #8a8170; }
.ink-button { display: inline-flex; align-items: center; gap: 18px; border: 1px solid #27231d; padding: 10px 13px 9px 16px; background: #201e19; color: #f0ebdf; font: 600 11px "Noto Serif KR", serif; cursor: pointer; box-shadow: 3px 3px 0 rgba(35,31,26,.22); transition: transform .18s, box-shadow .18s; }
.ink-button:hover { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 rgba(35,31,26,.2); }
.ink-button:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(35,31,26,.2); }
.ink-button b { color: #b8af9d; font-size: 14px; }
.privacy-note { position: absolute; left: clamp(28px,4.2vw,52px); bottom: 29px; margin: 0; font: 500 8px "Noto Serif KR", serif; letter-spacing: .05em; color: #8d8474; }
.page-number { position: absolute; right: 25px; bottom: 23px; font: 600 10px "Cormorant SC", serif; color: #8d8474; }

.entries-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.entry-actions { display: flex; align-items: center; gap: 12px; padding-top: 2px; }
.text-button { border: 0; border-bottom: 1px solid transparent; padding: 2px 0; background: transparent; color: #807768; font: 500 9px "Noto Serif KR", serif; cursor: pointer; white-space: nowrap; }
.text-button:hover { color: #4b4439; border-color: currentColor; }
.text-button:disabled { opacity: .25; cursor: default; border-color: transparent; }
.record-page-label { margin: 10px 0 -13px; color: #9b927f; font: 600 8px "Cormorant SC", serif; letter-spacing: .18em; }
.entries { height: calc(100% - 84px); margin-top: 22px; padding-right: 10px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #98907f transparent; }
.entry { position: relative; padding: 10px 32px 13px 5px; border-bottom: 1px solid rgba(73,65,53,.2); animation: inkIn .8s steps(12,end) both; }
.entry-name { margin: 0 0 2px; color: #1b1814; font: 24px/1.1 "Griun KimTang", "Noto Serif KR", cursive; letter-spacing: 0; }
.entry-story { margin: 0; color: #40392f; font: 18px/1.35 "Griun KimTang", "Noto Serif KR", cursive; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-date { display: flex; align-items: center; gap: 7px; margin-top: 7px; color: #8b816f; font: 500 9px "Noto Serif KR", serif; letter-spacing: .02em; }
.entry-date b { color: #5f584c; font-weight: 600; }
.delete-entry { position: absolute; top: 13px; right: 3px; width: 24px; height: 24px; border: 0; background: transparent; color: #8d8474; cursor: pointer; opacity: 0; transition: opacity .2s, color .2s; }
.entry:hover .delete-entry, .delete-entry:focus-visible { opacity: 1; }
.delete-entry:hover { color: var(--accent); }
.empty-state { height: 70%; display: grid; place-content: center; text-align: center; color: #756d60; }
.empty-state p { margin: 0 0 4px; font: 500 13px "Noto Serif KR", serif; }
.empty-state small { font: 500 9px "Noto Serif KR", serif; color: #999080; }
.page-corner { position: absolute; z-index: 5; right: 0; bottom: 0; width: 76px; height: 76px; border: 0; cursor: pointer; clip-path: polygon(100% 0, 0 100%, 100% 100%); background: linear-gradient(135deg, transparent 48%, #c2b9a4 49%, #e1dac9 100%); filter: drop-shadow(-3px -3px 3px rgba(44,36,26,.16)); }
.page-corner span { position: absolute; right: 7px; bottom: 8px; width: 46px; color: #71695c; font: 600 8px "Noto Serif KR", serif; transform: rotate(-45deg); }
.page-corner:disabled { opacity: .25; cursor: default; }
.page-turn-sheet { position: absolute; z-index: 4; inset: 0; pointer-events: none; opacity: 0; transform-origin: left center; background: linear-gradient(90deg, #d6cebb, #eee8da 22%, #e1dac8 90%); box-shadow: inset 14px 0 24px rgba(60,45,29,.13), -8px 4px 18px rgba(47,37,25,.18); backface-visibility: hidden; }
.page-turn-sheet::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 31px, rgba(73,83,93,.12) 32px, transparent 33px); background-position: 0 118px; }
.page-turn-sheet.next { opacity: 1; animation: turnNext .72s cubic-bezier(.55,.05,.2,1) forwards; }
.page-turn-sheet.prev { opacity: 1; animation: turnPrev .72s cubic-bezier(.55,.05,.2,1) forwards; }
.mobile-records-button { display: none; }

.controls { min-height: 30px; }
.controls p { margin-left: auto; }
kbd { border: 1px solid #444540; border-bottom-width: 2px; border-radius: 3px; padding: 2px 5px; color: #aaa9a1; font: inherit; }
.close-book { border: 0; padding: 5px 0; background: none; color: #9d9c94; font: 500 10px "Noto Serif KR", serif; letter-spacing: .08em; cursor: pointer; }
.close-book:hover { color: #fff; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 34px; transform: translate(-50%, 18px); padding: 11px 16px; border: 1px solid #3e3d38; background: rgba(16,17,17,.94); box-shadow: 0 12px 30px rgba(0,0,0,.35); color: #d9d6ca; font: 500 10px "Noto Serif KR", serif; letter-spacing: .04em; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes inkIn { from { clip-path: inset(0 100% 0 0); opacity: .4; } to { clip-path: inset(0); opacity: 1; } }
@keyframes turnNext { 0% { transform: rotateY(0deg); opacity: 1; } 100% { transform: rotateY(-178deg); opacity: .15; } }
@keyframes turnPrev { 0% { transform: rotateY(-178deg); opacity: .15; } 100% { transform: rotateY(0deg); opacity: 1; } }
@keyframes lockShake { 0%,100% { transform: translateY(-50%) translateX(0); } 25% { transform: translateY(-50%) translateX(-6px); } 75% { transform: translateY(-50%) translateX(6px); } }

@media (max-width: 760px) {
  :root { --book-w: min(84vw, 390px); --book-h: min(70vh, 570px); }
  .scene { padding: 20px 14px 15px; }
  .masthead { font-size: 8px; }
  .book-stage { min-height: 610px; overflow: hidden; }
  .spread { width: min(94vw, 460px); grid-template-columns: 1fr; height: var(--book-h); }
  .page-left, .page-right { position: absolute; inset: 0; border-radius: 6px; }
  .page-right { opacity: 0; pointer-events: none; transform: rotateY(8deg) translateX(12px); transform-origin: left; transition: opacity .45s, transform .45s; }
  .spread.show-records .page-left { opacity: 0; pointer-events: none; transform: rotateY(-8deg) translateX(-12px); }
  .spread.show-records .page-right { opacity: 1; pointer-events: auto; transform: rotateY(0) translateX(0); }
  .spine { display: none; }
  .page-content { padding: 30px 29px; }
  .privacy-note { left: 29px; }
  .book-stage.open .cover { left: 50%; transform: translateY(-50%) rotateY(-178deg); }
  .controls p { display: none; }
  .cover-title { font-size: clamp(30px, 9vw, 42px); }
  .lock-clasp { right: -18px; width: 42px; }
  .lock-panel { left: 50%; right: auto; top: 50%; bottom: auto; width: calc(100% - 54px); transform: translate(-46%,-50%) scale(.96); }
  .lock-panel.visible { transform: translate(-50%,-50%) scale(1); }
  .lock-panel::before { display: none; }
  .mobile-records-button { display: block; margin: 13px 0 0 auto; border: 0; border-bottom: 1px solid #7c7363; padding: 4px 0; background: transparent; color: #5e574c; font: 600 10px "Noto Serif KR", serif; }
  .entry-actions { gap: 8px; }
}

@media (max-height: 700px) and (min-width: 761px) {
  :root { --book-h: 520px; }
  .book-stage { min-height: 550px; }
  .scene { padding-top: 17px; padding-bottom: 12px; }
  .page-content { padding-top: 35px; padding-bottom: 30px; }
  textarea { min-height: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
