/* Claude 앱(Code 탭) 느낌 — 따뜻한 다크 톤 */
:root {
  --bg: #262624; --side: #1f1e1d; --panel: #30302e; --panel2: #3a3a37; --line: #44443f; --fg: #f0eee6; --muted: #a6a39a;
  --accent: #d97757; --accent2: #c6613f; --danger: #e5484d; --ok: #5bb26b; --warn: #e5a50a; --code: #1a1a18;
  --mono: "Cascadia Mono", "Cascadia Code", "D2Coding", Consolas, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover { background: var(--panel2); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent2); }
button.danger { background: #5a1d1f; border-color: var(--danger); color: #fff; }
.danger-text { color: #ff8a8d; }
button.icon { padding: 5px 9px; }
button.tiny { padding: 0 6px; font-size: 12px; }
button.wide { width: 100%; padding: 11px; margin-top: 6px; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { background: var(--side); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
input, select { width: 100%; margin-top: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; margin: 12px 0; color: var(--muted); font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--fg); }
label.check input { width: auto; margin-top: 5px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; color: var(--fg); }
.brand { font-weight: 650; font-size: 20px; }
.brand.small { font-size: 16px; }
.spark { color: var(--accent); }
.tag { font-size: .7em; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 0 5px; vertical-align: 2px; }
.msg { min-height: 1.4em; color: var(--warn); margin: 8px 0 0; }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.row.between { justify-content: space-between; align-items: center; margin-top: 0; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.spacer { flex: 1; }
.chip { font-size: 12px; color: var(--muted); padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.warn { color: #fff; background: #6b4a00; border-color: var(--warn); }

.screen { position: fixed; inset: 0; }
#login { display: grid; place-items: center; padding: 16px; overflow: auto; }
#login .card { width: 100%; max-width: 380px; }

/* 레이아웃 */
#main { display: flex; }
#side { width: 268px; flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px 10px; gap: 4px; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; }
.newbtn { text-align: left; background: transparent; border: 1px solid var(--line); margin-bottom: 8px; }
.side-sec { font-size: 12px; color: var(--muted); padding: 10px 8px 4px; display: flex; justify-content: space-between; align-items: center; }
.slist { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; }
#histList { flex: 1; }
.sitem { display: flex; align-items: center; gap: 8px; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 7px 8px; width: 100%; color: var(--fg); }
.sitem:hover { background: var(--panel); }
.sitem.active { background: var(--panel2); }
.sitem .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.sitem .sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.sitem .x { opacity: 0; font-size: 12px; padding: 0 4px; color: var(--muted); }
.sitem:hover .x { opacity: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); }
.dot.busy { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.side-bottom { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }

#pane { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); min-height: 52px; }
.title { min-width: 0; }
#chatTitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.path { font: 12px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#modeSel { width: auto; margin: 0; padding: 5px 8px; font-size: 13px; background: var(--panel); }
button.stop { background: var(--panel2); color: var(--fg); padding: 5px 10px; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* 대화 */
.msgs { flex: 1; overflow-y: auto; padding: 20px 16px 8px; }
.msgs > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.empty { color: var(--muted); text-align: center; margin-top: 18vh; }
.empty .big { font-size: 28px; color: var(--fg); margin-bottom: 6px; }
.u { display: flex; justify-content: flex-end; margin: 18px auto 10px; }
.u .bubble { background: var(--panel2); border-radius: 16px; padding: 10px 14px; max-width: 85%; white-space: pre-wrap; word-break: break-word; }
.u .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.a { margin: 8px auto; word-break: break-word; }
.a p { margin: 8px 0; }
.a h2, .a h3, .a h4, .a h5 { margin: 16px 0 6px; line-height: 1.3; }
.a ul, .a ol { padding-left: 22px; margin: 6px 0; }
.a a { color: #e3a184; }
.a blockquote { border-left: 3px solid var(--line); margin: 8px 0; padding: 2px 12px; color: var(--muted); }
.a code, .tool code { font: 13px var(--mono); background: var(--code); padding: 1px 5px; border-radius: 5px; }
.code { background: var(--code); border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; overflow: hidden; }
.code-h { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); padding: 4px 10px; border-bottom: 1px solid var(--line); }
.code-h .copy { padding: 1px 8px; font-size: 12px; }
.code pre { margin: 0; padding: 10px 12px; overflow-x: auto; }
.code pre code { background: none; padding: 0; }
.tbl { overflow-x: auto; } .tbl table { border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 4px 10px; text-align: left; }
.streaming { white-space: pre-wrap; }

.tool { margin: 4px auto; font-size: 13.5px; }
.tool .th { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); padding: 3px 0; }
.tool .th:hover { color: var(--fg); }
.tool .th .nm { color: var(--fg); font-weight: 600; flex: none; }
.tool .th .sm { font: 13px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tool .st { flex: none; width: 14px; text-align: center; }
.tool.run .st::before { content: "●"; color: var(--accent); animation: pulse 1s infinite; }
.tool.ok .st::before { content: "✓"; color: var(--ok); }
.tool.err .st::before { content: "✕"; color: var(--danger); }
.tool .tb { margin: 4px 0 8px 22px; border-left: 2px solid var(--line); padding-left: 10px; }
.tool pre { font: 12.5px/1.45 var(--mono); background: var(--code); border-radius: 8px; padding: 8px 10px; margin: 4px 0; overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-all; }
.diff .del { color: #ff9b9b; background: rgba(229,72,77,.12); display: block; }
.diff .add { color: #a6e3a1; background: rgba(91,178,107,.12); display: block; }
.todo { list-style: none; padding: 0; margin: 4px 0 8px 22px; }
.todo li { padding: 1px 0; } .todo .done { color: var(--muted); text-decoration: line-through; }
.todo .doing { color: var(--accent); }

.req { margin: 10px auto; border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; background: rgba(217,119,87,.07); }
.req.done { border-color: var(--line); background: transparent; opacity: .75; }
.req .q { font-weight: 600; margin-bottom: 6px; }
.req pre { font: 12.5px var(--mono); background: var(--code); border-radius: 8px; padding: 8px 10px; margin: 6px 0; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; }
.req .opts { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.req .opt { text-align: left; } .req .opt small { display: block; color: var(--muted); }
.req .opt.sel { border-color: var(--accent); background: rgba(217,119,87,.15); }
.note { text-align: center; color: var(--muted); font-size: 13px; margin: 12px auto; }
.note.bad { color: #ff9b9b; }
.typing { margin: 8px auto; color: var(--muted); font-size: 14px; }
.typing .spark { display: inline-block; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 6px; }

/* 입력창 */
.composer { margin: 0 auto 14px; width: calc(100% - 32px); max-width: 820px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 8px 10px 6px; }
.composer:focus-within { border-color: #6b6b64; }
.composer textarea { width: 100%; resize: none; border: 0; background: transparent; padding: 6px 6px; max-height: 40vh; line-height: 1.5; }
.composer textarea:focus { outline: none; }
.crow { display: flex; align-items: center; gap: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-left: 4px; }
.send { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); border: 0; color: #fff; font-weight: 700; padding: 0; }
.send:hover { background: var(--accent2); }
.atts { display: flex; flex-wrap: wrap; gap: 6px; }
.att { display: flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; font-size: 13px; max-width: 260px; }
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.att .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .rm { padding: 0 4px; background: transparent; border: 0; color: var(--muted); }
.att.up .n { color: var(--muted); } .att.bad { border-color: var(--danger); }
.drop { position: absolute; inset: 52px 0 0 0; background: rgba(217,119,87,.12); border: 2px dashed var(--accent); display: grid; place-items: center; font-size: 18px; z-index: 6; pointer-events: none; }

/* 터미널 보기 */
#termWrap { flex: 1; min-height: 0; padding: 6px 4px 2px 10px; background: #1a1915; }
#term { width: 100%; height: 100%; }
.keys { display: flex; gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); overflow-x: auto; }
.keys button { flex: none; font-size: 13px; }

.overlay { position: absolute; inset: 52px 0 0 0; display: grid; place-items: center; background: rgba(20,20,18,.75); z-index: 5; padding: 16px; }
.overlay .card { max-width: 440px; text-align: center; white-space: pre-line; }
dialog { max-width: min(520px, calc(100vw - 24px)); width: 100%; }
dialog.wide { max-width: min(760px, calc(100vw - 24px)); max-height: 86vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin: 4px 0 10px; }
.list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.item { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--side); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.item .meta { color: var(--muted); font-size: 12px; } .item.cur { border-color: var(--accent); }
.list.small .item { padding: 5px 10px; font-size: 12px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--accent); color: #fff; margin-left: 6px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 9px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }
.scrim { display: none; }
.only-sm { display: none; }

@media (max-width: 760px) {
  .only-sm { display: inline-block; }
  .hide-sm { display: none; }
  #side { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .18s; width: 82vw; max-width: 300px; }
  #side.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
  .bar { padding: 6px 8px; gap: 6px; }
  .msgs { padding: 12px 10px 6px; }
  .composer { width: calc(100% - 16px); margin-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .u .bubble { max-width: 92%; }
}
