:root {
  --bg: #eef2f5;        /* 배경: 차가운 회청색 */
  --surface: #ffffff;   /* 카드 */
  --ink: #1b2430;       /* 본문 */
  --muted: #4f5d6c;     /* 보조 글자 */
  --line: #d3dbe3;      /* 경계 */
  --accent: #1d5a85;    /* 링크·버튼 */
  --up: #b42318;        /* 상승(국내 관례: 빨강) */
  --down: #1556a8;      /* 하락(파랑) */
  --radius: 10px;
  --font: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.65;
  word-break: keep-all; overflow-wrap: anywhere;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
h1, h2 { line-height: 1.3; text-wrap: balance; letter-spacing: -0.01em; margin: 0; }
p { text-wrap: pretty; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; gap: 16px; justify-content: space-between; align-items: flex-end; padding-top: 22px; padding-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 26px; font-weight: 800; }
.sub { margin: 4px 0 0; color: var(--muted); max-width: 46em; }
.top-side { display: flex; align-items: center; gap: 12px; }
.stamp { margin: 0; color: var(--muted); font-size: 13px; }
.btn {
  font: inherit; font-size: 14px; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px;
}
.btn:hover { background: #164a6e; }
.btn[disabled] { opacity: .6; cursor: progress; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding-top: 20px; padding-bottom: 28px; }
.span-all { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
h2 { font-size: 17px; font-weight: 700; }
.go { font-size: 13px; font-weight: 600; white-space: nowrap; }
.note { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.ph { color: var(--muted); font-size: 14px; list-style: none; }
.err { color: var(--up); font-size: 14px; }

.tickers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.tickers li { padding: 4px 14px; border-left: 1px solid var(--line); }
.tickers li:first-child { border-left: 0; padding-left: 0; }
.t-name { font-size: 13px; color: var(--muted); }
.t-price { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chg { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.chg.up { color: var(--up); } .chg.down { color: var(--down); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.rank li:first-child { border-top: 0; }
.sym { font-weight: 700; }

.sim-row { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.sim-row:first-child { border-top: 0; padding-top: 0; }
.k { display: block; font-size: 12px; color: var(--muted); }
.v { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: #dfe6ec; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.tbl th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { text-align: right; padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; }
.tbl tr:last-child td { border-bottom: 0; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.metrics div { min-width: 0; }
.metrics dt { font-size: 12px; color: var(--muted); }
.metrics dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metrics small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.tripod { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 8px; background: #f7f9fb; }
.tripod.good { border-left-color: #2e7d4f; } .tripod.warning { border-left-color: #b26a00; } .tripod.critical { border-left-color: var(--up); }
.tripod strong { font-size: 16px; }
.tripod p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 22px 0 36px; color: var(--muted); font-size: 13px; }
.foot p { max-width: 62em; margin: 0 0 10px; }
.foot-h { font-size: 13px; color: var(--ink); margin: 12px 0 4px; }

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .tickers { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .tickers li, .tickers li:first-child { border-left: 0; padding-left: 0; }
}
@media (max-width: 420px) {
  .two { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .sim-row { grid-template-columns: 1fr 1fr; }
  .sim-row > :first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise .35s ease-out both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* 등락 목록: 종목명은 한 줄로 줄이고 등락률은 오른쪽에 고정 */
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; }
.rank li > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chg { white-space: nowrap; }
