/* ══ 팔레트 ══════════════════════════════════════════
   낮/밤 두 벌을 같은 변수 이름으로 정의한다. 색감(네이비·코랄·크림)은
   그대로 두고, 밤에는 같은 계열을 어둡게 뒤집는다 (차가운 검정 아님).
   테마 전환은 <html data-theme="light|dark"> 를 app.js가 시간에 맞춰 붙인다. */
:root {
  --navy: #1b3a5c;
  --coral: #f1685e;
  --cream: #f6efdf;
  /* 위 두 색은 "글자·테두리"용이라 다크모드에서 밝아진다.
     아래 두 개는 "흰 글씨를 얹는 바탕"용이라 항상 충분히 어두워야 한다.
     (분리 안 하면 다크모드에서 로그인 배경이 하늘색이 되고 흰 글씨가 안 읽힌다) */
  --brand-navy: #1b3a5c;        /* 로그인 배경·칩 바탕 */
  --coral-solid: #f1685e;       /* 내 말풍선·전송 버튼 바탕 */
  --ios-blue: #1b3a5c;          /* 링크·강조 = 네이비 */
  --ios-gray-bubble: #f3ecdf;   /* 상대 말풍선 = 웜 크림 */
  --ios-bg: #fdfaf4;            /* 대화 배경 = 따뜻한 종이 */
  --ios-grouped-bg: #f6f0e4;    /* 목록·패널 배경 */
  --ios-separator: #eadfcc;     /* 구분선 */
  --ios-secondary: #a1927f;     /* 보조 텍스트 = 웜 그레이 */
  --text: #33291f;              /* 본문 = 따뜻한 다크브라운 */
  --warm-shadow: 0 3px 14px rgba(120, 90, 60, .08);
  /* 표면 계열 (다크모드에서 뒤집히도록 토큰화) */
  --card: #fffdf8;              /* 카드·모달 바탕 */
  --card-active: #f6efe2;       /* 카드 눌림 */
  --input-bg: #ffffff;
  --input-border: #ddd2c0;
  --overlay: rgba(51, 41, 31, .45);
  --header-bg: rgba(253, 250, 244, .94);
  --chip-bg: #ffffff;
  /* AI 3인 고유색 — 레퍼런스와 동일하게 파랑/보라/초록 */
  --ai-blue: #35608f;
  --ai-purple: #7a4d9e;
  --ai-green: #2b7a5f;
  --ai-blue-soft: #e7edf4;
  --ai-purple-soft: #f0e8f7;
  --ai-green-soft: #e7f6ef;
  --ai-pink: #b2537a;        /* 마현이(디자인실장) */
  --ai-pink-soft: #f9e9f1;
  --coral-soft: #fdeae5;
  --warn-bg: #fff8e6;
  --warn-border: #f0e2b6;
  --warn-text: #6b5b2a;
  color-scheme: light;
}
html[data-theme="dark"] {
  --navy: #7fb3e3;              /* 어두운 바탕에서 읽히도록 밝은 네이비 */
  --coral: #f47a70;
  --cream: #241d16;
  --brand-navy: #14293f;        /* 밤에는 브랜드 네이비를 더 깊게 */
  --coral-solid: #c93f35;       /* 흰 글씨 대비 확보용으로 코랄을 눌러서 */
  --ios-blue: #7fb3e3;
  --ios-gray-bubble: #2b241c;
  --ios-bg: #16120e;            /* 웜 다크 — 검정이 아니라 짙은 갈색 */
  --ios-grouped-bg: #100d0a;
  --ios-separator: #362d23;
  --ios-secondary: #a39281;
  --text: #f2e9db;
  --warm-shadow: 0 3px 16px rgba(0, 0, 0, .45);
  --card: #1f1a14;
  --card-active: #2a231b;
  --input-bg: #241e17;
  --input-border: #3d3327;
  --overlay: rgba(0, 0, 0, .62);
  --header-bg: rgba(31, 26, 20, .94);
  --chip-bg: #241e17;
  --ai-blue: #6ea8dc;
  --ai-purple: #bb8fe3;
  --ai-green: #4fc79b;
  --ai-blue-soft: #1d2836;
  --ai-purple-soft: #2a1f36;
  --ai-green-soft: #16302a;
  --ai-pink: #e08bb0;
  --ai-pink-soft: #33202a;
  --coral-soft: #3a221e;
  --warn-bg: #2b2413;
  --warn-border: #453a1d;
  --warn-text: #e0cf95;
  color-scheme: dark;
}
/* 테마 전환은 부드럽게 (단, 입력 중 깜빡임 방지를 위해 색상만) */
body, .screen, .room-card, .bubble, .modal-box, .composer, .chat-header, .rooms-header {
  transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior-y: none; }
body {
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue",
    "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--ios-grouped-bg);
  color: var(--text);
}
.screen { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--ios-bg); }
.hidden { display: none !important; }

/* ── 입장 화면 (브랜드 유지) ── */
#login-screen { justify-content: center; align-items: center; background: var(--brand-navy); }
.login-box {
  background: var(--card); border-radius: 28px; padding: 40px 32px; width: min(90%, 360px);
  text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-logo { width: 170px; max-width: 65%; margin-bottom: 8px; }
.login-box h1 { color: var(--navy); font-size: 26px; margin-bottom: 6px; }
.login-sub { color: var(--ios-secondary); font-size: 13px; margin-bottom: 24px; }
.login-box input {
  width: 100%; padding: 13px 16px; border: 2px solid var(--input-border); border-radius: 16px;
  font-size: 16px; margin-bottom: 12px; outline: none;
}
.login-box input:focus { border-color: var(--coral); }
.user-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 6px; }
.user-pill {
  background: var(--input-bg); border: 2px solid var(--input-border); border-radius: 999px;
  padding: 10px 20px; font-size: 15px; font-weight: 700; color: var(--navy); cursor: pointer;
}
.user-pill:hover { border-color: var(--coral); color: var(--coral); }
.pin-who { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 10px; }
.linklike {
  background: none !important; border: none; color: var(--ios-secondary) !important;
  font-size: 13px; cursor: pointer; margin-top: 10px; font-weight: 400 !important;
}
.admin-btn {
  background: var(--input-bg); border: 1.5px solid var(--ios-separator); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; font-weight: 700; color: var(--navy); cursor: pointer;
}
.login-err { color: #c0392b; font-size: 13px; margin-top: 8px; min-height: 18px; text-align: center; }

/* 메시지별 음성 읽기 버튼 */
.speak-btn {
  background: none; border: none; color: var(--ios-secondary); font-size: 13px;
  cursor: pointer; padding: 1px 6px; margin-left: 2px;
}
.speak-btn:hover { color: var(--coral); }

/* 프로필 원본 사진 뷰어 */
.img-viewer {
  position: fixed; inset: 0; background: rgba(20,15,10,.9); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out;
}
.img-viewer[hidden] { display: none; }
.img-viewer img { max-width: 100%; max-height: 90dvh; border-radius: 14px; }
.iv-close {
  position: absolute; top: 16px; right: 18px; background: rgba(255,255,255,.15);
  border: none; color: #fff; font-size: 20px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}

/* PIN 변경 모달 폼 */
.pin-form { display: flex; flex-direction: column; gap: 8px; }
.pin-form input {
  border: 1.5px solid var(--input-border); border-radius: 14px; padding: 11px 14px;
  font-size: 16px; outline: none; text-align: center; letter-spacing: 4px;
}
.pin-form input:focus { border-color: var(--coral); }
.pin-form button {
  background: var(--coral-solid); color: #fff; border: none; border-radius: 999px;
  padding: 11px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.modal-head .linklike { background: none; border: none; color: var(--ios-secondary); cursor: pointer; font-size: 13px; }

/* ── 출력물 보관함 모달 ── */
.modal {
  position: fixed; inset: 0; background: var(--overlay); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--card); border-radius: 22px; padding: 18px; width: min(440px, 100%);
  max-height: 76dvh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head strong { color: var(--navy); font-size: 16px; }
.modal-hint { font-size: 12px; color: var(--ios-secondary); margin-bottom: 10px; line-height: 1.6; }
.file-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; text-align: left; background: var(--input-bg); border: 1px solid var(--ios-separator);
  border-radius: 14px; padding: 11px 14px; margin-bottom: 7px; cursor: pointer; font-size: 14px;
}
.file-row:hover { border-color: var(--coral); }
.file-name { font-weight: 600; color: var(--text); word-break: break-all; }
.file-meta { font-size: 11px; color: var(--ios-secondary); flex-shrink: 0; }
.login-box button {
  width: 100%; padding: 13px; background: var(--coral-solid); color: #fff; border: none;
  border-radius: 16px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.login-box button:active { filter: brightness(.92); }

/* ── 방 목록 (iOS 그룹 리스트 느낌) ── */
#rooms-screen { background: var(--ios-grouped-bg); }
.rooms-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--header-bg); border-bottom: 1px solid var(--ios-separator);
}
.header-logo { height: 30px; }
#my-name-label { font-size: 14px; color: var(--navy); font-weight: 700; }
.ai-status-bar { padding: 8px 18px; font-size: 12px; color: var(--ios-secondary); }
.room-list { padding: 4px 14px; display: flex; flex-direction: column; gap: 10px; }
.room-card {
  background: var(--card); border-radius: 22px; padding: 16px; cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  transition: background .1s; box-shadow: var(--warm-shadow);
}
.room-card:active { background: var(--card-active); }
.room-icon {
  width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 22px; flex-shrink: 0; background: var(--ios-grouped-bg);
}
.room-icon.culture { background: var(--coral-soft); }
.room-icon.ceo { background: var(--ai-blue-soft); }
.room-info strong { display: block; font-size: 16px; color: var(--text); }
.room-info small { color: var(--ios-secondary); font-size: 12px; }
.room-lock { margin-left: auto; color: var(--ios-secondary); font-size: 16px; }
.room-icon.custom { background: var(--ai-green-soft); }
.room-del {
  margin-left: auto; background: none; border: none; color: #c0392b;
  font-size: 15px; cursor: pointer; padding: 4px 8px; font-weight: 700;
}
.room-card.room-add { border: 2px dashed var(--input-border); background: transparent; box-shadow: none; border-radius: 22px; }
.room-card.room-add .room-info strong { color: var(--ios-secondary); }

/* ── 채팅 (iMessage 스타일) ── */
.chat-header {
  display: flex; align-items: center; padding: 8px 12px;
  background: var(--header-bg); color: var(--text);
  border-bottom: 1px solid var(--ios-separator);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  position: relative;
}
#back-btn {
  background: none; border: none; color: var(--coral); font-size: 30px; cursor: pointer;
  line-height: 1; padding: 0 8px; z-index: 1;
}
.chat-title {
  position: absolute; left: 0; right: 0; text-align: center; pointer-events: none;
}
.voice-btn {
  margin-left: auto; background: none; border: 1.5px solid var(--ios-separator);
  border-radius: 999px; font-size: 16px; cursor: pointer; padding: 4px 10px; z-index: 1;
}
.voice-btn.on { border-color: var(--coral); background: var(--coral-soft); }
.chat-title strong { font-size: 15px; display: block; font-weight: 700; color: var(--navy); }
.chat-title small { font-size: 11px; color: var(--ios-secondary); }

.messages { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 2px; background: var(--ios-bg); }

.msg-row { display: flex; margin-top: 8px; align-items: flex-end; gap: 8px; }
.msg-row.mine { justify-content: flex-end; }
.avatar {
  width: 39px; height: 39px; border-radius: 50%; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: #fff;
  align-self: flex-end; margin-bottom: 2px;
  background: linear-gradient(180deg, #c4b49e, #a8957c);
}
.avatar-img {
  width: 39px; height: 39px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  align-self: flex-end; margin-bottom: 2px; box-shadow: 0 1px 3px rgba(120,90,60,.2);
}
#my-name-label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.mini-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.mini-av-txt {
  background: #c4b49e; color: #fff; display: inline-flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
}
.avatar.ai-saeroyi { background: linear-gradient(180deg, #35608f, var(--navy)); }
.avatar.ai-joyseo { background: linear-gradient(180deg, #9a6cc0, #7a4d9e); }
.avatar.ai-mahyun { background: linear-gradient(180deg, #d17ba0, #b2537a); }
.avatar.ai-team { background: linear-gradient(180deg, #3aa17e, #2b7a5f); }
.msg-body { max-width: 74%; display: flex; flex-direction: column; }
.msg-row.mine .msg-body { align-items: flex-end; }
.sender-name { font-size: 11px; color: var(--ios-secondary); margin: 0 0 2px 12px; }
.sender-name .badge {
  font-size: 9px; background: var(--ios-blue); color: #fff; border-radius: 6px;
  padding: 1px 5px; margin-left: 4px; vertical-align: 1px;
}
.bubble-line { display: flex; align-items: flex-end; gap: 6px; }
.msg-row.mine .bubble-line { flex-direction: row-reverse; }
.bubble {
  padding: 9px 14px; border-radius: 22px; font-size: 15px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
  background: var(--ios-gray-bubble); color: var(--text);
  box-shadow: 0 1px 2px rgba(120,90,60,.07);
}
.msg-row.mine .bubble {
  background: var(--coral-solid); color: #fff;
}
.bubble a { color: var(--ios-blue); text-decoration: underline; word-break: break-all; }
.msg-row.mine .bubble a { color: #fff; }
/* 사진 메시지 */
.chat-img {
  max-width: min(240px, 100%); max-height: 320px; border-radius: 16px;
  display: block; cursor: pointer;
}
.bubble:has(> .chat-img:only-child) { padding: 4px; background: transparent; }
#img-btn, #mic-btn {
  background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px 2px;
  flex-shrink: 0;
}
#mic-btn.recording {
  animation: micPulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px #ff3b30);
}
@keyframes micPulse { 50% { transform: scale(1.25); opacity: .7; } }
#chat-screen.dragging::after {
  content: '사진을 놓으면 전송됩니다'; position: absolute; inset: 0;
  background: rgba(27,58,92,.55); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 18px; font-weight: 700; z-index: 20;
  border: 3px dashed #fff; pointer-events: none;
}

/* 파일 첨부 칩 */
.file-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--input-border); border-radius: 16px;
  padding: 8px 14px; font-size: 13.5px; color: var(--navy) !important;
  text-decoration: none !important; font-weight: 600; word-break: break-all;
}
.msg-row.mine .file-chip { background: rgba(255,255,255,.9); }

/* AI 대기열 */
.queue-bar {
  background: var(--warn-bg); border-top: 1px solid var(--warn-border); padding: 6px 14px;
  font-size: 12px; color: var(--warn-text); display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.q-title { font-weight: 700; flex-shrink: 0; }
.q-item {
  background: var(--card); border: 1px solid var(--warn-border); border-radius: 999px;
  padding: 3px 6px 3px 10px; display: inline-flex; align-items: center; gap: 4px;
}
.q-del {
  background: none; border: none; color: #c0392b; font-size: 12px;
  cursor: pointer; padding: 0 3px; font-weight: 700;
}

/* 댓글/대댓글 */
.cmt-wrap { margin-top: 2px; }
.msg-row.mine .cmt-wrap { text-align: right; }
.cmt-toggle {
  background: none; border: none; color: var(--ios-secondary); font-size: 11px;
  cursor: pointer; padding: 1px 4px;
}
.cmt-toggle:hover { color: var(--ios-blue); }
.cmt-thread {
  background: var(--ios-grouped-bg); border-radius: 18px; padding: 10px 14px;
  margin-top: 3px; max-width: 100%; text-align: left; font-size: 13px;
}
.cmt-item { padding: 3px 0; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.cmt-item.reply { margin-left: 18px; }
.cmt-item.reply::before { content: '↳'; color: var(--ios-secondary); }
.cmt-sender { font-weight: 700; font-size: 12px; color: var(--navy); flex-shrink: 0; }
.cmt-body { word-break: break-word; }
.cmt-time { font-size: 10px; color: var(--ios-secondary); }
.cmt-reply {
  background: none; border: none; color: var(--ios-secondary); font-size: 10.5px;
  cursor: pointer; padding: 0 2px;
}
.cmt-reply:hover { color: var(--ios-blue); }
.cmt-replybox { margin-left: 18px; }
.cmt-input {
  width: 100%; border: 1px solid var(--input-border); border-radius: 14px; padding: 7px 12px;
  font-size: 13px; font-family: inherit; outline: none; margin-top: 4px; background: var(--input-bg);
}
.cmt-input:focus { border-color: var(--coral); }

/* 읽음 표시: 해당 메시지까지 읽은 참여자 */
.read-marker {
  text-align: right; font-size: 10.5px; color: var(--ios-secondary); margin: 2px 4px 0 0;
}

/* 새 메시지 알림 버튼 */
#chat-screen { position: relative; }
.new-msg-chip {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 118px;
  background: var(--brand-navy); color: #fff; border: none; border-radius: 999px;
  padding: 8px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 5;
}

.msg-row.system { justify-content: center; margin-top: 12px; }
.msg-row.system .bubble {
  background: none; color: var(--ios-secondary); font-size: 11.5px; border-radius: 0;
  text-align: center; padding: 0 20px;
}
.timestamp { font-size: 10px; color: var(--ios-secondary); flex-shrink: 0; margin-bottom: 2px; }
.tag-review { color: #ff9500; font-weight: 700; }
.tag-team { color: var(--ai-green); font-weight: 700; }
.tag-pending { color: #b8860b; font-weight: 700; }
.tag-approve { color: #34c759; font-weight: 700; }
.tag-reject { color: #ff3b30; font-weight: 700; }
.tag-del { color: #af52de; font-weight: 700; }
/* [보드:...] 마커 — 파랑 계열(작업 지시가 아니라 "화면에 띄웠다"는 알림이라 눈에 덜 튀게) */
.tag-board { color: var(--ai-blue); font-weight: 700; }
.msg-row.mine .tag-review, .msg-row.mine .tag-approve, .msg-row.mine .tag-reject, .msg-row.mine .tag-del { color: #fff; text-decoration: underline; }

.typing { padding: 6px 16px; font-size: 12px; color: var(--ios-secondary); background: var(--cream); }
.typing::after { content: '⋯'; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ── AI 작업 로그 ── */
.msg-row.log { margin-left: 38px; margin-top: 6px; }
.log-details {
  background: var(--ios-grouped-bg); border-radius: 16px;
  padding: 8px 14px; font-size: 12px; color: var(--text); max-width: 76%;
}
.log-details summary { cursor: pointer; font-weight: 600; color: var(--ios-secondary); list-style: none; }
.log-details summary::-webkit-details-marker { display: none; }
.log-lines {
  margin-top: 6px; font-family: "SF Mono", Consolas, "Courier New", monospace;
  display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ios-secondary);
}
.livelog {
  padding: 8px 16px; font-size: 11.5px;
  color: var(--text); background: var(--cream); border-top: 1px solid var(--ios-separator);
}
.livelog-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.livelog-header {
  font-size: 13px; font-weight: 600; color: var(--ios-blue);
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.ai-stop-btn {
  background: var(--input-bg); border: 1.5px solid #ff3b30; color: #ff3b30;
  border-radius: 999px; padding: 3px 13px; font-size: 12px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
}
.ai-stop-btn:hover { background: #ff3b30; color: #fff; }
.ai-stop-btn:disabled { opacity: .5; cursor: default; }
.spin { display: inline-block; animation: spinstar 2.5s linear infinite; color: var(--coral); }
@keyframes spinstar { to { transform: rotate(360deg); } }
.livelog-lines {
  margin-top: 4px; font-family: "SF Mono", Consolas, "Courier New", monospace;
  max-height: 90px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
  color: var(--ios-secondary);
}
.livelog-lines div { animation: loglineIn .15s ease-out; }
@keyframes loglineIn { from { opacity: 0; transform: translateY(3px); } }

/* ── 입력창 (iMessage 스타일) ── */
.composer { background: var(--ios-bg); border-top: 1px solid var(--ios-separator); padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }

/* 전송 전 첨부 미리보기 */
.attach-preview { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 2px 4px; }
.attach-preview[hidden] { display: none; }
.attach-item { position: relative; }
.attach-item img {
  width: 60px; height: 60px; object-fit: cover; border-radius: 12px; border: 1px solid var(--ios-separator);
}
.attach-file {
  display: inline-flex; align-items: center; background: var(--ios-grouped-bg);
  border-radius: 12px; padding: 8px 12px; font-size: 12px; color: var(--navy); max-width: 160px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-x {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: #33291f; color: #fff; border: none; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.mention-btns { display: flex; gap: 6px; margin-bottom: 6px; }
.mention-btn {
  border: none; border-radius: 999px; padding: 5px 13px; font-size: 12px; cursor: pointer;
  font-weight: 600; background: var(--ios-grouped-bg); color: var(--ios-blue);
}
.mention-btn.joyseo { color: var(--ai-purple); }
.mention-btn.mahyun { color: var(--ai-pink); }
.mention-btn.team { color: var(--ai-green); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
#msg-input {
  flex: 1; border: 1.5px solid var(--input-border); border-radius: 22px; padding: 9px 16px;
  font-size: 15px; font-family: inherit; resize: none; outline: none; max-height: 120px;
  background: var(--ios-bg);
}
#msg-input:focus { border-color: var(--coral); }

/* ── 모바일 최적화 ── */
@media (max-width: 520px) {
  /* iOS는 입력창 글씨가 16px 미만이면 화면을 확대시킴 → 방지 */
  #msg-input, .cmt-input, .login-box input { font-size: 16px; }
  .messages { padding: 12px 10px 6px; }
  .msg-body { max-width: 80%; }
  .mention-btn { padding: 7px 14px; font-size: 13px; }   /* 터치 영역 확대 */
  .cmt-toggle { padding: 4px 8px; font-size: 12px; }
  .cmt-reply { padding: 3px 6px; font-size: 12px; }
  .q-del, .room-del { padding: 8px 10px; }
  .chat-img { max-width: min(210px, 78vw); }
  .livelog-lines { max-height: 66px; }
  /* 헤더 버튼: 모바일에선 아이콘 위주로 컴팩트하게 */
  .rooms-header { flex-wrap: wrap; gap: 4px 6px; padding: 10px 12px; }
  .admin-btn { padding: 5px 9px; font-size: 11px; }
  #my-name-label span:last-child { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
#chat-screen { will-change: transform; } /* 스와이프 백 애니메이션 부드럽게 */
#send-btn {
  background: var(--coral-solid); color: #fff; border: none; border-radius: 50%;
  width: 34px; height: 34px; font-size: 18px; font-weight: 700; cursor: pointer;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  margin-bottom: 1px;
}
#send-btn:active { filter: brightness(.9); }

/* ══ 모델 설정 화면 ═══════════════════════════════════
   AI 한 명 = 카드 한 장. 카드마다 고유색(파랑/보라/초록) 테두리로 구분한다. */
.modal-box.wide { width: min(560px, 100%); max-height: 88dvh; }
.mc-head-actions { display: flex; align-items: center; gap: 8px; }
.mc-list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }

.mc-card {
  --accent: var(--ai-blue);
  --accent-soft: var(--ai-blue-soft);
  background: var(--card); border: 1px solid var(--ios-separator);
  border-radius: 20px; padding: 16px; position: relative; overflow: hidden;
}
/* 카드 위쪽에 고유색 그라데이션 — 레퍼런스의 컬러 글로우 */
.mc-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 92px;
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  opacity: .75; pointer-events: none;
}
.mc-card > * { position: relative; }
.mc-card.joyseo { --accent: var(--ai-purple); --accent-soft: var(--ai-purple-soft); }
.mc-card.team   { --accent: var(--ai-green);  --accent-soft: var(--ai-green-soft); }
.mc-card.off { opacity: .62; }

.mc-top { display: flex; align-items: center; gap: 12px; }
.mc-av {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2.5px solid var(--accent); background: var(--ios-grouped-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; color: var(--accent);
}
.mc-who { min-width: 0; flex: 1; }
.mc-who strong { display: block; font-size: 17px; color: var(--text); }
.mc-who small { font-size: 12px; color: var(--ios-secondary); }
.mc-badge {
  background: var(--accent-soft); color: var(--accent); border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; font-weight: 700; flex-shrink: 0; white-space: nowrap;
}
.mc-badge.off { background: var(--ios-grouped-bg); color: var(--ios-secondary); }

/* 사용량 두 칸 */
.mc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.mc-stat {
  background: var(--ios-grouped-bg); border-radius: 13px; padding: 10px 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.mc-stat span { font-size: 12.5px; color: var(--ios-secondary); }
.mc-stat b { font-size: 15.5px; color: var(--text); }

/* 모델 / 추론 강도 선택 */
.mc-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 11px; }
.mc-pick label {
  display: block; font-size: 12.5px; color: var(--ios-secondary); margin-bottom: 5px;
}
.mc-pick select {
  width: 100%; background: var(--input-bg); color: var(--text);
  border: 1.5px solid var(--input-border); border-radius: 13px;
  padding: 11px 12px; font-size: 15px; font-family: inherit; cursor: pointer; outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ios-secondary) 50%),
                    linear-gradient(135deg, var(--ios-secondary) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.mc-pick select:focus { border-color: var(--accent); }
.mc-pick select:disabled { cursor: default; opacity: .6; }
.mc-note { font-size: 11.5px; color: var(--ios-secondary); margin-top: 9px; line-height: 1.55; }
.mc-note.saved { color: var(--accent); }

/* ── 테마 전환 버튼 (해/달) ── */
.theme-btn {
  background: none; border: 1.5px solid var(--ios-separator); border-radius: 999px;
  padding: 5px 11px; font-size: 13px; cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; gap: 4px;
}
.theme-btn:hover { border-color: var(--coral); }
.theme-btn small { font-size: 10.5px; color: var(--ios-secondary); }

@media (max-width: 520px) {
  .mc-picks, .mc-stats { grid-template-columns: 1fr; }
  .mc-pick select { font-size: 16px; }   /* iOS 확대 방지 */
  .modal { padding: 10px; }
  .modal-box.wide { max-height: 92dvh; }
}

/* ══ 지금 하는 일 / 예정·대기 대시보드 ══════════════════ */
.work-panel { padding: 0 14px 8px; }
.work-summary {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: 1.5px dashed var(--input-border); border-radius: 16px;
  padding: 10px 15px; font-size: 13px; font-weight: 600; color: var(--text);
  font-family: inherit; cursor: pointer; text-align: left;
}
.work-summary:hover { border-color: var(--coral); }
.work-summary.busy {
  border-style: solid; border-color: var(--coral); background: var(--coral-soft);
}
/* 진행 중일 때 앞에 도는 표시 */
.work-summary.busy #work-summary-text::before {
  content: '✱'; display: inline-block; margin-right: 6px; color: var(--coral);
  animation: spinstar 2.5s linear infinite;
}
.work-caret { font-size: 11.5px; color: var(--ios-secondary); font-weight: 400; flex-shrink: 0; }

.work-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.work-cards[hidden] { display: none; }

.work-card {
  --accent: var(--ai-blue);
  --accent-soft: var(--ai-blue-soft);
  background: var(--card); border: 1px solid var(--ios-separator);
  border-radius: 18px; padding: 14px; box-shadow: var(--warm-shadow);
}
.work-card.joyseo { --accent: var(--ai-purple); --accent-soft: var(--ai-purple-soft); }
.work-card.team   { --accent: var(--ai-green);  --accent-soft: var(--ai-green-soft); }
.work-card.idle { opacity: .72; }

.work-top { display: flex; align-items: center; gap: 10px; }
.work-av {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--accent); background: var(--ios-grouped-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: var(--accent);
}
.work-who { flex: 1; min-width: 0; }
.work-who strong { display: block; font-size: 15px; color: var(--text); }
.work-who small { font-size: 11.5px; color: var(--ios-secondary); }
.work-badge {
  background: var(--accent-soft); color: var(--accent); border-radius: 999px;
  padding: 4px 11px; font-size: 11.5px; font-weight: 700; flex-shrink: 0; white-space: nowrap;
}
.work-badge.zero { background: var(--ios-grouped-bg); color: var(--ios-secondary); }

.work-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
.work-count {
  background: var(--ios-grouped-bg); border-radius: 12px; padding: 9px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.work-count span { font-size: 12px; color: var(--ios-secondary); }
.work-count b { font-size: 15px; color: var(--text); }

.work-sec { margin-top: 11px; }
.work-sec > label {
  display: block; font-size: 12px; color: var(--ios-secondary); margin-bottom: 5px;
}
.work-empty {
  border: 1.5px dashed var(--input-border); border-radius: 12px;
  padding: 11px 13px; font-size: 13px; color: var(--ios-secondary);
}
.work-item {
  background: var(--ios-grouped-bg); border-radius: 12px; padding: 9px 12px;
  margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.work-item:last-child { margin-bottom: 0; }
.work-item.running { background: var(--accent-soft); }
.work-item-body { flex: 1; min-width: 0; }
.work-item-label {
  font-size: 13.5px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.work-item-meta { font-size: 11px; color: var(--ios-secondary); margin-top: 2px; }
.work-room {
  background: var(--chip-bg); border: 1px solid var(--ios-separator); border-radius: 999px;
  padding: 2px 8px; font-size: 10.5px; color: var(--ios-secondary); flex-shrink: 0;
}
.work-cancel {
  background: none; border: none; color: #c0392b; font-size: 14px;
  cursor: pointer; padding: 4px 7px; font-weight: 700; flex-shrink: 0;
}
.work-hidden { font-size: 11.5px; color: var(--ios-secondary); margin-top: 8px; }

@media (max-width: 520px) {
  .work-counts { grid-template-columns: 1fr; }
  .work-cancel { padding: 8px 10px; }
}
