/* ============================================================
   moim.bio 실시간 정보 — tools.css 위에 얹는다.
   tools.css 가 먼저 오고(색·글꼴·머리말·꼬리말·카드) 여기는
   /live/ 에만 있는 것만 정의한다. 두 곳에 같은 규칙을 두지 않는다.
   ============================================================ */

/* ── 기준 시각 ─────────────────────────────────────────────
   페이지에서 숫자 다음으로 중요한 정보다. 작게 두되 숨기지는 않는다. */

.stamp {
  margin: -0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--fg-dim);
}

.stamp time { font-variant-numeric: tabular-nums; }

.stamp a { color: inherit; }

/* ── 큰 숫자 ───────────────────────────────────────────────
   대표 지표 하나를 크게 세운다. 나머지는 표에서 본다. */

.live { margin: 1.5rem 0 0; }

.big {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.big-label { font-size: 0.9rem; color: var(--fg-dim); width: 100%; }

.big-value {
  font-size: clamp(1.9rem, 1.2rem + 3vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

/* ── 등락 ──────────────────────────────────────────────────
   색만으로 방향을 나타내지 않는다. ▲▼ 기호를 항상 함께 둔다
   (색각 이상과 흑백 인쇄에서 색은 사라진다). */

.delta { font-size: 0.95rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up   { color: var(--err); }
.delta.down { color: var(--ok); }
.delta.flat { color: var(--fg-dim); }

/* ── 표 ────────────────────────────────────────────────────
   좁은 화면에서 가로로 민다. 칸을 줄여 숫자를 접는 것보다 낫다. */

.table-scroll { overflow-x: auto; margin: 1.25rem 0 0; }

.rates {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.rates th, .rates td {
  padding: 0.62rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rates th { font-size: 0.82rem; color: var(--fg-dim); font-weight: 600; }
.rates thead th { border-bottom: 1px solid var(--line-strong); }
.rates th:first-child, .rates td:first-child { text-align: left; font-variant-numeric: normal; }
.rates tbody tr:last-child td { border-bottom: 0; }
.rates .cur { font-weight: 600; }
.rates .cur small { display: block; font-weight: 400; font-size: 0.78rem; color: var(--fg-dim); }
.rates .main td { background: var(--bg-sunken); }

/* ── 환산기 ────────────────────────────────────────────────
   숫자를 보러 온 사람의 다음 행동이 "그래서 얼마지" 라서 바로 밑에 둔다. */

.conv {
  margin: 1.5rem 0 0;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.conv h2 { font-size: 1.02rem; margin: 0 0 0.75rem; }

.conv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.conv input[type="text"], .conv select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.conv input[type="text"] { flex: 1 1 9rem; min-width: 7rem; text-align: right; }
.conv .eq { color: var(--fg-dim); }

.conv-out {
  flex: 1 1 100%;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  padding-top: 0.15rem;
}

.conv-note { margin: 0.6rem 0 0; font-size: 0.8rem; color: var(--fg-dim); }

.tool-grid .empty {
  list-style: none;
  color: var(--fg-dim);
  font-size: 0.88rem;
}

/* ── 추이 그림 ─────────────────────────────────────────────
   스크립트 없이 SVG 하나로 그린다. preserveAspectRatio 를 껐으므로
   폭이 변해도 높이는 그대로다 — 좁은 화면에서 그래프가 납작해질 뿐
   레이아웃이 흔들리지 않는다. */

.spark {
  position: relative;
  margin: 1.25rem 0 0;
  padding: 0.9rem 1rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.spark figcaption {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-bottom: 0.5rem;
}

.spark svg {
  display: block;
  width: 100%;
  height: 90px;
  color: var(--fg);
  opacity: 0.85;
}

/* 최저·최고를 눈금 대신 양 끝에 적는다. 축을 그리면 이 크기에서는 어지럽다. */
.spark-lo, .spark-hi {
  position: absolute;
  right: 1rem;
  font-size: 0.75rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.spark-hi { top: 2.6rem; }
.spark-lo { bottom: 0.5rem; }

/* ── 지역 표 ───────────────────────────────────────────────
   제목에 최저·최고를 넣는다. 표를 다 읽지 않아도 답이 보여야 한다. */

.sido { margin: 2rem 0 0; }
.sido h2 {
  font-size: 1.02rem;
  line-height: 1.5;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.sido .table-scroll { margin-top: 0; }

/* ── 채팅 ──────────────────────────────────────────────────
   라이브에서 유일하게 서버가 붙는 화면이다. 다른 페이지와 같은 얼굴을
   쓰되, 대화는 아래로 흐르므로 목록만 따로 스크롤한다. */

.chat { margin: 1.25rem 0 0; }

.chat-log {
  list-style: none;
  margin: 0;
  padding: 0.9rem 1rem;
  height: min(58vh, 30rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-size: 0.95rem;
}

.chat-log li {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 0.15rem 0.5rem;
  padding: 0.28rem 0;
}

.chat-log b { font-weight: 600; }
.chat-log time { font-size: 0.75rem; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
/* 본문은 줄바꿈을 살린다. 아주 긴 낱말은 잘라 넘긴다 — 안 그러면 가로가 밀린다. */
.chat-log span { white-space: pre-wrap; overflow-wrap: anywhere; }

/* 좁은 화면에서는 이름 줄과 본문 줄을 나눈다. 셋을 한 줄에 두면 본문이 눌린다. */
@media (max-width: 32rem) {
  .chat-log li { grid-template-columns: auto 1fr; }
  .chat-log span { grid-column: 1 / -1; }
}

/* 빈 안내는 상자 밖이 아니라 상자 한가운데 둔다. 밖에 두면 큰 빈 칸이 먼저
   보여서 화면이 고장 난 것처럼 읽힌다. 클릭은 통과시킨다. */
.chat-box { position: relative; }
.chat-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--fg-dim);
  pointer-events: none;
}

.chat-form { margin: 0.9rem 0 0; display: grid; gap: 0.6rem; }

.chat-who { display: flex; align-items: center; gap: 0.5rem; }
.chat-who label { font-size: 0.82rem; font-weight: 600; white-space: nowrap; }

.chat-say { display: flex; gap: 0.5rem; align-items: stretch; }

.chat-form input[type="text"], .chat-form textarea {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.chat-who input[type="text"] { max-width: 14rem; }

.chat-form button {
  flex: 0 0 auto;
  padding: 0 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.chat-form button:hover { opacity: 0.88; }
.chat-form button:disabled { opacity: 0.45; cursor: default; }

.chat-note { margin: 0; min-height: 1.2em; font-size: 0.82rem; color: var(--fg-dim); }
.chat-note.bad { color: var(--err); }

/* ── 금리 곡선 ─────────────────────────────────────────────
   추이 그림(.spark)과 달리 축 글자가 들어간다. preserveAspectRatio 를
   기본값으로 두어 글자가 늘어나지 않게 한다 — 대신 높이가 폭을 따라간다. */

.curve {
  margin: 1.25rem 0 0;
  padding: 0.9rem 1rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.curve figcaption { font-size: 0.85rem; color: var(--fg-dim); margin-bottom: 0.4rem; }

.curve svg { display: block; width: 100%; height: auto; color: var(--fg); }
.curve svg polyline { opacity: 0.85; }
.curve .c-x, .curve .c-y {
  font-size: 11px;
  font-family: var(--ko);
  fill: currentColor;
  opacity: 0.5;
}

/* 장단기 차이 한 줄. 표보다 위에 두어 먼저 읽히게 한다. */
.note {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--line-strong);
  background: var(--bg-sunken);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  line-height: 1.65;
}

/* 값이 멈춰 있을 때. 사고가 아니라 알림이라 빨간 딱지를 쓰지 않는다 —
   출처가 죽었을 때의 .err 와 눈에 띄는 정도가 같으면 둘을 구별할 수 없다. */
.note.stale {
  margin: 0.75rem 0 0;
  color: var(--fg-dim);
}

/* ── 대기질 등급 ───────────────────────────────────────────
   에어코리아 관례색을 따르되, 색만으로 나타내지 않는다 — 딱지 안에
   '좋음·보통·나쁨' 글자가 늘 함께 있다. 색각 이상과 흑백 인쇄에서
   색은 사라지지만 글자는 남는다. */

.aq {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid currentColor;
}
.aq--good  { color: #1b6ec2; }
.aq--fair  { color: #197a4b; }
.aq--bad   { color: #b06000; }
.aq--worst { color: #b3261e; }
.aq--none  { color: var(--fg-dim); font-weight: 400; }

@media (prefers-color-scheme: dark) {
  .aq--good  { color: #79b8ff; }
  .aq--fair  { color: #5bc98d; }
  .aq--bad   { color: #ffb454; }
  .aq--worst { color: #ff8a80; }
}

/* 큰 숫자 옆의 단위는 숫자보다 작고 흐리게 */
.big-value small { font-size: 0.42em; font-weight: 500; opacity: 0.55; margin-left: 0.25em; }

/* ── 날씨 ──────────────────────────────────────────────────
   대기질 딱지와 같은 모양을 쓴다. 두 페이지가 나란히 놓이는데
   딱지 모양이 다르면 같은 종류의 정보가 아닌 것처럼 읽힌다. */

.wx {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid currentColor;
}
.wx--clear    { color: #b06000; }
.wx--cloudy   { color: #5a6675; }
.wx--overcast { color: #4a5260; }
.wx--rain     { color: #1b6ec2; }
.wx--snow     { color: #1b6ec2; }
.wx--none     { color: var(--fg-dim); font-weight: 400; }

@media (prefers-color-scheme: dark) {
  .wx--clear    { color: #ffb454; }
  .wx--cloudy   { color: #a8b3c1; }
  .wx--overcast { color: #93a0b0; }
  .wx--rain     { color: #79b8ff; }
  .wx--snow     { color: #79b8ff; }
}
