@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1f1e1b;
  --muted: #8b877d;
  --line: #e8e5dd;
  --bubble: #efede6;
  --accent: #d97757;
  --accent-hover: #c4664a;
  --shadow: 0 1px 2px rgba(31, 30, 27, 0.04), 0 4px 16px rgba(31, 30, 27, 0.06);
  --pet-line: #0c0908;
  --pet-black: #262020;
  --pet-ear: #42342d;
  --pet-tan: #8e5530;
  --pet-eye: #f4ede4;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1d;
    --surface: #2a2a27;
    --text: #ecebe6;
    --muted: #9c998f;
    --line: #383834;
    --bubble: #33332f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.25);
    --pet-black: #3f3531;
    --pet-ear: #5a4840;
    --pet-tan: #a8683c;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; letter-spacing: inherit; }
button { cursor: pointer; }

/* ---------- 로그인 ---------- */
.login {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-pet { height: 60px; align-items: flex-end; display: flex; justify-content: center; margin-bottom: 20px; }
.login h1 { color: var(--accent); font-size: 26px; font-weight: 700; letter-spacing: -0.03em; margin: 0 0 6px; }
.login p.sub { color: var(--muted); font-size: 16px; margin: 0 0 28px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login input {
  width: 100%; padding: 14px 16px; font-size: 17px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.btn-primary {
  padding: 14px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.hint { color: var(--muted); font-size: 14px; margin-top: 18px; }

/* 위쪽 내 이름 + 사람 관리 */
.me { color: var(--muted); margin-left: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.me .lv-badge { margin-left: 4px; vertical-align: 1px; }
.people-btn { font-size: 14px !important; color: var(--text) !important; border: 1px solid var(--line) !important; }

/* 파일 칸: 누구 파일 */
.owners { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 10px; align-items: center; }
.owners[hidden] { display: none; }
.owners .lbl { font-size: 12px; color: var(--muted); margin-right: 2px; }
.owner-btn {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
}
.owner-btn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 700; }
.viewing-other { margin: 0 18px 10px; font-size: 13px; color: var(--accent); }
.viewing-other span { color: var(--muted); font-size: 12px; }
.file-item.locked { opacity: .55; cursor: not-allowed; user-select: none; }
.file-item.locked:hover { background: none; }
.file-item.locked .lock-ic { margin-left: auto; font-size: 12px; }

/* 다른 사람 대화 보기(읽기 전용) */
.chat-view-bar {
  margin: 0 16px 6px; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.chat-view-bar[hidden] { display: none; }
.chat-view-bar button {
  margin-left: auto; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 600;
}
.composer.readonly { opacity: .55; }
.composer.readonly .icon-btn, .composer.readonly .send { pointer-events: none; }

/* 세션 관리 모달 */
.sess-card {
  width: 100%; max-width: 1000px; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding-bottom: 18px;
}
.sess-graph { position: relative; margin: 0 18px; overflow-x: auto; }
.sess-graph svg.sg-edges { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.sess-graph svg path { fill: none; stroke-width: 2; }
.sess-graph svg path.manage { stroke: var(--line); }
.sess-graph svg path.own { stroke: color-mix(in srgb, var(--accent) 35%, var(--line)); stroke-dasharray: 2 5; }
.sess-graph svg path.request { stroke: var(--accent); stroke-dasharray: 6 4; }
.sess-graph svg text { font-size: 11px; fill: var(--muted); }
.snode {
  position: absolute; width: 200px; min-height: 84px; padding: 10px 12px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg); cursor: pointer; font-size: 13px; line-height: 1.4;
  transition: transform .1s, box-shadow .1s;
}
.snode:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.snode.main { border-color: var(--text); background: var(--surface); }
.snode.user { border-color: #2d6bd1; }
.snode.maker { border-color: var(--accent); border-style: dashed; }
.snode.on { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.snode .nt { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.snode .ns { color: var(--muted); font-size: 12px; }
.snode .nm { margin-top: 4px; font-size: 12px; color: var(--muted); }
.snode .live { width: 9px; height: 9px; border-radius: 50%; background: #9aa0a6; display: inline-block; }
.snode .live.on { background: #2f9e6b; box-shadow: 0 0 0 3px color-mix(in srgb, #2f9e6b 25%, transparent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, #2f9e6b 10%, transparent); } }
.sess-detail { margin: 14px 18px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; font-size: 14px; min-height: 60px; }
.sess-detail h4 { margin: 0 0 8px; font-size: 16px; }
.sess-detail .row { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.sess-detail .row:last-child { border-bottom: 0; }
.sess-detail .k { width: 110px; color: var(--muted); flex-shrink: 0; }
.sess-detail button {
  margin-top: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 7px 12px; font-size: 14px; font-weight: 600;
}

/* 사람 관리 모달 */
.people-card {
  width: 100%; max-width: 480px; max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding-bottom: 18px;
}
.pp-title { flex: 1; font-size: 18px; font-weight: 700; }
.pp-sub { margin: 0; padding: 0 22px 12px; color: var(--muted); font-size: 14px; }
.pp-list { display: flex; flex-direction: column; gap: 8px; padding: 0 18px; }
.pp-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); text-align: left;
  font-size: 16px; color: var(--text);
}
.pp-user .nm { flex: 1; font-weight: 600; }
.pp-user .ss { font-size: 12px; color: var(--muted); }
.pp-user.can { cursor: pointer; }
.pp-user.can:hover { border-color: var(--accent); }
.pp-user.me-row { opacity: .75; }
.pp-add { display: flex; gap: 8px; padding: 14px 18px 0; }
.pp-add input, .pp-add select, #umSession {
  padding: 10px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); outline: none;
}
.pp-add input { flex: 1; min-width: 0; }
.pp-add .btn-primary { padding: 10px 16px; font-size: 15px; }
#ppErr { padding: 6px 18px 0; }
.um-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 4px; }
.um-levels { display: flex; gap: 8px; flex-wrap: wrap; }
.um-del { margin-right: auto; border: 1px solid #f1b0a8; background: none; color: #c0392b; border-radius: 12px; padding: 10px 14px; font-weight: 700; }
.um-del:hover { background: #fdecea; }
.pp-gone { margin: 14px 18px 0; border-top: 1px dashed var(--line); padding-top: 10px; }
.pp-gone[hidden] { display: none; }
.pp-gone .gh { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.pp-gone .gr { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 14px; color: var(--muted); }
.pp-gone .gr .nm { flex: 1; text-decoration: line-through; }
.pp-gone .gr button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.um-limits { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.um-limits label { display: flex; flex-direction: column; gap: 4px; }
.um-limits select {
  padding: 10px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); outline: none;
}
.pp-user .use { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pp-user .use.full { color: #c0392b; font-weight: 700; }
.me .quota { font-size: 12px; font-weight: 500; margin-left: 6px; }
.quota-btn {
  margin-left: 6px; border: 1px solid var(--accent) !important; color: var(--accent) !important;
  background: transparent; border-radius: 999px; padding: 2px 9px !important; font-size: 12px !important; font-weight: 700;
}
.quota-btn:hover { background: color-mix(in srgb, var(--accent) 10%, transparent) !important; }
.quota-wait { margin-left: 6px; font-size: 12px; color: var(--accent); font-weight: 600; }
.people-btn { position: relative; }
.people-btn .dot {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; line-height: 1;
}
.req-sel, .req-note {
  padding: 10px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); outline: none;
}
.req-box { margin: 0 18px 14px; border: 1px solid color-mix(in srgb, #e5484d 35%, var(--line)); border-radius: 14px; overflow: hidden; }
.req-box[hidden] { display: none; }
.req-head { padding: 10px 14px; font-weight: 700; font-size: 15px; background: color-mix(in srgb, #e5484d 8%, var(--surface)); }
.req-list { display: flex; flex-direction: column; }
.req-item { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.req-item.done { opacity: .55; }
.req-item .who { font-weight: 700; }
.req-item .meta { color: var(--muted); font-size: 12px; }
.req-item .note { font-size: 13px; background: var(--bg); border-radius: 8px; padding: 6px 8px; }
.req-item .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.req-item .acts button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 600;
}
.req-item .acts button.give { border-color: var(--accent); color: var(--accent); }
.req-item .acts button:disabled { opacity: .5; }
.um-levels label {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; font-size: 15px;
}
.um-levels input { accent-color: var(--accent); }

/* 로그인: 사용 신청 */
.signup-btn {
  margin-top: 14px; width: 100%; padding: 12px; border: 1px dashed var(--line); border-radius: 12px;
  background: transparent; color: var(--text); font-size: 16px; font-weight: 600;
}
.signup-btn:hover { border-color: var(--accent); color: var(--accent); }
.lv-badge.lv-1 { background: #111; color: #7ee0a0; }
#actBtn.acting { border-color: #7a4cc9 !important; color: #7a4cc9 !important; font-weight: 700; }

/* 사람 관리: 비밀번호·잠금·전화 */
.pp-user .sec { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pp-user .sec button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 3px 9px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.pp-user .sec .pin { font-family: Consolas, monospace; font-size: 15px; letter-spacing: 3px; color: var(--accent); font-weight: 800; }
.pp-user .sec .lockd { color: #c0392b; font-size: 12px; font-weight: 700; }
.pp-user .ph { font-size: 12px; color: var(--muted); }
/* 사전 등록 모달 */
.pr-add { display: flex; gap: 8px; padding: 0 18px 10px; flex-wrap: wrap; }
.pr-add input { flex: 1; min-width: 120px; padding: 10px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); outline: none; }
.pr-sec { padding: 4px 18px; }
.pr-sec .h { font-weight: 700; font-size: 14px; color: var(--muted); margin: 10px 0 6px; }
.pr-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 15px; flex-wrap: wrap; }
.pr-row .nm { font-weight: 700; min-width: 70px; }
.pr-row .ph { color: var(--muted); flex: 1; }
.pr-row .st { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bubble); }
.pr-row .st.joined { background: #e7f4ea; color: #2f7a45; }
.pr-row .st.applied { background: #fbe3d8; color: #a8452a; }
.pr-row button, .pr-row select { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.pr-row button.ok { border-color: #2f9e6b; color: #2f9e6b; }

/* 이름 버튼 로그인 */
.who { display: flex; flex-direction: column; gap: 10px; }
.who-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); font-size: 18px; font-weight: 600;
  box-shadow: var(--shadow); transition: border-color .15s, transform .1s;
}
.who-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.lv-badge {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--bubble); color: var(--muted);
}
.lv-badge.lv0 { background: #2b2421; color: #f5d9b8; }
.lv-badge.lv1 { background: #fbe3d8; color: #a8452a; }
.lv-badge.lv2 { background: #e3eefb; color: #2c5d9e; }
.lv-badge.lv3 { background: #e7f4ea; color: #2f7a45; }
@media (prefers-color-scheme: dark) {
  .lv-badge.lv1 { background: #4a2a20; color: #f5b49a; }
  .lv-badge.lv2 { background: #1f3350; color: #9cc1f0; }
  .lv-badge.lv3 { background: #1f3a29; color: #9dd6ae; }
}
.error { color: #c0392b; font-size: 15px; min-height: 1.4em; }

/* ---------- 대화 ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
}
.topbar .title { color: var(--accent); font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.topbar button {
  border: 0; background: none; color: var(--muted); font-size: 14px;
  padding: 6px 10px; border-radius: 8px;
}
.topbar button:hover { background: var(--bubble); color: var(--text); }
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 8px; }
.thread-inner { max-width: 720px; margin: 0 auto; }
.welcome { text-align: center; margin-top: 20vh; }
.welcome h2 { font-size: 30px; font-weight: 700; letter-spacing: -0.035em; margin: 0 0 8px; }
.welcome p { color: var(--muted); margin: 0; font-size: 16px; }
.msg { margin: 18px 0; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.msg.user {
  margin-left: auto; width: fit-content; max-width: 85%;
  background: var(--bubble); padding: 10px 16px; border-radius: 18px;
}
.msg .file {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 15px;
}
.typing { color: var(--muted); }
/* AI 답 마크다운 */
.msg.md { white-space: normal; }
.msg.md p { margin: 0 0 10px; }
.msg.md p:last-child, .msg.md ul:last-child, .msg.md ol:last-child { margin-bottom: 0; }
.msg.md h3, .msg.md h4, .msg.md h5 { margin: 14px 0 6px; font-size: 17px; }
.msg.md ul, .msg.md ol { margin: 4px 0 10px; padding-left: 22px; }
.msg.md li { margin: 3px 0; }
.msg.md strong { font-weight: 700; }
.msg.md code { background: var(--bubble); border-radius: 5px; padding: 1px 5px; font-size: .92em; }
.msg.md pre { background: var(--bubble); border-radius: 10px; padding: 10px 12px; overflow-x: auto; font-size: 14px; white-space: pre; }
.msg.md blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.msg.md table { border-collapse: collapse; margin: 6px 0 10px; font-size: 15px; }
.msg.md th, .msg.md td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.msg.md th { background: var(--bubble); }
.msg.md a { color: var(--accent); }

.composer-wrap { padding: 0 16px 20px; }
.composer-box { max-width: 720px; margin: 0 auto; position: relative; }
.pet-lane { position: relative; height: 60px; pointer-events: none; }
.pet { position: absolute; left: 0; bottom: -2px; transform-origin: center; pointer-events: auto; cursor: pointer; line-height: 0; touch-action: manipulation; user-select: none; }
.pet svg { pointer-events: none; }
.pet[hidden] { display: none; }
.pet-house {
  position: absolute; left: 6px; bottom: -2px; line-height: 0;
  pointer-events: auto; cursor: pointer; user-select: none; touch-action: manipulation;
  animation: house-in .5s ease-out;
}
.pet-house[hidden] { display: none; }
.pet-house svg { pointer-events: none; }
.pet-house.leaving { animation: house-out .6s ease-in forwards; }
.pet-z {
  position: absolute; bottom: 78px; pointer-events: none;
  font-weight: 800; color: var(--muted); font-family: var(--font);
  animation: zzz 2.4s ease-out forwards;
}
@keyframes zzz {
  0% { transform: translate(0, 0) rotate(-8deg); opacity: 0; }
  15% { opacity: .9; }
  100% { transform: translate(22px, -60px) rotate(12deg); opacity: 0; }
}
@keyframes house-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes house-out { to { transform: translateY(12px); opacity: 0; } }
.pet-heart {
  position: absolute; bottom: 52px; line-height: 0; pointer-events: none;
  animation: heart 1.1s ease-out forwards;
}
@keyframes heart {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  20% { transform: translateY(-6px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-36px) scale(1); opacity: 0; }
}

.composer {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow); padding: 12px 12px 10px 16px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.composer textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent;
  color: var(--text); font-size: 17px; line-height: 1.6; max-height: 40vh; padding: 4px 0;
}
.composer textarea::placeholder { color: var(--muted); }
.composer .row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.composer .spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bubble); color: var(--text); }
.send {
  width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  transition: background .15s, opacity .15s;
}
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:disabled { opacity: 0.35; cursor: default; }
.icon-btn svg, .send svg { width: 20px; height: 20px; }

/* ---------- 레이아웃 + 오른쪽 파일 이력 ---------- */
.layout { height: 100%; display: flex; overflow: hidden; }
.layout .app { flex: 1; min-width: 0; min-height: 0; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.files-toggle { display: none; }

.files {
  width: 300px; flex-shrink: 0; height: 100%;
  border-left: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column;
}
.files-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px; font-size: 15px; font-weight: 600;
}
.files-close { display: none; border: 0; background: none; color: var(--muted); font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 12px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
}
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .n { opacity: .6; margin-left: 3px; }
.files-list { flex: 1; overflow-y: auto; padding: 0 10px 16px; }
.day { font-size: 12px; font-weight: 600; color: var(--muted); padding: 14px 8px 6px; }
/* 날짜별 접기·펼치기 */
.day-h {
  display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 8px; padding: 8px;
  border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 12px; font-weight: 700; text-align: left;
}
.day-h:hover { background: var(--bubble); color: var(--text); }
.day-h .arrow { width: 14px; display: inline-block; transition: transform .15s; }
.day-h.closed .arrow { transform: rotate(-90deg); }
.day-h .cnt { margin-left: auto; font-weight: 600; font-size: 11px; background: var(--bubble); border-radius: 999px; padding: 1px 7px; }
.day-files[hidden] { display: none; }
.day-h.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 60% { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); } }
.files-head { position: relative; }
.fh-tools { display: inline-flex; gap: 4px; margin-left: auto; margin-right: 6px; }
.fh-btn { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 8px; padding: 2px 8px; font-size: 13px; }
.fh-btn:hover, .fh-btn.on { border-color: var(--accent); }
/* 달력 */
.cal-pop {
  margin: 0 14px 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
  box-shadow: var(--shadow); font-size: 13px;
}
.cal-pop[hidden] { display: none; }
.cal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 700; }
.cal-top button { border: 0; background: none; color: var(--text); font-size: 16px; padding: 2px 8px; border-radius: 6px; }
.cal-top button:hover { background: var(--bubble); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-grid .wd { font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal-grid .wd.sun, .cal-grid .d.sun { color: #c0392b; }
.cal-grid .d {
  position: relative; border: 0; background: none; color: var(--muted); border-radius: 8px; padding: 6px 0 9px; font-size: 13px; opacity: .45;
}
.cal-grid .d.has { opacity: 1; color: var(--text); font-weight: 700; cursor: pointer; }
.cal-grid .d.has:hover { background: var(--bubble); }
.cal-grid .d.has::after {
  content: ""; position: absolute; left: 50%; bottom: 3px; width: 5px; height: 5px; margin-left: -2.5px;
  border-radius: 50%; background: var(--accent);
}
.cal-grid .d.today { outline: 1.5px solid var(--accent); }
.cal-grid .d:disabled { cursor: default; }
.file-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 10px; color: inherit; text-decoration: none;
}
.file-item:hover { background: var(--bubble); }
.ext {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0; color: #fff; text-transform: uppercase;
}
.ext.image { background: #7c6ce0; }
.ext.excel { background: #1f8a4c; }
.ext.ppt { background: #d0582f; }
.ext.pdf { background: #c8312f; }
.ext.doc { background: #2d6bd1; }
.ext.media { background: #b04a9a; }
.ext.etc { background: #8b877d; }
.file-meta { min-width: 0; }
.file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: 12px; color: var(--muted); }
.files-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 12px; }

.yt-btn svg { width: 22px; height: 22px; }

/* 파일 주고받기 */
.m-choice { grid-template-columns: repeat(4, 1fr); }
.modal-card.wide .m-choice { grid-template-columns: repeat(4, auto); }
.choice.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
@media (max-width: 520px) { .m-choice { grid-template-columns: 1fr 1fr; } }
button.choice { font-family: inherit; cursor: pointer; }
.send-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; }
.send-list label {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; font-size: 16px;
}
.send-list label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.send-list input { accent-color: var(--accent); }
.send-list .nm { flex: 1; font-weight: 600; }
.xf-sec { padding: 0 18px; }
.xf-sec .xf-in {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface)); font-size: 15px;
}
.xf-in .acts { display: flex; gap: 6px; margin-top: 8px; }
.xf-in .acts button, .xf-row button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 5px 12px; font-size: 13px; font-weight: 700;
}
.xf-in .acts button.ok { border-color: #2f9e6b; color: #2f9e6b; }
.xf-in .note, .xf-row .note { font-size: 13px; color: var(--muted); }
.xf-head { padding: 14px 18px 6px; font-weight: 700; font-size: 14px; color: var(--muted); }
.xf-hist { padding: 0 18px; display: flex; flex-direction: column; }
.xf-row { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 14px; flex-wrap: wrap; }
.xf-row .when { color: var(--muted); font-size: 12px; width: 78px; flex-shrink: 0; }
.xf-row .who { font-weight: 700; }
.xf-row .fn { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xf-row .st { font-size: 12px; white-space: nowrap; }
.xf-empty { color: var(--muted); font-size: 14px; padding: 10px 2px; }
.yt-loading { font-size: 14px; color: var(--muted); }
.yt-loading[hidden] { display: none; }

/* 제작 중 카드(대화 맨 아래) + 파일 목록 자리 */
.job-cards { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.job-card {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px; font-size: 15px;
  border: 1px dashed color-mix(in srgb, var(--accent) 60%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.job-card.queued { border-color: var(--line); background: var(--surface); color: var(--muted); }
.job-card .jc-main { flex: 1; font-weight: 600; }
.job-card .jc-time { font-size: 13px; color: var(--muted); white-space: nowrap; }
.file-item.ghost { opacity: .75; cursor: default; }
.file-item.ghost .ext { background: var(--bubble); }
.file-item.ghost .spinner.small { margin: 0; }

/* 파일을 끌어 입력창에 붙이기 */
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 6px; }
.attach-chips[hidden] { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-size: 13px; max-width: 100%;
}
.attach-chip .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.attach-chip button { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 0 4px; border-radius: 6px; }
.attach-chip button:hover { color: #c0392b; }
.attach-note { font-size: 12px; color: var(--muted); padding-bottom: 4px; width: 100%; }
.composer.drop-ok { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.file-item[draggable="true"] { cursor: grab; }
.msg .att { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.msg .att span {
  font-size: 13px; padding: 2px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
}

.dev-link {
  font-size: 13px; color: var(--muted); text-decoration: none;
  padding: 6px 10px; border: 1px dashed var(--line); border-radius: 8px;
}
.dev-link:hover { color: var(--text); }

/* 드래그해서 올리기 */
.drop-overlay {
  position: fixed; inset: 0; z-index: 20; display: none;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(2px); padding: 24px;
}
.drop-overlay.on { display: flex; }
.drop-box {
  flex: 1; display: grid; place-items: center;
  border: 3px dashed var(--accent); border-radius: 24px;
  font-size: 24px; font-weight: 700; color: var(--accent); pointer-events: none;
}
.ext.text { background: #5b6b7a; }
.ext.hwp { background: #2f8fce; }

/* 파일 모달 */
.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(20, 18, 15, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 560px; max-height: 92vh;
  background: var(--surface); border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  display: flex; flex-direction: column; overflow: hidden;
  transition: max-width .2s ease;
}
.modal-card.wide { max-width: 1000px; height: 92vh; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 18px 4px; }
.m-name {
  flex: 1; min-width: 0; font-size: 17px; font-weight: 600; color: var(--text);
  border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; background: transparent; outline: none;
}
.m-name:hover { border-color: var(--line); }
.m-name:focus { border-color: var(--accent); background: var(--bg); }
.m-btn {
  border: 0; border-radius: 8px; padding: 7px 12px; font-size: 14px; font-weight: 600;
  background: var(--text); color: var(--bg);
}
.m-close { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 6px 8px; border-radius: 8px; }
.m-close:hover { background: var(--bubble); color: var(--text); }
.m-sub { color: var(--muted); font-size: 13px; padding: 0 26px 14px 66px; }
.m-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 4px 18px 18px; }
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 22px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--text); font-size: 16px; font-weight: 600; text-decoration: none;
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--accent); }
.choice svg { width: 28px; height: 28px; color: var(--accent); }
.modal-card.wide .m-choice { grid-template-columns: auto auto; justify-content: start; padding-bottom: 10px; }
.modal-card.wide .choice { flex-direction: row; padding: 8px 14px; font-size: 14px; }
.modal-card.wide .choice svg { width: 18px; height: 18px; }
.m-convert { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 18px 14px; font-size: 14px; color: var(--muted); }
.m-convert button {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 14px;
}
.m-convert button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.m-convert button:disabled { opacity: .45; cursor: default; }
.m-preview { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--line); background: var(--bg); }
.m-preview > img, .m-preview > video { display: block; max-width: 100%; max-height: 100%; margin: 0 auto; }
.m-preview > iframe { width: 100%; height: 100%; border: 0; }
.m-preview audio { width: calc(100% - 48px); margin: 40px 24px; }
.m-preview pre { margin: 0; padding: 20px 24px; white-space: pre-wrap; font-family: var(--font); font-size: 15px; }
.m-center { display: grid; place-items: center; height: 100%; min-height: 160px; color: var(--muted); padding: 24px; text-align: center; }

/* 로딩 동그라미 */
.loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  height: 100%; min-height: 200px; color: var(--muted); font-size: 15px; text-align: center; padding: 24px;
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.small { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading .elapsed { font-size: 13px; opacity: .8; }
.media-wrap { position: relative; width: 100%; height: 100%; min-height: 200px; }
.media-wrap > .loading { position: absolute; inset: 0; background: var(--bg); z-index: 1; }
.media-wrap > iframe { width: 100%; height: 100%; border: 0; display: block; }
.media-wrap > img, .media-wrap > video { display: block; max-width: 100%; max-height: 100%; margin: 0 auto; }
.sheet-tabs { display: flex; gap: 4px; padding: 10px 12px 0; position: sticky; top: 0; background: var(--bg); }
.sheet-tabs button { border: 1px solid var(--line); border-bottom: 0; background: var(--surface); color: var(--muted); border-radius: 8px 8px 0 0; padding: 4px 12px; font-size: 13px; }
.sheet-tabs button.on { color: var(--text); font-weight: 600; }
.grid { border-collapse: collapse; font-size: 14px; margin: 0 12px 16px; background: var(--surface); }
.grid td { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.grid tr:first-child td { background: var(--bubble); font-weight: 600; }
.doc-view { max-width: 720px; margin: 0 auto; padding: 24px 28px 40px; background: var(--surface); min-height: 100%; }
.doc-view h3 { font-size: 20px; margin: 18px 0 8px; }
.doc-view p { margin: 0 0 10px; white-space: pre-wrap; }
.slide { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 12px; background: var(--bg); }
.slide .n { font-size: 12px; color: var(--muted); }
.slide .t { font-weight: 700; font-size: 17px; margin: 2px 0 6px; }
.note { font-size: 13px; color: var(--muted); padding: 10px 28px 0; max-width: 720px; margin: 0 auto; }

/* 모달 작업 버튼 */
.m-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 12px; }
.m-actions button {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 10px; padding: 7px 12px; font-size: 14px;
}
.m-actions button:hover { background: var(--bubble); }
.m-actions button.danger { color: #c0392b; }
.m-actions button.danger:hover { background: #fdecea; border-color: #f1b0a8; }
.m-actions button.on { border-color: var(--accent); color: var(--accent); }

/* 숨긴 파일 칩 + 비밀번호 창 */
.chip.lock { border-style: dashed; }
.chip.lock.on { background: #3b3a36; border-color: #3b3a36; color: #fff; border-style: solid; }
.files { position: relative; }
/* 파일 목록 가운데 연한 안내(목록 글자 뒤에 깔림, 클릭·끌기 방해 안 함) */
.drop-hint {
  position: absolute; left: 0; right: 0; top: 55%; transform: translateY(-50%);
  text-align: center; font-size: 17px; font-weight: 700; line-height: 1.5; color: var(--muted);
  opacity: .28; pointer-events: none; user-select: none; z-index: 0;
}
.drop-hint svg { display: block; width: 40px; height: 40px; margin: 0 auto 6px; }
.files-list { position: relative; z-index: 1; }
.files.hidden-mode .drop-hint { display: none; }
.files.hidden-mode { background: #ecebe7; }
@media (prefers-color-scheme: dark) { .files.hidden-mode { background: #34342f; } }

/* 숨긴 파일 보는 중: 왼쪽 가운데 픽셀 화살표 '안 숨긴 파일로' */
.back-arrow {
  position: absolute; left: 0; top: 50%; transform: translate(calc(-100% - 8px), -50%); z-index: 4;
  border: 0; padding: 0; background: none; cursor: pointer; line-height: 0;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.18)); transition: transform .15s;
}
.back-arrow[hidden] { display: none; }
.back-arrow:hover { transform: translate(calc(-100% - 14px), -50%); }
.back-arrow .label {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: #fff; font-size: 13px; font-weight: 700; line-height: 1; white-space: nowrap; letter-spacing: -0.02em;
}
/* 좁은 화면(서랍형)에서는 칸 밖이 화면 밖이라 칸 위쪽 머리 줄 옆에 둔다 */
@media (max-width: 900px) {
  .back-arrow { top: 12px; left: auto; right: 48px; transform: scale(.8); transform-origin: right top; }
  .back-arrow:hover { transform: scale(.8) translateX(-4px); }
}
.hidden-banner { margin: 0 18px 10px; font-size: 13px; color: var(--muted); }
.pw-card {
  width: 100%; max-width: 340px; background: var(--surface); border-radius: 18px;
  padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 10px;
}
.pw-title { font-size: 18px; font-weight: 700; }
.pw-sub { margin: 0; color: var(--muted); font-size: 14px; }
.pw-card input {
  padding: 12px 14px; font-size: 17px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); outline: none;
}
.pw-card input:focus { border-color: var(--accent); }
.pw-row { display: flex; gap: 8px; justify-content: flex-end; }
.pw-row .btn-primary { padding: 10px 18px; font-size: 15px; }
.pw-cancel { border: 0; background: none; color: var(--muted); padding: 10px 14px; border-radius: 12px; }

/* 변경 이력 노드 그래프 */
.history { position: relative; margin: 20px; }
.history svg.edges { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.history svg.edges path { fill: none; stroke: var(--line); stroke-width: 2; }
.history svg.edges path.branch { stroke: var(--accent); stroke-dasharray: 5 4; }
.hnode {
  position: absolute; width: 190px; height: 70px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  padding: 8px 10px; font-size: 13px; line-height: 1.4; box-shadow: var(--shadow);
}
.hnode .t { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.hnode .d { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hnode.file .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hnode.file { border-width: 2px; border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.hnode.file .nm { font-weight: 600; overflow-wrap: anywhere; }
.hnode.file .ext { width: 26px; height: 26px; font-size: 8px; border-radius: 7px; }
.hnode.focus { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.hnode.file.clickable { cursor: pointer; }
.hnode.ev-delete { border-color: #f1b0a8; background: #fdecea; color: #a8322a; }
.hnode.ev-hide { background: #ecebe7; }
.hnode.ev-convert { border-color: var(--accent); }
.hnode.ev-analyze { border-color: #7c6ce0; background: #f1effc; }
@media (prefers-color-scheme: dark) {
  .hnode.ev-delete { background: #3a2220; color: #f1a39a; border-color: #6b3530; }
  .hnode.ev-hide { background: #33332f; }
  .hnode.ev-analyze { background: #2b2840; border-color: #5b4fb0; }
  .m-actions button.danger:hover { background: #3a2220; border-color: #6b3530; }
}
.m-panelbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px 8px 18px; border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--muted);
}
.m-panelbar[hidden] { display: none; }
.m-panelbar button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 6px 12px; font-size: 14px; font-weight: 600;
}
.m-panelbar button:hover { border-color: var(--accent); color: var(--accent); }
.modal-card.history-mode .m-choice,
.modal-card.history-mode .m-actions,
.modal-card.history-mode .m-convert { display: none; }
.history-bar {
  position: sticky; top: 0; left: 0; z-index: 6; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.history-bar button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 6px 12px; font-size: 14px; font-weight: 600;
}
.history-bar button:hover { border-color: var(--accent); }
.node-busy {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
}
.node-busy .spinner { width: 26px; height: 26px; border-width: 3px; }
.hnode.busy { pointer-events: none; }
.hnode.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.hnode.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.hnode.ev-restore { border-color: #2f9e6b; background: #e9f7f0; }
.hnode.ev-made { border-color: #d4a017; background: #fdf6e0; }
@media (prefers-color-scheme: dark) { .hnode.ev-made { background: #3a3220; border-color: #8a6d1a; } }
@media (prefers-color-scheme: dark) { .hnode.ev-restore { background: #1f3a2e; border-color: #2f7a55; } }
.node-menu {
  position: absolute; z-index: 5; min-width: 180px; max-width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 6px; display: flex; flex-direction: column;
}
.node-menu .nm-ev { font-size: 12px; color: var(--muted); padding: 6px 8px 0; }
.node-menu .nm-title { font-size: 13px; font-weight: 700; padding: 6px 8px 6px; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.node-menu .nm-note { font-size: 13px; color: var(--muted); padding: 6px 8px; }
.node-menu button {
  text-align: left; border: 0; background: none; color: var(--text);
  padding: 7px 8px; border-radius: 8px; font-size: 14px;
}
.node-menu button:hover:not(:disabled) { background: var(--bubble); }
.node-menu button:disabled { opacity: .5; }
.node-menu button.danger { color: #c0392b; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: 15px;
  box-shadow: var(--shadow); animation: toast 2.4s ease forwards;
}
@keyframes toast { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 900px) {
  .files-toggle { display: inline-block; }
  .files {
    position: fixed; top: 0; right: 0; z-index: 10; box-shadow: var(--shadow);
    transform: translateX(100%); transition: transform .2s ease;
    max-width: 86vw;
  }
  .files.open { transform: none; }
  .files-close { display: block; }
}

@media (max-width: 600px) {
  .welcome { margin-top: 12vh; }
  .welcome h2 { font-size: 26px; }
}
