:root {
  --page: #ffffff;
  --sheet: #ffffff;
  --ink: #161616;
  --rule: #161616;
  --muted: #8a8a8a;
  --mono: 'agahnsangsoo2012', 'IBM Plex Mono', 'Noto Sans KR', monospace; /* 안상수체 (Adobe Fonts), 못 불러오면 고정폭 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
}
button, textarea, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; text-align: left; }
button:disabled { opacity: .3; cursor: default; }
a { color: inherit; text-decoration: none; }

.stage { overflow-x: auto; overscroll-behavior-x: contain; }
/* 판: 테두리 없이 화면 폭을 꽉 채우는 공용 판. 모두가 같은 자리에 같은 걸 보도록 비율은 고정 */
.paper {
  position: relative;
  --u: calc(1cqw / var(--stretch)); /* 원래 판 폭의 1%. --stretch = 오른쪽으로 늘린 배율 (core.js) */
  width: calc(100% * var(--stretch));
  aspect-ratio: calc(420 * var(--stretch)) / 297;
  background: var(--sheet);
  container-type: inline-size;
  overflow: hidden;
  cursor: crosshair;
}
/* 글씨 = 판 폭 1%. 폰: 약 12px로 읽히게 판을 키우고 밀어서 둘러본다 */
@media (max-width: 639px) {
  .paper { width: calc(1200px * var(--stretch)); }
}

/* 왼쪽 위 안내: 크기는 판 너비 기준 */
.intro {
  position: absolute;
  left: calc(2 * var(--u)); top: calc(2 * var(--u));
  width: max-content; /* 줄바꿈은 글에서 정한 대로 */
  z-index: 2;
  background: var(--sheet); /* 아래로 들어간 기록이 글자와 겹쳐 보이지 않게 */
  padding: 0 calc(1.2 * var(--u)) calc(1 * var(--u)) 0;
  box-sizing: content-box;
  font-size: calc(1.3 * var(--u)); /* 보는 사람 고려해 남긴 글(1)보다 조금 크게 */
  line-height: 1.55;
  cursor: default;
}
.quote { margin-bottom: calc(1 * var(--u)); }
#quote { white-space: pre-line; }
.quote cite { display: block; font-style: normal; }
/* 소개 블록 자리에 놓인 기록은 블록 바로 밑에 위쪽을 맞춰 보여 준다 */
.note.below { transform: translateX(-50%); }
.actions { margin-bottom: calc(.9 * var(--u)); }
/* 문장 속 단어 버튼: 밑줄로 누를 수 있다는 걸 알린다 */
.kw { font: inherit; padding: 0; text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .22em; cursor: pointer; }
/* 아래 상자의 고르기 줄: 고른 것만 밑줄 */
.modes .kw { text-decoration: none; }
.modes .kw.on { text-decoration: underline; text-decoration-thickness: .1em; text-underline-offset: .22em; }
.hint { margin-top: calc(.9 * var(--u)); color: var(--muted); }

/* 남긴 것: 상자 없이 판 위에 그대로 */
.note {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: calc(1 * var(--u));
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note img { display: block; width: calc(11 * var(--u)); height: auto; }
.note figcaption { max-width: calc(16 * var(--u)); } /* 폭 제한은 글에만, 사진·그림은 고른 크기 그대로 */
.when { display: none; margin-top: calc(.3 * var(--u)); font-size: .8em; }
.time-always .when, .note.show-time .when { display: block; }
.note img + figcaption { margin-top: calc(.4 * var(--u)); }
.spot {
  position: absolute;
  width: calc(.8 * var(--u)); height: calc(.8 * var(--u));
  border: 1px solid var(--ink);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* 판이 옆으로 더 있다는 걸 알려 주는 얇은 위치 막대 (밀 때만 보임) */
.track {
  position: fixed; z-index: 2;
  left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 10px);
  height: 4px; border-radius: 2px; background: #e6e6e6; pointer-events: none;
  opacity: 0; transition: opacity .4s;
}
.track.on { opacity: 1; }
#thumb { position: absolute; top: 0; height: 100%; border-radius: 2px; background: var(--ink); }
/* 막대는 하나만: 마우스 = 잡고 끌 수 있는 기본 스크롤바, 손가락(폰·아이패드) = 위치 막대 */
@media (pointer: fine) { .track { display: none; } }
@media not all and (pointer: fine) {
  .stage { scrollbar-width: none; }
  .stage::-webkit-scrollbar { display: none; }
}

/* 컴퓨터 웹캠 */
.cam { display: flex; flex-direction: column; gap: 10px; }
.cam video { display: block; width: 100%; max-height: 40dvh; object-fit: cover; background: #111; }
#shoot { align-self: flex-start; min-height: 44px; }

/* 사진·앨범 파일 입력: 화면에만 안 보이게 (display:none 이면 아이폰에서 카메라가 안 열림) */
.file-input { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* 아래 입력 */
.box {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 520px; margin: 0 auto;
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  background: var(--page);
  border-top: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 12px;
  font-size: 22px; /* 안상수체는 같은 크기에서 작아 보여서 크게 */
  z-index: 3;
}
@media (min-width: 640px) { .box { border: 1px solid var(--rule); bottom: 24px; max-width: 680px; font-size: 26px; } }
.box textarea {
  width: 100%; resize: none;
  border: 0; outline: 0; background: none;
  font-size: 1.15em;
}
.pad { position: relative; }
.pad canvas {
  display: block; width: 100%; aspect-ratio: 3 / 2; max-height: 40dvh; /* 큰 화면에서 판을 다 덮지 않게 */
  border: 1px solid var(--rule);
  touch-action: none; cursor: crosshair;
}
#clear { position: absolute; right: 10px; top: 6px; font-size: .8em; }
.colors { display: flex; gap: 12px; margin-top: 12px; }
.colors button {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--c); border: 2px solid var(--page);
  outline: 1px solid transparent;
}
.colors button[aria-checked="true"] { outline-color: var(--ink); }
.sizer { display: flex; align-items: center; gap: 12px; }
.sizer input { flex: 1; accent-color: var(--ink); }
.muted { color: var(--muted); }
/* 판 위에 놓인, 아직 안 남긴 사진 */
.draft { outline: 1px dashed var(--ink); outline-offset: 2px; cursor: grab; touch-action: none; z-index: 1; }
.draft img, .draft figcaption { pointer-events: none; }

.msg { color: #c0392b; }
.msg:empty { display: none; }
.row { display: flex; align-items: center; gap: 20px; }
.grow { flex: 1; }
.photo { cursor: pointer; }
.row button, .photo { min-height: 48px; display: inline-flex; align-items: center; }
