/* base.css — 모든 페이지 공통: 리셋, 본문, 페이지 폭, 그리드, 로딩, 버튼.
 *
 * 2026-09-25 점검: 스피너 @keyframes 5벌·.loading 6벌·복사 버튼 3벌이 크기·색이
 * 제각각 복붙돼 있었고(F054), 본문 최대폭이 1600/1400/1200으로 갈려 메뉴를 옮길
 * 때마다 폭이 튀었다(F052), 인라인 repeat(4,1fr) 그리드는 모바일에서 열당 80px로
 * 찌그러졌다(F028). 한 벌만 여기 둔다. 색은 전부 tokens.css.
 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent-text); }

/* ---- 페이지 폭 ---- */
.page { max-width: var(--page-max); margin: 0 auto; padding: 20px; }
.page--wide { max-width: var(--page-max-wide); }

/* ---- 그리드 (모바일에서 자동으로 접힌다) ---- */
.grid-2, .grid-3, .grid-4 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .page { padding: 12px; }  /* 크론 같은 넓은 표가 폰에서 폭을 되찾게 */
}

/* ---- 로딩 ---- */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 36px; height: 36px; margin: 0 auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading { text-align: center; padding: 48px 16px; color: var(--text-secondary); }
.loading .spinner { margin-bottom: 14px; }
.loading p { word-break: keep-all; }  /* 한국어 안내문이 모바일에서 음절 단위로 끊기지 않게 */

/* '데이터 없음 (사유)' 한 줄 — common.js loadCard/renderCardEmpty/cardEmptyHtml 이 그린다.
   대시보드 style.css 에만 있어 매매 페이지(trading-common.css)에선 맨 글자로 보였다 (F018 재수정) */
.widget-empty { padding: 16px 8px; text-align: center; font-size: 0.8rem; color: var(--text-muted); }

/* ---- 버튼 ---- */
.btn-action {
    background: var(--accent); color: var(--text-on-accent);
    border: none; border-radius: 6px; padding: 8px 16px;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-action:hover { background: var(--accent-hover); }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-action.secondary { background: var(--bg-inset); color: var(--text-primary); border: 1px solid var(--border); }
.btn-action.secondary:hover { background: var(--bg-hover); }

/* 화면 하단 고정 버튼 묶음 (시황 복사/새로고침) */
.fab-group {
    position: fixed; right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    display: flex; gap: 8px; z-index: 100;
}
.fab-group .btn-action { border-radius: 12px; padding: 12px 18px; font-size: 14px; box-shadow: var(--shadow); }
/* 데스크톱에서는 제목 줄 안에 놓는다 — 페이지 폭이 1400px로 넓어지자 고정 버튼이 오른쪽
   타일(PICK 배지, 볼린저 %B 값)을 가렸다. 폰에서만 엄지 닿는 하단에 띄운다. */
@media (min-width: 769px) {
    .fab-group--inline-desktop { position: static; justify-content: center; margin-top: 12px; }
    .fab-group--inline-desktop .btn-action { border-radius: 8px; padding: 6px 14px; font-size: 13px; box-shadow: none; }
}

/* ---- 등락 ---- */
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

/* ---- 오래된 데이터 배너 ---- */
.stale-banner {
    background: var(--bad-bg); border: 1px solid var(--bad); color: var(--bad);
    border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; line-height: 1.5;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation-duration: 0.01s !important; }
}

/* 비로그인 요약 응답 아래의 로그인 안내 한 줄 (docs/public-hardening-design.md §2) */
.login-hint { display: block; margin-top: 8px; font-size: 12px; color: var(--text-secondary); text-decoration: underline; }

/* 화면 안 한 줄 '이 종목(시장) 궁금한 점은 💬 물어보기'(docs/ask-everywhere-design.md §3) — 종목 분석 머리 아래·시장 브리핑 📝 오늘 브리핑 아래 */
.ask-line { margin: 6px 0 0; font-size: 13px; color: var(--text-secondary); }
.ask-line a { display: inline-flex; align-items: center; min-height: 36px; font-weight: 600; color: var(--accent-text); text-decoration: none; }
.ask-line a:hover { text-decoration: underline; }
