/* M1 최소 화면. 3단 틀(상단·왼쪽·가운데·오른쪽)만 잡고 내용은 M3에서 채운다(해석안 R-08). */
:root {
  --bg: #f6f6f4; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e2e1dc;
  --accent: #1f4fd1; --mine: #d9731a; --wait: #4a4a46; --alert: #b3261e; --ok: #1e7a3c;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.btn { display: inline-block; padding: .45rem .9rem; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; font: inherit; cursor: pointer; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--accent); }
.btn-link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
.inline-form { display: inline; }
.stack { display: grid; gap: .75rem; max-width: 24rem; margin-bottom: 1rem; }
.stack label { display: grid; gap: .25rem; font-size: .9rem; }
.stack label > input, .stack label > select { width: 100%; min-width: 0; }
.row { display: flex; gap: .5rem; align-items: center; }
input[type=text], input[type=email], input[type=password], select { padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.copy-field { width: 100%; max-width: 40rem; }
.flash { padding: .6rem .8rem; border-radius: 6px; margin: 0 0 1rem; }
.flash ul { margin: 0; padding-left: 1.2rem; }
.flash-notice { background: #e8f3ec; color: var(--ok); }
.flash-alert { background: #fbeaea; color: var(--alert); }
.list { padding-left: 1.2rem; }
.table { border-collapse: collapse; width: 100%; background: var(--panel); }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); font-size: .92rem; }

/* 로그인·초대 같은 바깥 화면 */
.plain-main { max-width: 32rem; margin: 3rem auto; padding: 2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }

/* 워크스페이스 안 3단 */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .spacer { flex: 1; }
.ws-switch { display: flex; gap: .75rem; align-items: baseline; font-size: .92rem; }
.columns { display: grid; grid-template-columns: 14rem minmax(0, 1fr) 20rem; min-height: calc(100vh - 3rem); }
.left, .right { background: var(--panel); padding: 1rem; }
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
.left nav { display: grid; gap: .4rem; margin: .5rem 0 1rem; }
.ws-name { font-weight: 600; margin: 0; }
.center { padding: 1.5rem 2rem; }
@media (max-width: 900px) { .columns { grid-template-columns: 1fr; } .right { display: none; } }

/* ---- M3: 과제 화면 ---- */
:root { --mine: #d9731a; --wait: #4a4a46; --agent: #1f5fd1; --done-c: #1d1d1b; --soon: #b3261e; }
.topbar .count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: var(--mine); color: #fff; font-size: .78rem; text-align: center; }
.topbar .unread { display: inline-block; min-width: 1.2em; padding: 0 .3em; border-radius: 999px; background: #e2e1dc; font-size: .72rem; text-align: center; }
.topbar .crumb { color: var(--muted); font-size: .9rem; }
.inbox-btn { text-decoration: none; color: var(--text); }
.side-nav { display: grid; gap: .3rem; margin: .5rem 0 1rem; }
.side-h { font-size: .8rem; color: var(--muted); margin: 1rem 0 .3rem; }
.task-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .15rem; }
.task-list a { display: flex; justify-content: space-between; gap: .4rem; padding: .3rem .4rem; border-radius: 6px; color: var(--text); text-decoration: none; font-size: .9rem; }
.task-list a.active, .task-list a:hover { background: var(--bg); }
.t-proj { display: block; }
details.proj summary { cursor: pointer; font-weight: 600; margin-top: .6rem; font-size: .9rem; }
.legend { margin-top: 1.5rem; display: grid; gap: .2rem; }
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; white-space: nowrap; }
.badge .dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; }
.badge-mine .dot { background: var(--mine); } .badge-mine { color: var(--mine); }
.badge-wait .dot { background: var(--wait); }
.badge-agent .dot { background: var(--agent); } .badge-agent { color: var(--agent); }
.badge-done .dot, .badge-idle .dot { background: #c9c8c2; }
.task-head h1 { margin: .1rem 0 .3rem; }
.task-head .goal { margin: 0 0 .4rem; }
.status-lines { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; margin: .6rem 0 1rem; font-size: .9rem; }
.status-lines p { margin: .1rem 0; }
.soon, .due-soon, .due-late { color: var(--soon); }
.flow { display: grid; gap: .5rem; }
.flow-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; }
.flow-pending { opacity: .6; }
.flow-current { border-color: var(--agent); }
.flow-title { margin: 0; font-weight: 600; }
.flow-title .num { display: inline-block; width: 1.4em; height: 1.4em; border-radius: 50%; background: var(--bg); text-align: center; font-size: .8rem; }
.flow-state { font-weight: 400; font-size: .8rem; color: var(--muted); margin-left: .3rem; }
.flow-calls { display: grid; gap: .35rem; align-content: start; }
.substep { display: inline-block; padding: 0 .4rem; margin-right: .2rem; border-radius: 999px; background: var(--bg); color: var(--muted); }
.substep.on { background: var(--agent); color: #fff; }
.chip { display: grid; gap: .1rem; padding: .4rem .55rem; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: .85rem; border-left: 4px solid var(--wait); }
.chip-mine { border-left-color: var(--mine); } .chip-mine .chip-who { color: var(--mine); font-weight: 600; }
.chip-rejected { border-left-color: var(--soon); }
.chip-decided { border-left-color: var(--done-c); opacity: .8; }
.chip-who { font-size: .75rem; color: var(--muted); }
.chip-due { font-size: .72rem; color: var(--muted); }
.history h2, .thread h2 { font-size: 1.05rem; margin: .3rem 0; }
.events { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .6rem; }
.event { border-bottom: 1px solid var(--line); padding-bottom: .5rem; font-size: .88rem; }
.event p { margin: .1rem 0; }
.ev-follow { margin: .2rem 0 0 .6rem; padding-left: .6rem; border-left: 2px solid var(--line); list-style: none; }
.band { padding: .4rem .6rem; border-radius: 6px; font-size: .85rem; margin: .4rem 0; background: var(--bg); }
.band-mine { background: #fbe9da; color: var(--mine); font-weight: 600; }
.band-done { background: var(--done-c); color: #fff; }
.band-rejected { background: #fbeaea; color: var(--soon); }
.card { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; background: #fff; margin: .5rem 0; }
.card .q { font-weight: 600; margin-top: 0; }
.options { border: 0; padding: 0; margin: 0; display: grid; gap: .3rem; }
.opt { display: block; font-size: .9rem; }
.recommend { background: #eaf0fc; padding: .3rem .5rem; border-radius: 6px; }
.policy p { margin: .15rem 0; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.compare img { max-width: 100%; border: 1px solid var(--line); }
.decided { background: var(--bg); border-radius: 8px; padding: .6rem; }
.versions { margin: .6rem 0; }
.old-version { border-left: 2px solid var(--line); padding-left: .5rem; margin: .3rem 0; }
.messages { margin-top: 1rem; }
.msg { margin: .3rem 0; }
.msg-me { text-align: right; }
.msg-body { display: inline-block; padding: .35rem .6rem; border-radius: 10px; background: #f1f1ee; margin: 0; font-size: .88rem; }
.msg-me .msg-body { background: #1d1d1b; color: #fff; }
.msg-lead .msg-body { background: #eaf0fc; }
.msg-who { margin: 0; color: var(--muted); }
.inbox-panel { position: absolute; right: 1rem; top: 3.2rem; width: 26rem; max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .8rem; z-index: 10; }
.inbox-head { display: flex; gap: .5rem; align-items: baseline; justify-content: space-between; margin-bottom: .5rem; }
.inbox-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.inbox-list a { display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem; padding: .4rem; border-radius: 6px; text-decoration: none; color: var(--text); font-size: .88rem; }
.inbox-list li.unread a { background: #fbe9da; }
.ib-kind { font-weight: 600; font-size: .78rem; }
.ib-time { grid-column: 2; }
.right { overflow-y: auto; max-height: calc(100vh - 3rem); }
.stack label.opt { display: flex; align-items: center; gap: .45rem; }
.stack label.opt > input { width: auto; }
.turn .task-list a { flex-direction: column; gap: 0; }
.ib-form { margin: 0; }
.ib-open { display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem; width: 100%; padding: .4rem; border: 0; border-radius: 6px; background: none; text-align: left; font: inherit; color: var(--text); cursor: pointer; font-size: .88rem; }
.inbox-list li.unread .ib-open { background: #fbe9da; }
/* 결정 카드는 스레드를 내려도 위에 고정(02 "결정 카드(맨 위 고정)") */
.thread #decision-card, .thread #decided { position: sticky; top: 0; z-index: 2; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
/* 근거 인용(M6 K-12) */
.citation { margin: .4rem 0; padding: .4rem .6rem; border-left: 3px solid var(--muted); background: rgba(0,0,0,.025); }
.citation p { margin: 0 0 .25rem; white-space: pre-wrap; }
.citation .warn, .warn { color: #a3361e; }
.knowledge-table td, .knowledge-table th { vertical-align: top; }
/* 설정 탭(M7 S-01) */
.tabs { display: flex; flex-wrap: wrap; gap: .2rem; border-bottom: 1px solid var(--line); margin: .6rem 0 1rem; }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--muted); }
.tabs a.on { color: var(--text); font-weight: 700; box-shadow: inset 0 -2px 0 var(--text); }
.routing-table select, .routing-table input[type=number] { max-width: 11rem; }
.fixed-row td { color: var(--muted); }
