:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000;
  --surface: #000;
  --green: #22b14c;
  --lime: #b5e61d;          /* 글자·테두리에 쓰는 강조색 (밝은 테마에서는 더 짙은 초록) */
  --fill: #b5e61d;          /* 버튼 바탕 강조색 */
  --fill-hover: #cdf350;
  --on-fill: #000;
  --text: #e6f4ea;
  --muted: #7fa38b;
  --err: #ff9d8a;
  --err-border: #d9674f;
  --err-text: #ffb4a4;
  --warn: #e8b04a;
  --code-bg: rgba(255, 255, 255, .09);
  --pre-bg: rgba(255, 255, 255, .07);
  --chip-bg: rgba(0, 0, 0, .25);
  --user-bg: rgba(181, 230, 29, .14);
  --user-border: rgba(181, 230, 29, .55);
  --overlay: rgba(0, 0, 0, .82);
  --plate: #e6f4ea;
  --plate-edge: transparent;
  --side-w: clamp(190px, 14.8vw, 280px);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6faf6;
  --surface: #fff;
  --green: #1d8f3d;
  --lime: #1f6f2f;
  --fill: #b5e61d;
  --fill-hover: #a3d312;
  --on-fill: #000;
  --text: #12261a;
  --muted: #4d6a57;
  --err: #b3321b;
  --err-border: #b3321b;
  --err-text: #9c2b17;
  --warn: #8a5a00;
  --code-bg: rgba(0, 0, 0, .07);
  --pre-bg: rgba(0, 0, 0, .05);
  --chip-bg: rgba(255, 255, 255, .7);
  --user-bg: rgba(110, 170, 10, .16);
  --user-border: rgba(31, 111, 47, .5);
  --overlay: rgba(246, 250, 246, .9);
  --plate-edge: var(--green);
}
/* 글자 크기: html 글자 크기를 바꾸면 rem 으로 쓴 글자가 모두 따라온다 */
:root { --fs: 1; }
:root[data-fs="s"] { --fs: .875; }
:root[data-fs="l"] { --fs: 1.125; }
:root[data-fs="xl"] { --fs: 1.3; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { font-size: calc(100% * var(--fs)); }
body {
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
button { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }

/* sidebar */
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 2px solid var(--green); background: var(--bg); }
.brand { padding: 20px 18px 12px; }
.brand img { display: block; width: 100%; max-width: 168px; height: auto; }
.history { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 10px; scrollbar-width: thin; scrollbar-color: var(--green) transparent; }
.history h2 { margin: 14px 8px 4px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.history .none { margin: 18px 8px; font-size: .875rem; color: var(--muted); }
.conv { position: relative; display: flex; align-items: center; margin: 2px 0; border: 1px solid transparent; border-radius: 10px; }
.conv:hover { background: rgba(34, 177, 76, .1); }
.conv.active { border-color: var(--green); background: rgba(34, 177, 76, .14); }
.conv-open { flex: 1; min-width: 0; padding: 8px 10px; background: none; border: 0; border-radius: 10px; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .875rem; }
.conv-del { flex: none; width: 30px; height: 30px; margin-right: 4px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; opacity: 0; }
.conv:hover .conv-del, .conv:focus-within .conv-del, .conv-del.confirm { opacity: 1; }
.conv-del:hover { color: var(--lime); }
.conv-del.confirm { width: auto; padding: 0 8px; font-size: .75rem; color: var(--on-fill); background: var(--fill); }
.side-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px 14px; }
.side-foot .gear { margin-left: auto; }
/* 로그인한 사람의 사진과 닉네임 */
.av { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: var(--surface); color: #fff; font-size: .8rem; font-weight: 700; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 10px 4px 4px; background: none; border: 0; border-radius: 999px; color: inherit; font: inherit; cursor: pointer; }
.who:hover { background: var(--hover); }
.who[hidden] { display: none; }
.who-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.acct-who .av { width: 40px; height: 40px; font-size: 1rem; }
.acct-who[hidden] + .row { border-top: 0; }
.ff-form { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 12px; }
.ff-form[hidden] { display: none; }
.ff-form label { font-size: .8125rem; color: var(--muted); }
.ff-form .mem-input { flex: none; }
.ff-msg { min-height: 1.2em; margin: 2px 0 0; font-size: .8rem; color: var(--lime); overflow-wrap: anywhere; }
.ff-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ff-new { margin-left: auto; font-size: .8125rem; color: var(--muted); }

/* buttons */
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; background: none; border: 0; border-radius: 50%; color: var(--lime); cursor: pointer; }
.icon-btn:hover { background: rgba(181, 230, 29, .12); }
.gear { color: var(--green); }
:is(button, textarea):focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }


/* main */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: var(--green) transparent; }
.empty { margin: auto; padding: 24px; display: grid; place-items: center; }
/* 캐릭터에 검은 칸이 있어 검은 배경에서는 묻히므로 밝은 판을 깐다 */
.empty .spr.big { box-sizing: border-box; display: block; width: min(46vmin, 336px); padding: 8px; outline-width: 2px; border-radius: 12%; }
.empty .spr.big svg { width: 100%; height: auto; }
.empty .spr.big > img { display: block; width: 100%; height: auto; image-rendering: pixelated; }   /* 자바스크립트가 그림을 바꾸기 전 잠깐만 보인다 */
.thread { width: min(780px, 100%); margin: 0 auto; padding: 28px 20px 12px; }
.msg { display: flex; margin: 14px 0; }
.msg.user { justify-content: flex-end; }
.msg.bot { flex-direction: column; align-items: flex-start; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.md { white-space: normal; }
.bubble.md > :first-child { margin-top: 0; } .bubble.md > :last-child { margin-bottom: 0; }
.bubble.md p { margin: 0 0 .7em; }
.bubble.md ul, .bubble.md ol { margin: 0 0 .7em; padding-left: 1.4em; }
.bubble.md li { margin: .15em 0; }
.bubble.md .md-h { font-weight: 700; margin: .9em 0 .4em; color: var(--lime); }
.bubble.md .md-h1 { font-size: 1.15em; } .bubble.md .md-h2 { font-size: 1.08em; }
.bubble.md code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; padding: 1px 5px; border-radius: 5px; background: var(--code-bg); }
.bubble.md pre { margin: 0 0 .7em; padding: 10px 12px; overflow-x: auto; border-radius: 10px; background: var(--pre-bg); white-space: pre; }
.bubble.md pre code { padding: 0; background: none; font-size: .9em; }
.bubble.md blockquote { margin: 0 0 .7em; padding: 2px 0 2px 12px; border-left: 3px solid rgba(34, 177, 76, .7); color: var(--muted); }
.bubble.md a { color: var(--lime); }
.bubble.md hr { border: 0; border-top: 1px solid rgba(34, 177, 76, .5); margin: .8em 0; }
.msg.user .bubble { background: var(--user-bg); border: 1px solid var(--user-border); }
.msg.bot .bubble { border: 1px solid rgba(34, 177, 76, .7); }
/* 답을 기다리는 동안: 말풍선 없이 상태줄만(- \ | / 가 돈다). 글이 오기 시작하면 말풍선이 나오고 끝에 블록 커서가 깜빡인다 */
.msg.bot.typing .bubble:empty { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0; border: 0; border-radius: 0; font: .8125rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK KR", monospace; color: var(--muted); }
.msg.bot.typing .bubble:empty::before { content: "-"; content: attr(data-spin) / ""; width: 1ch; text-align: center; color: var(--lime); font-weight: 700; }
.msg.bot.typing .bubble:empty::after { content: attr(data-label) / ""; }
.msg.bot.live .bubble:not(.md)::after,
.msg.bot.live .bubble.md > :is(p, h1, h2, h3, .md-h):last-child::after,
.msg.bot.live .bubble.md > :is(ul, ol):last-child > li:last-child::after { content: ""; display: inline-block; width: .56em; height: 1.05em; margin-left: 2px; vertical-align: -.17em; background: var(--lime); animation: blink 1.05s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer { padding: 0 24px 22px; }
.pill { display: flex; align-items: flex-end; gap: 6px; width: min(920px, 100%); margin: 0 auto; padding: 8px 10px; border: 2px solid var(--green); border-radius: 30px; background: var(--surface); }
.pill:focus-within { border-color: var(--lime); }
.pill textarea { flex: 1; min-width: 0; max-height: 168px; padding: 9px 6px; background: transparent; border: 0; outline: 0; resize: none; color: var(--text); font: inherit; line-height: 1.5; }
.pill textarea::placeholder { color: var(--muted); }
.send[disabled] { opacity: .35; cursor: default; }
.send[disabled]:hover { background: none; }

/* phone: the sidebar becomes a drawer */
.burger, .scrim { display: none; }
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(82vw, 300px); transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; padding-top: env(safe-area-inset-top); }
  .app.drawer .sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
  .scrim { position: fixed; z-index: 10; inset: 0; background: rgba(0, 0, 0, .6); }
  .app.drawer .scrim { display: block; }
  .burger { display: inline-grid; position: absolute; z-index: 5; top: 8px; left: 8px; border: 2px solid var(--green); background: var(--bg); }
  .composer { padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
  .thread { padding-top: 60px; }
  .empty .spr.big { width: min(80vw, 272px); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none !important; }
  .msg.bot.live .bubble::after, .msg.bot.live .bubble > :last-child::after, .msg.bot.live .bubble > :last-child > li:last-child::after, .spr .q { animation: none !important; }
}

/* 폴더 연결 */
.icon-btn.folder { color: var(--muted); }
.icon-btn.folder.on { color: var(--lime); }
.composer { position: relative; }
.folder-bar { width: min(920px, 100%); margin: 0 auto 6px; padding: 0 10px; }
.folder-chip { max-width: 100%; padding: 4px 12px; background: none; border: 1px solid var(--green); border-radius: 14px; color: var(--lime); font-size: .8125rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-chip:hover { background: rgba(34, 177, 76, .14); }
.folder-panel { position: absolute; z-index: 6; left: 50%; bottom: calc(100% - 12px); width: min(520px, calc(100% - 24px)); transform: translateX(-50%); max-height: 60vh; overflow-y: auto; padding: 12px 14px; background: var(--surface); border: 2px solid var(--green); border-radius: 14px; }
.fp-head { display: flex; align-items: center; gap: 8px; }
.fp-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-x { width: 30px; height: 30px; background: none; border: 0; color: var(--muted); font-size: 1.25rem; cursor: pointer; border-radius: 8px; }
.fp-note { margin: 6px 0; font-size: .8125rem; color: var(--muted); }
.fp-h { margin: 12px 0 4px; font-size: .75rem; font-weight: 600; color: var(--muted); }
.fp-acts { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.fp-btn { padding: 7px 14px; background: none; border: 1px solid var(--green); border-radius: 10px; font-size: .875rem; cursor: pointer; }
.fp-btn:hover:not([disabled]) { background: rgba(34, 177, 76, .16); }
.fp-btn.pri { background: var(--fill); border-color: var(--fill); color: var(--on-fill); font-weight: 600; }
.fp-btn.pri:hover:not([disabled]) { background: var(--fill-hover); }
.fp-btn.small { padding: 2px 10px; font-size: .75rem; border-radius: 8px; }
.fp-btn[disabled] { opacity: .5; cursor: default; }
.fp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid rgba(34, 177, 76, .35); }
.fp-path { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; font-size: .875rem; }
.fp-meta { font-size: .75rem; color: var(--muted); }
.fp-err { flex-basis: 100%; font-size: .8125rem; color: var(--err); }

/* 승인 카드 */
.bubble.approve { width: min(640px, 100%); max-width: 100%; white-space: normal; border-color: var(--lime); }
/* 출처 카드: 종류 아이콘 + 종류 이름 + 제목(2줄) + 라이선스 */
.sources.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 8px; width: 100%; max-width: 640px; margin-top: 10px; }
.card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px; border: 1px solid rgba(34, 177, 76, .7); border-radius: 12px; color: inherit; text-decoration: none; }
.card:hover, .card:focus-visible { background: rgba(34, 177, 76, .14); }
.card .top { display: flex; align-items: center; gap: 8px; }
.card .ic { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--tc, var(--lime)); background: color-mix(in srgb, var(--tc, var(--lime)) 16%, transparent); }
.card .ic svg { display: block; }
.card .kind { font: .6875rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK KR", monospace; color: var(--muted); letter-spacing: .03em; }
.card .ttl { font-size: .84rem; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card .lic { margin-top: auto; display: flex; justify-content: space-between; gap: 6px; font: .6875rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK KR", monospace; color: var(--muted); }
.card .lic span:first-child { padding: 2px 6px; border: 1px solid rgba(34, 177, 76, .7); border-radius: 5px; }
.card .lic .none { padding-left: 0; border-color: transparent; }
.t-site { --tc: var(--lime); } .t-game { --tc: var(--green); } .t-tool { --tc: var(--warn); } .t-wp { --tc: var(--muted); }
/* 말풍선 옆 작은 캐릭터(js/sprite.js). 말풍선은 그대로 두고 왼쪽 칸에 얹는다 */
.msg.bot.av { position: relative; padding-left: 40px; min-height: 34px; }
.msg.bot.av > .spr { position: absolute; left: 0; top: 0; }
.spr { display: inline-block; line-height: 0; background: var(--plate); outline: 1px solid var(--plate-edge); border-radius: 12%; flex: none; }
.spr svg { display: block; image-rendering: pixelated; }
.spr.sm { border-radius: 6px; }
.spr .q { position: absolute; right: -6%; top: -10%; display: grid; place-items: center; border-radius: 50%; background: var(--fill); color: var(--on-fill); font: 800 1em/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 2px solid var(--bg); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8%); } }
.msg.bot.info .bubble { border-style: dashed; color: var(--muted); }
.msg.bot.err .bubble { border-color: var(--err-border); color: var(--err-text); }
.ap-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-path { overflow-wrap: anywhere; }
.ap-tag { padding: 1px 8px; border-radius: 10px; font-size: .75rem; border: 1px solid var(--green); }
.ap-tag.over { border-color: var(--warn); color: var(--warn); }
.ap-why, .ap-stat, .ap-note { margin-top: 4px; font-size: .8125rem; color: var(--muted); }
.diff { margin-top: 8px; max-height: 320px; overflow: auto; border: 1px solid rgba(34, 177, 76, .5); border-radius: 8px; font: .7813rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK KR", monospace; }
.dl { display: flex; gap: 6px; padding: 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dl .dm { flex: none; width: 1ch; user-select: none; }
.dl.add { background: rgba(34, 177, 76, .22); }
.dl.del { background: rgba(217, 103, 79, .22); }
.dl.ctx { color: var(--muted); }
.dl.gap { color: var(--muted); font-style: italic; justify-content: center; background: var(--pre-bg); }
.ap-btns { display: flex; gap: 8px; margin-top: 10px; }
.ap-status { margin-top: 8px; font-size: .875rem; }
.ap-status.ok { color: var(--lime); }
.bubble.approve[data-state="rejected"] { border-color: #666; color: var(--muted); }
.bubble.approve[data-state="undone"] { border-color: #666; }

/* 새 대화 버튼(사이드바) */
.side-new { padding: 0 14px 6px; }
.side-new-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; background: none; border: 1px solid var(--green); border-radius: 10px; color: var(--lime); font-size: .875rem; cursor: pointer; }
.side-new-btn:hover { background: rgba(34, 177, 76, .14); }

/* 사진·파일 붙이기 */
.drop-hint { position: absolute; z-index: 8; inset: 8px; display: grid; place-items: center; border: 2px dashed var(--lime); border-radius: 18px; background: var(--overlay); color: var(--lime); font-size: 1.125rem; pointer-events: none; }
.attach-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: min(920px, 100%); margin: 0 auto 6px; padding: 0 10px; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 4px 3px 8px; border: 1px solid var(--green); border-radius: 14px; font-size: .8125rem; }
.att-thumb { flex: none; width: 28px; height: 28px; margin-left: -4px; object-fit: cover; border-radius: 8px; }
.att-name { min-width: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-cut { flex: none; font-size: .6875rem; color: var(--warn); }
.att-x { flex: none; width: 22px; height: 22px; padding: 0; background: none; border: 0; border-radius: 50%; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.att-x:hover { color: var(--lime); background: rgba(181, 230, 29, .12); }
.att-wait { font-size: .8125rem; color: var(--muted); }
.att-err { flex-basis: 100%; font-size: .8125rem; color: var(--err); }
.bubble .atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.bubble .atts:last-child { margin-bottom: 0; }
.bubble .att-chip { padding-right: 8px; background: var(--chip-bg); }
.bubble .att-thumb { width: 44px; height: 44px; margin-left: -4px; }

/* 설정 창 (시안 6-A: 왼쪽 탭) */
:root { --line: rgba(34, 177, 76, .7); --hover: rgba(34, 177, 76, .14); --scrim: rgba(0, 0, 0, .62); }
:root[data-theme="light"] { --line: rgba(29, 143, 61, .6); --hover: rgba(29, 143, 61, .12); --scrim: rgba(10, 25, 15, .45); }
html.modal-open, html.modal-open body { overflow: hidden; }
.modal { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--scrim); }
.dlg { width: min(720px, 100%); height: min(470px, 100%); display: flex; flex-direction: column; background: var(--surface); color: var(--text); border: 2px solid var(--green); border-radius: 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, .45); overflow: hidden; }
.dlg:focus { outline: none; }
.dh { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.dh h2 { margin: 0; flex: 1; font-size: 1.0625rem; }
.x { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.x:hover { background: var(--hover); color: var(--lime); }
.db { flex: 1; min-height: 0; display: grid; grid-template-columns: 168px minmax(0, 1fr); }
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-right: 1px solid var(--line); overflow-y: auto; }
.tabs button { padding: 8px 10px; background: none; border: 1px solid transparent; border-radius: 10px; text-align: left; font-size: .875rem; cursor: pointer; color: var(--muted); }
.tabs button:hover { background: var(--hover); }
.tabs button[aria-selected="true"] { border-color: var(--green); background: var(--hover); color: var(--text); font-weight: 600; }
.panes { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane { flex: 1; min-height: 0; padding: 16px 20px 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--green) transparent; }
.pane h4 { margin: 0 0 4px; font-size: .9375rem; }
.pane > p { margin: 0 0 12px; font-size: .8125rem; color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.row:first-of-type { border-top: 0; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-size: .875rem; font-weight: 600; }
.row .t > span { display: block; font-size: .78rem; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.btn { padding: 7px 14px; background: none; border: 1px solid var(--green); border-radius: 10px; font-size: .875rem; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.pri { background: var(--fill); border-color: var(--fill); color: var(--on-fill); font-weight: 600; }
.btn.pri:hover { background: var(--fill-hover); }
.btn.danger { border-color: var(--err-border); color: var(--err); }
.btn.danger.confirm { background: var(--err-border); color: var(--bg); }
.sw { flex: none; position: relative; width: 44px; height: 26px; border-radius: 999px; border: 2px solid var(--green); background: none; cursor: pointer; padding: 0; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.sw[aria-checked="true"] { background: var(--fill); border-color: var(--fill); }
.sw[aria-checked="true"]::after { transform: translateX(18px); background: var(--on-fill); }
.badge-exp { margin-left: 6px; padding: 1px 8px; border: 1px solid var(--warn); border-radius: 999px; font: .6875rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--warn); font-weight: 400; }
.set-field { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.set-field legend { padding: 0; margin-bottom: 6px; font-size: .875rem; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt { position: relative; display: block; }
.seg-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 7px 14px; border: 1px solid var(--green); border-radius: 10px; font-size: .875rem; }
.seg-opt:hover span { background: var(--hover); }
.seg-opt input:checked + span { background: var(--fill); border-color: var(--fill); color: var(--on-fill); font-weight: 600; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }
.sw:focus-visible, .tabs button:focus-visible, .btn:focus-visible, .x:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
@media (max-width: 760px) {
  .modal { padding: 0; place-items: stretch; }
  .dlg { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .dh { padding-top: calc(12px + env(safe-area-inset-top)); }
  .db { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .tabs { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 8px 10px; }
  .tabs button { white-space: nowrap; }
  .pane { padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); }
  .row { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .sw::after { transition: none; } }

/* 내 기억 */
.mem-toggle { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; cursor: pointer; }
.mem-toggle input { width: 18px; height: 18px; accent-color: var(--green); }
.mem-row .mem-text { flex: 1 1 160px; }
.mem-input { flex: 1 1 160px; min-width: 0; padding: 6px 10px; background: var(--surface); color: var(--text); border: 1px solid var(--green); border-radius: 10px; font: inherit; font-size: .875rem; }
.mem-input:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
.mem-pin.on { border-color: var(--lime); }
.mem-toast { position: absolute; z-index: 6; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); width: min(520px, calc(100% - 24px)); display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--lime); border-radius: 12px; font-size: .8125rem; }
.mem-toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
