/* totle chat 기본 스타일 — 리셋 · 타이포 · 포커스 · 공용 유틸리티 (docs/08 § 2.5~2.6, § 6).
 * 순서: <link rel="stylesheet" href="/assets/tokens.css"> → base.css → /ui/ui.css → 화면 스타일.
 */
@import url("./fonts/pretendard.css");

/* ── 리셋 ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul[role="list"], ol[role="list"], menu { list-style: none; padding: 0; margin: 0; }
img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
button, input, select, textarea, optgroup { font: inherit; color: inherit; letter-spacing: inherit; margin: 0; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
table { border-collapse: collapse; border-spacing: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-4) 0; }
[hidden] { display: none !important; }

/* ── 바탕 · 글자 ──────────────────────────────────────────────────── */
html {
  font-family: var(--font-sans);
  font-size: var(--t-md);
  line-height: var(--lh-md);
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  word-break: keep-all;          /* 한글은 어절 단위로 줄바꿈 */
  overflow-wrap: anywhere;        /* 긴 URL·이메일은 끊어서 */
  text-wrap: pretty;              /* 마지막 줄에 한 어절만 남지 않게(아래 "줄바꿈 가독성") */
}
body { min-height: 100dvh; }
code, kbd, samp, pre { font-family: var(--font-mono); font-size: .92em; }
::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }
::placeholder { color: var(--text-3); opacity: 1; }

/* 제목 기본값 — 화면에서 크기를 다시 정해도 된다 */
h1 { font-size: var(--t-2xl); line-height: var(--lh-2xl); font-weight: 700; }
h2 { font-size: var(--t-xl); line-height: var(--lh-xl); font-weight: 600; }
h3 { font-size: var(--t-md); line-height: var(--lh-md); font-weight: 600; }

/* 줄바꿈 가독성(docs/08 § 2.5, 12-04) — 한글은 어절 단위(html keep-all). 한글에 word-break: normal·break-all·break-word 를 쓰지 않는다
   (글자 중간에서 끊긴다 — 코드·주소 칸만 예외). 모든 글은 마지막 줄에 한 어절만 남지 않게(html pretty — 상속),
   제목·가운데 정렬 안내·짧은 말풍선은 줄 길이를 고르게(balance). 지원하지 않는 브라우저는 그냥 지금처럼 끊는다. */
h1, h2, h3, h4, h5, h6, legend, caption { text-wrap: balance; }

/* ── 포커스: 키보드 포커스만 ───────────────────────────────────────── */
:focus { outline: none; }
:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

/* ── 스크롤바 ─────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ── 움직임 줄이기: 토큰 0ms 와 함께 남은 애니메이션도 멈춘다 ───────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── 글자 크기 유틸리티(크기 + 줄간격 짝) ─────────────────────────── */
.t-3xs { font-size: var(--t-3xs); line-height: var(--lh-3xs); }
.t-2xs { font-size: var(--t-2xs); line-height: var(--lh-2xs); }
.t-xs  { font-size: var(--t-xs);  line-height: var(--lh-xs); }
.t-sm  { font-size: var(--t-sm);  line-height: var(--lh-sm); }
.t-md  { font-size: var(--t-md);  line-height: var(--lh-md); }
.t-lg  { font-size: var(--t-lg);  line-height: var(--lh-lg); }
.t-xl  { font-size: var(--t-xl);  line-height: var(--lh-xl); }
.t-2xl { font-size: var(--t-2xl); line-height: var(--lh-2xl); }
.t-3xl { font-size: var(--t-3xl); line-height: var(--lh-3xl); }

.text-2 { color: var(--text-2); }
.m-0 { margin: 0; }
.text-3 { color: var(--text-3); }
.ink-ok { color: var(--ok-ink); }
.ink-warn { color: var(--warn-ink); }
.ink-danger { color: var(--danger-ink); }
.ink-ai { color: var(--ai); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* 숫자 정렬(표·통계·품질 점수) */
.num { font-variant-numeric: tabular-nums; }
.num-right { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* 화면에는 안 보이고 스크린리더만 읽는 글자 */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 아이콘 — public/ui/icon.js 가 만든다. Phosphor regular, 16/20px (docs/08 § 5).
   테두리 도형은 늘 currentColor. fill 은 "채움 겹"에만 물려준다: 기본 none → 고른 상태에서 fill: currentColor 면 채움 아이콘,
   fill-opacity 를 더하면 연하게 물듦. visibility: hidden 을 함께 주면 테두리 없이 순수 fill 글리프만(장식 아이콘에만). */
.icon {
  flex: none; width: 20px; height: 20px;
  fill: none; stroke: none;
  vertical-align: middle;
}
.icon.is-14 { width: 14px; height: 14px; }
.icon.is-16 { width: 16px; height: 16px; }
.icon.is-24 { width: 24px; height: 24px; }
.icon.is-32 { width: 32px; height: 32px; }
.icon.is-spin { animation: tc-spin 0.9s linear infinite; }
@keyframes tc-spin { to { transform: rotate(360deg); } }
