/* AI 비서 화면 스타일. 최신 iOS 메시지식 화면. 라이트/다크는 theme.js가 html[data-theme]로 정한다. */

/* ---------- 디자인 토큰 ---------- */
:root {
  /* 테마 공통 */
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI Variable Text", "Segoe UI", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "D2Coding", monospace;
  --r-bubble: 18px; --r-card: 26px; --r-field: 14px; --r-sheet: 22px; --r-pill: 999px;
  --fs-bubble: 15px; --lh-bubble: 20px;
  --head-h: 86px;            /* 머리말 내용 높이(안전 영역 제외) */
  --w-in: min(88%, 720px);   /* 받은 말풍선과 그 아래 줄들의 최대 너비 */
  --av-size: 46px; --av-gap: 10px; --av-gut: calc(var(--av-size) + var(--av-gap));   /* 말풍선 옆 사진 */
  --w-out: min(70%, 560px);  /* 보낸 말풍선 최대 너비 */
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --spring-pop: cubic-bezier(0.34, 1.36, 0.64, 1);     /* linear() 미지원 대체 */
  --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-push: 500ms; --t-sheet-in: 500ms; --t-sheet-out: 380ms; --t-panel-out: 320ms;
  --t-msg: 550ms; --t-pop: 540ms;
  --r-group: 12px; --row-h: 44px; --fs-row: 15px; --seg-h: 34px;
  --t-quick-in: 460ms; --t-quick-out: 300ms; --t-pop-out: 180ms;
  --ic-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M3.5 9.5l3.6 3.6L14.5 5' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ic-spin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 6.7V2.5'/%3E%3Cpath d='M15.75 8.25l2.97-2.97' opacity='.16'/%3E%3Cpath d='M17.3 12h4.2' opacity='.22'/%3E%3Cpath d='M15.75 15.75l2.97 2.97' opacity='.3'/%3E%3Cpath d='M12 17.3v4.2' opacity='.44'/%3E%3Cpath d='M8.25 15.75l-2.97 2.97' opacity='.58'/%3E%3Cpath d='M6.7 12H2.5' opacity='.72'/%3E%3Cpath d='M8.25 8.25L5.28 5.28' opacity='.86'/%3E%3C/svg%3E");
  --ic-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 14'%3E%3Cpath d='M1.5 1.5 6.5 7l-5 5.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* 라이트 (기본) */
  color-scheme: light;
  accent-color: var(--c-tint);
  --c-bg: #FFFFFF;            --c-bg-elevated: #FFFFFF;
  --c-bg-grouped: #F2F2F7;    --c-bg-grouped-2: #FFFFFF;   --c-sidebar: #F2F2F7;
  --c-label: #000000;         --c-label-2: #6E6E73;        --c-label-3: #AEAEB2;  --c-placeholder: #8E8E93;
  --c-sep: rgba(60, 60, 67, 0.29);  --c-sep-opaque: #C6C6C8;
  --c-fill: rgba(120, 120, 128, 0.20);  --c-fill-2: rgba(120, 120, 128, 0.16);
  --c-fill-3: rgba(118, 118, 128, 0.12); --c-fill-4: rgba(116, 116, 128, 0.08);
  --c-hover: rgba(0, 0, 0, 0.04);   --c-pressed: rgba(0, 0, 0, 0.10);
  --c-tint: #007AFF;  --c-on-tint: #FFFFFF;  --c-tint-soft: rgba(0, 122, 255, 0.12);
  --c-bubble-out: #007AFF;  --c-bubble-out-text: #FFFFFF;
  --c-bubble-in: #E9E9EB;   --c-bubble-in-text: #000000;
  --c-code-block: #FFFFFF;  --c-code-inline: rgba(0, 0, 0, 0.07);  --c-code-inline-out: rgba(255, 255, 255, 0.22);
  --c-red: #FF3B30;    --c-red-text: #D70015;    --c-red-bg: rgba(255, 59, 48, 0.10);
  --c-orange: #FF9500; --c-orange-text: #C93400; --c-orange-bg: rgba(255, 149, 0, 0.12);
  --c-green: #34C759;  --c-green-text: #248A3D;
  --c-seg-thumb: #FFFFFF;
  --c-scrim: rgba(0, 0, 0, 0.25);  --c-dim: rgba(0, 0, 0, 0.10);
  --glass-bg: rgba(255, 255, 255, 0.62);  --glass-solid: #F7F7F8;  --glass-press: rgba(255, 255, 255, 0.45);
  --glass-shadow: inset 0 1px 0 rgba(255,255,255,0.8), inset 0 0 0 0.5px rgba(0,0,0,0.10), 0 4px 16px rgba(0,0,0,0.10);
  --shadow-card: 0 0 0 0.5px rgba(0,0,0,0.06), 0 6px 20px rgba(0,0,0,0.08);
  --shadow-sheet: 0 20px 60px rgba(0,0,0,0.18);
  --shadow-push: -1px 0 0 rgba(0,0,0,0.04), -8px 0 24px rgba(0,0,0,0.08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #000000;            --c-bg-elevated: #1C1C1E;
  --c-bg-grouped: #000000;    --c-bg-grouped-2: #1C1C1E;   --c-sidebar: #1C1C1E;
  --c-label: #FFFFFF;         --c-label-2: #98989F;        --c-label-3: #636366;  --c-placeholder: #8E8E93;
  --c-sep: rgba(84, 84, 88, 0.60);  --c-sep-opaque: #38383A;
  --c-fill: rgba(120, 120, 128, 0.36);  --c-fill-2: rgba(120, 120, 128, 0.32);
  --c-fill-3: rgba(118, 118, 128, 0.24); --c-fill-4: rgba(118, 118, 128, 0.18);
  --c-hover: rgba(255, 255, 255, 0.06); --c-pressed: rgba(255, 255, 255, 0.10);
  --c-tint: #0A84FF;  --c-tint-soft: rgba(10, 132, 255, 0.20);
  --c-bubble-out: #0A84FF;
  --c-bubble-in: #262629;   --c-bubble-in-text: #FFFFFF;
  --c-code-block: #161618;  --c-code-inline: rgba(255, 255, 255, 0.12);
  --c-red: #FF453A;    --c-red-text: #FF6961;    --c-red-bg: rgba(255, 69, 58, 0.18);
  --c-orange: #FF9F0A; --c-orange-text: #FFB340; --c-orange-bg: rgba(255, 159, 10, 0.18);
  --c-green: #30D158;  --c-green-text: #30DB5B;
  --c-seg-thumb: #636366;
  --c-scrim: rgba(0, 0, 0, 0.50);  --c-dim: rgba(0, 0, 0, 0.40);
  --glass-bg: rgba(44, 44, 48, 0.56);  --glass-solid: #2C2C2E;  --glass-press: rgba(255, 255, 255, 0.14);
  --glass-shadow: inset 0 1px 0 rgba(255,255,255,0.16), inset 0 0 0 0.5px rgba(0,0,0,0.60), 0 4px 16px rgba(0,0,0,0.50);
  --shadow-card: 0 0 0 0.5px rgba(255,255,255,0.10), 0 8px 24px rgba(0,0,0,0.50);
  --shadow-sheet: 0 20px 60px rgba(0,0,0,0.60);
  --shadow-push: -1px 0 0 rgba(255,255,255,0.06), -10px 0 30px rgba(0,0,0,0.50);
}
@media (max-width: 699px) {
  :root { --fs-bubble: 17px; --lh-bubble: 22px; --w-in: calc(100% - 24px); --w-out: 78%; --r-group: 14px; --fs-row: 17px; --av-size: 42px; }
}
@supports (animation-timing-function: linear(0, 1)) {
  :root {
    /* 감쇠비 0.72, 응답 0.40s 스프링(최대 3.8% 넘침) */
    --spring-pop: linear(0, 0.076 5%, 0.242 10%, 0.436 15%, 0.617 20%, 0.766 25%, 0.879 30%, 0.956 35%, 1.003 40%, 1.028 45%, 1.038 50%, 1.038 55%, 1.033 60%, 1.025 65%, 1.018 70%, 1.012 75%, 1.007 80%, 1.003 85%, 1.001 90%, 1);
    /* 감쇠비 0.6, 응답 0.35s 스프링(최대 9.5% 넘침) */
    --spring-bounce: linear(0, 0.096 5%, 0.307 10%, 0.547 15%, 0.76 20%, 0.921 25%, 1.025 30%, 1.078 35%, 1.095 40%, 1.087 45%, 1.068 50%, 1.045 55%, 1.025 60%, 1.009 65%, 0.998 70%, 0.993 75%, 0.991 80%, 0.992 85%, 0.993 90%, 0.996 95%, 1);
  }
}
/* 기존 변수 이름 별칭: 빠뜨린 규칙 대비용. 새로 쓰는 규칙에서는 사용하지 않는다. */
:root {
  --bg: var(--c-bg-grouped); --panel: var(--c-bg); --side: var(--c-sidebar); --line: var(--c-sep);
  --text: var(--c-label); --muted: var(--c-label-2); --accent: var(--c-tint); --accent-text: var(--c-on-tint);
  --bubble-in: var(--c-bubble-in); --bubble-in-text: var(--c-bubble-in-text);
  --danger: var(--c-red-text); --danger-bg: var(--c-red-bg); --warn: var(--c-orange-text); --warn-bg: var(--c-orange-bg);
  --ok: var(--c-green-text); --code-bg: var(--c-code-inline); --hover: var(--c-hover); --active: var(--c-tint-soft);
  --shadow: var(--shadow-card); --radius: var(--r-bubble);
}

/* ---------- 기초 ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--c-bg);
  color: var(--c-label);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; margin: 0; padding: 0; border: 0; background: none; }
button:disabled { cursor: default; }
input, select, textarea { font: inherit; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--c-tint); outline-offset: 2px; }
:root:not(.kb) .layer :focus-visible,
:root:not(.kb) .layer .seg-item:has(input:focus-visible),
:root:not(.kb) .layer .choice-row:has(> input:focus-visible) { outline: none; }

/* 버튼, 목록 행, 세그먼트는 선택과 길게 누르기 메뉴를 막는다. 말풍선은 선택할 수 있게 둔다. */
button, .seg, .conv-item, .assistant-item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.muted { color: var(--c-label-2); }

/* ---------- 유리 재질 ---------- */
.glass {
  position: relative;
  isolation: isolate;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  box-shadow: var(--glass-shadow);
  border: 0;
}
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--glass-press);
  opacity: 0;
  transition: opacity 300ms ease-out;
  pointer-events: none;
}
button.glass { transition: transform 450ms var(--spring-pop); }
button.glass:active:not(:disabled) { transform: scale(1.06); transition-duration: 120ms; }
button.glass:active:not(:disabled)::before { opacity: 1; transition-duration: 0s; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .chip { background: var(--glass-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .chip, .chat-head::before, .chat-dock::before {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--glass-solid);
  }
}

/* ---------- 공통 컨트롤 ---------- */
.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--c-label);
}
.icon-btn svg { display: block; }

/* 글자와 아이콘만 있는 버튼: 누르면 흐려진다 */
.link-btn, .meta-more, .dl-link { transition: opacity 250ms ease-out; }
.link-btn:active, .meta-more:active, .dl-link:active { opacity: 0.35; transition-duration: 0s; }

/* 채운 버튼: 누르면 줄어든다 */
.btn-primary, .btn-allow, .btn-deny, .btn-small, .stop-btn {
  transition: transform 400ms var(--spring-pop), opacity 400ms var(--spring-pop);
}
.btn-primary:active:not(:disabled), .btn-allow:active:not(:disabled), .btn-deny:active:not(:disabled),
.btn-small:active:not(:disabled), .stop-btn:active:not(:disabled) {
  transform: scale(0.96);
  opacity: 0.85;
  transition-duration: 80ms;
}

.link-btn.glass:active { opacity: 1; }
.link-btn { font-size: 15px; color: var(--c-tint); min-height: 44px; padding: 0 6px; }

/* 터치 영역 44px: 보이는 크기가 작은 요소는 ::after로 넓힌다(::before는 꼬리와 유리 효과에 쓴다) */
.attach-btn, .collab-btn, .send-btn, .stop-btn, .chip-x, .btn-small, .meta-more, .dl-link, .seg-item { position: relative; }
.attach-btn::after { content: ""; position: absolute; inset: -2px; }
.collab-btn::after { content: ""; position: absolute; inset: -2px 0; }
.send-btn::after, .stop-btn::after { content: ""; position: absolute; inset: -6px; }
.chip-x::after { content: ""; position: absolute; inset: -10px; }
.btn-small::after { content: ""; position: absolute; inset: -6px 0; }
.meta-more::after { content: ""; position: absolute; inset: -14px -8px; }
.dl-link::after { content: ""; position: absolute; inset: -12px -8px; }
.seg-item::after { content: ""; position: absolute; inset: -6px 0; }
.side-edit { position: relative; }
.side-edit::after { content: ""; position: absolute; inset: -14px -8px; }

/* 세그먼트 컨트롤(테마 선택) */
.seg { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); height: 32px; padding: 2px; border-radius: 9px; background: var(--c-fill-3); }
.seg-item { z-index: 1; display: grid; place-items: center; font-size: 13px; font-weight: 500; color: var(--c-label); cursor: pointer; }
.seg-item input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg-item:has(input:checked) { font-weight: 600; }
.seg-item:has(input:focus-visible) { outline: 2px solid var(--c-tint); outline-offset: 1px; border-radius: 7px; }
.seg-thumb {
  position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / 3); border-radius: 7px;
  background: var(--c-seg-thumb); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); transition: transform 450ms var(--spring-pop);
}
#theme-picker:has(input[value="light"]:checked) .seg-thumb { transform: translateX(100%); }
#theme-picker:has(input[value="dark"]:checked) .seg-thumb { transform: translateX(200%); }

/* iOS 스위치 */
.perm-remember input[type="checkbox"], .check input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 51px; height: 31px; margin: 0;
  border-radius: 999px; background: var(--c-fill); cursor: pointer;
}
.perm-remember input[type="checkbox"]::before, .check input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform 400ms var(--spring-pop);
}
.perm-remember input:checked, .check input:checked { background: var(--c-green); }   /* 트랙 색은 즉시 전환 */
.perm-remember input:checked::before, .check input:checked::before { transform: translateX(20px); }
.perm-remember input:disabled, .check input:disabled { opacity: 0.5; }

/* 입력칸 */
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; color: var(--c-label-2); }
.field > span { padding-left: 4px; }
.field input, .field select, .field textarea {
  font: inherit;
  font-size: 15px;
  color: var(--c-label);
  background-color: var(--c-bg-grouped-2);
  border: 0;
  border-radius: var(--r-field);
  padding: 0 14px;
  height: 44px;
  outline: none;
  min-width: 0;
}
.field textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 200px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: 0 0 0 3px var(--c-tint-soft); }
.field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 36px;
  width: 100%;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 16'%3E%3Cpath d='M3 6l3-3 3 3M3 10l3 3 3-3' fill='none' stroke='%238E8E93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 16px;
}
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row > .field { min-width: 0; }
.form-error { min-height: 1.2em; color: var(--c-red-text); font-size: 13px; }

/* ---------- 로그인 ---------- */
.auth {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--app-top, 0px);
  height: var(--app-h, 100dvh);
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--c-bg-grouped);
  animation: card-rise 500ms var(--ease-out) backwards; /* 흔들기(.shake)가 끝나도 다시 재생되지 않게 카드가 아닌 화면에 건다 */
}
.auth-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}
.auth-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 16px; animation: logo-pop 550ms var(--spring-pop) 60ms backwards; }
.auth-card h1 { font-size: 28px; line-height: 34px; font-weight: 700; }
.auth-desc { font-size: 15px; color: var(--c-label-2); }
.auth-card .field input { height: 50px; font-size: 17px; }
.btn-primary {
  height: 50px;
  border-radius: 25px;
  background: var(--c-tint);
  color: var(--c-on-tint);
  font-size: 17px;
  font-weight: 600;
}
.btn-primary:disabled { opacity: 0.5; }
.auth-card.shake { animation: shake 450ms var(--ease-out); }
.login-btn { display: grid; place-items: center; text-decoration: none; }

/* ---------- 전체 틀 ---------- */
.app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--app-top, 0px);
  height: var(--app-h, 100dvh);
  overflow: hidden;
  overflow: clip;
  background: var(--c-bg);
  display: grid;
  grid-template-columns: 328px 1fr;
}
.scrim { display: none !important; }

/* ---------- 사이드바 ---------- */
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 8px 0 8px 8px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--c-sidebar);
  box-shadow: var(--shadow-card);
}
.sidebar::after { display: none; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 4px 16px; }
.brand { font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: 0.01em; }
.brand img { display: none; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 12px; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 12px 6px 20px; }
.side-head .side-title { margin: 0; }
.side-edit { min-height: 0; padding: 0 6px; }
.side-title { margin: 14px 20px 6px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--c-label-2); }
.side-empty { padding: 24px; font-size: 15px; color: var(--c-label-2); text-align: center; }
.conv-list, .assistant-list, .settings-list { list-style: none; margin: 0; padding: 0; }

/* 고정 비서 격자 */
#assistant-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px 4px;
  padding: 4px 12px 10px;
}
#assistant-list .assistant-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border-radius: 14px;
  text-align: center;
}
#assistant-list .avatar { width: 52px; height: 52px; font-size: 20px; transition: transform 450ms var(--spring-pop); }
#assistant-list .assistant-item:active:not(:disabled) .avatar { transform: scale(0.9); transition-duration: 100ms; }
#assistant-list .assistant-text { width: 100%; min-width: 0; }
#assistant-list .assistant-name { display: block; font-size: 12.5px; line-height: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#assistant-list .badge {
  display: block;
  padding: 0;
  background: none;
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  color: var(--c-label-2);
  overflow: hidden;
  text-overflow: ellipsis;
}
#assistant-list .badge.warn { color: var(--c-orange-text); background: none; }
#assistant-list .assistant-role {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
:root[data-view="chat"] #assistant-list .assistant-role { position: static; width: auto; height: auto; margin: 0; clip: auto; clip-path: none; display: block; font-size: 11px; line-height: 14px; color: var(--c-label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#assistant-list .assistant-item.active .avatar { outline: 2px solid var(--c-tint); outline-offset: 2px; }
#assistant-list .assistant-item:disabled { opacity: 0.4; }

.avatar {
  flex: none;
  position: relative;
  overflow: hidden;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: var(--c-tint);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.has-img { background: var(--c-fill-3) !important; }
.avatar.has-img::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 0.5px var(--c-sep); pointer-events: none; }

/* 대화 행. 눌림 표시는 ::before 덮개의 opacity만 바꾼다 */
.conv-list { padding: 0 8px; }
.conv-item, .settings-list .assistant-item { position: relative; }
.conv-item::before, .settings-list .assistant-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--c-pressed);
  opacity: 0;
  transition: opacity 350ms ease-out;
  pointer-events: none;
}
.conv-item:active::before, .settings-list .assistant-item:active:not(:disabled)::before { opacity: 1; transition-duration: 0s; }
.conv-item.deselect::before { animation: deselect-fade 600ms ease-out 300ms backwards; }
.conv-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
  min-height: 54px;
  padding: 6px 10px;
  border-radius: 12px;
  text-align: left;
}
.conv-avatar { width: 38px; height: 38px; font-size: 15px; }
.conv-body { display: block; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-title { display: block; flex: 1; min-width: 0; font-size: 14.5px; line-height: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { flex: none; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--c-label-2); white-space: nowrap; }
.conv-preview {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  line-height: 18px;
  color: var(--c-label-2);
}
.conv-item.active { background: var(--c-tint); color: #fff; }
.conv-item.active .conv-preview, .conv-item.active .conv-time { color: rgba(255, 255, 255, 0.82); }

/* 설정 메뉴(사이드바 머리의 ... 버튼으로 여는 시트·팝오버) 안쪽 */
#theme-picker { margin: 0 16px; height: 36px; }
.engine-status { display: flex; flex-direction: column; gap: 3px; margin: 10px 20px 0; font-size: 12px; color: var(--c-label-2); }
.engine-row { display: flex; align-items: center; gap: 6px; }
.group:has(> #logout[hidden]) { display: none; }
.head-actions { display: flex; align-items: center; gap: 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c-label-3); flex: none; }
.dot.ok { background: var(--c-green); }
.dot.bad { background: var(--c-red); }
.badge {
  display: inline-block;
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--c-fill-3);
  color: var(--c-label-2);
  white-space: nowrap;
}
.badge.ok { color: var(--c-green-text); }
.badge.warn { color: var(--c-orange-text); background: var(--c-orange-bg); }

/* ---------- 채팅 머리말 (떠 있음) ---------- */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--c-bg); }
.chat-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  height: calc(var(--head-h) + env(safe-area-inset-top));
  padding: calc(env(safe-area-inset-top) + 2px) 10px 0;
  display: grid; grid-template-columns: 44px 1fr 44px; column-gap: 8px; align-items: start; pointer-events: none;
}
.chat-head::before {
  content: ""; position: absolute; inset: 0 0 -24px; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, var(--c-bg) 0%, color-mix(in srgb, var(--c-bg) 90%, transparent) 55%, transparent 100%);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent); mask-image: linear-gradient(to bottom, #000 65%, transparent);
}
.chat-head > * { pointer-events: auto; }
.chat-head .menu-btn { grid-column: 1; }
.chat-head-text { grid-column: 2; justify-self: center; max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; padding-top: 4px; border-radius: 20px; text-align: center; }
.chat-title-row { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; }
.head-chev { flex: none; width: 6px; height: 10px; background: var(--c-label-3); -webkit-mask: var(--ic-chevron) center / contain no-repeat; mask: var(--ic-chevron) center / contain no-repeat; }
.chat-head-text .chat-title-pill, .chat-head-text .chat-avatar { transition: transform 450ms var(--spring-pop); }
.chat-head-text:active .chat-title-pill { transform: scale(1.04); transition-duration: 120ms; }
.chat-head-text:active .chat-avatar { transform: scale(0.94); transition-duration: 120ms; }
#files-btn { grid-column: 3; }
.chat:has(> .files-panel:not([hidden])) #files-btn { opacity: 0; pointer-events: none; }
.chat-avatar { width: 36px; height: 36px; font-size: 15px; font-weight: 600; }
.chat-title-pill { max-width: 100%; min-width: 0; padding: 4px 12px 5px; border-radius: 16px; text-align: center; }
#chat-title { display: block; min-width: 0; font-size: 14px; line-height: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { display: block; font-size: 11px; line-height: 13px; color: var(--c-label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub:empty { display: none; }

/* ---------- 메시지 영역 ---------- */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-behavior: auto;
  display: flex;
  flex-direction: column;
  padding: calc(var(--head-h) + env(safe-area-inset-top) + 4px) 24px calc(var(--dock-h, 64px) + 24px);
}
.empty-state { margin: auto; text-align: center; color: var(--c-label-2); padding: 24px; animation: fade-up 300ms var(--ease-out) backwards; }
.empty-title { font-size: 22px; line-height: 28px; font-weight: 700; color: var(--c-label); margin: 0 0 6px; }
.empty-desc { font-size: 15px; }
.empty-av { width: 64px; height: 64px; font-size: 26px; margin: 0 auto 10px; }
.empty-team { display: flex; justify-content: center; margin: 0 0 12px; }
.empty-team .avatar { width: 52px; height: 52px; font-size: 20px; box-shadow: 0 0 0 2px var(--c-bg); }
.empty-team .avatar + .avatar { margin-left: -12px; }
.empty-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; margin-top: 14px; padding: 0 12px 0 14px; border-radius: 999px; background: var(--c-fill-3); font-size: 13px; font-weight: 600; color: var(--c-label); }
.empty-chip::after { content: ""; width: 6px; height: 10px; background: var(--c-label-3); -webkit-mask: var(--ic-chevron) center / contain no-repeat; mask: var(--ic-chevron) center / contain no-repeat; }

.time-sep { flex: none; margin: 14px 0 8px; font-size: 12px; line-height: 16px; color: var(--c-label-2); text-align: center; }
.time-sep strong { font-weight: 600; }

.row { flex: none; display: flex; flex-direction: column; max-width: 100%; }
.row.user { align-items: flex-end; }
.row.assistant { align-items: flex-start; }
.row + .row { margin-top: 12px; }
.row.cont { margin-top: 3px; }
:root[data-view="detail"] .row.cont { margin-top: 8px; }
.time-sep + .row { margin-top: 0; }
.row.assistant { padding-left: var(--av-gut); }

.sender { display: flex; align-items: baseline; gap: 6px; margin: 0 0 3px 12px; line-height: 16px; }
.sender-name { font-size: 13px; font-weight: 600; color: var(--c-label-2); }
.sender-dept { font-size: 11px; font-weight: 400; color: var(--c-label-2); }
.bubble-wrap { position: relative; align-self: stretch; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.bubble-av { position: absolute; left: calc(-1 * var(--av-gut)); bottom: 0; z-index: 1; width: var(--av-size); height: var(--av-size); font-size: calc(var(--av-size) * 0.43); }
.collab-line, .route-line { font-size: 12px; line-height: 16px; color: var(--c-label-2); margin: 0 0 4px 14px; max-width: var(--w-in); }
.collab-line strong { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--c-fill-3); font-size: 11px; font-weight: 600; color: var(--c-label-2); }
.route-line strong { color: var(--c-label); font-weight: 600; }

/* 말풍선. overflow hidden을 걸지 않는다(꼬리가 잘린다) */
.bubble {
  position: relative;
  min-width: 0;
  font-size: var(--fs-bubble);
  line-height: var(--lh-bubble);
  padding: 6px 12px;
  border-radius: var(--r-bubble);
  overflow-wrap: anywhere;
  word-break: keep-all;
}
.row.user .bubble {
  max-width: var(--w-out);
  background: var(--c-bubble-out);
  color: var(--c-bubble-out-text);
  white-space: pre-wrap;
}
.row.user .bubble a { color: inherit; text-decoration: underline; }
.row.user .bubble ::selection, .row.user .bubble::selection { background: rgba(255, 255, 255, 0.35); }
.row.assistant .bubble { max-width: var(--w-in); background: var(--c-bubble-in); color: var(--c-bubble-in-text); }

/* 꼬리: 가상 요소 두 개. ::after가 --c-bg로 바깥을 가리므로 메시지 영역 배경은 단색 --c-bg여야 한다 */
/* 꼬리는 묶음의 마지막 말풍선(.tail)에만 붙는다 */
.row.user .bubble.tail::before, .row.user .bubble.tail::after,
.row.assistant .bubble.tail::before, .row.assistant .bubble.tail::after { content: ""; position: absolute; bottom: 0; height: 20px; pointer-events: none; }
.row.user .bubble.tail::before { right: -7px; width: 20px; background: var(--c-bubble-out); border-bottom-left-radius: 16px 14px; }
.row.user .bubble.tail::after  { right: -10px; width: 10px; background: var(--c-bg); border-bottom-left-radius: 10px; }
.row.assistant .bubble.tail::before { left: -7px; width: 20px; background: var(--c-bubble-in); border-bottom-right-radius: 16px 14px; }
.row.assistant .bubble.tail::after  { left: -10px; width: 10px; background: var(--c-bg); border-bottom-right-radius: 10px; }
/* 타이핑 말풍선: 꼬리 대신 작은 원 두 개 */
.row.assistant .bubble.bubble-typing { padding: 14px 16px; }
.row.assistant .bubble.bubble-typing.tail::before { left: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; }
.row.assistant .bubble.bubble-typing.tail::after { left: -7px; bottom: -7px; width: 6px; height: 6px; border-radius: 50%; background: var(--c-bubble-in); }
.bubble-pop { animation: fade-up 200ms var(--ease-out) backwards; }
.typing { display: flex; gap: 5px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--c-placeholder); animation: typing-dot 1.2s ease-in-out infinite; animation-delay: calc(var(--phase, 0ms) + var(--d, 0ms)); }
.typing i:nth-child(2) { --d: 200ms; }
.typing i:nth-child(3) { --d: 400ms; }

/* 받은 말풍선 안의 마크다운 */
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 0.6em; }
.bubble ul, .bubble ol { margin: 0 0 0.6em; padding-left: 1.3em; }
.bubble li + li { margin-top: 2px; }
.bubble h3 { margin: 0.8em 0 0.35em; font-size: 1.12em; font-weight: 700; }
.bubble h4 { margin: 0.8em 0 0.35em; font-size: 1em; font-weight: 700; }
.bubble strong { font-weight: 600; }
.bubble a { color: var(--c-tint); text-decoration: underline; }
.bubble code { font-family: var(--mono); font-size: 0.88em; background: var(--c-code-inline); padding: 0.1em 0.35em; border-radius: 6px; }
.row.user .bubble code { background: var(--c-code-inline-out); }
.bubble pre { margin: 8px 0; padding: 10px 12px; border-radius: 12px; background: var(--c-code-block); font-size: 13px; line-height: 1.5; overflow-x: auto; }
.bubble pre code { background: none; padding: 0; font-size: inherit; white-space: pre; border-radius: 0; }
.bubble .table-wrap { margin: 8px 0; border-radius: 12px; background: var(--c-code-block); overflow: auto; }
.bubble table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 13.5px; overflow-wrap: normal; word-break: keep-all; }
.bubble th, .bubble td { padding: 7px 10px; text-align: left; vertical-align: top; }
.bubble tbody td { box-shadow: inset 0 0.5px 0 var(--c-sep); }
.bubble td + td, .bubble th + th { box-shadow: inset 0.5px 0 0 var(--c-sep); }
.bubble tbody td + td { box-shadow: inset 0 0.5px 0 var(--c-sep), inset 0.5px 0 0 var(--c-sep); }
.bubble th { background: var(--c-fill-4); font-weight: 600; white-space: nowrap; }
.bubble td > .cell { display: block; max-width: 18em; overflow-wrap: break-word; }
.bubble hr { border: 0; height: 0.5px; margin: 10px 0; background: var(--c-sep); }

/* 첨부(보낸 쪽) */
.att-grid { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; margin-bottom: 4px; max-width: var(--w-out); }
.att-img { display: block; border-radius: 18px; overflow: hidden; outline: 0.5px solid var(--c-sep); outline-offset: -0.5px; }
.att-img img { display: block; max-width: 220px; max-height: 220px; object-fit: cover; }
.att-file {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 16px; background: var(--c-fill-4);
  color: var(--c-label); text-decoration: none; font-size: 14px; max-width: 260px;
}
.chip-text { min-width: 0; display: flex; flex-direction: column; }
.chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.chip-sub { color: var(--c-label-2); font-size: 11.5px; }
.file-ico {
  flex: none; width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center; background: var(--c-tint-soft); color: var(--c-tint); font-size: 10.5px; font-weight: 700;
}
.dl-link { color: var(--c-tint); text-decoration: none; font-weight: 500; }

/* ---------- 메타 줄, 알림, 권한 카드 ---------- */
.meta { margin: 4px 0 0 14px; font-size: 11.5px; line-height: 16px; color: var(--c-label-2); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; max-width: var(--w-in); }
.meta > span:not(.badge):not(:first-child)::before { content: none; }
.meta > span:not(.badge):not(:last-child)::after { content: "·"; margin-left: 6px; color: var(--c-label-3); }
.meta-more { color: var(--c-tint); font-size: inherit; font-weight: 500; text-decoration: none; }
.meta-detail {
  margin: 6px 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--c-fill-4);
  font-size: 12px; color: var(--c-label-2); max-width: var(--w-in);
  animation: fade-down 200ms var(--ease-out) backwards;
}
.meta-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.meta-detail dt { color: var(--c-label-2); }
.meta-detail dd { margin: 0; color: var(--c-label); overflow-wrap: anywhere; }

.notice { margin: 8px 0 0; border-radius: 14px; padding: 10px 12px; font-size: 14px; max-width: var(--w-in); }
.notice.error { background: var(--c-red-bg); color: var(--c-label); }
.notice.error strong { color: var(--c-red-text); }
.notice.warn { background: var(--c-orange-bg); color: var(--c-label); }
.notice.warn strong { color: var(--c-orange-text); }
.notice.info { background: var(--c-tint-soft); color: var(--c-label); }
.notice strong { display: block; margin-bottom: 2px; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.notice .detail { margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--c-label-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.notice-actions { margin-top: 8px; display: flex; gap: 8px; }
.row > .notice-actions { margin-left: 14px; }
.row.assistant .att-grid { justify-content: flex-start; max-width: var(--w-in); margin: 6px 0 0 14px; }
.chip-more { align-self: center; font-size: 12px; color: var(--c-label-2); }
.messages > .notice { flex: none; align-self: center; max-width: min(92%, 480px); text-align: center; animation: fade-up 250ms var(--ease-out) backwards; }
.messages > .sys-line { flex: none; align-self: center; max-width: min(92%, 440px); margin: 10px 0 2px; padding: 5px 12px; border-radius: 12px; background: var(--c-fill-4); font-size: 12.5px; line-height: 17px; color: var(--c-label-2); text-align: center; animation: fade-up 250ms var(--ease-out) backwards; }
.sys-line .sys-actions { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.sys-ack .btn-small { height: 36px; padding: 0 16px; }
.sys-line .sys-detail { margin: 6px 0 0; text-align: left; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--c-label-2); }
.btn-small {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--c-fill-3);
  color: var(--c-tint);
  font-size: 14px;
  font-weight: 600;
}

/* 권한 승인 카드: 대화 흐름 안의 알림창형 카드 */
.perm-card {
  margin: 10px 0 0; width: min(100%, 460px); padding: 14px 14px 12px; border-radius: var(--r-card);
  background: var(--c-bg-elevated); box-shadow: var(--shadow-card); font-size: 14px;
}
.perm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.perm-head::before {
  content: ""; flex: none; width: 18px; height: 18px; background: var(--c-tint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='5' y='10.5' width='14' height='10' rx='2.5'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='5' y='10.5' width='14' height='10' rx='2.5'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") center / contain no-repeat;
}
.perm-head strong { font-size: 15px; font-weight: 600; }
.perm-tool { font-weight: 400; color: var(--c-label); }
.perm-detail {
  margin: 10px 0 0; padding: 8px 10px; background: var(--c-fill-4); border-radius: 10px;
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow-y: auto;
}
.perm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn-allow, .btn-deny { height: 44px; border-radius: 22px; padding: 0 18px; font-size: 16px; font-weight: 600; }
.btn-allow { background: var(--c-tint); color: var(--c-on-tint); }
.btn-deny { background: var(--c-fill-3); color: var(--c-label); }
.btn-allow:disabled, .btn-deny:disabled { opacity: 0.5; }
.perm-remember { grid-column: 1 / -1; display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; min-height: 44px; font-size: 14px; color: var(--c-label); }
.perm-help { margin-top: 6px; font-size: 12px; color: var(--c-label-2); }
.perm-compact { padding: 12px 14px 10px; }
.perm-line { margin: 6px 0 0; font-size: 14.5px; line-height: 20px; }
.perm-line .badge { vertical-align: 1px; }
.perm-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--c-label-2); }
.perm-details { margin-top: 6px; }
.perm-details summary { cursor: pointer; font-size: 13px; color: var(--c-tint); }

.meta-list { margin: 6px 0 0 14px; max-width: var(--w-in); font-size: 12.5px; color: var(--c-label-2); }
.meta-list-title { font-weight: 600; margin-bottom: 2px; }
.meta-list ul { margin: 0; padding-left: 0; list-style: none; }
.meta-list li { margin: 2px 0; overflow-wrap: anywhere; color: var(--c-label); }
.meta-list-note { color: var(--c-label-2); margin-left: 4px; }
.perm-status { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 6px; background: var(--c-fill-3); color: var(--c-label-2); }
.perm-status.allowed, .perm-status.auto_allowed { color: var(--c-green-text); }
.perm-status.denied, .perm-status.auto_denied, .perm-status.timeout { color: var(--c-red-text); }

/* ---------- 아래 독 (진행 상태, 첨부 칩, 입력부) ---------- */
.chat-dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; flex-direction: column; gap: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom)); pointer-events: none;
}
:root.kb-open .chat-dock { padding-bottom: 8px; }
.chat-dock::before {
  content: ""; position: absolute; inset: -28px 0 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to top, var(--c-bg) 0%, color-mix(in srgb, var(--c-bg) 80%, transparent) 55%, transparent 100%);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to top, #000 55%, transparent); mask-image: linear-gradient(to top, #000 55%, transparent);
}
.chat-dock > * { pointer-events: auto; }

.run-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: center;
  width: max-content;
  max-width: calc(100% - 32px);
  pointer-events: none;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  line-height: 16px;
  color: var(--c-label-2);
  text-align: center;
  animation: fade-up 220ms var(--ease-out) backwards;
}
.chat-dock > .run-status { pointer-events: none; }
.run-av { width: 18px; height: 18px; font-size: 9px; }
/* 대화 모드: 사진(18px)과 글자가 한 줄인 얇은 알약. 입력창 위 별도 줄에 놓이고 입력창을 덮지 않는다. */
.run-status.run-chat { height: 30px; gap: 6px; padding: 0 12px; border-radius: 999px; }
.run-status.run-chat .spinner { display: none; }
.run-status.run-chat #run-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#run-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-width: 0; }
.spinner {
  flex: none;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 6.7V2.5'/%3E%3Cpath d='M15.75 8.25l2.97-2.97' opacity='.16'/%3E%3Cpath d='M17.3 12h4.2' opacity='.22'/%3E%3Cpath d='M15.75 15.75l2.97 2.97' opacity='.3'/%3E%3Cpath d='M12 17.3v4.2' opacity='.44'/%3E%3Cpath d='M8.25 15.75l-2.97 2.97' opacity='.58'/%3E%3Cpath d='M6.7 12H2.5' opacity='.72'/%3E%3Cpath d='M8.25 8.25L5.28 5.28' opacity='.86'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 6.7V2.5'/%3E%3Cpath d='M15.75 8.25l2.97-2.97' opacity='.16'/%3E%3Cpath d='M17.3 12h4.2' opacity='.22'/%3E%3Cpath d='M15.75 15.75l2.97 2.97' opacity='.3'/%3E%3Cpath d='M12 17.3v4.2' opacity='.44'/%3E%3Cpath d='M8.25 15.75l-2.97 2.97' opacity='.58'/%3E%3Cpath d='M6.7 12H2.5' opacity='.72'/%3E%3Cpath d='M8.25 8.25L5.28 5.28' opacity='.86'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: spin 1s steps(8) infinite;
}

.attach-tray { display: flex; gap: 8px; overflow-x: auto; padding: 0 12px; animation: fade-up 220ms var(--ease-out) backwards; }
.chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 6px 8px 6px 6px;
  border-radius: 14px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  box-shadow: var(--glass-shadow);
  font-size: 13px;
}
.chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; flex: none; }
.chip .file-ico { width: 40px; height: 40px; border-radius: 10px; }
.chip-x { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--c-fill-2); color: var(--c-label-2); font-size: 16px; line-height: 1; display: grid; place-items: center; }
.chip.uploading { opacity: 0.6; }
.chip.failed { box-shadow: inset 0 0 0 1px var(--c-red); }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 0 20px; pointer-events: none; }
.composer > * { pointer-events: auto; }
.attach-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--c-label); }
.attach-btn svg { display: block; }
.collab-btn {
  flex: none; height: 40px; padding: 0 14px; border-radius: 20px;
  font-size: 13px; font-weight: 600; color: var(--c-label-2); white-space: nowrap;
  animation: fade-up 220ms var(--ease-out) backwards;
}
.collab-btn[aria-pressed="true"] { color: var(--c-tint); background: color-mix(in srgb, var(--c-tint) 16%, var(--glass-bg)); }
.composer-field { flex: 1; min-width: 0; display: flex; align-items: flex-end; min-height: 40px; border-radius: 20px; padding-right: 4px; }
.composer-field:focus-within { box-shadow: var(--glass-shadow), 0 0 0 1.5px color-mix(in srgb, var(--c-tint) 55%, transparent); }
#input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--c-label);
  caret-color: var(--c-tint);
  max-height: 40dvh;
  overflow-y: hidden;
  font-size: 15px;
  line-height: 20px;
  padding: 10px 14px;
}
#input::placeholder { color: var(--c-placeholder); }
.send-btn, .stop-btn { flex: none; width: 32px; height: 32px; margin: 4px 0; border-radius: 50%; display: grid; place-items: center; }
.send-btn svg, .stop-btn svg { display: block; }
.send-btn {
  background: var(--c-bubble-out);
  color: #fff;
  transition: transform var(--t-pop) var(--spring-bounce), opacity 120ms linear;
}
.send-btn:active:not(:disabled) { transform: scale(0.96); opacity: 0.85; transition-duration: 80ms, 80ms; }
.send-btn:disabled {
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  transition-duration: 150ms, 150ms;
  transition-timing-function: var(--ease-in), var(--ease-in);
}
.stop-btn { background: var(--c-label); color: var(--c-bg); animation: pop-in 400ms var(--spring-bounce) backwards; }

/* ---------- 파일 패널과 드래그 ---------- */
.files-panel {
  position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(360px, calc(100% - 20px)); z-index: 15;
  display: flex; flex-direction: column;
  border-radius: 20px; background: var(--c-bg-elevated); box-shadow: var(--shadow-sheet), 0 0 0 0.5px var(--c-sep);
  overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 8px 0 16px; flex: none; }
.panel-head strong { font-size: 17px; font-weight: 600; }
.panel-head .link-btn { font-size: 17px; }
.files-body { flex: 1; overflow-y: auto; padding: 0 12px 16px; }
.files-group { margin: 16px 4px 6px; font-size: 13px; font-weight: 600; color: var(--c-label-2); }
.file-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px; border-radius: 12px; }
.file-row .chip-text { flex: 1; }
.files-empty { color: var(--c-label-2); font-size: 13px; padding: 12px 4px; }

.chat.dragging::after {
  content: '여기에 놓으면 첨부됩니다';
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--c-tint);
  border-radius: 22px;
  background: color-mix(in srgb, var(--c-tint) 8%, var(--c-bg));
  color: var(--c-tint);
  font: 600 16px var(--font);
  z-index: 25;
  pointer-events: none;
  animation: drag-in 150ms linear backwards;
}

/* ---------- 설정 공통 컴포넌트(빠른 설정과 비서 설정이 함께 쓴다) ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.group-title { margin: 22px 16px 7px; padding: 0 16px; font-size: 13px; line-height: 18px; color: var(--c-label-2); }
.large-title + .group-title, .page > .group-title:first-child, .quick-body > .group-title:first-child { margin-top: 12px; }
.group { margin: 0 16px; border-radius: var(--r-group); background: var(--c-bg-grouped-2); overflow: hidden; }
.group-gap { margin-top: 24px; }
.group-foot { margin: 7px 16px 0; padding: 0 16px; font-size: 13px; line-height: 18px; color: var(--c-label-2); }
.group-error { margin: 7px 16px 0; padding: 0 16px; font-size: 13px; line-height: 18px; color: var(--c-red-text); }
.group-foot:empty, .group-error:empty { display: none; }
.inline-note { margin: 12px 16px 0; padding: 10px 14px; border-radius: 12px; background: var(--c-tint-soft); font-size: 13.5px; line-height: 19px; color: var(--c-label); }

.settings-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--row-h);
  padding: 0 16px;
  font-size: var(--fs-row);
  text-align: left;
  color: var(--c-label);
}
/* 눌림 표시는 ::before 덮개의 opacity만 바꾼다 */
.settings-row::before { content: ""; position: absolute; inset: 0; background: var(--c-pressed); opacity: 0; transition: opacity 350ms ease-out; pointer-events: none; }
button.settings-row:active::before { opacity: 1; transition-duration: 0s; }
.settings-row:not(:first-child), li + li > .settings-row {
  background-image: linear-gradient(var(--c-sep), var(--c-sep));
  background-repeat: no-repeat;
  background-size: calc(100% - 16px) 0.5px;
  background-position: 16px 0;
}
li + li > .assistant-row { background-size: calc(100% - 64px) 0.5px; background-position: 64px 0; }
.row-label { min-width: 0; }
.row-detail { margin-left: auto; min-width: 0; max-width: 60%; color: var(--c-label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-row > .row-label { flex: 1; }
.nav-row::after, .assistant-row::after {
  content: ""; flex: none; width: 8px; height: 14px; background: var(--c-label-3);
  -webkit-mask: var(--ic-chevron) center / contain no-repeat; mask: var(--ic-chevron) center / contain no-repeat;
}
.assistant-row::after { display: none; }
.two-line { flex-wrap: wrap; padding: 10px 16px; row-gap: 2px; }
.row-preview {
  flex-basis: 100%;
  order: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 13px;
  line-height: 18px;
  color: var(--c-label-2);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.add-row { color: var(--c-tint); }
.add-row::after {
  content: ""; order: -1; flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(#fff, #fff) center / 10px 2px no-repeat, linear-gradient(#fff, #fff) center / 2px 10px no-repeat, var(--c-tint);
}
.danger-row { justify-content: center; color: var(--c-red-text); font-weight: 500; }
.assistant-row .avatar { width: 36px; height: 36px; font-size: 15px; }
.assistant-row { min-height: 60px; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row-name { min-width: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; line-height: 18px; color: var(--c-label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.off { color: var(--c-orange-text); }
.assistant-row.flash::before { background: var(--c-tint-soft); animation: flash-out 1000ms ease-out 200ms backwards; }

.settings-row.check { justify-content: space-between; cursor: pointer; }
.settings-row.check .row-label { flex: 1; }
.settings-row.static { min-height: var(--row-h); }

.input-row { position: relative; display: flex; align-items: center; padding-right: 12px; }
.input-row + .input-row {
  background-image: linear-gradient(var(--c-sep), var(--c-sep));
  background-repeat: no-repeat;
  background-size: calc(100% - 16px) 0.5px;
  background-position: 16px 0;
}
.input-row input, .custom-row input {
  flex: 1; min-width: 0; height: var(--row-h); padding: 0 16px; background: transparent; border: 0; outline: 0;
  font-size: var(--fs-row); color: var(--c-label);
}
.input-row .input-label { flex: none; width: 44px; margin-left: 16px; font-size: var(--fs-row); color: var(--c-label-2); }
.input-row .input-label + input { padding-left: 8px; }
.input-row input::placeholder, .custom-row input::placeholder { color: var(--c-placeholder); }
.input-row input[aria-invalid="true"], .custom-row input[aria-invalid="true"] { color: var(--c-red-text); }
.input-count { display: none; flex: none; font-size: 12px; color: var(--c-label-3); }
.input-row:focus-within .input-count { display: block; }
.custom-row { display: flex; align-items: center; margin-top: 8px; animation: fade-down 200ms var(--ease-out) backwards; }
.custom-row .link-btn { padding: 0 16px; font-weight: 600; }

.select-row { cursor: pointer; }
.select-row .row-label { flex: none; }
.select-row select {
  flex: 1; min-width: 0; height: var(--row-h); padding: 0 20px 0 0; text-align: right; text-align-last: right; text-overflow: ellipsis;
  -webkit-appearance: none; appearance: none; border: 0; outline: 0; background-color: transparent; color: var(--c-label-2); font-size: var(--fs-row);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 16'%3E%3Cpath d='M3 6l3-3 3 3M3 10l3 3 3-3' fill='none' stroke='%238E8E93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0 center; background-size: 12px 16px;
}

/* 세그먼트(항목 수가 바뀌는 형태): 바늘 위치를 CSS만으로 계산한다 */
.seg-n { --n: 2; --i: 0; margin: 0 16px; height: var(--seg-h); grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.seg-n:has(> .seg-item:nth-of-type(3)) { --n: 3; }
.seg-n:has(> .seg-item:nth-of-type(4)) { --n: 4; }
.seg-n:has(> .seg-item:nth-of-type(5)) { --n: 5; }
.seg-n:has(> .seg-item:nth-of-type(6)) { --n: 6; }
.seg-n:has(> .seg-item:nth-of-type(2) > input:checked) { --i: 1; }
.seg-n:has(> .seg-item:nth-of-type(3) > input:checked) { --i: 2; }
.seg-n:has(> .seg-item:nth-of-type(4) > input:checked) { --i: 3; }
.seg-n:has(> .seg-item:nth-of-type(5) > input:checked) { --i: 4; }
.seg-n:has(> .seg-item:nth-of-type(6) > input:checked) { --i: 5; }
.seg-n .seg-thumb { width: calc((100% - 4px) / var(--n)); transform: translateX(calc(var(--i) * 100%)); transition: transform 450ms var(--spring-pop), scale 300ms var(--spring-pop); }
.seg-n:active .seg-thumb { scale: 0.96; transition-duration: 450ms, 120ms; }
.seg-n .seg-item { font-size: 13px; padding: 0 2px; white-space: nowrap; }

/* 선택 목록(모델) */
.choice-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: var(--row-h); padding: 7px 16px; cursor: pointer; }
.choice-row + .choice-row {
  background-image: linear-gradient(var(--c-sep), var(--c-sep));
  background-repeat: no-repeat;
  background-size: calc(100% - 16px) 0.5px;
  background-position: 16px 0;
}
.choice-row > input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.choice-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.choice-label { font-size: var(--fs-row); line-height: 22px; }
.choice-sub { font-size: 12.5px; line-height: 16px; color: var(--c-label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.choice-check { flex: none; width: 18px; height: 18px; background: var(--c-tint); -webkit-mask: var(--ic-check) center / contain no-repeat; mask: var(--ic-check) center / contain no-repeat; opacity: 0; }
.choice-row:has(> input:checked) .choice-check { opacity: 1; animation: check-pop 380ms var(--spring-bounce) backwards; }
.choice-row:has(> input:focus-visible) { outline: 2px solid var(--c-tint); outline-offset: -2px; }

/* 스테퍼 */
.stepper { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.step-val {
  width: 44px; padding: 0; text-align: right; background: transparent; border: 0; outline: 0; font-size: var(--fs-row); color: var(--c-label);
  -moz-appearance: textfield; appearance: textfield;
}
.step-val::-webkit-inner-spin-button, .step-val::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; display: none; }
.step-unit { color: var(--c-label-2); }
.step-pair { display: flex; height: 32px; border-radius: 9px; background: var(--c-fill-3); }
.step-btn { position: relative; width: 46px; height: 32px; font-size: 20px; line-height: 1; color: var(--c-label); transition: transform 400ms var(--spring-pop); }
.step-btn:first-child { border-radius: 9px 0 0 9px; }
.step-btn:last-child { border-radius: 0 9px 9px 0; }
.step-btn + .step-btn { box-shadow: inset 0.5px 0 0 var(--c-sep); }
.step-btn::after { content: ""; position: absolute; inset: -6px 0; }
.step-btn:active:not(:disabled) { transform: scale(0.9); transition-duration: 80ms; }
.step-btn:disabled { color: var(--c-label-3); }

/* 저장 상태 캡슐 */
.save-status {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 13px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--c-fill-3); color: var(--c-label-2);
  opacity: 0; transition: opacity 300ms ease-out; pointer-events: none;
}
.save-status[data-state] { opacity: 1; transition-duration: 0s; animation: status-in 200ms var(--spring-pop) backwards; }
.save-status.off { opacity: 0; transition-duration: 300ms; animation: none; }
.save-status[data-state="saving"]::before {
  content: ""; width: 12px; height: 12px; background: currentColor;
  -webkit-mask: var(--ic-spin) center / contain no-repeat; mask: var(--ic-spin) center / contain no-repeat; animation: spin 1s steps(8) infinite;
}
.save-status[data-state="saved"] { color: var(--c-green-text); }
.save-status[data-state="saved"]::before {
  content: ""; width: 12px; height: 12px; background: currentColor;
  -webkit-mask: var(--ic-check) center / contain no-repeat; mask: var(--ic-check) center / contain no-repeat; animation: check-pop 380ms var(--spring-bounce) backwards;
}
.save-status[data-state="error"] { color: var(--c-red-text); background: var(--c-red-bg); }

/* ---------- 겹침 화면 공통 ---------- */
.layer { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); }
.settings { z-index: 40; }
.quick { z-index: 45; }
.confirm { z-index: 60; }
.sheet-scrim { position: absolute; inset: 0; background: var(--c-scrim); animation: fade-in 300ms linear backwards; }
.layer.is-leaving .sheet-scrim { animation: fade-out var(--t-sheet-out) linear forwards; }
#quick.is-leaving .sheet-scrim { animation-duration: var(--t-quick-out); }
#confirm.is-leaving .sheet-scrim { animation-duration: 150ms; }
.sheet { position: absolute; z-index: 1; }
.sheet-drag { touch-action: none; }
.is-dragging .sheet, .is-dragging.files-panel { transition: none; }
.sheet-grab { position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--c-label-3); opacity: 0.6; display: none; pointer-events: none; }
.panel-head { position: relative; }

/* ---------- 비서 설정 시트 ---------- */
.settings { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 24px; }
.settings-sheet {
  position: relative; width: min(960px, 100%); height: min(780px, 100%); border-radius: var(--r-sheet); overflow: hidden;
  display: flex; flex-direction: column; background: var(--c-bg-grouped); box-shadow: var(--shadow-sheet);
}
:root[data-theme="dark"] .settings-sheet, :root[data-theme="dark"] .quick-card {
  --c-bg-grouped: #1C1C1E; --c-bg-grouped-2: #2C2C2E;
  box-shadow: var(--shadow-sheet), 0 0 0 0.5px rgba(255, 255, 255, 0.12);
}
.settings-head {
  position: relative; flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 10px;
  box-shadow: inset 0 -0.5px 0 var(--c-sep);
}
.settings-head h1 { grid-column: 2; font-size: 17px; font-weight: 600; text-align: center; transition: opacity 200ms ease-out; }
.settings-head #settings-back { justify-self: start; }
.settings-head .save-status { grid-column: 3; justify-self: end; }
.settings[data-depth="0"] .ic-back { display: none; }
.settings:not([data-depth="0"]) .ic-close { display: none; }
.large-title { display: none; }
.settings-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.settings-side { overflow-y: auto; min-height: 0; box-shadow: inset -0.5px 0 0 var(--c-sep); padding-bottom: 16px; }
.settings-pages { position: relative; min-height: 0; overflow: hidden; }
.settings-pages > .page { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 0 8px 24px; visibility: hidden; }
.settings-pages > .page.is-current, .settings-pages > .page.is-behind { visibility: visible; }
.settings-pages > .page.swap-in { animation: fade-up 220ms var(--ease-out) backwards; }
.page:focus { outline: none; }
.settings-list { margin: 0; padding: 0; list-style: none; }
.settings-pages > .page-instr {
  display: flex; flex-direction: column; overflow: hidden; padding: 12px 16px 16px; background: var(--c-bg-grouped);
  transform: translateX(100%); transition: transform var(--t-push) var(--ease-ios), visibility 0s linear var(--t-push);
}
.settings-pages > .page-instr.is-current { transform: none; transition: transform var(--t-push) var(--ease-ios), visibility 0s; }
.settings-pages > .page-instr.is-behind { visibility: hidden; }

.detail-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 16px 16px 4px; }
.detail-hero .avatar { width: 64px; height: 64px; font-size: 26px; }
.hero-photo { position: relative; width: 64px; height: 64px; border-radius: 50%; padding: 0; }
.hero-photo:disabled { opacity: 1; }
.hero-cam {
  position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-tint); box-shadow: 0 0 0 2px var(--c-bg-grouped);
}
.hero-cam::before {
  content: ""; position: absolute; inset: 5px; background: var(--c-on-tint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M4 8.5A2.5 2.5 0 0 1 6.5 6h1.2l1.1-1.6A1.5 1.5 0 0 1 10 3.7h4a1.5 1.5 0 0 1 1.2.7L16.3 6h1.2A2.5 2.5 0 0 1 20 8.5v8A2.5 2.5 0 0 1 17.5 19h-11A2.5 2.5 0 0 1 4 16.5zM12 9.3a3.2 3.2 0 1 0 0 6.4a3.2 3.2 0 1 0 0-6.4z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M4 8.5A2.5 2.5 0 0 1 6.5 6h1.2l1.1-1.6A1.5 1.5 0 0 1 10 3.7h4a1.5 1.5 0 0 1 1.2.7L16.3 6h1.2A2.5 2.5 0 0 1 20 8.5v8A2.5 2.5 0 0 1 17.5 19h-11A2.5 2.5 0 0 1 4 16.5zM12 9.3a3.2 3.2 0 1 0 0 6.4a3.2 3.2 0 1 0 0-6.4z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.hero-photo:disabled .hero-cam { display: none; }
.hero-photo-links { display: flex; gap: 14px; justify-content: center; }
.hero-photo-links .link-btn { min-height: 28px; padding: 0; font-size: 13px; }
.hero-photo-note { font-size: 12px; color: var(--c-label-2); }
.detail-hero-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 100%; }
#sf-hero-name { font-size: 20px; line-height: 26px; font-weight: 700; overflow-wrap: anywhere; }
#sf-hero-sub { font-size: 13px; line-height: 18px; color: var(--c-label-2); overflow-wrap: anywhere; }
.create-bar { position: sticky; bottom: 0; margin-top: 8px; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--c-bg-grouped) 70%, transparent); }
.create-bar:has(> button[hidden]) { display: none; }
.create-bar .btn-primary { width: 100%; }
.settings-form, #collab-form { display: block; }

.page-instr .instr-head { display: flex; align-items: center; gap: 8px; flex: none; padding-bottom: 8px; }
.instr-head strong { font-size: 17px; font-weight: 600; }
#sf-instructions {
  flex: 1; min-height: 0; resize: none; border: 0; outline: 0; border-radius: var(--r-group); padding: 14px 16px;
  background: var(--c-bg-grouped-2); font-size: var(--fs-row); line-height: 1.55; color: var(--c-label);
}
.instr-foot { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--c-label-2); }
.instr-foot .link-btn { min-height: 32px; padding: 0; font-size: 13px; }
.instr-foot .link-btn:last-child { margin-left: auto; }
.instr-error { color: var(--c-red-text); }

/* 데스크톱·태블릿: 왼쪽 목록 선택 표시 */
@media (min-width: 700px) {
  .settings-row.active { background-color: var(--c-tint); color: #fff; }
  .settings-row.active .row-sub, .settings-row.active .row-detail { color: rgba(255, 255, 255, 0.82); }
  .settings-row.active .row-sub.off { color: #fff; }
  .settings-row.active .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); }
  .settings-row.active .badge { background: rgba(255, 255, 255, 0.22); color: #fff; }
  .settings-row.active::after { background: rgba(255, 255, 255, 0.7); }
}
@media (min-width: 700px) {
  .settings-side .nav-row::after { display: none; }
  .settings-side #collab-row { flex-wrap: wrap; align-content: center; row-gap: 1px; min-height: 60px; padding: 8px 16px; }
  .settings-side #collab-row .row-label { flex: 1 0 100%; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .settings-side #collab-row .row-detail { margin-left: 0; max-width: none; font-size: 13px; line-height: 18px; }
}
@media (min-width: 700px) and (max-width: 1023px) { .settings-body { grid-template-columns: 280px minmax(0, 1fr); } }

/* ---------- 빠른 설정 ---------- */
.quick-card {
  left: 8px; right: 8px; bottom: 8px; max-height: calc(100% - env(safe-area-inset-top) - 24px);
  display: flex; flex-direction: column; border-radius: 32px; overflow: hidden;
  background: var(--c-bg-grouped); box-shadow: var(--shadow-sheet);
  animation: quick-up var(--t-quick-in) var(--ease-ios) backwards;
}
#quick.is-leaving .quick-card, #menu.is-leaving .quick-card { animation: quick-down var(--t-quick-out) var(--ease-ios) forwards; }
.quick-head { position: relative; flex: none; display: flex; align-items: center; gap: 12px; padding: 18px 12px 10px 16px; }
.q-avatar { width: 44px; height: 44px; font-size: 18px; }
.quick-id { flex: 1; min-width: 0; }
#q-name { font-size: 17px; line-height: 22px; font-weight: 600; }
#q-sub { font-size: 13px; line-height: 18px; color: var(--c-label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#q-error { margin: 8px 16px 0; }
.q-close { position: relative; width: 36px; height: 36px; }
.q-close::after { content: ""; position: absolute; inset: -4px; }
.quick-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
@media (min-width: 700px) {
  #quick .sheet-scrim, #menu .sheet-scrim { background: transparent; animation: none; }
  .quick-card {
    left: auto; right: auto; bottom: auto; border-radius: 22px; transform-origin: var(--qx, 50%) 0;
    animation: pop-down 420ms var(--spring-pop) backwards, fade-in 140ms linear backwards;
  }
  #quick.is-leaving .quick-card, #menu.is-leaving .quick-card { animation: pop-out var(--t-pop-out) var(--ease-in) forwards; }
  :root[data-theme="dark"] .quick-card {
    --c-bg-grouped: #2C2C2E; --c-bg-grouped-2: #3A3A3C;
    box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.16), 0 24px 64px rgba(0, 0, 0, 0.7);
  }
  .quick-head { padding-top: 12px; }
  .quick-body { padding-bottom: 16px; }
  :root:not([data-theme="dark"]) .quick-card { box-shadow: var(--shadow-sheet), 0 0 0 0.5px rgba(0, 0, 0, 0.08); }
}

/* ---------- 확인창 ---------- */
.confirm-box { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; animation: sheet-up 400ms var(--ease-ios) backwards; }
#confirm.is-leaving .confirm-box { animation: fade-out 150ms linear forwards; }
.confirm-main { display: flex; flex-direction: column; border-radius: 14px; background: var(--c-bg-elevated); text-align: center; overflow: hidden; }
.confirm-main strong { display: block; padding: 16px 16px 4px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--c-label-2); }
.confirm-main strong:has(+ p[hidden]) { padding-bottom: 16px; }
.confirm-main p { padding: 0 16px 16px; font-size: 13px; line-height: 18px; color: var(--c-label-2); }
.confirm-btn { width: 100%; height: 57px; font-size: 20px; color: var(--c-tint); position: relative; transition: transform 400ms var(--spring-pop); }
.confirm-btn.danger { color: var(--c-red); }
.confirm-main .confirm-btn { box-shadow: inset 0 0.5px 0 var(--c-sep); }
.confirm-btn.cancel { border-radius: 14px; background: var(--c-bg-elevated); font-weight: 600; }
.confirm-btn:active { opacity: 0.6; transition-duration: 0s; }
@media (min-width: 700px) {
  .confirm { display: grid; place-items: center; }
  .confirm-box {
    position: relative; left: auto; right: auto; bottom: auto; width: 300px; display: grid; grid-template-columns: 1fr 1fr; gap: 0;
    grid-template-areas: "t t" "m m" "c o"; border-radius: 14px; background: var(--c-bg-elevated); overflow: hidden;
    animation: alert-in 300ms var(--spring-pop) backwards, fade-in 150ms linear backwards;
  }
  .confirm-main { display: contents; }
  .confirm-main strong { grid-area: t; font-size: 17px; line-height: 22px; color: var(--c-label); padding: 20px 20px 4px; }
  .confirm-main strong:has(+ p[hidden]) { padding-bottom: 20px; }
  .confirm-main p { grid-area: m; padding: 0 20px 20px; }
  #confirm-ok { grid-area: o; height: 44px; font-size: 17px; font-weight: 600; box-shadow: inset 0.5px 0.5px 0 var(--c-sep); }
  #confirm-cancel { grid-area: c; height: 44px; font-size: 17px; border-radius: 0; background: none; font-weight: 400; box-shadow: inset 0 0.5px 0 var(--c-sep); }
}

/* ---------- 애니메이션 ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise-out { from { transform: translateY(28px) scale(.92); } }
@keyframes rise-in { from { transform: translateY(10px) scale(.7); } }
@keyframes card-in { from { transform: translateY(12px) scale(.96); } }
@keyframes pop-in { from { transform: scale(.5); opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-4px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(32px) scale(.97); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes panel-in-x { from { transform: translateX(calc(100% + 20px)); } }
@keyframes panel-out-x { to { transform: translateX(calc(100% + 20px)); } }
@keyframes typing-dot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-2px) scale(1.12); } }
@keyframes typing-fade { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 0%, 100% { transform: none; } 15% { transform: translateX(-10px); } 30% { transform: translateX(9px); } 45% { transform: translateX(-7px); } 60% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
@keyframes rm-fade { from { opacity: 0; } }
@keyframes card-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes logo-pop { from { transform: scale(.8); } }
@keyframes drag-in { from { opacity: 0; transform: scale(.98); } }
@keyframes deselect-fade { from { opacity: 1; } }
@keyframes quick-up   { from { transform: translateY(calc(100% + 16px)); } }
@keyframes quick-down { to   { transform: translateY(calc(100% + 16px)); } }
@keyframes pop-down   { from { transform: translateY(-6px) scale(.92); } }
@keyframes pop-out    { to   { opacity: 0; transform: scale(.96); } }
@keyframes check-pop  { from { opacity: 0; transform: scale(.4); } }
@keyframes status-in  { from { opacity: 0; transform: scale(.9); } }
@keyframes nudge      { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
@keyframes alert-in   { from { opacity: 0; transform: scale(1.08); } }
@keyframes flash-out  { from { opacity: 1; } to { opacity: 0; } }

.row.enter.user { transform-origin: 100% 100%; animation: rise-out var(--t-msg) var(--spring-pop) backwards, fade-in 120ms linear backwards; }
.row.enter.assistant { transform-origin: 0 100%; animation: rise-in var(--t-pop) var(--spring-bounce) backwards, fade-in 120ms linear backwards; }
.row.user.enter + .row.assistant.enter { animation-delay: 180ms, 180ms; }
.row.enter.assistant.gap { animation-delay: 280ms, 280ms; }
.perm-card.enter { animation: card-in var(--t-msg) var(--spring-pop) backwards, fade-in 160ms linear backwards; }
.settings-sheet { animation: sheet-in 450ms var(--ease-ios) backwards; }
.settings.is-leaving .settings-sheet { animation: sheet-out var(--t-sheet-out) var(--ease-ios) forwards; }
.files-panel { animation: panel-in-x 450ms var(--ease-ios) backwards; }
.files-panel.is-leaving { animation: panel-out-x var(--t-panel-out) var(--ease-ios) forwards; }
.st-in { animation: fade-up 360ms var(--ease-out) backwards; animation-delay: calc(80ms + min(var(--si, 0), 9) * 24ms); }
#conv-list > .st-in { animation-duration: 340ms; animation-delay: calc(min(var(--si, 0), 9) * 20ms); }
.nudge { animation: nudge 320ms var(--ease-out); }
#chat-sub.swap { animation: fade-up 240ms var(--ease-out) backwards; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 300ms; animation-timing-function: ease; }

/* ---------- 호버(마우스가 있는 기기에서만) ---------- */
@media (hover: hover) and (pointer: fine) {
  .conv-item:hover:not(.active) { background: var(--c-hover); }
  #assistant-list .assistant-item:hover:not(:disabled) { background: var(--c-hover); }
  button.settings-row:hover:not(.active):not(:disabled) { background-color: var(--c-hover); }
  .chat-head-text:hover .chat-title-pill::before { opacity: 0.5; }
  .choice-row:hover { background-color: var(--c-hover); }
  .file-row:hover, .att-file:hover { background: var(--c-hover); }
  .dl-link:hover { text-decoration: underline; }
  .btn-small:hover { background: var(--c-fill-2); }
  .collab-btn:hover { color: var(--c-label); }

  /* 얇은 둥근 스크롤바. 표준 스크롤바 속성을 같은 요소에 함께 쓰면 Chrome이 이 규칙을 무시하므로 쓰지 않는다 */
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  *::-webkit-scrollbar-track, *::-webkit-scrollbar-corner { background: transparent; }
  *::-webkit-scrollbar-thumb { background-color: var(--c-fill); border: 3px solid transparent; border-radius: 999px; background-clip: padding-box; }
  *::-webkit-scrollbar-thumb:hover { background-color: var(--c-label-3); }
  .messages::-webkit-scrollbar-track { margin-top: calc(var(--head-h) + env(safe-area-inset-top)); margin-bottom: var(--dock-h, 64px); }
}

/* ---------- 데스크톱 전용 ---------- */
@media (min-width: 700px) {
  .menu-btn { display: none; }
  #assistant-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 2px; padding: 4px 8px 10px; }
  .conv-item.active .conv-avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); }
  :root:not([data-theme="dark"]) .bubble pre { box-shadow: 0 0 0 0.5px var(--c-sep); }
}

/* ---------- 모바일(폰) ---------- */
@media (max-width: 699px) {
  .row.assistant { --w-in: calc(100% - 16px); }   /* 사진 자리를 뺀 받은 말풍선 최대 폭(390px 기준 304px) */
  /* 두 화면을 겹쳐 놓고 밀어 넣기/꺼내기로 바꾼다. nav-open은 "목록이 보임"을 뜻한다 */
  .app { display: block; }
  .sidebar, .chat { position: absolute; inset: 0; }
  .sidebar { z-index: 1; margin: 0; border-radius: 0; box-shadow: none; transform: translateX(-28%); visibility: hidden; background: var(--c-bg); }
  .sidebar::after { display: block; content: ""; position: absolute; inset: 0; background: var(--c-dim); opacity: 1; pointer-events: none; }
  .chat { z-index: 2; box-shadow: var(--shadow-push); }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  .app.nav-open .sidebar::after { opacity: 0; }
  .app.nav-open .chat { transform: translateX(100%); visibility: hidden; }
  /* 숨는 쪽은 이동이 끝난 뒤 visibility:hidden, 보이는 쪽은 즉시 visible */
  .app.nav-ready .sidebar, .app.nav-ready .chat {
    transition: transform var(--t-push) var(--ease-ios), visibility 0s linear var(--t-push);
  }
  .app.nav-ready.nav-open .sidebar, .app.nav-ready:not(.nav-open) .chat {
    transition: transform var(--t-push) var(--ease-ios), visibility 0s;
  }
  .app.nav-ready .sidebar::after { transition: opacity var(--t-push) var(--ease-ios); }
  .menu-btn { display: grid; }

  /* 사이드바 */
  .sidebar-head { padding: calc(env(safe-area-inset-top) + 6px) 12px 4px 16px; }
  .brand { font-size: 34px; line-height: 41px; }
  .side-title { margin: 12px 16px 6px; }
  .side-head { margin: 12px 8px 6px 16px; }
  #assistant-list .avatar { width: 60px; height: 60px; font-size: 24px; }
  .conv-list { padding: 0; }
  .conv-item { column-gap: 12px; min-height: 64px; padding: 0 0 0 16px; border-radius: 0; }
  .conv-avatar { width: 44px; height: 44px; font-size: 18px; }
  .conv-body { padding: 8px 16px 8px 0; }
  li + li > .conv-item .conv-body { box-shadow: inset 0 0.5px 0 var(--c-sep); }
  .conv-title { font-size: 17px; line-height: 22px; }
  .conv-time { font-size: 15px; }
  .conv-time::after { content: ""; width: 7px; height: 12px; background: var(--c-label-3); -webkit-mask: var(--ic-chevron) center / contain no-repeat; mask: var(--ic-chevron) center / contain no-repeat; }
  .conv-preview { font-size: 15px; line-height: 20px; }
  .conv-item.active { background: none; color: inherit; }
  .conv-item.active .conv-preview, .conv-item.active .conv-time { color: var(--c-label-2); }

  /* 채팅 */
  #chat-title { font-size: 13px; line-height: 16px; }
  .messages { padding-left: 16px; padding-right: 16px; padding-bottom: calc(var(--dock-h, 64px) + 20px); }
  .bubble { padding: 7px 13px; }
  .bubble table { font-size: 14px; }
  .att-img img { max-width: 200px; max-height: 200px; }
  .composer { padding: 0 12px; }
  .collab-btn { font-size: 12px; padding: 0 10px; }
  #input { font-size: 17px; line-height: 22px; padding: 9px 14px; }
  .perm-card { font-size: 15px; }
  .meta { font-size: 12px; }

  /* 파일 패널: 아래에서 올라오는 시트 */
  .files-panel {
    top: env(safe-area-inset-top); left: 0; right: 0; bottom: 0; width: auto;
    border-radius: 0; padding-bottom: env(safe-area-inset-bottom);
  }
  .files-panel { animation-name: sheet-up; animation-duration: var(--t-sheet-in); }
  .files-panel.is-leaving { animation-name: sheet-down; }

  /* 겹침 화면: 폰은 아래에서 올라오는 시트 */
  .sheet-grab { display: block; }
  .settings { display: block; padding: 0; }
  .settings-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; top: env(safe-area-inset-top); width: auto; height: auto;
    border-radius: 0;
    animation-name: sheet-up; animation-duration: var(--t-sheet-in);
  }
  .can-recede .settings-sheet { top: calc(env(safe-area-inset-top) + 12px); border-radius: 12px 12px 0 0; }
  .settings.is-leaving .settings-sheet { animation-name: sheet-down; }
  .settings-head { padding-top: 16px; }
  .settings[data-depth="0"]:not(.title-collapsed) .settings-head { box-shadow: none; }
  .settings[data-depth="0"]:not(.title-collapsed) #settings-title { opacity: 0; }
  .settings-body { display: block; position: relative; flex: 1; min-height: 0; }
  .settings-pages { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
  .page {
    position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--c-bg-grouped);
    padding-bottom: calc(24px + env(safe-area-inset-bottom)); pointer-events: auto;
    transform: translateX(100%); visibility: hidden;
    transition: transform var(--t-push) var(--ease-ios), visibility 0s linear var(--t-push);
  }
  .settings-pages > .page { padding: 0 0 calc(24px + env(safe-area-inset-bottom)); overflow-x: hidden; }
  .page.is-current, .settings-pages > .page.is-current { transform: none; visibility: visible; transition: transform var(--t-push) var(--ease-ios), visibility 0s; }
  .page.is-behind, .settings-pages > .page.is-behind { transform: translateX(-28%); visibility: hidden; }
  .page::after { content: ""; position: fixed; inset: 0; background: var(--c-dim); opacity: 0; pointer-events: none; transition: opacity var(--t-push) var(--ease-ios); }
  .page.is-behind::after { opacity: 1; }
  .settings.no-anim .page, .settings.no-anim .page::after { transition: none !important; }
  .settings-side { box-shadow: none; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .large-title { display: block; margin: 4px 16px 4px; padding: 0 16px; font-size: 34px; line-height: 41px; font-weight: 700; }
  .settings-pages > .page-instr { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); transform: translateX(100%); }
  .settings-pages > .page-instr.is-current { transform: none; }
  .page-instr .instr-head { display: none; }
  .settings-pages > .page.swap-in { animation: none; }
  .assistant-row::after { display: block; }
  #sf-hero-name { font-size: 22px; line-height: 28px; }
  .bubble td > .cell { max-width: 15em; }

  /* 빠른 설정(폰 떠 있는 시트)과 확인창은 기본 규칙을 그대로 쓴다 */

  /* 뒤 화면 살짝 물러남: 폰의 전체 높이 설정 시트에서만 */
  .can-recede .app { transform-origin: 50% 0; transition: scale var(--t-sheet-out) var(--ease-ios), translate var(--t-sheet-out) var(--ease-ios); }
  :root.recede .app { scale: 0.93; translate: 0 calc(env(safe-area-inset-top) + 2px); border-radius: 12px; transition-duration: var(--t-sheet-in); }
  :root.recede-out .app { border-radius: 12px; } /* 돌아오는 동안 모서리 유지 */
  :root.recede, :root.recede body, :root.recede-out, :root.recede-out body { background: #000; }
  :root.recede .app .glass, :root.recede .chat-head::before, :root.recede .chat-dock::before { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- 태블릿 폭(700~1023px): 사이드바를 조금 좁게 ---------- */
@media (min-width: 700px) and (max-width: 1023px) {
  .app { grid-template-columns: 308px 1fr; }
}

/* ---------- 터치 기기: 폭과 상관없이 누르기 쉽게, 입력 글자는 17px(iOS 자동 확대 방지) ---------- */
@media (pointer: coarse) {
  :root { --row-h: 50px; --seg-h: 40px; --fs-row: 17px; --fs-bubble: 17px; --lh-bubble: 22px; }
  #input { font-size: 17px; line-height: 22px; padding: 9px 14px; }
  input, select, textarea { font-size: max(17px, 1em); }
}

/* ---------- 삭제: 대화 행 밀기·휴지통, 컨텍스트 메뉴 ---------- */
.ic-trash {
  flex: none; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 3.5h6l.7 1.5H20v2H4V5h4.3zM6 8h12l-.9 11.2A2 2 0 0 1 15.1 21H8.9a2 2 0 0 1-2-1.8z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 3.5h6l.7 1.5H20v2H4V5h4.3zM6 8h12l-.9 11.2A2 2 0 0 1 15.1 21H8.9a2 2 0 0 1-2-1.8z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.conv-swipe { position: relative; touch-action: pan-y; }
.conv-swipe.open, .conv-swipe.dragging { overflow: hidden; }
.conv-swipe .conv-item { transition: transform 280ms var(--ease-ios); }
.conv-swipe.open .conv-item, .conv-swipe.dragging .conv-item { background: var(--c-sidebar); }
.conv-swipe.open .conv-item { transform: translateX(calc(-1 * 80px)); }
.conv-swipe.dragging .conv-item, .conv-swipe.dragging .conv-del { transition: none; }
.conv-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 80px; display: grid; place-items: center;
  background: var(--c-red); color: #fff; font-size: 16px; font-weight: 600;
  transition: width 280ms var(--ease-ios); z-index: 0;
}
.conv-swipe:not(.open):not(.dragging) .conv-del { visibility: hidden; transition: width 280ms var(--ease-ios), visibility 0s linear 280ms; }
.conv-swipe .conv-item { z-index: 1; }
.conv-trash {
  display: none; position: absolute; top: 50%; right: 10px; width: 30px; height: 30px; margin-top: -15px; border-radius: 50%;
  place-items: center; color: var(--c-label-2); background: var(--c-fill-3); z-index: 2;
}
.conv-trash:hover { color: var(--c-red-text); }
@media (hover: hover) and (pointer: fine) {
  .conv-swipe:hover .conv-trash, .conv-swipe:focus-within .conv-trash { display: grid; }
  .conv-swipe:hover .conv-time, .conv-swipe:focus-within .conv-time { visibility: hidden; }
}
.conv-swipe.leaving { transition: opacity 280ms var(--ease-ios), transform 280ms var(--ease-ios); opacity: 0; transform: translateX(-24px); pointer-events: none; }
.conv-notice { margin: 4px 16px 8px; padding: 8px 12px; border-radius: 12px; background: var(--c-red-bg); color: var(--c-label); font-size: 13px; }

.row.msg-leaving { transition: opacity 220ms var(--ease-ios), transform 220ms var(--ease-ios); opacity: 0; transform: scale(.96); pointer-events: none; }
.row.ctx-source { opacity: 0; }
.messages .bubble { -webkit-touch-callout: none; }
.ctx-layer { position: fixed; inset: 0; z-index: 90; }
.ctx-dim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.34); opacity: 0; transition: opacity 200ms linear; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.ctx-layer.show .ctx-dim { opacity: 1; }
.ctx-layer.leaving .ctx-dim { opacity: 0; transition-duration: 150ms; }
.row.ctx-clone { position: fixed; margin: 0; padding: 0; transform-origin: 50% 50%; transition: transform 240ms var(--spring-pop); pointer-events: none; z-index: 1; }
.ctx-layer.show .row.ctx-clone { transform: scale(1.03); }
.ctx-layer.leaving .row.ctx-clone { transform: none; opacity: 0; transition: opacity 150ms linear, transform 150ms linear; }
.ctx-card {
  position: fixed; z-index: 2; width: 220px; padding: 6px; border-radius: 16px; background: var(--c-bg-elevated); box-shadow: var(--shadow-sheet), 0 0 0 0.5px var(--c-sep);
  opacity: 0; transform: scale(.92); transform-origin: 50% 0; transition: opacity 160ms linear, transform 240ms var(--spring-pop);
}
.ctx-layer.show .ctx-card { opacity: 1; transform: none; }
.ctx-layer.leaving .ctx-card { opacity: 0; transition-duration: 120ms; }
.ctx-item { width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 14px; border-radius: 10px; font-size: 17px; color: var(--c-label); text-align: left; }
.ctx-item.danger { color: var(--c-red-text); }
.ctx-item:active:not(:disabled) { background: var(--c-fill-3); }
.ctx-item:disabled { opacity: 0.4; }
.ctx-note { margin: 4px 14px 8px; font-size: 12.5px; line-height: 17px; color: var(--c-label-2); }
@media (max-width: 699px) { .conv-swipe.open .conv-item, .conv-swipe.dragging .conv-item { background: var(--c-bg); } }
@media (hover: hover) and (pointer: fine) { .ctx-item:hover:not(:disabled) { background: var(--c-fill-3); } }

/* ---------- 임시 채팅 ---------- */
.temp-badge { flex: none; font-size: 10px; line-height: 14px; padding: 0 6px; border: 1px dashed var(--c-label-3); border-radius: 999px; color: var(--c-label-2); }
.temp-badge[hidden] { display: none; }
.temp-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; margin: 14px 0 0 8px; padding: 0 14px; border-radius: 999px;
  border: 1.5px dashed var(--c-label-3); color: var(--c-label-2); font-size: 13px; font-weight: 600; background: transparent;
}
.temp-toggle::before {
  content: ""; flex: none; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zm1 4v4.6l3 1.8-.8 1.3-3.7-2.2V7.5z' fill-rule='evenodd'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zm1 4v4.6l3 1.8-.8 1.3-3.7-2.2V7.5z' fill-rule='evenodd'/%3E%3C/svg%3E") center / contain no-repeat;
}
.temp-toggle[aria-pressed="true"] { border-style: solid; border-color: var(--c-tint); color: var(--c-tint); background: var(--c-tint-soft); }
.chat.temp .composer-field { outline: 1.5px dashed var(--c-label-3); outline-offset: -2px; }
.messages > .sys-temp { margin-top: 6px; }
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 95; max-width: calc(100% - 32px);
  padding: 9px 16px; border-radius: 16px; background: var(--c-bg-elevated); box-shadow: var(--shadow-card), 0 0 0 0.5px var(--c-sep);
  color: var(--c-label); font-size: 13.5px; line-height: 18px; pointer-events: none;
  opacity: 0; transform: translate(-50%, 8px); transition: opacity 200ms linear, transform 280ms var(--ease-ios);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 기억 ---------- */
.mem-row { align-items: flex-start; }
.mem-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.mem-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 15px; line-height: 20px; overflow-wrap: anywhere; }
.mem-sub { font-size: 12px; line-height: 16px; color: var(--c-label-2); }
.mem-head { display: flex; align-items: center; gap: 8px; padding: 8px 16px 0; }
.mem-head strong { font-size: 17px; font-weight: 600; }
#mem-text { display: block; width: 100%; min-height: 120px; resize: vertical; border: 0; outline: 0; padding: 14px 16px; background: transparent; font-size: var(--fs-row); line-height: 1.5; color: var(--c-label); }
@media (max-width: 699px) { .mem-head { display: none; } }
.ic-memo {
  flex: none; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 3.5h12a1 1 0 0 1 1 1V21l-7-4-7 4V4.5a1 1 0 0 1 1-1z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 3.5h12a1 1 0 0 1 1 1V21l-7-4-7 4V4.5a1 1 0 0 1 1-1z'/%3E%3C/svg%3E") center / contain no-repeat;
}


/* ---------- 프로필 보기 ---------- */
.profile { z-index: 50; }
.profile .sheet-scrim { background: rgba(0, 0, 0, 0.92); animation-duration: 250ms; }
#profile.is-leaving .sheet-scrim { animation-duration: 260ms; }
.profile-card {
  inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); pointer-events: none; color: #fff; touch-action: none;
}
.profile-card > * { pointer-events: auto; }
.profile-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 12px; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, 0.14);
}
.profile-photo {
  width: min(calc(100vw - 32px), 560px, calc(100dvh - 300px)); aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: #111;
  display: grid; place-items: center;
}
.profile-photo img { width: 100%; height: 100%; object-fit: contain; display: block; -webkit-user-drag: none; }
.profile-photo.no-img { color: #fff; }
.profile-letter { font-size: 96px; font-weight: 700; }
.profile-info { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; animation: fade-in 250ms linear 120ms backwards; }
#profile.is-leaving .profile-info { animation: fade-out 160ms linear forwards; }
.profile-info h2 { font-size: 22px; line-height: 28px; font-weight: 700; color: #fff; }
.profile-info p { font-size: 15px; line-height: 20px; color: rgba(255, 255, 255, 0.7); }
.profile-actions { display: flex; gap: 12px; margin-top: 16px; }
.profile-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 128px; height: 46px; padding: 0 20px; border-radius: 23px;
  background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 16px; font-weight: 600;
}
.profile-btn:active { background: rgba(255, 255, 255, 0.26); }
.ic-chat, .ic-gear { flex: none; width: 20px; height: 20px; background: currentColor; }
.ic-chat {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3.5c-4.7 0-8.5 3.2-8.5 7.2 0 2.1 1 4 2.7 5.3-.2 1.3-.8 2.5-1.7 3.4 2-.1 3.6-.8 4.7-1.7.9.2 1.8.3 2.8.3 4.7 0 8.5-3.2 8.5-7.2S16.700 3.500 12 3.500z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3.5c-4.7 0-8.5 3.2-8.5 7.2 0 2.1 1 4 2.7 5.3-.2 1.3-.8 2.5-1.7 3.4 2-.1 3.6-.8 4.7-1.7.9.2 1.8.3 2.8.3 4.7 0 8.5-3.2 8.5-7.2S16.700 3.500 12 3.500z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ic-gear {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M10.300 2.800h3.400l.5 2.300c.5.200 1 .5 1.500.8l2.200-.8 1.700 2.900-1.700 1.600c.1.600.1 1.100 0 1.700l1.700 1.600-1.700 2.900-2.200-.8c-.5.300-1 .6-1.500.8l-.5 2.300h-3.400l-.5-2.300c-.5-.2-1-.5-1.500-.8l-2.200.8-1.700-2.900 1.700-1.600c-.1-.6-.1-1.100 0-1.700L4.400 7l1.700-2.900 2.200.8c.5-.3 1-.6 1.500-.8zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M10.300 2.800h3.400l.5 2.300c.5.200 1 .5 1.500.8l2.200-.8 1.700 2.900-1.700 1.600c.1.600.1 1.100 0 1.700l1.700 1.600-1.700 2.900-2.200-.8c-.5.300-1 .6-1.500.8l-.5 2.300h-3.400l-.5-2.300c-.5-.2-1-.5-1.500-.8l-2.200.8-1.700-2.900 1.700-1.600c-.1-.6-.1-1.100 0-1.700L4.400 7l1.700-2.900 2.200.8c.5-.3 1-.6 1.500-.8zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.bubble-av { cursor: pointer; }
.q-avatar[role="button"] { cursor: pointer; }

/* ---------- 감소된 동작 ---------- */
@media (prefers-reduced-motion: reduce) {
  .app.nav-ready .sidebar, .app.nav-ready .chat, .app.nav-ready .sidebar::after, .page, .page::after, .seg-n .seg-thumb, .step-btn,
  .chat-head-text .chat-title-pill, .chat-head-text .chat-avatar,
  .send-btn, .seg-thumb, button.glass, .glass::before, .conv-item::before, #assistant-list .avatar,
  .perm-remember input::before, .check input::before { transition: none !important; }
  .conv-swipe .conv-item, .conv-del, .conv-swipe.leaving, .row.msg-leaving, .ctx-dim, .ctx-clone, .ctx-card, .toast { transition: none !important; }
  .profile-info { animation: rm-fade 150ms linear backwards !important; }
  .row.enter, .perm-card.enter, .empty-state, .meta-detail, .messages > .notice, .messages > .sys-line, .bubble-pop, .run-status, .attach-tray, .stop-btn,
  .collab-btn, .auth, .auth-logo, .settings-sheet, .files-panel, .chat.dragging::after,
  .quick-card, #confirm .confirm-box, .sheet-scrim, .settings-pages > .page.swap-in, #chat-sub.swap {
    animation: rm-fade 150ms linear backwards !important;
  }
  .st-in, .nudge, .choice-row:has(> input:checked) .choice-check, .assistant-row.flash::before, .save-status[data-state], .save-status[data-state]::before { animation: none !important; }
  :root.recede .app { scale: none; translate: none; }
  .step-btn:active { transform: none !important; }
  .typing i { animation-name: typing-fade !important; animation-duration: 2.4s !important; }
  button:active, button.glass:active, #assistant-list .assistant-item:active .avatar { transform: none !important; }
  .spinner { animation-duration: 2s; }
}
