:root {
  --bg: #f4f5f4;
  --surface: #ffffff;
  --text: #16201e;
  --muted: #5d6a67;
  --line: #e1e5e3;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #e3f3f1;
  --mine: #d9f2ec;
  --theirs: #ffffff;
  --warn: #9a3412;
  --warn-soft: #fff1e6;
  --badge: #dc2626;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1312;
    --surface: #172120;
    --text: #e6eeec;
    --muted: #93a39f;
    --line: #26332f;
    --accent: #2dd4bf;
    --accent-text: #062b27;
    --accent-soft: #123a35;
    --mine: #134139;
    --theirs: #1d2826;
    --warn: #fdba74;
    --warn-soft: #3a2414;
    --badge: #f87171;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
.calendar-field { display: grid; gap: 6px; margin: 12px 0; font-size: 14px; }
.calendar-field[hidden] { display: none; }
.calendar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.calendar-grid input { min-width: 0; }
.calendar-check { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.calendar-check input { flex: 0 0 auto; width: 20px; height: 20px; }
.calendar-status { color: var(--accent); font-size: 13px; margin: 8px 0; }
.calendar-warnings { background: var(--warn-soft); color: var(--warn); padding: 12px 12px 12px 28px; border-radius: 10px; font-size: 14px; }
.calendar-candidate blockquote { margin: 12px 0; padding-left: 12px; border-left: 3px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.calendar-editor .btn, .calendar-event .btn { margin: 8px 8px 0 0; }
.calendar-editor select { color: var(--text); font: inherit; }
.calendar-event { padding: 16px 0; border-bottom: 1px solid var(--line); }
.calendar-event h3 { font-size: 16px; margin: 0 0 6px; }
.calendar-manual { margin: 16px; }
.task-nav, .task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.task-nav { margin: 16px; }
.task-actions[hidden] { display: none; }
.task-row { padding: 18px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.task-row h3 { font-size: 17px; margin: 0 0 8px; }
.task-notes { white-space: pre-wrap; }
.task-completed h3 { text-decoration: line-through; color: var(--muted); }
.task-overdue { color: var(--warn); font-weight: 600; }
.task-highlight { outline: 2px solid var(--accent); border-radius: 10px; }
@media (max-width: 440px) { .calendar-grid { grid-template-columns: 1fr; gap: 0; } }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  /* 폰에서 당겨서 새로고침은 아래 .pull 로 직접 한다 (브라우저 기본 동작과 겹치지 않게) */
  overscroll-behavior-y: contain;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logo { width: 28px; height: 28px; flex: none; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  border: 0; background: transparent; font-size: 22px; line-height: 1;
  width: 40px; height: 40px; border-radius: 10px;
}
/* 상단 바 아이콘은 선 하나로 된 미니멀 아이콘 (작업실 = 연필과 종이, 설정 = 슬라이더) */
.icon-btn svg, .planning-actions svg { display: block; width: 24px; height: 24px; margin: auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: var(--accent-soft); }
#back { font-size: 32px; margin-left: -8px; }

.banner { padding: 10px 16px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
main { max-width: 720px; margin: 0 auto; }

/* 로그인 / QR */
.card { margin: 24px 16px; padding: 20px; background: var(--surface); border-radius: 16px; border: 1px solid var(--line); }
.card h2 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.pair-code { margin: 12px 0 4px; text-align: center; font: 700 32px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 4px; user-select: all; }
.qr { display: block; width: min(280px, 100%); margin: 12px auto; background: #fff; padding: 8px; border-radius: 12px; }
.field { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600;
  background: var(--accent); color: var(--accent-text);
}
.btn.secondary { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; }
.row > .grow { flex: 1; min-width: 0; }
.error { color: var(--warn); font-size: 14px; margin-top: 8px; }

/* 받은 메시지 목록 */
.section-title { margin: 18px 16px 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.list { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  padding: 12px 16px; border: 0; background: transparent; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item:active { background: var(--accent-soft); }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.item-main { flex: 1; min-width: 0; }
.item-top { display: flex; gap: 8px; align-items: baseline; }
.item-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 12px; color: var(--muted); }
.item-sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; margin-top: 4px; background: var(--accent-soft); color: var(--accent); }
.item-tag.warn { background: var(--warn-soft); color: var(--warn); }
.badge { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--badge); color: #fff; font-size: 12px; text-align: center; line-height: 20px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

.search-row { padding: 12px 16px 4px; }
.filter-row { display: flex; gap: 8px; padding: 10px 0 2px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.act { margin-left: auto; border-color: transparent; color: var(--accent); }
.chip.act:disabled { opacity: .6; }
/* 안 읽은 대화: 미리보기를 진하게 */
.item.unread .item-sub { color: var(--text); font-weight: 500; }
.more { display: flex; justify-content: center; padding: 10px 16px; }
.more:empty { display: none; }

/* 대화 화면 */
.thread { padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 6px; }
.bubble {
  max-width: 82%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word;
  background: var(--theirs); border: 1px solid var(--line); align-self: flex-start;
}
.bubble.mine { background: var(--mine); align-self: flex-end; border-color: transparent; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.bubble .who { display: block; font-size: 12px; font-weight: 600; color: var(--accent); }
/* 원문 아래 한국어 번역 */
.bubble .tr { display: block; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 14px; }

/* 사진·스티커: 누르면 불러와 보여 준다 */
.media-btn { display: block; margin: 2px 0 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 14px; }
.bubble img.media { display: block; max-width: 100%; max-height: 320px; margin: 2px 0 4px; border-radius: 10px; cursor: zoom-in; }
.bubble img.media.sticker { max-width: 140px; max-height: 140px; }
.viewer { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(0, 0, 0, .9); cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 메시지 고르기 (길게 누르기 / 우클릭) */
.bubble.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.thread.selecting .bubble { cursor: pointer; }
/* 길게 누를 때 iOS 가 대화 전체(click 을 받는 .thread)를 파랗게 덮지 않도록 */
.thread, .bubble { -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  /* 길게 눌렀을 때 글자 선택 메뉴 대신 메시지 고르기가 되도록 */
  .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
.hint { padding: 2px 16px 10px; font-size: 12px; color: var(--muted); text-align: center; }
/* 대화 화면은 보이는 영역 높이(--vvh, app.js 가 visualViewport 로 맞춘다)에 딱 맞추고, 대화 부분(.scroll)만 안에서 스크롤된다.
   키보드가 올라오면 보이는 영역이 줄어 입력 영역이 키보드 바로 위에 온다. 문서 자체는 스크롤되지 않는다. */
main.chat-view { position: relative; display: flex; flex-direction: column; height: calc(var(--vvh, 100dvh) - 61px - env(safe-area-inset-top)); min-height: 0; }
main.chat-view > .scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body:has(> main.chat-view) { min-height: 0; height: var(--vvh, 100dvh); overflow: hidden; }
/* 여러 개 고를 때의 바: 상단 바 바로 아래에 붙는다. 높이 0 인 틀에 넣어 대화를 밀어내지 않는다 */
.selbar-wrap { position: sticky; top: 0; z-index: 4; height: 0; }
.selbar {
  padding: 6px 0 8px;
  background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
  font-size: 14px; font-weight: 600;
}
.selbar[hidden] { display: none; }
.selbar .grow { flex: 1; }
.sel-head { display: flex; align-items: center; padding: 0 8px 4px 16px; }
/* 버튼이 많아 폰에서는 옆으로 밀어서 본다 */
.sel-actions { display: flex; align-items: center; gap: 8px; padding: 2px 16px; overflow-x: auto; scrollbar-width: none; }
.sel-actions::-webkit-scrollbar { display: none; }
.sel-actions .btn { flex: none; white-space: nowrap; }
.sel-actions .btn.emoji { font-size: 20px; padding: 4px 10px; }
.sel-actions .btn.emoji.on { box-shadow: 0 0 0 2px var(--accent); }
.sel-actions .emoji-input { flex: none; width: 120px; padding: 7px 10px; font-size: 14px; }
.btn.danger { background: var(--badge); color: #fff; }

/* 메시지 하나를 골랐을 때 그 말풍선에 붙는 메뉴 (WhatsApp 처럼 반응 줄 + 할 일 목록) */
.msg-shade { position: fixed; inset: 0; z-index: 14; background: rgba(0, 0, 0, .18); }
.msg-menu {
  position: absolute; left: 12px; z-index: 16; width: min(220px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 6px; overflow-y: auto;
}
.msg-menu.mine { left: auto; right: 12px; }
.menu-reacts, .menu-list {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.menu-reacts { display: flex; align-items: center; justify-content: space-between; gap: 2px; padding: 4px 6px; flex: none; }
.menu-reacts .emoji-input { flex: 1; min-width: 0; padding: 7px 10px; }
.react-btn { border: 0; background: transparent; width: 28px; height: 36px; padding: 0; border-radius: 8px; font-size: 20px; line-height: 1; }
.react-btn.on { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.react-btn:active, .menu-item:active { background: var(--accent-soft); }
.menu-list { display: flex; flex-direction: column; overflow: hidden; flex: none; }
.menu-item { border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 11px 16px; text-align: left; font-size: 15px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item.danger { color: var(--badge); }

/* 말풍선 안: 전달 표시, 인용한 메시지, 이모티콘 반응 */
.bubble.revoked { color: var(--muted); }
.bubble .fwd { display: block; font-size: 12px; font-style: italic; color: var(--muted); }
.bubble .quote {
  display: block; margin-bottom: 4px; padding: 4px 8px; border-left: 3px solid var(--accent); border-radius: 6px;
  background: rgba(127, 127, 127, .14); font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bubble .quote b { display: block; font-size: 12px; color: var(--accent); }
.bubble .reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.bubble .react { padding: 1px 7px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.bubble .react.mine { border-color: var(--accent); }

/* 보낼 메시지 칸 위: 답장할 메시지 / 수정 중 */
.ctx {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 10px; border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--accent-soft); font-size: 13px;
}
.ctx .grow { flex: 1; min-width: 0; }
.ctx b { display: block; font-size: 12px; color: var(--accent); }
.ctx span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ctx:empty { display: none; }

/* 전달할 대화방 고르기 */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box {
  width: 100%; max-width: 560px; max-height: 80dvh; display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: var(--surface);
}
.sheet-head { align-items: center; }
.sheet-box .list { overflow-y: auto; border: 0; margin: 0 -16px; }

/* 입력 영역은 대화 화면의 맨 아래 (문서가 아니라 화면에 붙어 있다). 너무 커지면 대화 부분을 60px 는 남기고 안에서 스크롤된다.
   홈 막대 자리(safe-area)는 여기서만 띄운다 (대화 화면에서는 body 의 아래 여백을 없앤다). 키보드가 올라오면 그 여백도 없앤다 */
.composer {
  flex: none; max-height: calc(100% - 60px); z-index: 3;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
body:has(> main.chat-view) { padding-bottom: 0; }
html.kb body { padding-bottom: 0; }
html.kb .composer { padding-bottom: 8px; }
html.kb .toast { bottom: 24px; }
.composer .error { margin-top: 0; }
.composer .error:empty { display: none; }
/* 입력 영역의 두 탭 */
.tabs { flex: none; display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--bg); }
.tab { flex: 1; border: 0; border-radius: 9px; padding: 7px 8px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
/* 답변 방향이 많아 입력 영역이 화면보다 커지면 탭은 두고 그 아래만 스크롤된다 */
.pane { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.pane[hidden], .composer [hidden] { display: none; }
/* 입력 영역의 1·2·3 은 숫자만 (설명은 설정에서) */
.composer .level-desc { display: none; }
/* 에이전트 탭: 폭을 반씩 나눈 [한글번역] [답변선택]. 자주 누르는 버튼이라 크게 */
.agent-actions { display: flex; align-items: center; gap: 8px; }
.agent-actions .btn { display: flex; align-items: center; justify-content: center; gap: 7px; }
.translation-icon svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.agent-actions .grow { flex: 1; min-width: 0; }
.agent-actions .btn { padding: 13px 16px; font-size: 16px; }
.planning-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.planning-actions .btn { display: flex; justify-content: center; align-items: center; gap: 7px; min-width: 0; padding: 13px 8px; }
.planning-panel { padding: 12px 0; }
.planning-panel h3 { font-size: 16px; }
.planning-panel blockquote { margin: 10px 0; padding-left: 12px; border-left: 3px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.planning-choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.btn.outline { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
/* 조정(메시지 다듬기): 전송과 헷갈리지 않게 강조색 테두리만 */
.btn.outline.accent { border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* 요약: 눈에 띄게 상자로 */
.summary-box { margin-top: 0; border-left: 3px solid var(--accent); }
.summary-text { white-space: pre-wrap; word-break: break-word; }
/* 스크롤되는 칸 안에서 사진의 × 가 잘리지 않도록 */
.pane .thumbs { margin-top: 0; padding: 6px 6px 0 0; }
.row.bottom { align-items: center; }
.row.bottom .btn { padding: 10px 14px; white-space: nowrap; }
.row.bottom .btn.ghost { padding-left: 4px; padding-right: 8px; }
/* 전송은 가장 중요한 버튼이라 가로로 1.5배쯤 넓게 */
#send-btn { padding-left: 30px; padding-right: 30px; }
/* 모델 선택 1 / 2 / 3: 숫자가 클수록 더 센 모델. 초록 → 주황 → 빨강. 오른쪽에 고른 단계의 짧은 설명 */
.level { display: flex; align-items: center; gap: 8px; min-width: 0; }
.level-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { flex: none; display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-btn { border: 0; border-right: 1px solid var(--line); background: transparent; padding: 8px 12px; font-size: 14px; font-weight: 700; color: var(--lv, var(--muted)); }
.seg-btn[data-level="easy"] { --lv: #16a34a; }
.seg-btn[data-level="normal"] { --lv: #d97706; }
.seg-btn[data-level="hard"] { --lv: #dc2626; }
.seg-btn:last-child { border-right: 0; }
.seg-btn.on { background: var(--lv, var(--accent)); color: #fff; }
/* 보낼 내용 칸은 4줄로 시작한다 (에이전트 탭보다 높아도 된다) */
#reply { min-height: 120px; }
#intent { resize: none; max-height: 160px; }
.summary { font-size: 13px; color: var(--muted); }
.drafts { display: flex; flex-direction: column; gap: 8px; }
.draft {
  text-align: left; border: 1px solid var(--line); background: var(--bg);
  border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word;
}
.draft.selected { border-color: var(--accent); background: var(--accent-soft); }
.draft .label { display: block; font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.drafts:empty { display: none; }
.assist-head { display: flex; align-items: center; justify-content: space-between; }
.assist-head .note-title { margin: 0; }
.link { border: 0; background: transparent; padding: 4px 0; font-size: 13px; color: var(--muted); text-decoration: underline; }
.composer > .note-title { margin: 0 0 -4px; }
.composer .checks, .composer .meaning { margin-top: 0; }
.loading { font-size: 14px; color: var(--muted); }
textarea.field { resize: vertical; min-height: 64px; max-height: 40dvh; }
/* 보낼 메시지 칸(대화방 #reply, 작업실 #out)은 글 길이만큼 늘어나 안에서 스크롤되지 않는다. 길면 입력 영역·화면이 통째로 스크롤된다 */
#reply, textarea.field.out { max-height: none; }
#reply { flex: none; }
/* 입력칸 글자가 16px 보다 작으면 아이폰이 누를 때 화면을 확대한다. 글자 크기는 줄이지 않는다 */
.instruction { padding: 10px 12px; }

/* 작성 화면 */
main > .card:first-child { margin-top: 16px; }
.card + .card, #result .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
/* 작업실 맨 위: 작성한 메시지 기록으로 가는 글자 버튼 (상단 바에 아이콘을 두지 않는다) */
.write-head { display: flex; justify-content: flex-end; margin: 12px 16px -8px; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.grow { flex: 1; }
.write-actions { display: flex; gap: 8px; margin: 12px 16px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs[hidden] { display: none; }
.thumb { position: relative; width: 72px; height: 72px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumb-x {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--text); color: var(--surface); font-size: 14px; line-height: 22px; padding: 0;
}
.note { margin-top: 8px; padding: 12px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; }
.note-title { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.translation { white-space: pre-wrap; word-break: break-word; margin-top: 6px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--accent); background: var(--surface); color: var(--text); border-radius: 99px; padding: 4px 10px; font-size: 13px; text-align: left; }
.result-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.result-head h2 { margin: 0; flex: 1; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.muted { background: var(--bg); color: var(--muted); }
textarea.field.out { background: var(--surface); font-size: 16px; }
.actions { margin-top: 10px; }
.actions .btn { flex: 1; }
.actions .btn.send-to { flex: 3; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.target {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 8px 12px;
  border-radius: 12px; background: var(--accent-soft); font-size: 13px;
}
.target .grow { flex: 1; min-width: 0; }
#send-error:empty { display: none; }
.checks { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.checks .note-title { color: var(--warn); }
.checks ul { margin: 0; padding-left: 18px; }
.meaning { margin-top: 12px; font-size: 14px; }
.meaning summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.meaning .translation { padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.result .summary { margin-top: 10px; }

/* 설정: Claude 모델과 사용량 */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; border-top: 1px solid var(--line); }
.kv > span:first-child { color: var(--muted); white-space: nowrap; }
.kv > span:last-child { text-align: right; }
.kv + .summary { margin-top: 4px; }

/* 기록 */
.item.hist { flex-direction: column; gap: 6px; }
.hist-main { border: 0; background: transparent; text-align: left; padding: 0; width: 100%; }
.hist-main .item-top { gap: 8px; margin-bottom: 4px; }
.hist-main .item-time { flex: 1; text-align: right; }
.hist-reply { white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.hist-actions { display: flex; gap: 6px; justify-content: flex-end; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
.toast[hidden] { display: none; }
.item.hist { align-items: stretch; }
.btn.link { background: transparent; color: var(--accent); font-weight: 600; padding-left: 0; }

/* 로그인: 패스키(Face ID·지문) 버튼과 "또는 비밀번호로" 구분선 */
.btn.passkey { width: 100%; padding: 14px; font-size: 16px; }
.or { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
/* 설정: 상황별 모델 단계 */
.model-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.model-row:first-child { border-top: 0; padding-top: 0; }
.model-head b { display: block; font-size: 15px; }
/* 설정: 등록된 기기 목록 */
.devices { margin: 4px 0 12px; }
.device { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: 14px; border-top: 1px solid var(--line); }
.device:last-child { border-bottom: 1px solid var(--line); }
.device > .grow { flex: 1; min-width: 0; }

/* 폰에서 화면을 아래로 당기면 나오는 "당겨서 새로고침" 표시 (상단 바 아래에 떠 있음) */
.pull {
  position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); z-index: 6;
  transform: translate(-50%, -10px); opacity: 0;
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  transition: opacity .15s, transform .15s; pointer-events: none;
}
.pull.on { opacity: 1; transform: translate(-50%, 0); }
.pull.ready { color: var(--accent); border-color: var(--accent); }
.pull[hidden] { display: none; }

/* 설정: 표현 슬라이더 */
.style-item { display: grid; grid-template-columns: 72px 1fr 12px; align-items: center; column-gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.style-value { color: var(--accent); font-weight: 600; text-align: right; }
.style-item input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
.style-ends { grid-column: 2; display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; font-size: 13px; color: var(--muted); }
.style-ends > span:last-child { text-align: right; }

/* 알림: 설정의 켜기·끄기 스위치, 알림을 끈 대화 목록, 대화 목록·상단 바의 종 */
.switch-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.switch-row .grow { flex: 1; min-width: 0; }
.switch-row p { margin: 2px 0 0; word-break: keep-all; }
.switch {
  flex: none; position: relative; width: 52px; height: 32px; padding: 0;
  border: 0; border-radius: 99px; background: var(--line); transition: background .15s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; }
.sub-title { margin: 20px 0 8px; font-size: 15px; }
.muted-list { display: flex; flex-direction: column; gap: 6px; }
.muted-row { display: flex; gap: 8px; align-items: center; }
.muted-row .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-muted { flex: none; align-self: center; color: var(--muted); }
.item-muted svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
#mute.off { color: var(--muted); }

.planning-actions svg { margin: 0; flex: none; }
.chat-records { margin-top: 0; }

.records-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.records-header .level { flex: none; }
.records-toggle { border: 0; background: transparent; color: inherit; padding: 8px 0; font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; }
.records-toggle::before { content: '▸'; display: inline-block; margin-right: 6px; }
.records-toggle[aria-expanded="true"]::before { content: '▾'; }
.planning-range { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.planning-days { width: auto; min-width: 120px; }

.chat-records h3 { font-size: 15px; }
.record-confirm { margin: 10px 0; padding: 12px; border: 1px solid var(--accent); border-radius: 10px; }
.record-confirm p { white-space: pre-line; }
.record-confirm .btn + .btn { margin-left: 8px; }
.records-group-header { align-items: center; }
.records-group-header h3 { margin: 4px 0; }
.record-totals { font-size: 12px; color: var(--muted); }
.chat-records section + section { margin-top: 8px; }
.chat-records section > [role="status"]:empty, .record-entry article > [role="status"]:empty { display: none; }
.chat-records section > .summary { margin: 4px 0; font-size: 12px; }
.record-entry { border-bottom: 1px solid var(--line); }
.record-entry > summary { list-style: none; }
.record-entry > summary::-webkit-details-marker { display: none; }
.record-line { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 0; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; text-align: left; }
.record-line::before { content: '›'; flex: none; color: var(--muted); }
.record-entry[open] > .record-line::before { content: '⌄'; }
.record-time { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.record-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.record-actions { display: flex; flex: none; align-items: center; gap: 4px; margin: 0; }
.record-entry:not([open]) .record-actions, .record-actions[hidden] { display: none; }
.record-actions .btn { margin: 0; padding: 4px 7px; font-size: 12px; border-radius: 7px; white-space: nowrap; }
.record-body { font-size: 13px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.completed-records { margin-top: 10px; font-size: 13px; }
.completed-records > summary { cursor: pointer; padding: 6px 0; color: var(--muted); }
.calendar-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: center; }
.calendar-edit-grid > * { min-width: 0; }
.calendar-datetime { display: flex; flex-wrap: wrap; gap: 6px; }
.calendar-datetime > .field { flex: 1 1 160px; width: 0; }
.calendar-clock { flex: 1 0 150px; width: 150px; }
.calendar-clock[hidden] { display: none; }
@media (max-width: 540px) {
  .calendar-datetime { flex-direction: column; }
  .calendar-datetime > .field, .calendar-clock { flex: auto; width: 100%; }
  .record-entry[open] .record-label { flex-direction: column; align-items: flex-start; gap: 2px; }
  .record-entry[open] .record-title { max-width: 100%; }
}
.record-open { border: 0; border-bottom: 1px solid var(--line); background: transparent; }
.record-entry[open] > summary { padding-bottom: 2px; }
.record-entry > article { padding: 0 0 7px; border: 0; }
.agent-records { max-height: 180px; overflow-y: auto; }
.agent-records .summary { margin: 4px 0; }
.chat-planning { display: flex; flex-direction: column; gap: 8px; }
.chat-planning > [role="status"] { margin: 0; }
.chat-planning > [role="status"]:empty, .planning-review:empty { display: none; }

.planning-tools { display: flex; flex-direction: column; gap: 8px; }
.planning-tools > p { margin: 0; }
.planning-count { min-width: 22px; padding: 2px 6px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.planning-actions .btn[aria-pressed="true"] { border-color: var(--accent); }
.planning-actions .btn[hidden] { display: none; }
.planning-links { display: flex; align-items: center; gap: 7px; padding: 5px 0 9px; font-size: 14px; }
.planning-links .link { padding: 3px 0; color: var(--text); }
.agent-footer { flex-wrap: nowrap; min-height: calc(1.45em + 20px); }
.agent-footer .planning-links { padding: 0; white-space: nowrap; }
.agent-footer .level { flex: none; }
.planning-review-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.planning-summary { white-space: pre-wrap; overflow-wrap: anywhere; margin: 5px 0; }
.planning-adjust .level { flex: none; }
.composer .agent-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.composer .agent-actions .btn { min-width: 0; min-height: calc(16px * 1.45 + 22px); padding: 10px 5px; font-size: 14px; }
.composer .agent-actions .translation-icon svg { width: 22px; height: 22px; }
.chat-planning .planning-range[hidden] { display: none; }

.planning-editor { display: flex; flex-direction: column; gap: 8px; }
.planning-editor[hidden], .planning-new[hidden] { display: none; }
.planning-editor > [role="status"], .planning-progress { margin: 0; }
.planning-editor > [role="status"]:empty { display: none; }
.planning-review-item { padding: 4px 0; }
.planning-review-item .calendar-check { margin: 4px 0; }

.planning-submit .calendar-check { margin: 0; font-size: 14px; }
.planning-adjust { flex-wrap: nowrap; }
.planning-adjust .btn { flex: none; }
@media (max-width: 540px) {
  .row.planning-adjust { gap: 4px; }
  .row.planning-adjust .btn { padding: 10px 6px; font-size: 12px; }
  .planning-adjust .seg-btn { padding: 8px 7px; font-size: 12px; }
  .planning-adjust .instruction { padding: 10px 6px; font-size: 13px; }
}

.ai-output { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 28rem; overflow: auto; font-size: .85rem; }
