:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f4f4f0;
  --border: #e4e3dd;
  --text: #1a1918;
  --muted: #76746d;
  --accent: #b1542f;
  --accent-soft: #fdf1ea;
  --user-bg: #efefe9;
  --warn-bg: #fff8ea;
  --warn-border: #e8c98a;
  --ok: #3f7d4f;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
          "Noto Sans KR", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a18;
    --surface: #232321;
    --surface-2: #2b2b28;
    --border: #393834;
    --text: #ececea;
    --muted: #9a988f;
    --accent: #e08a62;
    --accent-soft: #33261f;
    --user-bg: #2f2f2b;
    --warn-bg: #332a18;
    --warn-border: #6b5526;
    --ok: #7fba8c;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }

.app {
  display: grid; grid-template-columns: minmax(0,1fr) 332px;
  height: 100%; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
}

/* --- 채팅 --- */
.chat { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--border); }
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.dot.live { background: var(--ok); }
.dot.busy { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.bar-actions { display: flex; align-items: center; gap: 10px; }
.cost { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cost.warn { color: var(--accent); font-weight: 600; }

.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 5px 11px; border-radius: 8px; font-size: 13px;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }
.ghost.sm { padding: 2px 8px; font-size: 12px; }

.log { flex: 1; overflow-y: auto; padding: 24px 20px 8px; scroll-behavior: smooth; }
.log > * + * { margin-top: 18px; }

.empty { text-align: center; padding: 10vh 0; }
.empty-title { color: var(--muted); font-size: 16px; margin: 0 0 20px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggest button {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 7px 13px; border-radius: 999px; font-size: 13px;
}
.suggest button:hover { border-color: var(--accent); color: var(--accent); }

.msg { max-width: 760px; }
.msg.user {
  margin-left: auto; background: var(--user-bg); padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 4px var(--radius); width: fit-content;
  max-width: min(78%, 620px); white-space: pre-wrap; word-break: break-word;
}
.msg.bot { word-break: break-word; }
.msg.bot > :first-child { margin-top: 0; }
.msg.bot > :last-child { margin-bottom: 0; }
.msg.bot p { margin: 0 0 .7em; }
.msg.bot ul, .msg.bot ol { margin: 0 0 .7em; padding-left: 1.3em; }
.msg.bot li { margin: .2em 0; }
.msg.bot h1, .msg.bot h2, .msg.bot h3 { font-size: 1.02em; margin: 1.1em 0 .4em; }
.msg.bot code {
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px;
  font: 13px/1.5 var(--mono);
}
.msg.bot pre {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 13px; overflow-x: auto;
}
.msg.bot pre code { background: none; padding: 0; }
.msg.bot table {
  border-collapse: collapse; width: 100%; font-size: 14px; margin: 0 0 .7em;
  display: block; overflow-x: auto;
}
.msg.bot th, .msg.bot td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.msg.bot th { background: var(--surface-2); font-weight: 600; }
.msg.bot a { color: var(--accent); }
.msg.bot blockquote {
  margin: 0 0 .7em; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted);
}

.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  font-size: 12px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px;
}
.chip.run::after { content: "…"; }

.caret {
  display: inline-block; width: 7px; height: 1.05em; vertical-align: text-bottom;
  background: var(--accent); margin-left: 2px; animation: blink .9s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* --- 승인 카드 --- */
.confirm {
  border: 1px solid var(--warn-border); background: var(--warn-bg);
  border-radius: var(--radius); padding: 14px 16px; max-width: 760px;
}
.confirm h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.confirm .detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; white-space: pre-wrap; margin-bottom: 10px;
  word-break: break-word;
}
.confirm .steps { margin: 0 0 12px; padding-left: 1.2em; font-size: 13px; color: var(--muted); }
.confirm .steps code { font: 12px/1.5 var(--mono); }
.confirm .row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 7px 15px; font-size: 14px;
}
.btn.go { background: var(--accent); color: #fff; }
.btn.go:hover { filter: brightness(1.08); }
.btn.no { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.no:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.verdict { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.err {
  border: 1px solid #c75c4a; background: #fdecea; color: #8a2b1c;
  border-radius: 8px; padding: 10px 13px; font-size: 13px; white-space: pre-wrap;
  max-width: 760px; word-break: break-word;
}
@media (prefers-color-scheme: dark) { .err { background: #3a1f1a; color: #f0a99c; border-color: #7e3a2c; } }

/* --- 입력 --- */
.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 20px 18px; border-top: 1px solid var(--border); background: var(--bg);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); padding: 11px 13px;
  font: inherit; max-height: 220px; overflow-y: auto;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer button[type=submit] {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  width: 42px; height: 42px; display: grid; place-items: center; flex: none;
}
.composer button[type=submit]:disabled { opacity: .4; cursor: default; }

/* --- 사이드바 --- */
.side { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { font-size: 13px; margin: 0; font-weight: 650; letter-spacing: .01em; }
.week-nav { display: flex; gap: 4px; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }

.week { display: flex; flex-direction: column; gap: 2px; }
.day { display: grid; grid-template-columns: 46px 1fr; gap: 8px; padding: 5px 0; border-top: 1px solid var(--border); }
.day:first-child { border-top: none; }
.day.today .dlabel { color: var(--accent); font-weight: 700; }
.day.weekend .dlabel { color: var(--muted); }
.dlabel { font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.devents { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ev { font-size: 12.5px; display: flex; gap: 6px; min-width: 0; }
.ev time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.allday span { background: var(--accent-soft); border-radius: 4px; padding: 0 5px; }
.none { font-size: 12px; color: var(--border); }

.todo ul { margin: 0; padding-left: 1.1em; font-size: 13.5px; }
.todo li { margin: .25em 0; }
.todo li.done { color: var(--muted); text-decoration: line-through; }
.todo h4 { font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.todo h4:first-child { margin-top: 0; }

/* ─── 허브 추가 ─── */
.gate { max-width: 420px; margin: 18vh auto; text-align: center; }
.gate h1 { font-size: 20px; margin: 0 0 10px; }
.gate p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.gate a {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  padding: 9px 18px; border-radius: 9px; font-size: 14px;
}

.pitem {
  display: grid; grid-template-columns: 22px 1fr; gap: 9px; align-items: start;
  padding: 9px 0; border-top: 1px solid var(--border);
}
.pitem:first-of-type { border-top: none; }
.pitem input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--accent); }
.pitem .ptext { min-width: 0; }
.pitem .plabel { font-size: 14px; word-break: break-word; }
.pitem .pmeta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.pitem.dup .plabel::after {
  content: " 중복 의심"; font-size: 11px; color: var(--accent);
  background: var(--accent-soft); border-radius: 4px; padding: 1px 5px; margin-left: 5px;
}
.confirm .rowsel {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); margin: 2px 0 8px;
}
.confirm .rowsel button {
  background: none; border: none; color: var(--accent); font-size: 12px; padding: 0 4px;
}
.presult { font-size: 13px; margin-top: 8px; }
.presult div { padding: 2px 0; }
.presult .bad { color: #c75c4a; }

.apps { display: flex; flex-wrap: wrap; gap: 6px; }
.apps a {
  font-size: 12px; text-decoration: none; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
  display: inline-flex; align-items: center; gap: 5px;
}
.apps a:hover { color: var(--text); border-color: var(--muted); }
.apps .led { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.apps .led.up { background: var(--ok); }
.apps .led.down { background: #c75c4a; }
