:root { --ink: #f5f1e8; --bg: #12161c; --gold: #e8bd5c; --green: #3fbf62; --panel: rgba(18, 22, 28, .8); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; border: 0; cursor: pointer; color: inherit; }

#view { position: fixed; inset: 0; }
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: var(--bg); z-index: 40;
  font-weight: 800; letter-spacing: .12em; font-size: 22px; transition: opacity .6s; }
#loading small { display: block; margin-top: 8px; font-weight: 500; letter-spacing: .3em; font-size: 12px; color: #9fb0c0; }
#loading.gone { opacity: 0; pointer-events: none; }

.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud button, .hud .pill { pointer-events: auto; }
.pill { background: var(--panel); border-radius: 999px; backdrop-filter: blur(6px); }

.topbar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top));
  background: var(--panel); padding: 9px 16px; border-radius: 999px; white-space: nowrap; font-size: 14px; }
.topbar span { color: #b9c3cc; margin-left: 8px; font-size: 12px; }


#exitBtn { position: absolute; left: 16px; top: calc(14px + env(safe-area-inset-top)); padding: 10px 14px; font-size: 14px; font-weight: 600; }
#counter { position: absolute; right: 16px; top: calc(14px + env(safe-area-inset-top)); padding: 6px 6px 6px 14px; font-size: 14px;
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 130px); }
#countText { white-space: nowrap; }
#countText b { color: #ffd98a; }
#demoAdd { background: rgba(255, 255, 255, .12); border-radius: 999px; padding: 5px 10px; font-size: 12px; white-space: nowrap; }
#tip { position: absolute; left: 50%; transform: translateX(-50%); top: calc(62px + env(safe-area-inset-top));
  font-size: 12px; color: #dfe6ec; background: rgba(0, 0, 0, .35); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }

.dock { position: absolute; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 12px; padding: 0 16px; }
.dockBtn { display: flex; align-items: center; gap: 6px; background: var(--panel); backdrop-filter: blur(6px);
  padding: 13px 15px; border-radius: 18px; font-size: 19px; font-weight: 700; min-width: 0; white-space: nowrap; }
.dockBtn span { font-size: 15px; }
.dockBtn.on { background: #f5f1e8; color: #12161c; }
.dockBtn.write { background: var(--gold); color: #1b1408; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-height: 82vh; overflow: auto; touch-action: pan-y;
  background: #1a1f27; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); max-width: 560px; margin: 0 auto; }
.sheetHead { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-size: 19px; }
.close { background: rgba(255, 255, 255, .1); padding: 7px 12px; border-radius: 999px; font-size: 13px; }
.desc { color: #b9c3cc; font-size: 14px; line-height: 1.6; margin: 8px 0 12px; }
#capForm { display: grid; gap: 8px; }
#capForm input, #capForm textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #0f1318;
  border: 1px solid #2c3440; border-radius: 12px; padding: 12px; resize: vertical; }
.primary { background: var(--gold); color: #1b1408; padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 800; }
#capList { list-style: none; padding: 0; margin: 16px 0 8px; display: grid; gap: 8px; }
#capList li { display: flex; align-items: center; gap: 10px; background: #0f1318; border: 1px solid #262e38; border-radius: 12px; padding: 12px; }
#capList .ic { font-size: 22px; }
#capList .meta { flex: 1; min-width: 0; font-size: 13px; color: #aeb8c2; }
#capList .meta b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 2px; }
#capList button { background: var(--gold); color: #1b1408; padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: 13px; white-space: nowrap; }
#capList button:disabled { background: #2a313b; color: #8b96a2; cursor: default; }
#capList .empty { justify-content: center; color: #8b96a2; font-size: 13px; }
.demo { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #8b96a2; margin-top: 6px; }
blockquote { margin: 6px 0 4px; padding: 16px; background: #0f1318; border-left: 3px solid var(--gold); border-radius: 8px;
  font-size: 16px; line-height: 1.7; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }

#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: rgba(0, 0, 0, .8); padding: 10px 16px; border-radius: 999px; font-size: 14px; white-space: nowrap; }

/* 기도의 벽 */
#writeForm { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 700; color: #d6dde3; position: relative; }
.field em { font-style: normal; font-weight: 500; color: #8b96a2; }
.field input, .field textarea { width: 100%; font: inherit; font-weight: 400; font-size: 16px; color: var(--ink); background: #0f1318;
  border: 1px solid #2c3440; border-radius: 12px; padding: 12px; resize: none; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.field small { position: absolute; right: 10px; bottom: 8px; font-weight: 500; color: #6f7a86; font-size: 12px; }
.previewLabel { font-size: 12px; color: #8b96a2; margin-bottom: -6px; }
.chalk { background: radial-gradient(circle at 50% 40%, #33433b, #212b26); border: 6px solid #8a6440; border-radius: 10px;
  padding: 14px 18px; min-height: 96px; font-family: "Nanum Pen Script", cursive; color: #fbf6e9; text-align: center;
  display: grid; align-content: center; box-shadow: inset 0 0 30px rgba(0, 0, 0, .35); }
.chalk p { margin: 0; font-size: 30px; line-height: 1.15; word-break: keep-all; overflow-wrap: anywhere; }
.chalk p + p { font-size: 24px; text-align: right; opacity: .8; margin-top: 4px; }
.chalk p:empty { display: none; }
#pvText.placeholder { opacity: .4; }
.chalk.big { min-height: 160px; margin-top: 12px; }
.chalk.big p { font-size: 38px; }
.chalk.big p + p { font-size: 28px; }

/* 돋보기: 가운데 둥근 렌즈, 바깥은 어둡게 */
#lens { --r: min(43vw, 30vh); position: absolute; inset: 0;
  background: radial-gradient(circle var(--r) at 50% 46%, transparent calc(100% - 1px), rgba(8, 10, 14, .62) 100%); }
#lens::after { content: ""; position: absolute; left: 50%; top: 46%; width: calc(var(--r) * 2); height: calc(var(--r) * 2);
  transform: translate(-50%, -50%); border-radius: 50%; border: 5px solid #c9b48a;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .5), inset 0 0 40px rgba(255, 255, 255, .12); }

/* 벽 모양 비교(칠판/액자) */
.seg { position: absolute; right: 16px; top: calc(62px + env(safe-area-inset-top)); display: flex; pointer-events: auto;
  background: var(--panel); border-radius: 999px; padding: 3px; backdrop-filter: blur(6px); }
.seg button { padding: 6px 10px; white-space: nowrap; border-radius: 999px; font-size: 13px; color: #c9d1d8; background: none; }
.seg button.on { background: var(--gold); color: #1b1408; font-weight: 700; }
#tip { top: calc(104px + env(safe-area-inset-top)); }
.chalk.paper { background: #f6f0e2; border-color: #5a3d28; color: #2b2420; box-shadow: inset 0 0 0 10px #f6f0e2, inset 0 0 0 12px rgba(120,100,70,.3); }
.chalk.ivory { background: radial-gradient(circle, #f7f2e7, #ebe2cf); border: 8px solid #4a3122; outline: 2px solid #c9a35a; outline-offset: -10px; color: #2b2420; box-shadow: none; }
.chalk.news { background: #efe9da; border: 0; border-top: 4px double #141312; border-radius: 4px; color: #1e1c1a; text-align: left;
  font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-weight: 700; box-shadow: none; }
.chalk.news p { font-size: 19px; line-height: 1.45; }
.chalk.news p + p { font-family: "Apple SD Gothic Neo", sans-serif; font-weight: 500; font-size: 14px; color: #5b554d; }
.chalk.news.big p { font-size: 24px; }
.chalk.news.big p + p { font-size: 16px; }
.chalk.free { background: linear-gradient(#f7f5f0, #ece8df); border: 0; color: #1f2a44; box-shadow: inset 0 0 0 1px #d8d2c4; }
.chalk.free p { font-family: "Gaegu", cursive; transform: rotate(-2deg); }
.noGL { margin: 28px 0 0; font-size: 14px; line-height: 1.7; color: #cfd8e2; font-weight: 500; letter-spacing: 0; }
