/* AI 분석 page. Tokens mirror styles.css; layout is independent of the overview workspace. */
:root{--ink:#16191d;--muted:#727b88;--line:#e7e9ed;--bg:#f5f6f8;--yellow:#fff100;--green:#00836d;--red:#ca5864;--side:260px;--panel:380px;--bar:52px;--strip:50px}
*{box-sizing:border-box}
html,body{height:100%}
body.chat-view{margin:0;background:var(--bg);color:var(--ink);font:14px/1.5 Wanted,Arial,sans-serif;overflow:hidden}
button,input,select,textarea{font:inherit}button{border:0;background:none;cursor:pointer;color:inherit;-webkit-tap-highlight-color:transparent}a{color:inherit;text-decoration:none}h1,h2,h3,p{margin:0}
button:focus-visible,a:focus-visible,select:focus-visible,textarea:focus-visible{outline:3px solid #a89900;outline-offset:3px}
button:disabled{opacity:.45;cursor:default}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.muted{color:var(--muted)}

/* Header: same bar as the other modes. */
.chat-view .view-bar{height:var(--bar);min-height:var(--bar);padding:0 24px;gap:20px;border-color:var(--line)}
.chat-view .view-product{gap:9px}.chat-view .view-product b{font:780 13px Archivo,Wanted,sans-serif}
.chat-view .work-monogram{display:grid;place-items:center;width:29px;height:30px;border-radius:5px;padding:0 3px 3px 0;background:var(--yellow);color:#242a30;font:850 26px Archivo,Wanted,sans-serif;letter-spacing:-3px}
.chat-view .work-product-title{font-size:12px;font-weight:600;color:#5f6a75;padding-left:12px;border-left:1px solid var(--line)}
.chat-view .header-quarter{display:flex;align-items:center;gap:8px;font-size:10px;color:#84898e;white-space:nowrap}
.chat-view .header-quarter select{border:0;background:#f6f7f8;border-radius:6px;padding:8px 7px;font-size:11px;font-weight:600;color:#41474c;max-width:140px}

/* Scope strip under the header. */
.scope-strip{position:fixed;top:var(--bar);left:0;right:0;z-index:1300;height:var(--strip);display:flex;align-items:center;gap:14px;padding:0 24px;background:#fff;border-bottom:1px solid var(--line);font-size:11px;color:var(--muted);overflow-x:auto}
.scope-strip label{display:flex;align-items:center;gap:7px;white-space:nowrap}
.scope-strip select{border:1px solid var(--line);background:#fff;border-radius:6px;padding:6px 8px;font-size:12px;font-weight:600;color:#30363c;max-width:170px}
.side-toggle{display:none}
.scope-status{margin-left:auto;white-space:nowrap}.scope-status:empty{display:none}
.scope-status button{text-decoration:underline}
.area-chip{display:flex;align-items:center;gap:6px;padding:5px 6px 5px 10px;border-radius:999px;background:#fffbcc;border:1px solid #efe68a;color:#44400a;font-size:11px;white-space:nowrap}
.area-chip[hidden]{display:none}.area-chip strong{color:#16191d}.area-chip button{width:20px;height:20px;border-radius:50%;background:#f3eb9a;font-size:13px;line-height:1}

/* Three columns: history, thread, evidence. */
.chat-shell{display:flex;height:100vh;padding-top:calc(var(--bar) + var(--strip))}
.chat-side{flex:none;width:var(--side);display:flex;flex-direction:column;background:#fff;border-right:1px solid var(--line);padding:16px 12px}
.new-chat{width:100%;padding:11px 12px;border:1px solid #cfd3d8;border-radius:8px;background:#fff;font-weight:650;font-size:13px;text-align:left}
.new-chat:hover{background:#f7f8f9}
.side-label{margin:20px 12px 8px;font:600 10px Archivo,Wanted,sans-serif;letter-spacing:1px;color:#8d98a3}
.history-list{list-style:none;margin:0;padding:0;flex:1;overflow-y:auto}
.history-list li{display:flex;align-items:stretch;border-radius:7px}
.history-list li.active{background:#f1f2f4}
.history-list li:hover{background:#f5f6f8}
.history-list li.empty{padding:10px 12px;font-size:12px;color:var(--muted)}
.history-list [data-open]{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;padding:9px 12px;text-align:left}
.history-list [data-open] strong{font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.history-list [data-open] small{font-size:10px;color:var(--muted)}
.history-list .delete{width:26px;color:#9aa3ad;font-size:14px;opacity:0}
.history-list li:hover .delete,.history-list li:focus-within .delete{opacity:1}
.side-bottom{display:flex;flex-direction:column;gap:2px;margin-top:12px;padding-top:12px;border-top:1px solid var(--line)}
.side-bottom button,.side-bottom .related-analysis{display:block;padding:8px 12px;border-radius:6px;text-align:left;font-size:12px;color:#5f6a75;text-decoration:none}
.side-bottom button:hover,.side-bottom .related-analysis:hover{background:#f5f6f8;color:var(--ink)}
.side-bottom .related-analysis{margin-top:6px;padding-top:10px;border-top:1px dashed var(--line);border-radius:0 0 6px 6px}

.chat-main{flex:1;min-width:0;display:flex;flex-direction:column;overflow-y:auto;padding:0 24px}
.chat-main>*{width:100%;max-width:860px;margin-left:auto;margin-right:auto}
.hero{display:none;text-align:center;padding:64px 0 28px}
.wordmark{display:block;font:800 11px Archivo,Wanted,sans-serif;letter-spacing:3px;color:#8d98a3;margin-bottom:14px}
.hero h1{font-size:28px;font-weight:720;letter-spacing:-.8px}
.hero p{margin-top:10px;font-size:13px;color:var(--muted)}
.thread{flex:1;display:flex;flex-direction:column;gap:22px;padding:28px 0 24px}
.intents{display:none;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;padding:0 0 32px}
.intents button{display:flex;flex-direction:column;gap:5px;padding:14px;border:1px solid var(--line);border-radius:10px;background:#fff;text-align:left}
.intents button:hover{border-color:#b9bfc7;background:#fffdf0}
.intents strong{font-size:13px;font-weight:650}.intents small{font-size:11px;color:var(--muted);line-height:1.4}
body.empty .hero{display:block}body.empty .intents{display:grid}body.empty .thread{flex:none;padding:0}
body.empty .composer{position:static}

/* Composer */
.composer{position:sticky;bottom:0;display:grid;grid-template-columns:1fr auto;gap:0 10px;padding:14px 0 18px;background:linear-gradient(#f5f6f800,var(--bg) 30%)}
.composer textarea{width:100%;min-height:54px;max-height:200px;resize:vertical;padding:14px 16px;border:1px solid #cfd3d8;border-radius:12px;background:#fff;line-height:1.5}
.composer textarea:focus{border-color:#8f949b}
.send{align-self:end;width:46px;height:46px;border-radius:12px;background:var(--yellow);color:#16191d;font-size:20px;font-weight:700;box-shadow:0 1px 2px #0000001a}
.send:hover{background:#f0e300}
.privacy{grid-column:1/-1;margin-top:8px;font-size:10px;line-height:1.5;color:#8d98a3;text-align:center}

/* Messages */
.msg.user{align-self:flex-end;max-width:78%;padding:11px 15px;border-radius:14px 14px 4px 14px;background:#24282d;color:#fff;white-space:pre-wrap;word-break:break-word}
.msg.assistant{display:flex;flex-direction:column;gap:12px;padding:18px 20px;border:1px solid var(--line);border-radius:14px;background:#fff}
.stages{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px;font-size:12px;color:var(--muted)}
.stages li{display:flex;align-items:center;gap:9px}
.stages li.done{color:#9aa3ad}
.stages li i{width:12px;height:12px;flex:none;border-radius:50%;border:2px solid #c9ced4}
.stages li.done i{border-color:var(--green);background:var(--green);background-clip:content-box;padding:2px}
.stages li.live{color:var(--ink)}
.stages li.live i{border-color:#d9c400;border-top-color:transparent;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.scope{font-size:11px;color:var(--muted)}
.query-chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{padding:4px 10px;border-radius:999px;border:1px solid #d9dde2;background:#f8f9fa;font-size:11px;font-weight:600;color:#3b424a}
.chip.sort{border-color:#e8dc3b;background:#fffbcc;color:#44400a}
.chip.edit{cursor:pointer;border-style:dashed;background:#fff}.chip.edit[aria-expanded="true"]{border-color:#16191d}
/* Inline query editor; mirrors the map finder builder but stays self-contained. */
.chat-builder{display:flex;flex-direction:column;gap:6px;margin:8px 0 10px;padding:10px;border:1px solid var(--line);border-radius:8px;background:#f8f9fa}
.finder-filter{display:grid;grid-template-columns:minmax(0,1fr) 64px 130px 32px;gap:6px;align-items:center}
.finder-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px}.finder-sort{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:#4b545b}
.chat-builder select,.chat-builder input{min-height:32px;padding:4px 8px;border:1px solid #d5dbe0;border-radius:6px;background:#fff;font:12px Wanted,Arial,sans-serif;color:#202326;min-width:0}
.finder-input{display:flex;align-items:center;gap:4px;min-width:0}.finder-input input{flex:1;width:0}.finder-input b{font-size:11px;color:var(--muted);white-space:nowrap}
.finder-remove{width:30px;height:30px;border:1px solid #d5dbe0;border-radius:6px;background:#fff;font-size:14px;line-height:1}.finder-add{padding:6px 10px;border:1px dashed #b9c0c7;border-radius:6px;background:#fff;font-size:12px;font-weight:600}.finder-add[disabled]{opacity:.4}
.finder-note{margin:2px 0 0;font-size:11px;line-height:1.6;color:var(--muted)}
.evidence-note{margin:0 0 6px;padding:6px 10px;border-radius:6px;background:#fffbcc;font-size:11px;color:#44400a}
p.unverified{border-left:3px solid #e0a800;padding-left:10px}.warn{display:inline-block;margin-left:6px;padding:2px 7px;border-radius:999px;background:#fff3cd;color:#6b4e00;font-size:11px;font-weight:600;cursor:help}
.evidence-label{font-size:11px;color:var(--muted);margin-bottom:6px}
.evidence-empty{font-size:12px;color:var(--muted)}
.evidence-table{overflow-x:auto}
.evidence-table table{width:100%;border-collapse:collapse;font-size:12px}
.evidence-table th{text-align:left;font-weight:600;font-size:10px;color:var(--muted);padding:6px 8px;border-bottom:1px solid var(--line);white-space:nowrap}
.evidence-table td{padding:8px;border-bottom:1px solid #f0f1f3;white-space:nowrap;vertical-align:middle}
.evidence-table tr[data-href]{cursor:pointer}.evidence-table tr[data-href]:hover{background:#fafbfc}
.evidence-table td strong{display:block;font-weight:600}.evidence-table td small{font-size:10px;color:var(--muted)}
.evidence-table td a{font-size:11px;color:#5f6a75;text-decoration:underline}
.up{color:var(--green)}.down{color:var(--red)}
.answer{display:flex;flex-direction:column;gap:10px}
.answer-top{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.answer h2{font-size:17px;font-weight:700;letter-spacing:-.4px}
.answer p{line-height:1.65}
.badge{padding:3px 8px;border-radius:999px;background:#eef0f2;color:#5f6a75;font-size:10px;font-weight:600}
.cites{display:inline}
.cite{display:inline-block;vertical-align:baseline;margin:0 2px 2px 0;padding:1px 7px;border-radius:999px;border:1px solid #d9dde2;background:#f8f9fa;font-size:10px;font-weight:600;color:#3b424a;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.6}
.cite:hover{border-color:#e8dc3b;background:#fffbcc}
.cite.plain{border-style:dashed;color:var(--muted)}
.followups{display:flex;flex-wrap:wrap;gap:6px}
.followups button{padding:7px 12px;border:1px solid #cfd3d8;border-radius:999px;background:#fff;font-size:12px}
.followups button:hover{background:#fffbcc;border-color:#e8dc3b}
.actions{display:flex;align-items:center;gap:14px;padding-top:6px;border-top:1px solid #f0f1f3;font-size:10px;color:#9aa3ad}
.actions span{margin-left:auto}
.text-btn{padding:0;font-size:11px;color:#68727d;white-space:nowrap}.text-btn:hover{color:#111}
.clarification p{color:#44400a}
.error p{color:var(--red)}
.retry{align-self:flex-start;padding:7px 12px;border:1px solid var(--line);border-radius:7px;background:#fff;font-size:12px;font-weight:600}

/* Evidence panel */
.evidence-panel{flex:none;width:var(--panel);display:flex;flex-direction:column;background:#fff;border-left:1px solid var(--line);animation:slide .18s ease-out}
.evidence-panel[hidden]{display:none}
@keyframes slide{from{transform:translateX(24px);opacity:0}to{transform:none;opacity:1}}
.panel-head{display:flex;align-items:center;justify-content:space-between;padding:16px 18px 10px;font-size:13px}
.panel-close{width:28px;height:28px;border-radius:50%;font-size:18px;line-height:1;color:#5f6a75}.panel-close:hover{background:#f1f2f4}
.panel-tabs{display:flex;flex-wrap:wrap;gap:6px;padding:0 18px 12px;border-bottom:1px solid var(--line)}
.panel-tabs button{padding:5px 10px;border-radius:999px;border:1px solid #d9dde2;background:#f8f9fa;font-size:11px;font-weight:600;color:#3b424a}
.panel-tabs button[aria-selected=true]{background:var(--yellow);border-color:#e8dc3b;color:#16191d}
.panel-body{flex:1;overflow-y:auto;padding:16px 18px 24px;display:flex;flex-direction:column;gap:16px}
.fact-text{font-size:13px;line-height:1.7}
.area-card{display:flex;flex-direction:column;gap:4px;padding:14px;border:1px solid var(--line);border-radius:10px;background:#fafbfc}
.area-card strong{font-size:14px}.area-card small{font-size:11px;color:var(--muted)}
.area-card dl{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:10px 0 0}
.area-card dl div{display:flex;flex-direction:column;gap:2px}.area-card dt{font-size:10px;color:var(--muted)}.area-card dd{margin:0;font-size:13px;font-weight:650}
.area-links{display:flex;flex-wrap:wrap;gap:12px;margin-top:10px;font-size:12px}
.area-links a{text-decoration:underline;color:#3b424a}

/* Dialogs & toast */
dialog#helpDialog{width:min(520px,calc(100% - 32px));padding:24px;border:1px solid var(--line);border-radius:12px;background:#fff;color:var(--ink)}
dialog#helpDialog::backdrop{background:#0006}
.dialog-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.overline{font:600 10px Archivo,Wanted,sans-serif;letter-spacing:1px;color:#8d98a3}
.close{width:30px;height:30px;border-radius:50%;font-size:18px;line-height:1}.close:hover{background:#f1f2f4}
#helpDialog h2{font-size:18px;margin-bottom:12px}#helpDialog ol{margin:0 0 12px;padding-left:20px;font-size:13px;line-height:1.7}#helpDialog .muted{font-size:11px}
#toast{position:fixed;bottom:25px;left:50%;transform:translateX(-50%);z-index:1500;width:max-content;max-width:90%;padding:12px 20px;border-radius:9px;background:#24282d;color:#fff;font-size:12px;text-align:center;box-shadow:0 8px 30px #0002;pointer-events:none;opacity:0;transition:opacity .2s}
#toast.visible{opacity:1}

@media(max-width:1200px){:root{--side:220px;--panel:340px}}
@media(max-width:1000px){.chat-view .view-help{display:none}.intents{grid-template-columns:1fr 1fr}}
@media(max-width:760px){
 :root{--strip:46px}
 .chat-view .view-bar{padding:0 12px;gap:10px;overflow-x:auto;scrollbar-width:none}.chat-view .view-product b,.chat-view .work-product-title,.chat-view .header-quarter span{display:none}.chat-view .data-notice-trigger{font-size:10px;padding:6px}
 .scope-strip{padding:0 12px;gap:8px;scrollbar-width:none}.scope-strip label{gap:4px}.scope-strip label>span{display:none}.scope-strip select{max-width:110px;padding:5px 6px;font-size:11px}
 .side-toggle{display:inline-flex;flex:none;padding:6px 9px;border:1px solid var(--line);border-radius:6px;font-size:11px;font-weight:600;color:#30363c}
 .chat-side{position:fixed;top:calc(var(--bar) + var(--strip));left:0;right:0;z-index:1200;max-height:calc(100vh - var(--bar) - var(--strip));width:100%;border-right:0;border-bottom:1px solid var(--line);box-shadow:0 12px 30px #0002;transform:translateY(-8px);opacity:0;visibility:hidden;transition:transform .18s,opacity .18s,visibility .18s}
 body.side-open .chat-side{transform:none;opacity:1;visibility:visible}
 .history-list{max-height:40vh}.history-list .delete{opacity:1}
 .chat-main{padding:0 12px}.thread{padding-top:16px}.msg.user{max-width:90%}.msg.assistant{padding:14px}
 .hero{padding:36px 0 20px}.hero h1{font-size:22px}.intents{grid-template-columns:1fr;padding-bottom:20px}
 .evidence-panel{position:fixed;left:0;right:0;bottom:0;z-index:1350;width:100%;max-height:70vh;border-left:0;border-top:1px solid var(--line);border-radius:14px 14px 0 0;box-shadow:0 -12px 30px #0002;animation:rise .2s ease-out}
 @keyframes rise{from{transform:translateY(24px);opacity:0}to{transform:none;opacity:1}}
}
@media(prefers-reduced-motion:reduce){.evidence-panel,.chat-side,.stages li.live i,#toast{animation:none!important;transition:none!important}}
