@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;600;900&display=swap');

:root {
  --ink: #1a1815;
  --accent: #9b1c1c;
  --paper: #f7f4ec;
  --line: #d8d2c4;
  --muted: #6b655a;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: 'Noto Serif KR', Georgia, serif;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
a { color: inherit; }

/* 컨트롤 바 */
.controls {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  justify-content: center; margin-bottom: 18px;
}
.controls input[type="text"] {
  font-family: inherit; font-size: .95rem; padding: 8px 12px;
  border: 1px solid var(--ink); background: #fff; min-width: 200px;
}
.controls input[type="number"] { width: 64px; padding: 8px; border: 1px solid var(--ink); }
.btn {
  font-family: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
  padding: 8px 16px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
}
.btn:hover { background: #000; }
.btn.ghost { background: #fff; color: var(--ink); }
.btn.ghost:hover { background: #efe9dc; }

/* 마스트헤드 */
.masthead { text-align: center; }
.dateline {
  font-size: .76rem; letter-spacing: .12em; color: var(--muted);
  text-transform: uppercase; border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink); padding: 6px 0; margin-bottom: 14px;
  display: flex; justify-content: space-between;
}
.paper-name { font-weight: 900; font-size: 3rem; margin: 6px 0 2px; letter-spacing: -.02em; }
.tagline { font-style: italic; color: var(--muted); font-size: .95rem; margin-bottom: 8px; }
.rule-double { border-top: 3px double var(--ink); margin: 8px 0 18px; }

/* 인덱스 통계 바 */
.indexbar {
  display: flex; justify-content: center; flex-wrap: wrap;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 10px 0; margin-bottom: 22px;
}
.indexbar .item { padding: 0 26px; text-align: center; border-right: 1px solid var(--line); }
.indexbar .item:last-child { border-right: none; }
.indexbar .num { font-weight: 900; font-size: 1.6rem; line-height: 1; }
.indexbar .lbl { font-size: .72rem; letter-spacing: .1em; color: var(--muted);
  text-transform: uppercase; margin-top: 5px; }

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--ink); margin-bottom: 18px; }
.tab {
  font-family: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
  padding: 8px 18px; border: none; background: none; color: var(--muted);
}
.tab.active { color: var(--ink); border-bottom: 3px solid var(--accent); margin-bottom: -2px; }
.panel { display: none; }
.panel.active { display: block; }

/* 지면 필터 */
.filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filter button {
  font-family: inherit; font-size: .82rem; cursor: pointer; padding: 4px 12px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.filter button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 기사 그리드 */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }
.article { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.article .photo {
  width: 100%; height: 200px; object-fit: cover; display: block;
  border: 1px solid var(--line); margin-bottom: 10px;
  filter: grayscale(15%) contrast(1.03); transition: filter .2s;
}
.article .photo:hover { filter: none; }
.kicker { font-size: .72rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.headline { font-weight: 700; font-size: 1.28rem; line-height: 1.34;
  text-decoration: none; display: block; }
.headline:hover { text-decoration: underline; }
.lede { color: #34302a; font-size: .98rem; line-height: 1.6; margin: 8px 0;
  border-left: 3px solid var(--line); padding-left: 12px; }
.byline { font-size: .78rem; color: var(--muted); }
.byline .dot { margin: 0 7px; color: var(--line); }

/* 차트 (CSS 막대) */
.section-h { font-weight: 900; font-size: 1.1rem; border-bottom: 2px solid var(--ink);
  padding-bottom: 4px; margin: 4px 0 16px; }
.barrow { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: .9rem; }
.barrow .name { width: 80px; text-align: right; color: var(--muted); }
.barrow .track { flex: 1; background: #eae4d6; height: 20px; }
.barrow .fill { height: 100%; background: var(--ink); }
.barrow .val { width: 36px; font-weight: 700; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; }
@media (max-width: 720px) { .charts { grid-template-columns: 1fr; } }

/* 데스크(에이전트) */
.desk-examples { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.desk-examples button { font-family: inherit; font-size: .82rem; cursor: pointer;
  padding: 6px 12px; border: 1px solid var(--line); background: #fff; }
.desk-input { display: flex; gap: 8px; margin-bottom: 16px; }
.desk-input input { flex: 1; font-family: inherit; padding: 8px 12px; border: 1px solid var(--ink); }
.desk-meta { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.desk-answer { background: #fff; border: 1px solid var(--line); padding: 16px 18px; line-height: 1.7; }
.desk-answer a { color: var(--accent); }

.empty { color: var(--muted); font-style: italic; padding: 24px 0; text-align: center; }
.spinner { color: var(--muted); }

/* 우측 플로팅 챗봇 위젯 */
.chatbot { position: fixed; right: 22px; bottom: 22px; z-index: 999; }
.chatbot-toggle {
  display: flex; align-items: center; gap: 8px;
  font-family: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
  padding: 13px 20px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
  border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.chatbot-toggle:hover { background: #000; }
.chatbot.open .chatbot-toggle { display: none; }
.chatbot-panel {
  display: none; flex-direction: column;
  position: fixed; right: 22px; bottom: 92px; width: 370px; height: 540px; max-height: 72vh;
  background: var(--paper); border: 1px solid var(--ink);
  box-shadow: 0 14px 36px rgba(0,0,0,.24);
}
.chatbot.open .chatbot-panel { display: flex; }
.chatbot-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 2px solid var(--ink); font-weight: 900; font-size: .98rem;
}
.chatbot-close {
  font-family: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
  border: none; background: none; color: var(--muted);
}
.chatbot-close:hover { color: var(--ink); }
.chatbot-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.chatbot .msg { max-width: 86%; padding: 9px 13px; font-size: .87rem; line-height: 1.65; }
.chatbot .msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.chatbot .msg.user { align-self: flex-end; background: var(--ink); color: #fff; }
.chatbot .msg .meta { display: block; font-size: .7rem; color: var(--muted); margin-top: 7px; }
.chatbot .msg.user .meta { color: #cfc9bc; }
.chatbot .msg a { color: var(--accent); }
.chatbot-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.chatbot-quick button {
  font-family: inherit; font-size: .74rem; cursor: pointer; padding: 5px 10px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.chatbot-quick button:hover { border-color: var(--ink); color: var(--ink); }
.chatbot-input { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.chatbot-input input { flex: 1; font-family: inherit; font-size: .87rem; padding: 8px 10px; border: 1px solid var(--ink); background: #fff; }
.chatbot-input .btn { padding: 8px 16px; font-size: .8rem; }

@media (max-width: 480px) {
  .chatbot { right: 12px; bottom: 12px; }
  .chatbot-panel { right: 12px; left: 12px; width: auto; bottom: 82px; }
}
