/* ============================================================
   자비스 비서실 — 따뜻한 크림/베이지/브라운 테마
   ============================================================ */

:root {
  --page: #EFE2CE;
  --app: #FCF6EB;
  --card: #FFFDF7;
  --card-line: #EFE2CC;
  --brown-900: #46311F;
  --brown-800: #5A4026;
  --brown-700: #6E4E2E;
  --brown-500: #A97B4E;
  --brown-300: #D8BE99;
  --text: #4A3826;
  --text-soft: #8C765B;
  --text-faint: #AA957C;
  --pink: #F8CFD8;
  --pink-soft: #FBE6EA;
  --green: #3FAE72;
  --cream-grad: linear-gradient(160deg, #8C5C2E 0%, #6B4423 100%);
  --radius: 20px;
  --shadow-sm: 0 2px 8px rgba(120, 86, 46, .07);
  --shadow-md: 0 8px 22px rgba(120, 86, 46, .12);
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(900px 500px at 50% -10%, #FBF1DF 0%, rgba(251, 241, 223, 0) 70%),
    var(--page);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
h1, h2, h3 { margin: 0; }
ul, ol { margin: 0; }
.hidden { display: none !important; }

.app {
  max-width: 540px;
  margin: 0 auto;
  background: var(--app);
  min-height: 100vh;
  padding-bottom: 8px;
  box-shadow: 0 0 0 1px rgba(160, 122, 74, .10), 0 30px 60px rgba(120, 86, 46, .14);
  display: flex;
  flex-direction: column;
}

/* ───────── 상단 헤더 ───────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px 11px;
  background: rgba(252, 246, 235, .93);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #EEE0C9;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.crown {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 50%;
  background: linear-gradient(155deg, #FDEBC2 0%, #F8D797 100%);
  border: 2px solid #F3DBA9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 3px 8px rgba(170, 125, 60, .18);
}

.brand-text { min-width: 0; }

.brand h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--brown-900);
  line-height: 1.25;
  white-space: nowrap;
}

.owner {
  margin: 1px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: #7E6A50;
  display: flex;
  align-items: center;
  gap: 5px;
}

.owner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 174, 114, .15);
}

.badge {
  border: 1px solid #EBD9BB;
  background: #FCEFD8;
  color: #8B6A42;
  font-size: 11.5px;
  font-weight: 800;
  padding: 7px 11px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}

.badge.online {
  background: #E4F6EA;
  border-color: #BFE7CD;
  color: #2C8A57;
}

/* ───────── 탭 ───────── */
.tabs {
  position: sticky;
  top: var(--topbar-h, 68px);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 12px 11px;
  background: rgba(252, 246, 235, .95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid #F0E3CE;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: #7C6448;
  font-size: 12.5px;
  font-weight: 700;
  padding: 10px 4px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .18s, color .18s, box-shadow .18s;
}

.tab:hover { background: #F7EDDD; }

.tab.active {
  background: var(--cream-grad);
  color: #FFF7E8;
  box-shadow: 0 6px 16px rgba(120, 80, 40, .28);
}

/* ───────── 패널 공통 ───────── */
main { flex: 1; }

.panel { padding: 14px 14px 26px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.section-head h2 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.3px;
  color: var(--brown-900);
}

.count {
  font-size: 11.5px;
  font-weight: 800;
  color: #8A6C46;
  background: #F7EBD8;
  border: 1px solid #EFDFC4;
  border-radius: 999px;
  padding: 3px 9px;
}

.section-sub {
  margin: 4px 0 12px;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.55;
}

/* ───────── 오피스 맵 ───────── */
.hero {
  border-radius: var(--radius);
  padding: 15px 16px 16px;
  background: linear-gradient(150deg, #FDF0D7 0%, #F9E3C2 100%);
  border: 1px solid #F0DCB9;
  box-shadow: var(--shadow-sm);
}

.hero-tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  color: #8B5D2C;
  background: rgba(255, 253, 247, .82);
  border: 1px solid #EBD4AE;
  border-radius: 999px;
  padding: 4px 10px;
}

.hero h2 {
  margin: 10px 0 3px;
  font-size: 18.5px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: #4C3520;
  line-height: 1.35;
}

.hero p {
  margin: 0;
  font-size: 12.5px;
  color: #8A6E4E;
}

.map-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 0 9px;
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #F4E8D5;
  border: 1px solid #EADCC3;
  border-radius: 999px;
}

.seg-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #8A7050;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  transition: background .16s, box-shadow .16s, color .16s;
}

.seg-btn.active {
  background: #FFFDF8;
  color: #5C4026;
  box-shadow: 0 2px 7px rgba(140, 104, 60, .16);
}

.chip-toggle {
  border: 1px solid #EBD9BB;
  background: #FFFDF7;
  color: #8B6A42;
  font-size: 12.5px;
  font-weight: 800;
  padding: 8px 13px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: background .16s, color .16s, border-color .16s;
}

.chip-toggle.active {
  background: #FBEED6;
  border-color: #EFD8AE;
  color: #7A5327;
}

.map-chips {
  display: flex;
  gap: 7px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFDF7;
  border: 1px solid #EFE2CE;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11.8px;
  font-weight: 700;
  color: #6B4E31;
  box-shadow: var(--shadow-sm);
}

.dot-green {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #46B37B;
  box-shadow: 0 0 0 3px rgba(70, 179, 123, .16);
  animation: pulse 2.4s ease-in-out infinite;
}

/* 맵 스테이지 */
.map-stage {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid #E7D5BA;
  box-shadow: var(--shadow-md);
  background: #F7EBD8;
  line-height: 1.4;
}

.map-img { line-height: 0; }

.map-img {
  display: block;
  width: 100%;
  height: auto;
}

.map-stage .map-img { display: none; }
.map-stage.style-clay .map-img { display: block; }

/* 기본(평면도) 스타일 */
.map-flat {
  display: none;
  flex-direction: column;
  gap: 9px;
  padding: 13px;
  background: linear-gradient(165deg, #FBF2E2 0%, #F3E4C9 100%);
}

.map-stage.style-basic .map-flat { display: flex; }
.map-stage.style-basic .room-label { display: none; }

.flat-room {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 17px;
  border: 1px solid #EBD9BC;
  background: #FDF7EA;
  box-shadow: 0 2px 7px rgba(150, 120, 80, .07);
  transition: transform .15s ease, box-shadow .15s ease;
}

.flat-room:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(150, 120, 80, .13); }

.flat-command {
  background: linear-gradient(150deg, #FDEEE9 0%, #FADDDA 100%);
  border-color: #F0D3CD;
  min-height: 128px;
}

.flat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.flat-badge {
  font-size: 12px;
  font-weight: 800;
  color: #7A4A3F;
  background: rgba(255, 255, 255, .72);
  border: 1px solid #EFD7D0;
  border-radius: 999px;
  padding: 4px 9px;
}

.flat-on {
  font-size: 10.5px;
  font-weight: 800;
  color: #3D9C67;
}

.flat-scene {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  margin: 6px 0 2px;
}

.flat-desk {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 0;
  height: 15px;
  border-radius: 8px;
  background: linear-gradient(180deg, #D6A875, #C2915F);
  box-shadow: 0 3px 0 rgba(150, 110, 70, .25);
}

.flat-char {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 7px;
  border-radius: 50%;
  border: 2px solid #FFFDF7;
  background: linear-gradient(155deg, #FBD9E1 0%, #F5BECD 100%);
  color: #8A4356;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(140, 86, 80, .22);
}

/* 문투 — 자비스 옆에 작게 앉는 서브 비서 */
.flat-char.sub {
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
  font-size: 15px;
  background: linear-gradient(155deg, #E2E9FA 0%, #C6D6F2 100%);
  color: #3E4E7C;
}

.flat-ghost {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-bottom: 12px;
  font-size: 14px;
  border-radius: 50%;
  background: rgba(255, 253, 247, .92);
  border: 1px solid #EFDCD0;
  box-shadow: 0 2px 5px rgba(140, 100, 70, .10);
}

.flat-name {
  font-size: 11.5px;
  color: #966F68;
  font-weight: 600;
}

.flat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.flat-meeting { background: linear-gradient(150deg, #FAEFDB 0%, #F4E3C7 100%); }
.flat-lounge { background: linear-gradient(150deg, #EEF5E7 0%, #E2EEDA 100%); border-color: #D8E7CD; }

.flat-emoji { font-size: 21px; line-height: 1.2; }

.flat-room strong {
  font-size: 12.5px;
  font-weight: 800;
  color: #6B4E31;
}

.flat-room small {
  font-size: 10.5px;
  font-weight: 700;
  color: #3D9C67;
}

.flat-deskrow {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mini {
  font-size: 10.5px;
  font-weight: 700;
  color: #8B6C46;
  background: #FBF3E4;
  border: 1px dashed #E7D5B8;
  border-radius: 999px;
  padding: 4px 8px;
}

.room-label {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 11px;
  font-size: 11.8px;
  font-weight: 800;
  color: #63431F;
  background: rgba(255, 251, 242, .95);
  border: 1px solid #E9D7BB;
  border-radius: 999px;
  box-shadow: 0 5px 12px rgba(96, 64, 30, .20);
  line-height: 1.2;
  transition: transform .15s ease, box-shadow .15s ease;
  z-index: 3;
}

.room-label:hover,
.room-label:active {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: 0 8px 18px rgba(96, 64, 30, .26);
}

.l-meeting { left: 20%; top: 47%; }
.l-command { left: 52%; top: 30%; }
.l-lounge  { left: 68%; top: 86%; }

/* 움직이는 표시들 */
.room-label .lbl { display: inline-block; }

.map-stage.moving .room-label .lbl {
  animation: labelFloat 3.6s ease-in-out infinite;
}

.map-stage.moving .l-command .lbl { animation-delay: .2s; }
.map-stage.moving .l-meeting .lbl { animation-delay: 1.1s; }
.map-stage.moving .l-lounge .lbl  { animation-delay: 2s; }

.map-stage.moving .flat-char { animation: bob 3.1s ease-in-out infinite; }
.map-stage.moving .flat-ghost { animation: bob 3.1s ease-in-out infinite; animation-delay: .9s; }

@keyframes labelFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(70, 179, 123, .16); }
  50%      { box-shadow: 0 0 0 6px rgba(70, 179, 123, .05); }
}

/* 방 목록 */
.room-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.room-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, border-color .14s;
}

.room-card:hover { transform: translateY(-1px); border-color: #E5D2B6; }

.room-emoji {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  font-size: 18px;
  border-radius: 12px;
  background: #FBF0DD;
  border: 1px solid #F2E3CC;
}

.room-info { flex: 1; min-width: 0; }

.room-info strong {
  display: block;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--brown-800);
}

.room-info small {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
}

.room-on {
  font-size: 11px;
  font-weight: 800;
  color: #3D9C67;
  background: #EAF7EF;
  border: 1px solid #CFEBD9;
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}

/* ───────── 회의실(채팅) ───────── */
#panel-chat {
  display: flex;
  flex-direction: column;
  padding: 12px 12px 14px;
  min-height: calc(100vh - 150px);
}

.room-tabs {
  display: flex;
  gap: 6px;
  padding: 3px;
  background: #F5E9D6;
  border: 1px solid #EBDDC4;
  border-radius: 999px;
}

.room-tab {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: #8A7050;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 4px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .16s, color .16s, box-shadow .16s;
}

.room-tab.active {
  background: #FFFDF8;
  color: #5C4026;
  box-shadow: 0 2px 7px rgba(140, 104, 60, .16);
}

.room-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 4px 8px;
  font-size: 12.5px;
  font-weight: 800;
  color: #6E5133;
  border-bottom: 1px dashed #EBDCC2;
}

.room-head #roomTitle { flex: 1; }

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 2px 12px;
  overflow-y: auto;
  max-height: 52vh;
  min-height: 240px;
  scroll-behavior: smooth;
}

/* 대화가 적어도 입력창 바로 위에 붙어 있도록(위쪽 빈 공간을 대화 쪽으로) */
.messages > :first-child { margin-top: auto; }

.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg.me { flex-direction: row-reverse; }

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
  background: #F6EAD6;
  border: 1px solid rgba(120, 86, 46, .08);
  box-shadow: 0 2px 5px rgba(140, 104, 60, .10);
}

.avatar.a-yabes  { background: linear-gradient(155deg, #FDE6B8, #F6D089); color: #6B4A17; }
.avatar.a-mom    { background: linear-gradient(155deg, #FADDE4, #F3BFCB); }
.avatar.a-dad    { background: linear-gradient(155deg, #DBEADF, #BEDCC9); }
.avatar.a-bro    { background: linear-gradient(155deg, #DCE6F5, #BFD2EC); }
.avatar.a-jarvis { background: linear-gradient(155deg, #FBD9E1, #F5BECD); color: #8A4356; }
.avatar.a-trial  { background: linear-gradient(155deg, #FCE6D2, #F7D3B3); }
.avatar.a-gift   { background: linear-gradient(155deg, #FBE3E6, #F7CBD2); }
.avatar.a-cal    { background: linear-gradient(155deg, #DDEDE3, #C6E3D2); }
.avatar.a-review { background: linear-gradient(155deg, #FDF0CB, #F8DFA0); }
.avatar.a-moontwo { background: linear-gradient(155deg, #E2E9FA, #C6D6F2); color: #3E4E7C; }

/* 자비스 프로필 사진 — 원형 칸을 사진이 꽉 채웁니다. */
.avatar.has-img,
.staff-avatar.has-img,
.flat-char.has-img {
  overflow: hidden;
  padding: 0;
  background: #FBEFE4;
}

.avatar.has-img img,
.staff-avatar.has-img img,
.flat-char.has-img img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}

.msg-body { max-width: 78%; min-width: 0; }

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 0 4px 3px;
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.msg.me .msg-meta { justify-content: flex-end; }
.msg-meta .who { font-weight: 800; color: #5E4529; font-size: 12px; }
.msg-meta .role {
  font-size: 10px;
  font-weight: 700;
  color: #96795A;
  background: #F6EAD7;
  border-radius: 999px;
  padding: 1px 6px;
}

.bubble {
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: #4B3A27;
  background: #FFFDF8;
  border: 1px solid #EFE3D0;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 6px rgba(150, 120, 80, .06);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg.me .bubble {
  background: linear-gradient(160deg, #FBE2E7 0%, #F8D2DA 100%);
  border-color: #F3CAD3;
  border-radius: 16px 4px 16px 16px;
  color: #5C3641;
}

.msg.mention .bubble {
  border-color: #E7D2AC;
  background: #FFF9EC;
}

.messages .empty {
  margin: auto;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.7;
  padding: 24px 12px;
}

.composer {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding-top: 8px;
  /* 대화가 이 아래로 지나가도 글자가 비치지 않게 바탕은 불투명하게, 위쪽만 살짝 페이드 */
  background: var(--app);
}

.composer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -14px;
  height: 14px;
  background: linear-gradient(to bottom, rgba(252, 246, 235, 0), var(--app));
  pointer-events: none;
}

/* 입력창 위 한 줄 토글 바 — 평소엔 이 줄만 보이고, 누르면 아래로 칩 목록이 펼쳐집니다. */
.chip-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.chip-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  max-width: 62%;
  padding: 4px 10px;
  border: 1px solid #EDDFC7;
  border-radius: 999px;
  background: #FFFDF8;
  color: #7A6042;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}

.chip-toggle-btn .toggle-label {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .2px;
  color: #A08A6E;
}

.chip-toggle-btn .toggle-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.chip-toggle-btn .toggle-name,
.chip-toggle-btn .toggle-emoji { flex: 0 0 auto; }

.chip-toggle-btn .toggle-caret {
  flex: 0 0 auto;
  font-size: 9px;
  opacity: .7;
  transition: transform .16s;
}

.chip-toggle-btn[aria-expanded="true"] .toggle-caret { transform: rotate(180deg); }

.mention-toggle {
  background: #FAF2E3;
  border-style: dashed;
  border-color: #E4D2B4;
  color: #8B6C44;
}

.mention-toggle:hover { background: #F6EAD6; }
.mention-toggle[aria-expanded="true"] {
  background: #F6EAD6;
  border-style: solid;
  border-color: #DCC49E;
  color: #5C4026;
}

.chip-panel {
  margin: 0 0 8px;
  padding: 8px 9px;
  background: #FFFDF8;
  border: 1px solid #EFE2CC;
  box-shadow: 0 6px 16px rgba(120, 86, 46, .08);
  border-radius: 14px;
  max-height: 30vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chip-panel[hidden] { display: none; }
.chip-panel .chips { gap: 5px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #EDDFC7;
  background: #FFFDF8;
  color: #7A6042;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 999px;
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}

.mention-chip {
  background: #FAF2E3;
  color: #8B6C44;
  border-style: dashed;
  border-color: #E4D2B4;
}

.mention-chip:hover { background: #F6EAD6; }

/* 발신·멘션 칩 앞의 작은 원형 프로필 사진 */
.chip-avatar {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #FBEFE4;
  box-shadow: 0 0 0 1px rgba(120, 86, 46, .12);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 6px;
}

#chatInput {
  flex: 1;
  min-height: 42px;
  max-height: 112px;
  resize: none;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  background: #FFFDF8;
  border: 1px solid #E7D7BF;
  border-radius: 16px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

#chatInput:focus {
  border-color: #D9BE95;
  box-shadow: 0 0 0 3px rgba(200, 165, 115, .18);
}

.send {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 16px;
  border: none;
  border-radius: 14px;
  background: var(--cream-grad);
  color: #FFF7E8;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(120, 80, 40, .26);
}

.send:active { transform: translateY(1px); }

.sync-note {
  margin: 7px 2px 0;
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: center;
}

/* ───────── 작업실 ───────── */
.task-list { display: grid; gap: 8px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: opacity .2s;
}

.task.done { opacity: .55; }
.task.done .task-title { text-decoration: line-through; }

.check {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 2px solid #DFCBAA;
  background: #FFFDF8;
  color: transparent;
  font-size: 13px;
  font-weight: 900;
  transition: background .16s, border-color .16s, color .16s;
}

.task.done .check {
  background: #6B4A2B;
  border-color: #6B4A2B;
  color: #FFF6E6;
}

.task-main { flex: 1; min-width: 0; }

.task-title {
  display: block;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--brown-800);
  line-height: 1.4;
  word-break: keep-all;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.tag {
  font-size: 10.5px;
  font-weight: 700;
  color: #8B6C46;
  background: #F8EEDC;
  border: 1px solid #F0E1C8;
  border-radius: 999px;
  padding: 2px 7px;
}

.tag.run { color: #3D9C67; background: #EBF7F0; border-color: #D2EDDD; }

.task-del {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: #C4AE92;
  font-size: 15px;
  padding: 2px 4px;
  border-radius: 8px;
}

.task-del:hover { color: #A9805C; background: #F8EFE1; }

.add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.add-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  font-size: 13px;
  background: #FFFDF8;
  border: 1px solid #E7D7BF;
  border-radius: 14px;
  outline: none;
}

.add-row input:focus {
  border-color: #D9BE95;
  box-shadow: 0 0 0 3px rgba(200, 165, 115, .18);
}

.add-btn {
  flex: 0 0 auto;
  padding: 0 16px;
  border: none;
  border-radius: 14px;
  background: var(--cream-grad);
  color: #FFF7E8;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(120, 80, 40, .22);
}

/* ───────── 비서현황 ───────── */
.staff-list { display: grid; gap: 8px; }

.staff {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, border-color .14s;
}

.staff:hover { transform: translateY(-1px); border-color: #E5D2B6; }

.staff-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 19px;
  font-weight: 800;
  border: 1px solid rgba(120, 86, 46, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}

.staff-avatar.main {
  background: linear-gradient(155deg, #FBD9E1, #F5BECD);
  color: #8A4356;
  font-size: 20px;
}

.staff-body { flex: 1; min-width: 0; }

.staff-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--brown-800);
}

.staff-role {
  font-size: 10.5px;
  font-weight: 700;
  color: #93785A;
  background: #F7EBD7;
  border-radius: 999px;
  padding: 1px 7px;
}

.staff-note {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.45;
}

.staff-state {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 800;
  color: #3D9C67;
  background: #EBF7F0;
  border: 1px solid #D2EDDD;
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}

.staff-state.busy { color: #B07B22; background: #FDF4DE; border-color: #F2E2BE; }
.staff-state.rest { color: #8E7A62; background: #F7F1E7; border-color: #EDE2D2; }

/* ───────── AI한도 & 연결 ───────── */
.card {
  padding: 14px;
  margin-bottom: 10px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--brown-800);
  margin-bottom: 10px;
}

.card-copy {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-soft);
}

.timeline {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 2px;
}

.timeline li {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed #F0E4D1;
}

.timeline li:last-child { border-bottom: none; }

.timeline .t {
  flex: 0 0 46px;
  font-size: 11.5px;
  font-weight: 800;
  color: #97692F;
  padding-top: 1px;
  font-variant-numeric: tabular-nums;
}

.timeline div { min-width: 0; }

.timeline strong {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--brown-800);
}

.timeline small {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.45;
}

.hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.55;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 11.5px;
  font-weight: 800;
  color: #7E6141;
}

.text-input {
  width: 100%;
  padding: 11px 12px;
  font-size: 12.5px;
  color: var(--text);
  background: #FFFDF8;
  border: 1px solid #E7D7BF;
  border-radius: 12px;
  outline: none;
}

.text-input:focus {
  border-color: #D9BE95;
  box-shadow: 0 0 0 3px rgba(200, 165, 115, .18);
}

.btn-row {
  display: flex;
  gap: 6px;
  margin-top: 9px;
  flex-wrap: wrap;
}

.primary-btn {
  border: none;
  background: var(--cream-grad);
  color: #FFF7E8;
  font-size: 12.5px;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 5px 12px rgba(120, 80, 40, .22);
}

.ghost-btn {
  border: 1px solid #E7D7BF;
  background: #FFFDF8;
  color: #7E6141;
  font-size: 12.5px;
  font-weight: 800;
  padding: 10px 14px;
  border-radius: 12px;
}

.ghost-btn.small { padding: 7px 11px; font-size: 11.5px; margin-top: 6px; }
.ghost-btn:hover, .primary-btn:hover { filter: brightness(1.02); }

.conn-msg {
  margin: 9px 0 0;
  font-size: 11.5px;
  color: #8B7458;
  line-height: 1.5;
}

.conn-msg.ok { color: #2C8A57; }
.conn-msg.err { color: #B4553F; }

.how { margin-top: 12px; }

.how summary {
  font-size: 12px;
  font-weight: 800;
  color: #7E6141;
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
}

.how summary::-webkit-details-marker { display: none; }
.how summary::before { content: "▸ "; color: #B69A73; }
.how[open] summary::before { content: "▾ "; }

.how ol, .steps {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-soft);
}

.how ol li, .steps li { margin-bottom: 4px; }

.how pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: #5C4630;
  background: #F9F0E1;
  border: 1px solid #EFE0C8;
  border-radius: 10px;
  overflow-x: auto;
}

.how code, .steps code {
  font-size: 11px;
  background: #F5EAD9;
  border-radius: 5px;
  padding: 1px 4px;
  word-break: break-all;
}

.em { color: #7A5A34; font-weight: 700; }

/* ───────── 메모 ───────── */
.memo-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

#memoInput {
  width: 100%;
  padding: 12px 13px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: #FFFDF8;
  border: 1px solid #E7D7BF;
  border-radius: 16px;
  resize: vertical;
  outline: none;
}

#memoInput:focus {
  border-color: #D9BE95;
  box-shadow: 0 0 0 3px rgba(200, 165, 115, .18);
}

.memo-form .primary-btn { align-self: flex-end; }

.memo-list { display: grid; gap: 8px; }

.memo {
  position: relative;
  padding: 12px 38px 12px 13px;
  background: linear-gradient(170deg, #FFFDF7, #FDF6E9);
  border: 1px solid #EFE2CB;
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
}

.memo p {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.6;
  color: #4E3B27;
  white-space: pre-wrap;
  word-break: break-word;
}

.memo time {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  color: #B09A80;
}

.memo-del {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: #C9B295;
  font-size: 14px;
  padding: 4px;
  border-radius: 8px;
}

.memo-del:hover { background: #F7EDDD; color: #A9805C; }

.empty-note {
  padding: 22px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  background: #FBF3E4;
  border: 1px dashed #EBDCC2;
  border-radius: 14px;
}

/* ───────── 푸터 & 토스트 ───────── */
.foot {
  padding: 16px 12px 22px;
  text-align: center;
  font-size: 10.5px;
  color: #B39E84;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  max-width: 84vw;
  padding: 10px 16px;
  font-size: 12.5px;
  font-weight: 700;
  color: #FFF8EA;
  background: rgba(74, 52, 31, .94);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(70, 48, 24, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 90;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ───────── 애니메이션 줄이기 ───────── */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ───────── 모바일 — 머리·탭·입력창을 줄여 대화창 자리를 넓힘 ───────── */
@media (max-width: 640px) {
  :root { --topbar-h: 54px; }

  .topbar { padding: 7px 12px 7px; }
  .brand { gap: 8px; }
  .crown { width: 38px; height: 38px; flex: 0 0 38px; font-size: 19px; }
  .brand h1 { font-size: 17px; }
  .owner { font-size: 11px; }
  .badge { font-size: 11px; padding: 6px 9px; }

  .tabs { padding: 7px 9px 8px; gap: 5px; }
  .tab { font-size: 11.5px; padding: 8px 3px; }

  #panel-chat { padding: 8px 10px 10px; min-height: calc(100dvh - 138px); }
  .room-tabs { padding: 2px; }
  .room-tab { font-size: 11.5px; padding: 6px 3px; }
  .room-head { padding: 8px 3px 6px; font-size: 12px; }
  .messages { min-height: 200px; max-height: 60dvh; padding: 10px 2px 8px; gap: 10px; }
  .msg-body { max-width: 82%; }
  .composer { padding-top: 6px; }
  .chip-panel { max-height: 26dvh; padding: 7px 8px; }
  .sync-note { margin-top: 5px; font-size: 10px; }
}

/* ───────── 작은 화면 ───────── */
@media (max-width: 360px) {
  .brand h1 { font-size: 17px; }
  .tab { font-size: 11.5px; padding: 9px 2px; }
  .hero h2 { font-size: 17px; }
  .room-label { font-size: 11px; padding: 5px 9px; }
  .badge { font-size: 10.5px; padding: 6px 9px; }
}

/* ───────── 입장 잠금 ───────── */

html:not(.unlocked) body { overflow: hidden; }
html:not(.unlocked) .app { visibility: hidden; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(700px 420px at 50% 0%, #FBF1DF 0%, rgba(251, 241, 223, 0) 72%),
    var(--page);
}
html:not(.unlocked) .gate { display: flex; }

.gate-card {
  width: 100%;
  max-width: 360px;
  padding: 28px 22px 20px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.gate-card.shake { animation: gate-shake .32s ease-in-out; }

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.gate-emoji { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.gate-card h2 {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--brown-900);
  line-height: 1.4;
}
.gate-sub {
  margin: 8px 0 16px;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.55;
}
.gate-input {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  letter-spacing: .12em;
  text-align: center;
  color: var(--brown-900);
  background: var(--app);
  border: 1px solid var(--brown-300);
  border-radius: 14px;
  outline: none;
}
.gate-input:focus { border-color: var(--brown-500); box-shadow: 0 0 0 3px rgba(169, 123, 78, .16); }
.gate-btn {
  width: 100%;
  margin-top: 10px;
  padding: 13px 14px;
  font-size: 14.5px;
  font-weight: 800;
  color: #FFF8EA;
  background: var(--cream-grad);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(108, 68, 35, .22);
}
.gate-btn:active { transform: translateY(1px); }
.gate-msg {
  min-height: 17px;
  margin: 10px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
}
.gate-msg.err { color: #B4483A; }
.gate-msg.ok { color: var(--green); }
.gate-foot {
  margin: 14px 0 0;
  font-size: 11px;
  color: var(--text-faint);
}
