/* 메일 도우미 화면. 기본 서식은 견적 계산기와 같은 app.css를 쓰고, 메일 화면에만 쓰는 것을 여기 둔다. */

/* 메일 쓰기: 왼쪽 대화·고르기, 오른쪽 편집기 */
.write{display:grid;grid-template-columns:minmax(360px,460px) 1fr;gap:20px;align-items:start}
.write > *{min-width:0}
.chat-log{background:var(--tint);border-radius:4px;padding:10px;min-height:160px;max-height:46vh;overflow:auto;margin-bottom:8px;font-size:13px}
.chat-log .q{margin:8px 0 4px;font-weight:600;white-space:pre-wrap}
.chat-log .q::before{content:"나 ";color:var(--sub);font-weight:400}
.chat-log .a{padding:6px 10px;border-left:3px solid var(--line);margin-bottom:10px;background:#fff;border-radius:0 4px 4px 0}
.chat-log .a .text{white-space:pre-wrap;line-height:1.55}
.chat-log .a .err{color:var(--seal);margin:0}
.chat-log .cite{color:var(--focus);text-decoration:none;font-size:12px}
.chat-log .ev{margin-top:6px;padding:6px 8px;background:var(--tint);border-radius:4px;font-size:12px}
.chat-log .ev pre{white-space:pre-wrap;font:inherit;margin:4px 0 0;color:var(--sub)}
.chat-log .drafted{display:inline-block;margin-top:6px;font-size:12px;color:var(--ok)}
.chat textarea,.polish textarea{width:100%}
.polish .row{display:flex;gap:8px;align-items:center;margin-top:6px;flex-wrap:wrap}
.chat .row,.stages-head{display:flex;gap:8px;align-items:center;margin-top:6px}

.stages{display:flex;flex-direction:column;gap:2px;margin-top:10px;max-height:44vh;overflow:auto}
.stage{display:grid;grid-template-columns:34px 1fr;gap:8px;align-items:center;text-align:left;border:none;border-left:2px solid var(--line);border-radius:0;padding:6px 8px;background:none}
.stage:hover{background:var(--tint);border-left-color:var(--ink)}
.stage .ord{font-size:11px;color:var(--sub);font-variant-numeric:tabular-nums}
.stage .nm{font-size:13px}
.stage .st{display:block;font-size:11px;color:var(--sub)}

.editor{position:sticky;top:72px}
.fmtbar{display:flex;flex-wrap:wrap;gap:3px;align-items:center;margin-top:10px;padding:4px;background:var(--tint);border-radius:4px 4px 0 0;border:1px solid var(--line);border-bottom:none}
.fmtbar button{padding:3px 8px;font-size:12px;min-width:28px}
.fmtbar button[aria-pressed="true"]{background:var(--ink);color:#fff;border-color:var(--ink)}
.fmtbar .sep{width:1px;height:18px;background:var(--line);margin:0 3px}
.fmtbar .grow{flex:1}
.mailbody{min-height:52vh;max-height:70vh;overflow:auto;border:1px solid var(--line);border-radius:0 0 4px 4px;padding:14px 16px;background:#fff;outline:none}
.mailbody:focus-visible{outline:2px solid var(--focus);outline-offset:-1px}
.mailbody table td:focus-within,.mailbody table th:focus-within{outline:1px dashed var(--focus)}
.mailbody .hole,.preview .hole{background:#FBE3A6;border-radius:2px;box-shadow:0 0 0 1px #E4CFA6}
#ed-src{width:100%;min-height:52vh;border-radius:0 0 4px 4px;font-family:Consolas,"D2Coding",monospace;font-size:13px;line-height:1.6}
.holes{display:flex;flex-wrap:wrap;gap:4px;align-items:center;margin:8px 0;padding:8px;background:#FBF3E4;border-radius:4px;font-size:12px;color:#7A5418}
.holes[hidden]{display:none}
button:disabled{opacity:.45;cursor:not-allowed}
.holes button{border-color:#E4CFA6;background:#fff;border-radius:12px;padding:2px 9px;font-size:12px}
.ed-info{color:var(--sub);margin:6px 0 10px;display:flex;flex-direction:column;gap:3px}
.ed-info b{color:var(--ink);font-weight:500}

/* 템플릿 */
.tpl-wrap{display:grid;grid-template-columns:minmax(280px,360px) 1fr;gap:16px;align-items:start}
.tpl-wrap > *{min-width:0}
.tpl-list{background:#fff;border-radius:6px;padding:8px;max-height:calc(100vh - 150px);overflow:auto;position:sticky;top:72px}
.tpl-list h4{margin:10px 6px 4px;font-size:12px;color:var(--sub);font-weight:500}
.tpl-list .stage[aria-current="true"]{background:var(--tint);border-left-color:var(--ink)}
.tpl-list .src{font-size:10px;color:var(--sub);margin-left:4px}
.tpl-edit textarea{width:100%}
.tpl-edit textarea[data-t="body"]{min-height:46vh;line-height:1.6}
.varbar{display:flex;flex-wrap:wrap;gap:4px;margin:6px 0}
.varbar button{font-size:11px;padding:2px 7px;border-radius:10px;background:var(--tint);border-color:transparent}
.varbar button.snip{background:#E8EEF4;color:#3D5A80}
.preview{background:#fff;border:1px solid var(--line);border-radius:4px;padding:12px;font-size:13px;line-height:1.6;margin-top:8px}
.preview .subj{font-weight:600;margin-bottom:8px}

/* 사건 */
.case-wrap{display:grid;grid-template-columns:1fr minmax(320px,420px);gap:16px;align-items:start}
.case-wrap > *{min-width:0}
.case-wrap .panel{position:sticky;top:72px}
table.tbl tr.pick{cursor:pointer}
table.tbl tr.pick:hover td{background:var(--tint)}
table.tbl tr.sel td{background:#EEF3F8}
.tag.sent{background:#E6F0EA;color:var(--ok)}

/* 문체·서식 */
.style-grid textarea{width:100%;min-height:70px}
.learn{margin-top:10px}
.learn .cand{border:1px solid var(--line);border-radius:4px;padding:8px;margin-bottom:6px;background:#fff}
.learn .cand pre{white-space:pre-wrap;font:inherit;font-size:12px;color:var(--sub);margin:6px 0 0;max-height:160px;overflow:auto}

#pasteDlg{width:min(760px,94vw)}
#pasteDlg textarea{margin-bottom:10px}
#pasteDlg .row{align-items:center}

@media (max-width:1000px){
  .write,.tpl-wrap,.case-wrap{grid-template-columns:1fr}
  .editor,.tpl-list,.case-wrap .panel{position:static}
  .tpl-list{max-height:40vh}
}

/* 템플릿 편집: 서식 단추 + 기호 원문 + 바로 보기 */
.tpl-edit .fmtbar{margin-top:6px}
.tpl-edit textarea[data-t="body"]{border-radius:0 0 4px 4px;font-family:Consolas,"D2Coding",monospace;font-size:13px}
.tpl-cols{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.tpl-cols > *{min-width:0}
.tpl-cols .preview{margin-top:6px;max-height:60vh;overflow:auto}
.syntax{font-size:11px;color:var(--sub);margin:4px 0 0}
.syntax code{background:var(--tint);padding:0 3px;border-radius:2px}
@media (max-width:1200px){.tpl-cols{grid-template-columns:1fr}}

/* 첨부 링크 */
.files{display:flex;flex-wrap:wrap;gap:4px 10px;margin-top:4px}
a.file{color:var(--focus);font-size:12px;text-decoration:none}
a.file::before,.file.muted::before{content:"📎 "}
a.file:hover{text-decoration:underline}
.docrow{padding:6px 0;border-top:1px solid var(--line)}

/* 규칙 점검 */
.lint{margin:8px 0;padding:8px 10px;border-radius:4px;background:#FDECEA;color:#8A2A1F;font-size:12px}
.lint[hidden]{display:none}
.lint.ok{background:#E6F0EA;color:var(--ok)}
.lint li{margin:2px 0}
.lint ul{margin:4px 0 0;padding-left:18px}
.mailbody div[data-li]{margin:0}
.rules-link{color:var(--focus);text-decoration:none;margin-right:10px;white-space:nowrap}
.rules-link:hover{text-decoration:underline}
