/* 손님 공유방 — 규칙표
   방향: 개발을 모르는 공장 사장님이 휴대폰으로 연락·파일·질문지를 주고받는 곳. 밝고 단단하게, '보내기'와 메시지가 먼저 보이게.
   글자: 14 · 16 · 18(기본) · 22 · 28   굵기: 400 · 600 · 700
   간격: 4 · 8 · 12 · 16 · 24 · 32     모서리: 8 · 14 · 999(알약)
   색: 바탕 #fff · 판 #f3f4f1 · 선 #d9dcd5 · 글 #16181a / #43484e / #5d636a · 강조 #0b6b52(진한 초록, 하나만) · 위험 #b3261e
   누르는 것: 최소 48px, 주 단추 52px
*/
:root {
  --bg: #ffffff; --panel: #f3f4f1; --line: #d9dcd5; --ink: #16181a; --ink2: #43484e; --ink3: #5d636a;
  --acc: #0b6b52; --acc-d: #08533f; --acc-soft: #e4f1ec; --danger: #b3261e; --warn-soft: #fff4d6;
  --r1: 8px; --r2: 14px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 18px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--acc); }
.gr-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.gr-ic { width: 24px; height: 24px; flex: none; }
.gr-muted { color: var(--ink3); }
.gr-small { font-size: 16px; }
.gr-err { color: var(--danger); min-height: 1.5em; margin: 8px 0; font-size: 16px; }
.gr-h2 { font-size: 22px; margin: 0; font-weight: 700; }
.gr-h3 { font-size: 16px; margin: 24px 0 8px; color: var(--ink2); font-weight: 700; }
.gr-plain { list-style: none; padding: 0; margin: 0; }
.gr-plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }

/* 단추 */
.gr-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border-radius: var(--r2); border: 1.5px solid transparent; background: var(--panel); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.gr-btn:focus-visible, .gr-tab:focus-visible, .gr-input:focus-visible, .gr-cbtn:focus-visible { outline: 3px solid #f0b400; outline-offset: 2px; }
.gr-btn-main { background: var(--acc); color: #fff; }
.gr-btn-main:active { background: var(--acc-d); }
.gr-btn-line { background: #fff; border-color: var(--acc); color: var(--acc); }
.gr-btn-danger { background: var(--danger); color: #fff; }
.gr-btn-small { min-height: 44px; padding: 0 14px; font-size: 16px; background: var(--acc); color: #fff; }
.gr-btn-wide { width: 100%; }
.gr-btn-icon { width: 52px; padding: 0; background: var(--panel); }
.gr-btn-ghost { background: transparent; min-height: 48px; padding: 0 12px; color: var(--ink2); font-size: 16px; }
.gr-btn[disabled] { opacity: .5; cursor: default; }
.gr-row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* 입력 */
.gr-label { display: block; font-weight: 600; margin-bottom: 8px; }
.gr-input { width: 100%; border: 1.5px solid var(--line); border-radius: var(--r1); padding: 12px 14px; background: #fff; min-height: 52px; }
.gr-input:focus { border-color: var(--acc); outline: none; }
.gr-input-big { font-size: 28px; letter-spacing: .15em; text-align: left; }
textarea.gr-input { resize: vertical; }

/* 로그인 */
.gr-login { max-width: 420px; margin: 0 auto; padding: 18vh 24px 32px; }
.gr-login-name { font-size: 28px; margin: 0 0 32px; line-height: 1.3; }
.gr-login-form { margin-bottom: 32px; }
.gr-foot-link { color: var(--ink3); font-size: 16px; display: inline-block; padding: 12px 0; }

/* 앱 뼈대 */
.gr-app { display: flex; flex-direction: column; height: 100dvh; }
.gr-top { display: flex; align-items: center; gap: 12px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.gr-top-name { font-size: 22px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-btn-call { min-height: 48px; padding: 0 16px; }
.gr-tabs { display: flex; border-bottom: 1px solid var(--line); background: #fff; }
.gr-tab { flex: 1; min-height: 52px; border: 0; background: none; font-weight: 600; color: var(--ink3); border-bottom: 3px solid transparent; cursor: pointer; position: relative; }
.gr-tab.on { color: var(--ink); border-bottom-color: var(--acc); }
.gr-dot { display: none; width: 9px; height: 9px; background: var(--danger); border-radius: 50%; position: absolute; top: 12px; margin-left: 4px; }
.gr-dot.on { display: inline-block; }
body:not(.gr-op) .gr-op-only { display: none !important; }
.gr-body { flex: 1; min-height: 0; display: flex; }
.gr-view { display: none; flex: 1; min-width: 0; min-height: 0; }
body.t-chat #v-chat, body.t-files #v-files, body.t-forms #v-forms, body.t-stats #v-stats { display: flex; }
.gr-side { flex-direction: column; overflow-y: auto; padding: 16px 16px 32px; }
.gr-side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }

/* 대화 */
.gr-chat { flex-direction: column; background: var(--panel); }
.gr-pushbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--warn-soft); font-size: 16px; }
.gr-pushbar span { flex: 1; }
.gr-msgs { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.gr-day { align-self: center; font-size: 14px; color: var(--ink3); padding: 8px 0 4px; }
.gr-m { max-width: min(82%, 560px); display: flex; flex-direction: column; align-items: flex-start; }
.gr-m.mine { align-self: flex-end; align-items: flex-end; }
.gr-m-who { font-size: 14px; color: var(--ink3); margin: 0 4px 4px; }
.gr-bubble { background: #fff; border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 14px; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; cursor: default; }
.gr-m.mine .gr-bubble { background: var(--acc); color: #fff; border-color: var(--acc); }
.gr-bubble.gone { background: transparent !important; color: var(--ink3) !important; border-style: dashed !important; border-color: var(--line) !important; }
.gr-bubble.sys { background: var(--acc-soft); color: var(--ink); border-color: transparent; }
.gr-m.mine .gr-bubble.sys { background: var(--acc-soft); color: var(--ink); border-color: transparent; }
.gr-m-meta { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--ink3); margin: 2px 4px 0; }
.gr-m-act { border: 0; background: none; color: var(--ink3); font-size: 14px; min-height: 44px; min-width: 44px; padding: 0 8px; cursor: pointer; text-decoration: underline; }
.gr-fcard { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-height: 48px; }
.gr-fcard .gr-ic { width: 28px; height: 28px; }
.gr-fcard b { display: block; font-weight: 600; word-break: break-all; }
.gr-fcard small { font-size: 14px; opacity: .85; }
.gr-composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.gr-msg-in { flex: 1; min-width: 0; max-height: 160px; resize: none; line-height: 1.4; }
.gr-btn-send { padding: 0 16px; }
.gr-empty { color: var(--ink3); text-align: center; padding: 32px 16px; }

/* 파일·질문지 목록 */
.gr-list { list-style: none; padding: 0; margin: 0; }
.gr-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.gr-item-main { flex: 1; min-width: 0; }
.gr-item-name { font-weight: 600; word-break: break-all; }
.gr-item-sub { font-size: 14px; color: var(--ink3); }
.gr-item-btns { display: flex; gap: 4px; flex: none; }
.gr-item .gr-btn { min-height: 48px; padding: 0 12px; font-size: 16px; }
.gr-item .gr-btn-icon { width: 48px; padding: 0; }
.gr-badge { display: inline-block; background: var(--danger); color: #fff; border-radius: 999px; font-size: 14px; padding: 0 8px; margin-left: 6px; font-weight: 600; vertical-align: 2px; }
.gr-badge.ok { background: var(--acc-soft); color: var(--acc-d); }
.gr-trash { margin-top: 24px; }
.gr-trash summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; color: var(--ink2); font-weight: 600; }
.gr-progress { list-style: none; padding: 0; margin: 0; }
.gr-progress li { font-size: 16px; padding: 8px 0; }
.gr-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.gr-bar i { display: block; height: 100%; background: var(--acc); width: 0; }

/* 질문지 */
.gr-back { margin: -4px 0 8px -12px; }
.gr-q { padding: 16px 0; border-bottom: 1px solid var(--line); }
.gr-q-label { font-weight: 700; margin: 0 0 12px; }
.gr-q-num { color: var(--acc); margin-right: 6px; }
.gr-opt { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px 12px; border: 1.5px solid var(--line); border-radius: var(--r1); margin-bottom: 8px; cursor: pointer; background: #fff; }
.gr-opt input { width: 24px; height: 24px; accent-color: var(--acc); flex: none; margin: 0; }
.gr-opt:has(input:checked) { border-color: var(--acc); background: var(--acc-soft); }
.gr-etc { margin-top: 4px; }
.gr-form-btns { position: sticky; bottom: -32px;   /* .gr-side 아래 여백(32px)만큼 내려 화면 끝에 붙임 */  background: #fff; padding: 12px 0; display: flex; gap: 8px; border-top: 1px solid var(--line); }
.gr-form-btns .gr-btn { flex: 1; }
.gr-ans-tbl { width: 100%; border-collapse: collapse; font-size: 16px; }
.gr-ans-tbl th, .gr-ans-tbl td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.gr-ans-tbl th { width: 42%; color: var(--ink2); font-weight: 600; }
.gr-ans-tbl td { white-space: pre-wrap; word-break: break-word; }
.gr-ans-tbl td.none { color: var(--ink3); }
.gr-bld { border: 1.5px solid var(--line); border-radius: var(--r2); padding: 12px; margin-bottom: 12px; background: #fff; }
.gr-bld-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.gr-bld-top select { flex: 1; min-height: 48px; border: 1.5px solid var(--line); border-radius: var(--r1); padding: 0 8px; background: #fff; font-size: 16px; }
.gr-bld textarea { margin-top: 8px; font-size: 16px; }
.gr-tpls { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.gr-tpls .gr-btn { min-height: 44px; font-size: 16px; }

/* 관리 막대 */
.gr-bars { list-style: none; padding: 0; margin: 0; }
.gr-bars li { display: grid; grid-template-columns: 9em 1fr 3em; gap: 8px; align-items: center; padding: 6px 0; font-size: 16px; }
.gr-bars .gr-bar { height: 12px; margin: 0; }
.gr-bars b { text-align: right; font-weight: 600; }

/* 통화 */
.gr-call { position: fixed; inset: 0; z-index: 50; background: #0f1412; color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: max(32px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom)); }
.gr-rv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; background: #0f1412; }
.gr-lv { position: absolute; right: 16px; top: 16px; width: 28vw; max-width: 180px; border-radius: var(--r1); border: 2px solid #fff; }
.gr-call-info { text-align: center; margin-top: 12vh; }
.gr-call-who { font-size: 28px; font-weight: 700; margin: 0 0 8px; }
.gr-call-state { font-size: 18px; margin: 0; color: #cfd8d3; }
.gr-call-btns { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }
.gr-cbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 104px; height: 104px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; font-weight: 600; font-size: 16px; cursor: pointer; }
.gr-cbtn .gr-ic { width: 30px; height: 30px; }
.gr-cbtn-go { background: #1f9d55; }
.gr-cbtn-end { background: #d93025; }
.gr-cbtn[aria-pressed="true"] { background: #fff; color: #0f1412; }

/* 알림 줄·묻기 */
.gr-toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: #1d2321; color: #fff; border-radius: var(--r2);
  padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 24px); font-size: 16px; }
.gr-toast-btn { background: none; border: 0; color: #8fe0c0; font-weight: 700; min-height: 44px; padding: 0 12px; cursor: pointer; }
.gr-ask { border: 0; border-radius: var(--r2); padding: 24px; max-width: min(400px, calc(100vw - 32px)); }
.gr-ask::backdrop { background: rgba(0,0,0,.4); }
.gr-ask p { margin: 0 0 8px; }
.gr-ask .gr-btn { flex: 1; }

/* 문서 */
.gr-doc { max-width: 680px; margin: 0 auto; padding: 32px 20px 64px; }
.gr-doc h1 { font-size: 28px; }
.gr-doc h2 { font-size: 22px; margin-top: 32px; }

/* 넓은 화면: 왼쪽 대화 + 오른쪽 파일·질문지 */
@media (min-width: 1000px) {
  .gr-tab[data-tab="chat"] { display: none; }
  .gr-tabs { padding-left: calc(100% - 520px); }
  .gr-tab { flex: 0 1 auto; padding: 0 24px; }
  body #v-chat { display: flex; flex: 1; }
  .gr-side { flex: none; width: 520px; border-left: 1px solid var(--line); }
  .gr-msgs { padding: 24px max(24px, calc(50% - 420px)); }
  .gr-composer { padding-left: max(12px, calc(50% - 420px)); padding-right: max(12px, calc(50% - 420px)); }
  .gr-top { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 380px) {
  .gr-btn-send span { display: none; }
  .gr-btn-send { width: 52px; padding: 0; }
  .gr-cbtn { width: 92px; height: 92px; }
}
@media (prefers-reduced-motion: no-preference) {
  .gr-bar i { transition: width .2s; }
}
