:root {
  --midnight: #101B30;
  --ink: #13213C;
  --ink-deep: #0A1426;
  --ivory: #F6F5F1;
  --brass: #B79A63;
  --brass-text: #8C7346;
  --line: #E4E1D8;
  --line-soft: #EEECE6;
  --line-strong: #CFCBC1;
  --muted: #6B7280;
  --body: #4B5263;
  --navy-line: #2A3A5C;
  --navy-muted: #A9B3C6;
  --ok: #2F6B4F;
  --wait: #8C5A12;
  --wait-bg: #FBF3E6;
  --wait-line: #EAD9BC;
  --serif: 'Noto Serif KR', 'Apple SD Gothic Neo', serif;
  --num: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ivory); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
/* 한글 줄바꿈: 단어 중간에서 끊지 않음(긴 영문·URL만 필요할 때 끊음), 마지막 줄 한 글자 고아 방지 */
body { word-break: keep-all; overflow-wrap: break-word; line-break: strict; }
p, h1, h2, span, b, .me, .bot p, .tidy p { text-wrap: pretty; }
body { overscroll-behavior-y: none; }
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--ink); }
input::placeholder { color: #A5A9B1; }
[hidden] { display: none !important; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--ivory); position: relative; }

.eyebrow { font-size: 10px; letter-spacing: 0.2em; color: var(--brass-text); font-weight: 500; }
.label { font-size: 11px; letter-spacing: 0.14em; color: var(--muted); font-weight: 500; }
.serif { font-family: var(--serif); font-weight: 600; }
.num { font-family: var(--num); }

/* 주 버튼 */
.cta { height: 56px; border: none; border-radius: 4px; background: var(--ink); color: var(--ivory); font-size: 15px; font-weight: 500; letter-spacing: 0.04em; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; text-decoration: none; width: 100%; }
.cta:hover { background: var(--ink-deep); }
.cta:disabled { opacity: 0.5; cursor: default; }
.cta.center { justify-content: center; }
.ghost { height: 52px; border-radius: 4px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font-size: 14px; display: flex; align-items: center; justify-content: center; text-decoration: none; width: 100%; }

/* ---------- 로그인 ---------- */
.hero { position: relative; background: var(--midnight); color: var(--ivory); min-height: 452px; padding: 64px 32px 0; display: flex; flex-direction: column; overflow: hidden; }
.hero .globe { position: absolute; right: -170px; top: -40px; opacity: 0.55; }
.hero .logo { width: 150px; height: auto; filter: brightness(0) invert(1); position: relative; }
.hero .bottom { margin-top: auto; padding-bottom: 44px; display: flex; flex-direction: column; gap: 18px; position: relative; }
.hero .tag { display: flex; align-items: center; gap: 12px; }
.hero .tag i { width: 24px; height: 1px; background: var(--brass); }
.hero .tag span { font-size: 11px; letter-spacing: 0.22em; color: var(--brass); font-weight: 500; }
.hero h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.42; letter-spacing: -0.01em; text-wrap: balance; }
.hero .when { display: flex; gap: 14px; align-items: baseline; color: var(--navy-muted); font-size: 13px; flex-wrap: wrap; }
.hero .when b { font-family: var(--num); font-weight: 400; font-size: 20px; color: #E8E4DA; letter-spacing: 0.02em; }

.form { flex: 1; padding: 36px 32px 0; display: flex; flex-direction: column; gap: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; letter-spacing: 0.14em; color: var(--muted); font-weight: 500; }
.field input { height: 46px; border: none; border-bottom: 1px solid var(--line-strong); background: transparent; padding: 0; font-size: 17px; border-radius: 0; }
.field input:focus { outline: none; border-bottom-color: var(--ink); }
.field input.pin { font-family: var(--num); font-size: 24px; letter-spacing: 0.6em; }
.form-error { font-size: 13px; line-height: 1.6; color: #8A2E1F; min-height: 0; }
.foot { padding: 24px 32px 30px; display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 0.04em; color: var(--muted); gap: 12px; flex-wrap: wrap; }

/* ---------- 오늘의 배정 ---------- */
.top { padding: 52px 28px 0; display: flex; justify-content: space-between; align-items: center; }
.top img { width: 108px; height: auto; }
.top span { font-size: 12px; color: var(--muted); }
.greet { padding: 44px 28px 0; display: flex; flex-direction: column; gap: 10px; }
.greet h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 27px; line-height: 1.45; }
.assign { margin: 28px 20px 0; background: var(--midnight); color: var(--ivory); border-radius: 6px; padding: 26px 24px; display: flex; flex-direction: column; gap: 20px; position: relative; overflow: hidden; }
.assign svg { position: absolute; right: -80px; top: -60px; opacity: 0.6; }
.assign .who { display: flex; flex-direction: column; gap: 6px; position: relative; }
.assign .who span { font-size: 11px; letter-spacing: 0.14em; color: var(--brass); }
.assign .who b { font-family: var(--num); font-weight: 400; font-size: 38px; line-height: 1.05; word-break: keep-all; overflow-wrap: anywhere; }
.assign .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; border-top: 1px solid var(--navy-line); padding-top: 18px; position: relative; }
.assign .grid div { display: flex; flex-direction: column; gap: 4px; }
.assign .grid .wide { grid-column: span 2; }
.assign .grid small { font-size: 11px; color: var(--navy-muted); }
.assign .grid span { font-size: 15px; }
.steps { padding: 28px 28px 0; display: flex; flex-direction: column; gap: 14px; }
.steps .row { display: flex; gap: 14px; align-items: baseline; }
.steps .row b { font-family: var(--num); font-weight: 400; font-size: 18px; color: var(--brass); }
.steps .row span { font-size: 14px; line-height: 1.6; }
.bottom-actions { margin-top: auto; padding: 24px 20px 30px; display: flex; flex-direction: column; gap: 12px; }
.bottom-actions .hint { font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 대화 입력 ---------- */
.chat { height: 100dvh; display: flex; flex-direction: column; }
.bar { padding: 46px 20px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: var(--ivory); }
.icon-btn { width: 44px; height: 44px; margin-left: -10px; display: flex; align-items: center; justify-content: center; border: none; background: none; }
.bar .title { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bar .title b { font-family: var(--serif); font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .count { display: flex; flex-direction: column; align-items: flex-end; min-height: 44px; justify-content: center; border: none; background: none; padding: 0; }
.bar .count b { font-family: var(--num); font-weight: 400; font-size: 24px; line-height: 1; }
.bar .count span { font-size: 10px; letter-spacing: 0.08em; color: var(--muted); }
.progress { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 4px; padding: 10px 20px 0; }
.progress i { height: 2px; background: #DDD9CF; }
.progress i.on { background: var(--ink); }

.thread { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 22px 20px 16px; display: flex; flex-direction: column; gap: 18px; }
.bot { display: flex; flex-direction: column; gap: 6px; max-width: 320px; animation: rise .28s ease-out both; }
.bot p { margin: 0; font-size: 15px; line-height: 1.7; }
.me { align-self: flex-end; max-width: 280px; background: var(--ink); color: var(--ivory); border-radius: 18px 18px 4px 18px; padding: 12px 16px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; animation: rise .22s ease-out both; }
.tidy { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; animation: rise .3s ease-out both; }
.tidy .head { display: flex; align-items: center; gap: 10px; }
.tidy .head i { width: 16px; height: 1px; background: var(--brass); }
.tidy .head span { font-size: 10px; letter-spacing: 0.18em; color: var(--brass-text); font-weight: 500; }
.tidy p { margin: 0; font-family: var(--serif); font-size: 14px; line-height: 1.8; }
.tidy.wait p { font-family: var(--sans); font-size: 13px; color: var(--body); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 20px 18px 8px; display: flex; flex-direction: column; }
.card h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 17px; padding-bottom: 12px; }
.card .row { display: flex; gap: 12px; align-items: flex-start; border-top: 1px solid var(--line-soft); padding: 12px 0; }
.card .row small { width: 78px; flex-shrink: 0; font-size: 11px; letter-spacing: 0.06em; color: var(--muted); padding-top: 3px; }
.card .row span { flex: 1; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.card .row button { border: none; background: none; color: var(--brass-text); font-size: 12px; font-weight: 500; min-height: 32px; padding: 0 2px; text-decoration: underline; text-underline-offset: 3px; }
.done-card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 22px 18px; display: flex; flex-direction: column; gap: 10px; animation: rise .3s ease-out both; }
.done-card .t { display: flex; align-items: center; gap: 10px; }
.done-card .t b { font-family: var(--serif); font-weight: 600; font-size: 17px; }
.done-card p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--body); }

.composer { background: #fff; border-top: 1px solid var(--line); padding: 14px 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); border-radius: 999px; padding: 0 18px; font-size: 14px; }
@media (hover: hover) { .chip:hover { background: var(--ink); color: var(--ivory); border-color: var(--ink); } }
.chip:active { background: var(--ink); color: var(--ivory); border-color: var(--ink); }
.chip.mini { min-height: 40px; padding: 0 12px; font-size: 13px; }
.chip.on { background: var(--ink); color: var(--ivory); border-color: var(--ink); }
.survey { display: flex; flex-direction: column; gap: 12px; max-height: 52dvh; overflow-y: auto; }
.sq { display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line-soft); padding-bottom: 12px; }
.sq:last-child { border-bottom: none; }
.sq .sl { font-size: 14px; line-height: 1.5; }
.hintline { font-size: 12px; color: var(--muted); }
.chip.small { min-height: 40px; font-size: 13px; align-self: flex-start; }
.inputrow { display: flex; gap: 10px; align-items: center; }
.inputrow .cur { font-family: var(--num); font-size: 22px; color: var(--brass-text); }
.inputrow input, .inputrow textarea { flex: 1; min-width: 0; min-height: 50px; border: 1px solid var(--line-strong); border-radius: 25px; padding: 13px 18px; font-size: 16px; background: var(--ivory); resize: none; line-height: 1.5; max-height: 140px; }
.inputrow input:focus, .inputrow textarea:focus { outline: none; border-color: var(--ink); }
.send { width: 50px; height: 50px; border: none; border-radius: 50%; background: var(--ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send:disabled { opacity: 0.35; }
.complist { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.complist button { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; border: none; border-bottom: 1px solid var(--line-soft); background: #fff; text-align: left; font-size: 15px; }
.complist button:last-child { border-bottom: none; }
.complist button small { font-family: var(--num); font-size: 16px; color: var(--brass-text); }
.complist .none { padding: 14px 16px; font-size: 13px; color: var(--muted); }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* ---------- 내 목록 ---------- */
.mine-head { background: var(--midnight); color: var(--ivory); padding: 50px 24px 26px; display: flex; flex-direction: column; gap: 26px; }
.mine-head .r1 { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mine-head .r1 img { width: 112px; height: auto; filter: brightness(0) invert(1); }
.mine-head .r1 span { font-size: 12px; color: var(--navy-muted); text-align: right; }
.mine-head .r2 { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.mine-head .big { display: flex; align-items: baseline; gap: 8px; }
.mine-head .big b { font-family: var(--num); font-weight: 400; font-size: 64px; line-height: 0.9; }
.mine-head .big span { font-size: 14px; color: #C9D0DC; }
.mine-head .stat { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; font-size: 12px; color: #C9D0DC; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.ok { background: var(--ok); }
.dot.okl { background: #7BC4A0; }
.dot.wait { border: 1.5px solid var(--wait); }
.list { flex: 1; padding: 8px 24px 16px; display: flex; flex-direction: column; }
.item { border-bottom: 1px solid var(--line); padding: 18px 0; display: flex; gap: 16px; }
.item .tm { font-family: var(--num); font-size: 18px; color: var(--brass-text); width: 44px; flex-shrink: 0; padding-top: 1px; }
.item .bd { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item .bd b { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.item .bd p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--body); word-break: keep-all; overflow-wrap: anywhere; }
.item .bd .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; }
.item .st { display: flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.item .st.ok { color: var(--ok); }
.item .st.wait { color: var(--wait); }
.empty { padding: 48px 8px; text-align: center; font-size: 14px; color: var(--muted); line-height: 1.7; }
.sticky-foot { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 14px 20px calc(18px + env(safe-area-inset-bottom)); }

/* ---------- 연결 상태 배너 ---------- */
.netbar { background: var(--wait-bg); border-bottom: 1px solid var(--wait-line); padding: 12px 20px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; }
.netbar div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.netbar b { font-size: 14px; font-weight: 600; color: #6E460E; }
.netbar span { font-size: 12px; color: #6E460E; line-height: 1.5; }
.netbar button { border: 1px solid #D9BF92; background: transparent; color: #6E460E; border-radius: 4px; min-height: 36px; padding: 0 12px; font-size: 12px; }

/* ---------- PC 화면 (같은 링크, 넓은 화면에서 자동 전환) ---------- */
@media (min-width: 900px) {
  html, body { background: #E9E7E1; }
  body[data-screen="login"] .form:before { content: '통역사 로그인'; font-family: var(--serif); font-weight: 600; font-size: 24px; margin-bottom: 4px; }
  #app { margin: 40px auto; min-height: calc(100dvh - 80px); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: 0 20px 60px rgba(16, 27, 48, .10); }
  .toast { bottom: 64px; }

  /* 로그인: 왼쪽 남색 소개 / 오른쪽 입력 */
  body[data-screen="login"] #app { max-width: 1040px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; }
  body[data-screen="login"] .hero { grid-row: 1 / span 2; min-height: 620px; padding: 64px 56px 0; }
  body[data-screen="login"] .hero h1 { font-size: 34px; }
  body[data-screen="login"] .form { padding: 96px 64px 0; justify-content: flex-start; }
  body[data-screen="login"] .foot { padding: 24px 64px 36px; }

  /* 오늘의 배정·내 목록: 가운데 정렬된 넓은 카드 */
  body[data-screen="welcome"] #app, body[data-screen="mine"] #app { max-width: 760px; }
  body[data-screen="welcome"] .top, body[data-screen="welcome"] .greet, body[data-screen="welcome"] .steps { padding-left: 56px; padding-right: 56px; }
  body[data-screen="welcome"] .assign { margin-left: 48px; margin-right: 48px; }
  body[data-screen="welcome"] .bottom-actions { padding: 32px 48px 40px; flex-direction: row; flex-wrap: wrap; }
  body[data-screen="welcome"] .bottom-actions .cta, body[data-screen="welcome"] .bottom-actions .ghost { flex: 1 1 240px; width: auto; }
  body[data-screen="welcome"] .bottom-actions .hint { flex-basis: 100%; }
  body[data-screen="mine"] .mine-head { padding: 40px 48px 30px; }
  body[data-screen="mine"] .list { padding: 8px 48px 16px; }
  body[data-screen="mine"] .sticky-foot { padding: 16px 48px 20px; }
  body[data-screen="mine"] .sticky-foot .cta { max-width: 360px; margin-left: auto; }

  /* 대화 입력: 넓은 대화창 + 아래 입력줄 */
  body[data-screen="chat"] #app { max-width: 900px; }
  body[data-screen="chat"] .chat { height: calc(100dvh - 82px); }
  body[data-screen="chat"] .bar { padding: 22px 36px 18px; }
  body[data-screen="chat"] .progress { padding: 12px 36px 0; }
  body[data-screen="chat"] .thread { padding: 28px 48px 20px; }
  body[data-screen="chat"] .bot { max-width: 620px; }
  body[data-screen="chat"] .me { max-width: 560px; }
  body[data-screen="chat"] .tidy, body[data-screen="chat"] .card, body[data-screen="chat"] .done-card { max-width: 680px; }
  body[data-screen="chat"] .card .row small { width: 120px; }
  body[data-screen="chat"] .composer { padding: 18px 48px 22px; }
  body[data-screen="chat"] .composer > .cta, body[data-screen="chat"] .composer .pair { max-width: 420px; margin-left: auto; width: 100%; }
  body[data-screen="chat"] .complist { max-height: 300px; }
  body[data-screen="chat"] .survey { max-height: 56dvh; }
  body[data-screen="chat"] .sq { display: grid; grid-template-columns: 300px 1fr; align-items: center; gap: 16px; }
}

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--ivory); font-size: 13px; padding: 12px 18px; border-radius: 4px; z-index: 20; max-width: calc(100% - 40px); animation: rise .2s ease-out both; }
