/* 설교 슬라이드 화면
   방향: 슬라이드가 빛나 보이는 어두운 라이트테이블(오른쪽) + 맑은 회백색 대화 공책(왼쪽).
   시그니처: 번호 붙은 슬라이드 판, 누른 장에 노란 테두리, 그 아래 수정 단추 줄.

   never:
   - 웜 크림 바탕 + 세리프 제목 + 테라코타(AI 기본값 1형). 바탕은 차가운 회백색이다.
   - 옅은 베이지 헤어라인 + 이중 소프트 그림자. 선은 잉크 2px, 그림자는 단단한 오프셋 하나.
   - Pretendard, Inter, system-ui 단독. 글꼴은 나눔스퀘어 네오(SB Neo)뿐.
   - transition: all. 움직임은 transform, opacity, 색만.
   - 이모지 아이콘. 아이콘은 인라인 SVG 선.
*/
@font-face { font-family: "SB Neo"; src: url(/web/fonts/neo-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "SB Neo"; src: url(/web/fonts/neo-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "SB Neo"; src: url(/web/fonts/neo-900.woff2) format("woff2"); font-weight: 900; font-display: swap; }

:root {
  --paper: #EBEEEC;       /* 대화 쪽 바탕, 차가운 회백 */
  --paper-2: #DDE2DF;     /* 사용자 말풍선 */
  --ink: #1D2321;         /* 글자, 선 */
  --ink-soft: #4E5754;
  --table: #23292B;       /* 슬라이드 판 바탕(라이트테이블) */
  --table-2: #2E3537;
  --table-ink: #C9D1CE;
  --teal: #355F5B;        /* 주 단추, 신아삽 목사님 대지 청회색을 짙게 */
  --teal-ink: #F3F7F6;
  --mark: #F2C94C;        /* 고른 장, 슬라이드 강조색과 같은 노랑 */
  --warn: #9B3B2E;

  --font: "SB Neo", "NanumSquareNeo", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --fs: calc(17px * var(--scale, 1));
  --fs-sm: calc(14px * var(--scale, 1));
  --fs-lg: calc(20px * var(--scale, 1));
  --fs-display: calc(30px * var(--scale, 1));

  --r-btn: 10px;
  --r-card: 14px;
  --r-slide: 6px;
  --line: 2px solid var(--ink);
  --hard: 3px 3px 0 var(--ink);
  --chat-w: 46%;
  --cols: 3;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: var(--fs); color: var(--ink); background: var(--paper);
  word-break: keep-all; overflow-wrap: break-word; -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* 단추 */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; min-height: 44px;
  border: var(--line); border-radius: var(--r-btn); background: #fff; cursor: pointer; text-decoration: none;
  font-weight: 700; line-height: 1.1; transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: var(--hard); }
.btn:active { transform: translate(1px, 1px); box-shadow: none; }
.btn.primary { background: var(--teal); color: var(--teal-ink); border-color: var(--ink); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.link { background: none; border: 0; padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: inherit; }

/* 입장 */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: #fff; border: var(--line); border-radius: var(--r-card); box-shadow: 6px 6px 0 var(--ink); padding: 32px 28px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; font-size: var(--fs-display); font-weight: 900; letter-spacing: -0.02em; }
.login-card p { margin: 0; color: var(--ink-soft); line-height: 1.6; }
.login-card input { border: var(--line); border-radius: var(--r-btn); padding: 12px 14px; font-size: 22px; letter-spacing: .2em; text-align: center; }
.login-err { color: var(--warn) !important; font-weight: 700; }

/* 틀 */
.app { height: 100%; display: flex; flex-direction: column; }
.top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 22px; border-bottom: var(--line); background: var(--paper); }
.top-left { display: flex; align-items: baseline; gap: 14px; min-width: 0; flex-wrap: wrap; }
.brand { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); letter-spacing: .04em; }
.sermon { margin: 0; font-size: var(--fs-display); font-weight: 900; letter-spacing: -0.02em; line-height: 1.15; }
.sermon-ref { color: var(--ink-soft); font-weight: 700; }
.top-right { display: flex; gap: 10px; flex: none; }
.past { position: absolute; right: 22px; top: calc(100% + 8px); z-index: 20; width: min(440px, calc(100vw - 32px)); max-height: 60vh; overflow: auto; background: #fff; border: var(--line); border-radius: var(--r-card); box-shadow: 6px 6px 0 var(--ink); padding: 8px; }
.past button { display: grid; width: 100%; text-align: left; gap: 2px; background: none; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.past button:hover { background: var(--paper-2); }
.past b { font-size: var(--fs); }
.past small { color: var(--ink-soft); font-size: var(--fs-sm); }
.past .none { padding: 12px; color: var(--ink-soft); }

.tabs { display: none; }
.panes { flex: 1; display: grid; grid-template-columns: var(--chat-w) 1fr; min-height: 0; }

/* 대화 */
.chat { display: grid; grid-template-rows: 1fr auto auto; min-height: 0; border-right: var(--line); }
.log { overflow-y: auto; padding: 22px 22px 8px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: 92%; line-height: 1.65; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; }
.msg.bot.interim { color: var(--ink-soft); }
.msg.user { align-self: flex-end; background: var(--paper-2); border: var(--line); border-radius: var(--r-card) var(--r-card) 4px var(--r-card); padding: 10px 14px; }
.msg.user .att { display: block; font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 6px; }
.msg.error { color: var(--warn); }
.msg.user.long { max-height: 9.5em; overflow: hidden; position: relative; cursor: pointer; }
.msg.user.long::after { content: "원고 전체 보기"; position: absolute; right: 10px; bottom: 6px; background: var(--paper-2); font-size: var(--fs-sm); font-weight: 700; padding-left: 8px; }
.msg.user.long.open { max-height: none; }
.msg.user.long.open::after { display: none; }
.note { font-size: var(--fs-sm); color: var(--ink-soft); align-self: center; }
.starter { display: grid; gap: 10px; align-self: stretch; }
.starter h2 { margin: 6px 0 2px; font-size: var(--fs-lg); font-weight: 900; }
.starter button { text-align: left; background: #fff; border: var(--line); border-radius: var(--r-card); padding: 12px 14px; cursor: pointer; line-height: 1.5; transition: transform .12s ease, box-shadow .12s ease; }
.starter button:hover { transform: translate(-1px, -1px); box-shadow: var(--hard); }
.starter button b { display: block; }
.starter button span { color: var(--ink-soft); font-size: var(--fs-sm); }

/* 옵션 카드 */
.options { display: grid; gap: 14px; align-self: stretch; }
.opt { background: #fff; border: var(--line); border-radius: var(--r-card); overflow: hidden; }
.opt img { display: block; width: 100%; cursor: zoom-in; background: var(--table); }
.opt-foot { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.opt-num { font-size: 32px; font-weight: 900; line-height: 1; min-width: 1.2em; }
.opt-txt { flex: 1; line-height: 1.45; }
.opt-txt b { display: block; }
.opt-txt span { color: var(--ink-soft); font-size: var(--fs-sm); }
.cands { background: #fff; border: var(--line); border-radius: var(--r-card); padding: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-self: stretch; }
.cands figure { margin: 0; cursor: pointer; }
.cands img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; display: block; }
.cands figcaption { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.gen img { max-width: 260px; border: var(--line); border-radius: var(--r-slide); display: block; }

.status { display: flex; align-items: center; gap: 10px; padding: 8px 22px; color: var(--ink-soft); font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.composer { border-top: var(--line); padding: 12px 16px 14px; display: grid; gap: 8px; background: var(--paper); }
.composer textarea { width: 100%; resize: none; border: var(--line); border-radius: var(--r-card); padding: 12px 14px; line-height: 1.55; background: #fff; max-height: 40vh; min-height: 84px; }
.composer textarea:focus, .tray-form input:focus, .login-card input:focus { outline: 3px solid var(--mark); outline-offset: 1px; }
.composer-row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; min-height: 44px; border-radius: var(--r-btn); border: 2px solid transparent; background: none; cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.icon-btn:hover { border-color: var(--ink); color: var(--ink); }
.icon-btn.rec { color: var(--warn); border-color: var(--warn); }
.send { padding-inline: 24px; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.attachments span { background: #fff; border: var(--line); border-radius: 999px; padding: 4px 10px; font-size: var(--fs-sm); display: inline-flex; gap: 6px; align-items: center; }
.attachments button { border: 0; background: none; cursor: pointer; padding: 0 2px; font-weight: 900; }

/* 슬라이드 판 */
.board { background: var(--table); color: var(--table-ink); display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.board-head { padding: 14px 18px 4px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.files .file { background: var(--table-2); color: #fff; border-color: #0E1112; display: grid; gap: 2px; padding: 8px 14px; }
.files .file small { color: var(--table-ink); font-weight: 400; font-size: 12px; }
.files .file.pick { border-color: var(--mark); }
.files .file.pick small::after { content: " · 이번 예배"; color: var(--mark); }
.files .btn:hover { box-shadow: 3px 3px 0 #0E1112; }
.send-note { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--table-ink); }
.grid { overflow-y: auto; padding: 14px 18px 18px; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 18px 14px; align-content: start; }
.slide { position: relative; cursor: pointer; border: 0; padding: 0; background: none; text-align: left; color: inherit; }
.slide img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--r-slide); outline: 2px solid #0E1112; transition: transform .14s ease, outline-color .14s ease; }
.slide:hover img { transform: translateY(-2px); }
.slide.on img { outline: 4px solid var(--mark); }
.slide .n { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; font-size: var(--fs-sm); }
.slide .n b { font-size: 18px; font-weight: 900; color: #fff; }
.slide .n span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.slide.fresh img { animation: fresh 1.6s ease-out 1; }
@keyframes fresh { 0% { outline-color: var(--mark); outline-width: 4px; } 100% { outline-color: #0E1112; } }
.empty { grid-column: 1 / -1; display: grid; justify-items: center; gap: 16px; padding: 12vh 20px; text-align: center; color: var(--table-ink); line-height: 1.7; }
.empty-frame { width: min(320px, 70%); aspect-ratio: 16/9; border: 2px dashed #5A6466; border-radius: var(--r-slide); display: grid; place-items: center; }
.empty-frame span { font-size: 54px; font-weight: 900; color: #5A6466; }
.empty p { margin: 0; }

.tray { border-top: 2px solid #0E1112; background: var(--table-2); display: grid; grid-template-columns: minmax(160px, 34%) 1fr; gap: 14px; padding: 12px 18px 14px; }
.tray img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--r-slide); outline: 3px solid var(--mark); cursor: zoom-in; }
.tray-body { display: grid; gap: 10px; align-content: start; min-width: 0; }
.tray-title { margin: 0; display: flex; gap: 8px; align-items: baseline; color: #fff; }
.tray-title b { font-size: 22px; font-weight: 900; }
.tray-title span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--table-ink); }
.tray-title .link { color: var(--table-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: transparent; color: #fff; border: 2px solid #6B7678; border-radius: 999px; padding: 7px 13px; cursor: pointer; font-weight: 700; font-size: var(--fs-sm); transition: border-color .12s ease, background-color .12s ease; }
.chips button:hover { border-color: var(--mark); background: #3A4244; }
.tray-form { display: flex; gap: 8px; }
.tray-form input { flex: 1; min-width: 0; border: 2px solid #0E1112; border-radius: var(--r-btn); padding: 10px 12px; background: #fff; color: var(--ink); }

.foot { display: flex; gap: 16px; align-items: center; padding: 6px 22px; border-top: var(--line); font-size: var(--fs-sm); color: var(--ink-soft); background: var(--paper); }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 13, .92); display: grid; place-items: center; padding: 3vw; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: var(--r-slide); }
.lightbox p { color: #fff; margin: 10px 0 0; font-weight: 700; }

/* 좁은 화면: 대화와 슬라이드를 탭으로 */
@media (max-width: 900px) {
  .tabs { display: flex; border-bottom: var(--line); }
  .tabs button { flex: 1; padding: 12px; background: none; border: 0; font-weight: 700; cursor: pointer; border-bottom: 4px solid transparent; }
  .tabs button.on { border-bottom-color: var(--ink); }
  .panes { grid-template-columns: 1fr; }
  .chat { border-right: 0; }
  .panes[data-tab="chat"] .board, .panes[data-tab="board"] .chat { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top { padding: 12px 16px; }
  .sermon { font-size: 22px; }
  .brand { display: none; }
  .top { align-items: flex-start; }
  .top-left { flex-direction: column; gap: 2px; }
  .sermon-ref { font-size: var(--fs-sm); }
  .top-right .btn { padding: 8px 10px; min-height: 40px; }
  .top-right .btn .lbl { display: none; }
  .tray { grid-template-columns: 1fr; padding: 10px 14px; }
  .tray img { display: none; }
  .cands { grid-template-columns: repeat(2, 1fr); }
  .log { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
