/* =========================================================================
 * LottoLie (로또라이) - 화이트톤 미니멀 테마
 * 설계 원칙: 절제된 색·넉넉한 여백·부드러운 그림자·명확한 위계·섬세한 인터랙션
 * (웜 화이트 배경 / 소프트 오렌지 브랜드 / 그린→오렌지 파스텔 / 그라데이션 없음)
 * ========================================================================= */
:root {
  /* 표면·경계 (웜 뉴트럴) */
  --bg: #faf6f1;
  --surface: #ffffff;
  --surface-2: #f6f1ea;
  --border: #efe6db;
  --border-strong: #e3d6c7;
  /* 텍스트 (웜 다크) */
  --text: #2b231d;
  --text-2: #5d5147;
  --muted: #8b7d6f;
  --faint: #b3a596;
  /* 브랜드 (소프트 오렌지) */
  --brand: #e5946a;
  --brand-strong: #cf7645;
  --brand-soft: #fbe9dc;
  --gold: #cf923f;
  --gold-soft: #f8edd7;
  --danger: #d97a5f;
  --save: #3a8f83;
  --save-strong: #2f766c;
  --save-soft: #dff0ec;
  --profit: #2f766c;
  --loss: #c15c44;
  --shadow-brand: rgba(207, 118, 69, 0.26);
  /* 형태 */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.07), 0 2px 4px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.1);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 650; letter-spacing: -0.02em; color: var(--text); }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-soft); }

/* ---------- 헤더 / 네비 ---------- */
.site-header {
  /* 불투명 배경: 스크롤 콘텐츠가 메뉴 뒤로 비치지 않도록 반투명·블러 제거 */
  background: #fffdfa;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner { max-width: 1080px; margin: 0 auto; padding: 14px 24px 0; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.brand:hover .logo { color: var(--brand-strong); }
.brand .logo { font-size: 1.4rem; font-weight: 750; letter-spacing: -0.03em; color: var(--text); }
.brand .logo b { color: var(--brand); font-weight: 750; }
.brand .kr { color: var(--muted); font-size: 0.85rem; }
.header-latest-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.header-latest {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-sm);
}
.header-latest-date {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  white-space: nowrap;
}
.header-latest-balls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.header-latest .ball.sm {
  width: 22px;
  height: 22px;
  font-size: 0.62rem;
}
.header-refresh {
  width: 32px;
  height: 32px;
  padding: 0;
  flex: none;
}
.slogan { color: var(--muted); font-size: 0.82rem; margin-left: auto; }
.slogan b { color: var(--brand-strong); font-weight: 750; }
.quick-menu { position: relative; margin-left: 0; }
.quick-menu-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 750;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.quick-menu-btn:hover { border-color: var(--brand); color: var(--brand-strong); }
/* 좌측 슬라이드 드로어 (클로드 앱 스타일) — body 직속, position:fixed */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.42);
  z-index: 45;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.42s ease, visibility 0.42s ease;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(82vw, 300px);
  z-index: 46;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 10px 0 44px -8px rgba(20, 20, 30, 0.28);
  transform: translateX(-100%);
  transition: transform 0.46s cubic-bezier(0.22, 0.72, 0, 1);
  will-change: transform;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 16px;
  background: linear-gradient(135deg, var(--brand-soft), transparent 78%);
  border-bottom: 1px solid var(--border);
}
.drawer-brand { display: flex; align-items: baseline; gap: 8px; }
.drawer-brand .logo { font-size: 1.28rem; font-weight: 750; letter-spacing: -0.03em; color: var(--text); }
.drawer-brand .logo b { color: var(--brand); }
.drawer-brand .kr { color: var(--muted); font-size: 0.8rem; }
.drawer-close {
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.12s var(--ease);
}
.drawer-close svg { width: 16px; height: 16px; }
.drawer-close:hover { color: var(--brand-strong); border-color: var(--brand); }
.drawer-close:active { transform: scale(0.92); }
.drawer-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drawer button[data-tab] {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  font: inherit;
  font-size: 0.96rem;
  font-weight: 650;
  cursor: pointer;
  position: relative;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), transform 0.1s var(--ease), box-shadow 0.16s var(--ease);
}
.drawer button[data-tab] .d-ic {
  width: 24px; height: 24px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: color 0.16s var(--ease);
}
.drawer button[data-tab] .d-ic svg { width: 21px; height: 21px; }
.drawer button[data-tab] .d-label { flex: 1; }
.drawer button[data-tab]::after {
  content: "";
  width: 7px; height: 7px; flex: none;
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg) translateX(-3px);
  opacity: 0;
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}
.drawer button[data-tab]:hover {
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.drawer button[data-tab]:hover .d-ic { color: var(--brand-strong); }
.drawer button[data-tab]:active { transform: scale(0.98); }
.drawer button[data-tab].active {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  box-shadow: 0 8px 20px -8px var(--brand);
}
.drawer button[data-tab].active .d-ic { color: #fff; }
.drawer button[data-tab].active::after { opacity: 0.9; transform: rotate(45deg) translateX(0); }
.drawer-foot {
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}
.drawer-foot b { color: var(--brand-strong); font-weight: 700; }
nav.tabs {
  width: 100%;
  display: flex;
  gap: 2px;
  margin-top: 8px;
  flex-wrap: wrap;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: none;
  touch-action: pan-x;
  position: relative;
  --tab-indicator-x: 0px;
  --tab-indicator-w: 0px;
}
nav.tabs button {
  position: relative;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 550;
  cursor: pointer;
  touch-action: pan-x;
  transition: color 0.16s var(--ease);
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { color: var(--brand); }
nav.tabs button.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--brand);
  border-radius: 2px 2px 0 0;
}
nav.tabs::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: var(--tab-indicator-w);
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--brand);
  opacity: 0;
  transform: translate3d(var(--tab-indicator-x), 0, 0);
  transition: transform 0.52s cubic-bezier(0.22, 0.72, 0, 1), width 0.52s cubic-bezier(0.22, 0.72, 0, 1), opacity 0.14s ease;
  pointer-events: none;
}
nav.tabs.swipe-indicator button.active::after { opacity: 0; }
nav.tabs.swipe-indicator::after { opacity: 1; }
nav.tabs.swipe-indicator.dragging::after { transition: opacity 0.14s ease; }

/* ---------- 레이아웃 ---------- */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 96px;
  display: grid;
  align-items: start;
}
.tab-panel {
  display: none;
  grid-area: 1 / 1;
  min-width: 0;
}
.tab-panel.active { display: block; }
/* 등장 애니메이션은 클릭 전환에만 적용(rise-in). 스와이프 정리 시 재생되는 깜박임 방지 */
.tab-panel.active.rise-in { animation: rise 0.35s var(--ease); }
.tab-panel.swipe-panel,
.subpanel.swipe-panel,
.simmode-panel.swipe-panel,
#chartArea.swipe-panel {
  display: block;
  pointer-events: none;
  will-change: transform;
  backface-visibility: hidden;
  transition: transform 0.52s cubic-bezier(0.22, 0.72, 0, 1);
}
.tab-panel.swipe-panel.swipe-dragging,
.subpanel.swipe-panel.swipe-dragging,
.simmode-panel.swipe-panel.swipe-dragging,
#chartArea.swipe-panel.swipe-dragging { transition: none; }
.tab-panel.swipe-current, .subpanel.swipe-current { z-index: 2; }
.tab-panel.swipe-next, .subpanel.swipe-next { z-index: 1; }
/* 분석 메뉴 서브탭 스와이프: 서브탭 바(#subtabs)는 sticky 그대로 상단에 고정하고,
   두 서브패널만 같은 위치에 겹쳐 좌우로 드래그한다.
   ※ 서브탭 바를 grid item 으로 만들면 sticky 가 풀려 아래로 떨어지므로(측정 확인),
   #analyze 는 일반 블록으로 두고 들어오는 패널만 absolute 로 겹친다.
   ※ overflow:hidden 은 sticky 를 풀어버리므로 가로만 잘라내는 overflow-x:clip 사용. */
#analyze.sub-swiping { position: relative; }
#analyze.sub-swiping > .subpanel.swipe-next {
  position: absolute;
  left: 0; right: 0;
  top: var(--sub-next-top, 0);
}
/* 서브탭 스와이프 중 들어오는 패널이 position:absolute 가 되면 첫 자식의 top 마진 상쇄가
   풀려 콘텐츠가 마진만큼 아래로 밀렸다가, 정착(static)하며 위로 튄다(세로 흔들림).
   → 서브탭 아래 여백은 .subtabs 의 margin-bottom 이 담당하므로 첫 자식 top 마진을 제거해
   absolute/static 두 상태의 콘텐츠 세로 위치를 항상 일치시킨다.
   ※ .sim-modetabs(시뮬·차트 모드탭)는 margin-top:-24px 로 서브탭 바에 밀착되므로 제외한다. */
#analyze .subpanel > :first-child:not(.sim-modetabs) { margin-top: 0; }
main.swipe-interactive {
  /* 좌우로 밀려난 패널을 잘라내되, overflow:hidden 은 main 을 스크롤 컨테이너로 만들어
     내부 sticky(서브탭 바)를 풀어버리므로, 스크롤 컨테이너를 만들지 않는 overflow-x:clip 사용 */
  overflow-x: clip;
  overflow-y: visible;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
main.swipe-interactive .tab-panel.active { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tab-panel.active,
  .tab-panel.swipe-panel {
    animation: none;
    transition: none;
  }
}

/* 분석 메뉴 내부 서브탭 — 메인 메뉴(헤더)와 같은 프레임으로 연결:
   main 상단 패딩을 상쇄해 헤더에 밀착시키고, 배경을 화면 전체 폭으로 확장해 헤더와 같은 스타일 사용 */
.subtabs {
  position: sticky;
  top: calc(var(--header-h, 96px) - 1px);
  z-index: 19;
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: none;
  touch-action: pan-x;
  margin: -32px calc(50% - 50vw) 24px;
  padding: 4px calc(50vw - 50%) 0;
  border-bottom: 1px solid var(--border);
  /* 불투명 배경: 스크롤 콘텐츠가 메뉴 뒤로 비치지 않도록 반투명·블러 제거 */
  background: #fffdfa;
}
.subtabs button {
  position: relative;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 11px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: pan-x;
  transition: color 0.16s var(--ease);
}
.subtabs button:hover { color: var(--text); }
.subtabs button.active { color: var(--text); }
.subtabs button.active::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--brand); border-radius: 2px 2px 0 0;
}
.subpanel { display: none; }
.subpanel.active { display: block; }
.subpanel.active.rise-in { animation: rise 0.3s var(--ease); }

/* 시뮬레이션·차트의 하위 모드 탭(반복분석/회차분석, 합계변화/재등장)
   — 서브탭 바로 아래에 고정하고 같은 프레임(흰색 배경 · 전체 폭)으로 연결 */
.sim-modetabs {
  position: sticky;
  top: calc(var(--header-h, 96px) + 44px);
  z-index: 18;
  margin: -24px calc(50% - 50vw) 16px;
  padding: 2px calc(50vw - 50%) 0;
  border-bottom: 1px solid var(--border);
  /* 불투명 배경: 스크롤 콘텐츠가 메뉴 뒤로 비치지 않도록 반투명·블러 제거 */
  background: #fffdfa;
}
.sim-modetabs button { font-size: 0.85rem; padding: 9px 14px; }
/* 모드 탭이 있는 패널의 컨트롤 고정 위치는 모드 탭 아래로 한 단계 내림 */
#sub-simulation .bt-sticky-controls {
  top: calc(var(--header-h, 96px) + 84px);
}
.simmode-panel { display: none; }
.simmode-panel.active { display: block; animation: rise 0.28s var(--ease); }

.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 1rem; }
.card .big { font-size: 1.9rem; font-weight: 700; color: var(--text); letter-spacing: -0.03em; }
.card .sub { color: var(--muted); font-size: 0.8rem; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 30px 0 14px; }
.section-title h2 { margin: 0; font-size: 1.1rem; }
.badge {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 550;
}
.badge.type-number { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.badge.type-combo { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.selected-rule-badge {
  display: inline-flex;
  align-items: center;
  max-width: 260px;
  min-height: 24px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid rgba(47, 118, 108, 0.28);
  background: var(--save-soft);
  color: var(--save-strong);
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selected-rule-badge[hidden] { display: none !important; }

/* ---------- 히어로 ---------- */
.hero {
  background: var(--brand-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  margin-bottom: 24px;
}
.hero h2 { font-size: 1.75rem; letter-spacing: -0.03em; }
.hero p { color: var(--text-2); max-width: 620px; margin: 0; }

/* ---------- 대시보드(홈) ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.dash-title { font-size: 1.5rem; margin: 0 0 2px; }
.dash-top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-latest { display: flex; flex-direction: column; justify-content: center; }
.dash-latest-title {
  font-size: 1rem;
  font-weight: 750;
  color: var(--text);
}
.dash-latest-balls .ball {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}
.dash-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.tile .t-label { font-size: 0.76rem; color: var(--muted); }
.tile .t-val { font-size: 1.45rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; margin-top: 3px; line-height: 1.2; }
.tile .t-sub { font-size: 0.72rem; color: var(--faint); margin-top: 2px; }
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 0.98rem; }
.bt-target-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dash-reco { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.dash-reco:last-child { border-bottom: none; }
.dash-reco .rank { font-weight: 750; color: var(--gold); min-width: 26px; font-size: 0.9rem; }
.dash-reco .score-badge { margin-left: auto; background: var(--brand-soft); color: var(--brand-strong); border-radius: 999px; padding: 4px 11px; font-weight: 700; font-size: 0.78rem; }
.dash-reco .btn.mini { flex: none; }
.dash-flow-table .ball.sm {
  width: 24px;
  height: 24px;
  font-size: 0.68rem;
}
.dash-flow-table td { padding-top: 10px; padding-bottom: 10px; }
.bt-target-balls .ball,
.sim-target-balls .ball {
  width: 30px;
  height: 30px;
  font-size: 0.76rem;
}

/* 컬럼(세로 막대) 차트 */
.col-chart { display: flex; gap: 6px; align-items: flex-end; height: 150px; padding-top: 8px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; }
.col-bar { width: 62%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.5s var(--ease); }
.col-v { font-size: 0.6rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- 로또 공 ---------- */
.balls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ball {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.92rem;
  color: #1c1200;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow-sm);
}
.ball.sm { width: 30px; height: 30px; font-size: 0.8rem; }
/* 파스텔 그린→오렌지 순차 팔레트 (구간이 올라갈수록 초록→오렌지로 부드럽게 전환).
   채도·명도를 맞춘 파스텔, 글자색은 같은 계열의 진한 톤(토널) */
.ball.c1 { background: #b7d6a6; color: #3f5630; }
.ball.c2 { background: #d2dd9f; color: #565626; }
.ball.c3 { background: #f0d79f; color: #6b521f; }
.ball.c4 { background: #f2c39b; color: #6d4423; }
.ball.c5 { background: #eeab8f; color: #6d3a20; }
.ball.plus { background: transparent; color: var(--faint); box-shadow: none; border: none; font-weight: 400; }
.ball.dim { opacity: 0.32; }

/* ---------- 컨트롤(버튼/토글/슬라이더) ---------- */
button.btn {
  font-size: 0.9rem; font-weight: 600;
  padding: 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: background 0.16s var(--ease), transform 0.08s var(--ease), box-shadow 0.16s var(--ease), border-color 0.16s var(--ease);
}
button.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
button.btn:active { transform: translateY(1px); }
button.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px var(--shadow-brand); }
button.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
button.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
button.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
button.btn.mini { padding: 6px 12px; font-size: 0.76rem; border-radius: var(--radius-xs); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.control-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; color: var(--muted); font-weight: 550; }
/* 라벨을 콤보박스 옆(가로)으로 배치 */
.field.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field.field-inline label { white-space: nowrap; }
.field.field-inline .range-custom { width: 92px; }
.field.field-inline #simCountCustom { width: 92px; }
/* '규칙적용 회차' 콤보박스 가로 축소 — 모든 메뉴 공통(.range-sel). '전체 회차'가 안 잘리는 최소폭 */
.field.field-inline .range-sel { width: 104px; box-sizing: border-box; }
select, input[type="text"], input[type="number"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
select:focus, input[type="text"]:focus, input[type="number"]:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
/* 분석 대상 회차 콤보박스·규칙선택 버튼 등 컨트롤 높이 통일 (모든 탭) */
.control-row select,
.control-row input[type="text"],
.control-row input[type="number"],
.control-row button.btn:not(.mini) { height: 42px; box-sizing: border-box; }
.control-row button.btn:not(.mini) { display: inline-flex; align-items: center; justify-content: center; }
/* 최신 회차 새로고침 버튼 (콤보박스 옆 아이콘) */
button.btn.range-refresh { width: 42px; padding: 0; font-size: 1.1rem; line-height: 1; flex: 0 0 auto; }
button.btn.range-refresh.spin { animation: refresh-spin 0.8s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
input[type="range"] { accent-color: var(--brand); width: 140px; }
.range-stepper { display: flex; align-items: center; gap: 8px; }
.range-stepper input[type="range"] { width: 160px; }
.range-stepper .btn.mini {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* 토글 스위치 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background 0.2s var(--ease); }
.switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------- 규칙 패널 ---------- */
.rule-panel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.rule-cat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.rule-cat header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.rule-cat header h4 { margin: 0; font-size: 0.95rem; }
.rule-cat .cat-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.group-result-wrap { margin: 8px 0 4px; }
.group-result {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.78rem;
}
.group-result.muted { color: var(--faint); }
.group-meta { color: var(--muted); line-height: 1.45; }
.group-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}
.group-line > span {
  color: var(--faint);
  min-width: 86px;
}
.group-line em {
  color: var(--brand);
  font-style: normal;
  font-weight: 700;
}
.rule { display: grid; grid-template-columns: auto 1fr minmax(220px, auto); align-items: start; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.rule .rule-name { font-size: 0.86rem; color: var(--text-2); }
.rule .rule-name small { display: block; color: var(--faint); font-size: 0.72rem; }
.rule-result { margin-top: 8px; }
.rule-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  color: var(--muted);
  font-size: 0.72rem;
  max-width: 100%;
}
.rule-preview > span {
  color: var(--faint);
  flex: 0 0 auto;
  white-space: nowrap;
}
.rule-preview .balls, .group-line .balls { flex: 0 0 auto; flex-wrap: nowrap; }
.rule-preview em {
  color: var(--brand);
  font-style: normal;
  font-weight: 700;
  flex: 0 0 auto;
}
.selected-rule-preview { margin-top: 14px; }
.all-number-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.ranked-ball {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.ranked-ball em {
  min-width: 18px;
  color: var(--faint);
  font-style: normal;
  font-size: 0.68rem;
  text-align: right;
}
.ranked-ball b {
  min-width: 24px;
  color: var(--brand);
  font-size: 0.68rem;
  text-align: right;
}
.rule .weight { display: flex; align-items: center; gap: 8px; padding-top: 2px; }
.rule .weight .weight-caption {
  color: var(--faint);
  font-size: 0.72rem;
  white-space: nowrap;
}
.rule .weight .wval { width: 20px; text-align: right; color: var(--brand); font-weight: 700; font-size: 0.82rem; }
.rule .weight .wtext {
  min-width: 62px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

/* ---------- 검증 탭: 장기 경향 표 ---------- */
.bt-rule-table td { vertical-align: middle; }
.bt-rule-table .bt-cat-row td { color: var(--muted); font-size: 0.78rem; font-weight: 700; background: var(--surface); padding-top: 12px; }
.bt-rule-table .bt-rule-name { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.bt-rule-table tr.bt-off { opacity: 0.5; }
.bt-wcell { display: flex; align-items: center; gap: 8px; }
.bt-wcell .bt-wrange { flex: 0 0 100px; max-width: 120px; }
.bt-wcell .wval { width: 18px; text-align: right; color: var(--brand); font-weight: 700; font-size: 0.82rem; }
.bt-rule-table .switch { display: inline-flex; }
@media (max-width: 640px) {
  .bt-wcell .bt-wrange { flex: 1 1 80px; }
}

/* ---------- 접이식 섹션(추천 조합) ---------- */
.collapse { margin-top: 20px; }
.collapse-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 18px; cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow-sm);
}
.collapse-head:hover { border-color: var(--border-strong); }
.collapse-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.collapse-caret { color: var(--muted); font-size: 0.9rem; transition: transform 0.18s ease; }
.collapse.open .collapse-caret { transform: rotate(180deg); }
.collapse-body { display: none; margin-top: 12px; }
.collapse.open .collapse-body { display: block; }

/* ---------- 규칙 추가/삭제 팝업(모달) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(30, 22, 16, 0.42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: min(720px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; padding: 20px 22px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.modal-head h3 { margin: 0; }
.modal-x { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-xs); }
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal-tools { display: flex; align-items: center; gap: 8px; padding: 8px 0 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
/* 저장한 규칙 불러오기 바 — 저장 계열(청록)로 통일해 오렌지 테마와 충돌 없이 눈에 띄게 */
.modal-load {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
  padding: 9px 12px;
  border: 1px solid var(--save-soft);
  border-left: 3px solid var(--save);
  border-radius: var(--radius-xs);
  background: var(--save-soft);
}
.modal-load-label { font-size: 0.82rem; font-weight: 700; color: var(--save-strong); white-space: nowrap; }
.modal-load-sel {
  flex: 1 1 200px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--save);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.modal-load-sel:focus { outline: none; box-shadow: 0 0 0 3px rgba(58, 143, 131, 0.22); }
.modal-load-sel:disabled { opacity: 0.55; cursor: default; }
.modal-body { overflow-y: auto; padding: 12px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.modal-cat { min-width: 0; }
.modal-cat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.modal-cat-head h4 { margin: 0; font-size: 0.85rem; }
.modal-cat-head .cat-actions { display: flex; gap: 4px; }
.modal-rule { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: var(--radius-xs); border: 1px solid transparent; }
.modal-rule:hover { background: var(--surface-2); }
.modal-rule.on { background: var(--brand-soft); border-color: var(--brand-soft); }
.modal-rule-main { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.modal-rule-main input[type="checkbox"] { margin-top: 3px; flex: 0 0 auto; accent-color: var(--brand); }
.modal-rule-txt { display: flex; align-items: baseline; gap: 10px; font-size: 0.85rem; min-width: 0; line-height: 1.35; }
.modal-rule-txt b { flex: 0 0 auto; font-size: 0.85rem; font-weight: 650; color: var(--text); }
.modal-rule-txt small { color: var(--muted); font-size: 0.72rem; min-width: 0; }
.modal-rule-w { display: flex; align-items: center; gap: 8px; padding-left: 24px; }
.modal-rule-w .modal-w-label { color: var(--faint); font-size: 0.72rem; white-space: nowrap; }
.modal-rule-w .bt-wrange { flex: 1 1 auto; max-width: 130px; }
.modal-rule-w .wval { color: var(--brand); font-weight: 700; font-size: 0.8rem; width: 16px; text-align: center; }
.modal-rule-w input[disabled] { opacity: 0.4; }
.modal-rule-w .wstep { flex: 0 0 auto; min-width: 24px; padding: 2px 6px; font-weight: 700; line-height: 1; }
.modal-rule-w .wstep:disabled { opacity: 0.4; cursor: default; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.validation-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
}
.validation-inline b { color: var(--text); font-weight: 750; }
.validation-inline .rule-open-toggle { margin-left: auto; }
.rule-hit-help {
  flex: 1 0 100%;
  margin-top: 2px;
}
.rule-hit-help > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--brand-strong);
  font-size: 0.76rem;
  font-weight: 750;
}
.rule-hit-help > summary::-webkit-details-marker { display: none; }
.rule-hit-help > summary::before { content: "▸"; font-size: 0.68rem; }
.rule-hit-help[open] > summary::before { content: "▾"; }
.rule-hit-help p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}
@media (max-width: 560px) { .modal-body { grid-template-columns: 1fr; } }

/* ---------- 규칙 편집기: 카테고리 접이식 ---------- */
.modal-cat-head { cursor: pointer; user-select: none; padding: 4px 2px; border-radius: var(--radius-xs); }
.modal-cat-head:hover { background: var(--surface-2); }
.modal-cat-title { display: flex; align-items: center; gap: 4px; min-width: 0; }
.modal-cat-caret { color: var(--muted); font-size: 0.75rem; transition: transform 0.18s ease; flex: 0 0 auto; }
.modal-cat.open .modal-cat-caret { transform: rotate(180deg); }
.modal-cat-count {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  white-space: nowrap;
  margin-left: 4px;
}
.modal-cat-body { display: none; flex-direction: column; gap: 6px; margin-top: 4px; }
.modal-cat.open .modal-cat-body { display: flex; }

/* ---------- 나의규칙 저장 버튼(청록) / 정지 / 삭제 ---------- */
button.btn.save-rule { background: var(--save); border-color: var(--save); color: #fff; box-shadow: 0 1px 2px rgba(47, 118, 108, 0.24); }
button.btn.save-rule:hover { background: var(--save-strong); border-color: var(--save-strong); }
button.btn.save-rule.saved { background: var(--save-soft); border-color: var(--save); color: var(--save-strong); box-shadow: none; }
button.btn.stop { background: var(--danger); border-color: var(--danger); color: #fff; }
button.btn.stop:hover { background: #c5654c; border-color: #c5654c; }
button.btn.danger-btn { background: transparent; border-color: var(--danger); color: var(--danger); }
button.btn.danger-btn:hover { background: var(--danger); color: #fff; }
button.btn.danger-btn:disabled { opacity: 0.4; }

/* ---------- 규칙 관리 목록 ---------- */
.ruleset-list { display: flex; flex-direction: column; gap: 8px; }
.ruleset-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color 0.15s var(--ease), background 0.15s var(--ease); }
.ruleset-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.ruleset-row.active { border-color: var(--save); background: var(--save-soft); }
.ruleset-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ruleset-info b { font-size: 0.9rem; color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ruleset-info small { font-size: 0.72rem; color: var(--muted); }
.ruleset-info .ruleset-sim { color: var(--save-strong); font-weight: 700; }
.ruleset-acts { flex: 0 0 auto; display: flex; gap: 6px; }
.manage-name-input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: 0.9rem; color: var(--text); background: var(--surface); }
.manage-name-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.manage-editor-body { max-height: none; }
#manageEditor > .section-title {
  position: sticky;
  top: calc(var(--header-h, 64px) + 8px);
  z-index: 20;
  background: var(--bg);
  padding: 10px 0;
}
.rule-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--save-soft); color: var(--save-strong); font-weight: 700; font-size: 0.72rem; }

/* ---------- 시뮬레이션 손익 패널 / 기준일자 ---------- */
.sim-base-field { margin: 0; }
.sim-base-field select { min-width: 150px; }
.sim-money .card.profit-pos { border-color: var(--save); background: var(--save-soft); }
.sim-money .card.profit-pos .big { color: var(--profit); }
.sim-money .card.profit-neg { border-color: #f0d5cc; background: #fbeee9; }
.sim-money .card.profit-neg .big { color: var(--loss); }
.sim-congrats { max-width: 420px; text-align: center; }
.sim-congrats .balls { justify-content: center; }
/* 등수별 결과: 한 박스 안에 6개 항목(개수·%·당첨금액) */
.sim-ranks .card-head { margin-bottom: 10px; }
.sim-rank-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sim-rank-item { padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface-2); }
.sim-rank-item.miss { background: var(--surface); }
.sim-rank-top { display: flex; align-items: baseline; gap: 8px; }
.sim-rank-label { font-size: 0.82rem; font-weight: 700; color: var(--brand-strong); flex: 1 1 auto; }
.sim-rank-item.miss .sim-rank-label { color: var(--muted); }
.sim-rank-count { font-size: 0.92rem; font-weight: 800; color: var(--text); }
.sim-rank-pct { font-size: 0.76rem; color: var(--muted); }
.sim-rank-won { font-size: 0.86rem; font-weight: 700; color: var(--gold); margin-top: 4px; text-align: right; }
.sim-rank-item.miss .sim-rank-won { color: var(--faint); }
.round-result-table th,
.round-result-table td {
  padding-left: 6px;
  padding-right: 6px;
}
.round-draw-cell { min-width: 0; width: 1%; white-space: nowrap; }
.round-draw-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.round-draw-round { font-weight: 800; color: var(--text); }
.round-draw-numbers {
  color: var(--text-2);
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}
@media (max-width: 480px) { .sim-rank-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- 추천 결과(구형 인라인) ---------- */
.reco { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; box-shadow: var(--shadow-sm); }
.reco .rank { font-weight: 800; color: var(--gold); width: 26px; font-size: 1.1rem; }
.reco .score-badge { margin-left: auto; background: var(--brand-soft); border: 1px solid transparent; color: var(--brand); border-radius: 999px; padding: 5px 12px; font-weight: 700; }
.reasons { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.chip { font-size: 0.72rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-weight: 550; }

/* ---------- 빈도 차트 ---------- */
.chart { display: grid; grid-template-columns: repeat(45, 1fr); gap: 3px; align-items: end; height: 120px; }
.chart .bar { background: var(--brand); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; transition: opacity 0.15s var(--ease); }
.chart .bar:hover { opacity: 0.7; }
.chart .bar::before,
.chart .bar::after {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.12s var(--ease), transform 0.12s var(--ease);
}
.chart .bar::before {
  content: attr(data-no);
  bottom: calc(100% + 28px);
  background: var(--text);
  color: #fff;
}
.chart .bar::after {
  content: attr(data-value);
  bottom: calc(100% + 6px);
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.chart .bar:hover::before,
.chart .bar:focus-visible::before,
.chart .bar:hover::after,
.chart .bar:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.chart .bar span { position: absolute; bottom: -16px; left: 0; right: 0; text-align: center; font-size: 0.5rem; color: var(--faint); }

/* ---------- 번호 선택 그리드 ---------- */
.pick-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pick-card-head h3 { margin: 0; }
#pickPanel { margin-top: 14px; }
.pick-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 8px; max-width: 460px; }
.pick-grid .pick {
  aspect-ratio: 1; border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2);
  font-weight: 650; cursor: pointer; font-size: 0.85rem;
  transition: all 0.14s var(--ease);
}
.pick-grid .pick:hover { border-color: var(--brand); color: var(--brand); }
.pick-grid .pick.on { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 2px 6px var(--shadow-brand); }
.prev-entry {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.prev-entry-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.prev-entry-head h4 {
  margin: 0;
  font-size: 0.95rem;
}
.prev-entry-head span { font-size: 0.78rem; }
.prev-entry-grid {
  display: grid;
  grid-template-columns: minmax(110px, 150px) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.prev-nums-field input { min-width: 0; }
.prev-entry-note {
  margin: 8px 0 0;
  font-size: 0.76rem;
}

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; position: sticky; top: 0; font-size: 0.8rem; }
tbody tr { transition: background 0.12s var(--ease); }
tbody tr:hover td { background: #fafbfc; }
tr.latest td { background: var(--brand-soft); }

.saved-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.saved-item .rank-tag { padding: 4px 11px; border-radius: 999px; font-weight: 650; font-size: 0.78rem; border: 1px solid transparent; }
.rank-tag { padding: 4px 11px; border-radius: 999px; font-weight: 650; font-size: 0.78rem; border: 1px solid transparent; white-space: nowrap; }
.rank-tag.win { background: var(--gold-soft); color: #96610f; }
.rank-tag.none { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.rank-tag.pending { background: var(--brand-soft); color: var(--brand-strong); }

/* 내 번호 카드: 주차(회차) 헤더 + 당첨내역 */
.saved-head { display: flex; align-items: center; gap: 8px; }
.saved-head .saved-seq { font-weight: 800; font-size: 0.9rem; color: var(--accent, #4c8bf5); background: rgba(120,150,255,0.12); border-radius: 6px; padding: 2px 8px; }
.saved-head .saved-week { flex: 1; font-weight: 700; font-size: 0.92rem; }
.saved-head .btn { margin-left: 4px; }
.saved-round-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.saved-round-group + .saved-round-group { margin-top: 12px; }
.saved-round-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
}
.saved-round-group > summary::-webkit-details-marker { display: none; }
.saved-round-group[open] > summary { border-bottom: 1px solid var(--border); }
.saved-round-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.saved-round-title strong { font-size: 1rem; }
.saved-round-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.saved-round-toggle {
  min-width: 44px;
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 750;
  text-align: right;
}
.saved-round-body { padding: 16px 18px 18px; background: #fff; }
.saved-round-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.saved-summary-main { font-size: 1.1rem; font-weight: 750; color: var(--text); }
.saved-winning-draw {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}
.saved-ticket-list { display: grid; gap: 10px; }
.saved-ticket {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
}
.saved-ticket .saved-numline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.saved-ticket .saved-numline .balls { flex: 1; min-width: 0; }
.saved-ticket .saved-meta { font-size: 0.78rem; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-left: auto; text-align: right; justify-content: flex-end; white-space: nowrap; }
.saved-ticket .saved-meta b { font-weight: 750; }
.saved-delete-btn { margin-left: auto; }

.help-list { display: grid; gap: 12px; }
.help-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.help-group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 750;
}
.help-group > summary::-webkit-details-marker { display: none; }
.help-group > summary b {
  color: var(--brand-strong);
  font-size: 0.82rem;
}
.help-group[open] > summary { border-bottom: 1px solid var(--border); }
.help-body {
  display: grid;
  gap: 8px;
  padding: 16px 18px 18px;
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.65;
}
.help-body p { margin: 0; }

/* 추첨결과 표의 '내 번호 · 결과' 셀 */
.mine-cell .mine-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mine-cell .mine-row + .mine-row { margin-top: 6px; }
.mine-cell .rank-tag { font-size: 0.72rem; padding: 2px 8px; }
#resultsBody .ball.sm {
  width: 26px;
  height: 26px;
  font-size: 0.7rem;
}
.mine-cell .mine-full .ball.sm,
.mine-cell .mine-result-line .ball.sm {
  width: 22px;
  height: 22px;
  font-size: 0.62rem;
}
.mine-result-group + .mine-result-group { margin-top: 6px; }
.mine-result-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mine-result-group > summary::-webkit-details-marker { display: none; }
.mine-result-group > summary .rank-tag { cursor: pointer; }
.mine-group-body {
  display: grid;
  gap: 7px;
  margin-top: 7px;
}
.mine-detail-row {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
}
.mine-result-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mine-full {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.mine-full .muted { font-size: 0.72rem; font-weight: 700; }

.disclaimer { margin-top: 48px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); font-size: 0.8rem; text-align: center; background: var(--surface); }
.empty { color: var(--faint); text-align: center; padding: 32px 0; font-size: 0.9rem; }
.hl { color: var(--gold); font-weight: 700; }
.notice { border-radius: var(--radius-sm); padding: 13px 16px; font-size: 0.84rem; margin-bottom: 16px; line-height: 1.55; }
.notice.warn { background: var(--gold-soft); border: 1px solid #f0dcae; color: #8a5a12; }
.caveat { color: var(--faint); font-size: 0.74rem; margin-top: 6px; font-style: italic; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 0.85em; color: var(--brand-strong); }

/* ---------- 추천 개수 버튼 ---------- */
.count-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.count-btns button {
  padding: 2px 16px; border-radius: 999px; line-height: 1.1;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2);
  font-weight: 600; cursor: pointer; font-size: 0.85rem;
  transition: all 0.14s var(--ease);
}
.count-btns button:hover { border-color: var(--brand); color: var(--brand); }
.count-btns button.on { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 2px 6px var(--shadow-brand); }

/* ---------- 개별 분석 블록 ---------- */
.analysis-block { margin-bottom: 16px; }
.ab-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.ab-head h3 { margin: 0; flex: 1; }
/* 분석 보기: 접이식 블록 (details/summary) — 기본 닫힘 */
details.analysis-block > summary { list-style: none; cursor: pointer; }
details.analysis-block > summary::-webkit-details-marker { display: none; }
details.analysis-block:not([open]) > summary { margin-bottom: 0; }
.ab-caret { transition: transform 0.18s var(--ease); color: var(--muted); font-size: 0.8rem; }
details.analysis-block[open] .ab-caret { transform: rotate(180deg); }
/* 추천 후보 조합: 제목 라인 고정(sticky) + 우측 액션 + 최고점수 패널 */
/* 추천개수 선택 + 생성 카드 + 추천후보조합 라인: 스크롤해도 상단 고정 */
.reco-sticky { position: sticky; top: calc(var(--header-h, 96px) + 44px); z-index: 6; background: var(--bg); padding-bottom: 8px; scroll-margin-top: calc(var(--header-h, 96px) + 53px); }
.reco-sticky .card { margin-bottom: 8px; }
.bt-sticky-controls {
  position: sticky;
  top: calc(var(--header-h, 96px) + 44px);
  z-index: 8;
  background: var(--bg);
  padding: 10px 0;
  margin-bottom: 14px;
}
.bt-explain-text {
  margin-top: -6px;
  margin-bottom: 16px;
  font-size: 0.72rem;
  line-height: 1.45;
}
.individual-sticky-title {
  position: sticky;
  top: calc(var(--header-h, 96px) + 44px);
  z-index: 8;
  background: var(--bg);
  padding: 10px 0;
}
.reco-title-line { padding: 6px 0 0; flex-wrap: wrap; }
.reco-title-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-left: auto; }
/* 모두 저장 / 5등까지 저장 (일괄) — 개별 저장버튼과 같은 톤, on(저장됨)이면 취소 색 */
.reco-bulk-save { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-soft); font-weight: 700; }
.reco-bulk-save.on { background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); }
.reco-bulk-save:disabled { opacity: 0.5; cursor: default; }
.reco-title-actions { margin-left: auto; display: flex; gap: 8px; }
/* 제목 라인 우측 액션 그룹(분석 대상 회차·새로고침·규칙선택) */
.section-title.title-with-actions { flex-wrap: wrap; }
.title-near-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reco-best-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.reco-best-row:last-child { border-bottom: none; }
.reco-best-row .rank { font-weight: 750; color: var(--gold); min-width: 26px; }
.reco-best-row .score-badge { margin-left: auto; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 0.8rem; }
.reco-best-row .save-best-btn {
  flex: none;
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-weight: 750;
}
.ab-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.ab-grid .sub, .card .sub { margin-bottom: 6px; }
.metric-note {
  display: grid;
  gap: 4px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8rem;
  line-height: 1.45;
}
.metric-note span::before {
  content: "i";
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 800;
  vertical-align: 1px;
}
.stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--muted); }
.stat-row b { color: var(--text); text-align: right; font-weight: 600; }

/* 미니 막대 (분포/전환율) */
.mini-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.mb { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 10px; }
.mb-l { color: var(--muted); font-size: 0.8rem; }
.mb-v { font-size: 0.8rem; font-weight: 700; color: var(--brand); min-width: 42px; text-align: right; }
.mb-track { background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; }
.mb-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.5s var(--ease); }

/* ---------- 번호별 종합 점수 그리드 ---------- */
.score-grid { display: grid; grid-template-columns: repeat(45, 1fr); gap: 3px; align-items: end; height: 110px; margin: 12px 0 18px; }
.score-cell { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.score-cell .sc-bar { width: 78%; background: var(--brand); border-radius: 4px 4px 0 0; transition: height 0.5s var(--ease); }
.score-cell::before,
.score-cell::after {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.12s var(--ease), transform 0.12s var(--ease);
}
.score-cell::before {
  content: attr(data-no);
  bottom: calc(100% + 28px);
  background: var(--text);
  color: #fff;
}
.score-cell::after {
  content: attr(data-value);
  bottom: calc(100% + 6px);
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.score-cell:hover::before,
.score-cell:focus-visible::before,
.score-cell:hover::after,
.score-cell:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.score-cell span { position: absolute; bottom: -15px; font-size: 0.5rem; color: var(--faint); }
.score-top-details {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.score-top-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  list-style: none;
}
.score-top-details summary::-webkit-details-marker { display: none; }
.score-top-details summary::after {
  content: " ▾";
  color: var(--brand);
}
.score-top-details[open] summary { margin-bottom: 10px; }
.score-top-details[open] summary::after { content: " ▴"; }
.score-top-balls {
  padding: 12px;
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
}
.score-top-balls .ball {
  border-color: rgba(207, 118, 69, 0.35);
  box-shadow: 0 3px 10px var(--shadow-brand);
}

/* ---------- 추천 카드 (상세형) ---------- */
.reco-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease); }
.reco-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.reco-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.reco-top .rank { font-weight: 750; color: var(--gold); font-size: 1rem; min-width: 34px; }
.reco-top .score-badge { margin-left: auto; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 5px 13px; font-weight: 700; font-size: 0.85rem; }
.reco-top .save-reco-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-weight: 750;
}
.reco-top .save-reco-btn.on,
.reco-best-row .save-best-btn.on {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--muted);
}
.reco-top .save-reco-btn + .score-badge { margin-left: 0; }
.reco-stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0; font-size: 0.8rem; color: var(--muted); }
.reco-stats b { color: var(--text); font-weight: 650; }
.mono.pos { color: var(--brand); }
.mono.neg { color: var(--danger); }

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .rule-panel { grid-template-columns: 1fr; }
  .ab-grid { grid-template-columns: 1fr 1fr; }
  .dash-top, .dash-grid-2 { grid-template-columns: 1fr; }
  .slogan { display: none; }
  .header-latest-wrap { margin-left: auto; }
  .hero { padding: 30px 24px; }
  .hero h2 { font-size: 1.5rem; }
}
@media (max-width: 560px) {
  main { padding: 24px 18px 80px; }
  /* 모바일 헤더: 줄바꿈된 [당첨번호] 줄과 [메인메뉴] 줄 사이 간격 축소 (row-gap ↓ + tabs margin-top ↓) */
  .header-inner { padding: 12px 18px 0; row-gap: 6px; }
  /* 모바일 헤더 배치: [☰ 로고] / 날짜·당첨번호 / 탭 (로고 바로 밑에 최근 추첨번호) */
  .quick-menu { margin-left: 0; order: 0; }
  .brand { order: 1; }
  .header-latest-wrap { order: 2; width: 100%; justify-content: space-between; margin-left: 0; }
  nav.tabs { order: 3; margin-top: 2px; }
  .header-latest { flex: 1 1 auto; justify-content: space-between; }
  .header-latest-balls { overflow-x: auto; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .ab-grid { grid-template-columns: 1fr; }
  .chart, .score-grid { height: 80px; }
  .pick-grid { grid-template-columns: repeat(7, 1fr); }
  .prev-entry-grid { grid-template-columns: 1fr; }
  .saved-round-group > summary { align-items: flex-start; flex-direction: column; }
  .saved-round-meta { justify-content: flex-start; }
  .saved-ticket .saved-meta { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; }
  nav.tabs, .subtabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    touch-action: pan-x;
    contain: paint;
  }
  nav.tabs::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }
  nav.tabs button, .subtabs button { flex: 0 0 auto; white-space: nowrap; touch-action: pan-x; }
  .ball { width: 34px; height: 34px; }
  .mb { grid-template-columns: 56px 1fr auto; }
  .rule { grid-template-columns: auto 1fr; align-items: start; }
  .rule .weight { grid-column: 2; flex-wrap: wrap; }
  .rule .weight input[type="range"] { flex: 1 1 120px; }
}

/* ========================= 차트 분석 ========================= */
/* 주별/월별/연별 컨트롤: 모드 탭 아래에 고정 */
.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  position: sticky;
  top: calc(var(--header-h, 96px) + 84px);
  z-index: 17;
  background: var(--bg);
  padding: 6px 0;
}
.chart-periods { display: inline-flex; gap: 6px; }
.chart-periods button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.chart-periods button:hover { color: var(--text); border-color: var(--brand); }
.chart-periods button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 3px rgba(207, 118, 69, 0.28);
}
.chart-refresh {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
}
.chart-card { padding: 14px 12px 12px; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 8px;
}
.chart-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}
.chart-legend .lg i {
  width: 11px; height: 11px;
  border-radius: 3px;
  display: inline-block;
}
.chart-desc { font-size: 0.8rem; margin: 0 0 10px; line-height: 1.5; }
.chart-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 4px 0;
}
.chart-scroll svg.stockchart { display: block; }
.chart-scroll .cx-hit { cursor: crosshair; }
.chart-scroll .cx-hit:hover { fill: rgba(207, 118, 69, 0.06); }
.chart-range { font-weight: 700; color: var(--brand-strong); }

/* 호버 툴팁 */
.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 128px;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.76rem;
  line-height: 1.5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.chart-tip .tip-title { font-weight: 800; font-size: 0.86rem; }
.chart-tip .tip-sub { color: rgba(255, 255, 255, 0.62); font-size: 0.7rem; margin-bottom: 4px; }
.chart-tip .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.chart-tip .tip-row span { color: rgba(255, 255, 255, 0.68); }
.chart-tip .tip-row b { font-weight: 800; }
.chart-tip .tip-row b.up { color: #ff8a80; }
.chart-tip .tip-row b.down { color: #90caf9; }
.chart-tip .tip-row b.flat { color: rgba(255, 255, 255, 0.85); }

/* 숫자로 보기 버튼 (오렌지와 조화되는 청록) */
.chart-view-btn {
  border: 1px solid var(--save);
  background: var(--save-soft);
  color: var(--save-strong);
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  margin-left: 4px;
  transition: all 0.18s var(--ease);
}
.chart-view-btn:hover { background: #cfe6e0; border-color: var(--save-strong); }
.chart-view-btn.active {
  background: var(--save);
  border-color: var(--save);
  color: #fff;
  box-shadow: 0 1px 3px rgba(47, 118, 108, 0.28);
}

/* 설명 접이식 */
.chart-desc-toggle { margin: 0 0 10px; }
.chart-desc-toggle > summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chart-desc-toggle > summary::-webkit-details-marker { display: none; }
.chart-desc-toggle > summary::before { content: "▸"; font-size: 0.7rem; }
.chart-desc-toggle[open] > summary::before { content: "▾"; }
.chart-desc-toggle .chart-desc { margin: 8px 0 0; }

/* 선택된 캔들 하이라이트 */
.chart-scroll .cx-hit.sel { fill: rgba(207, 118, 69, 0.14); }

/* 시가/고가/저가 박스 */
.chart-ohlc { margin-top: 12px; }
.chart-ohlc .ohlc-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 0.82rem;
  margin-bottom: 8px;
}
.chart-ohlc .ohlc-head b.up { color: var(--up, #d64545); }
.chart-ohlc .ohlc-head b.down { color: #3b74c9; }
.ohlc-boxes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ohlc-box {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ohlc-box > span { font-size: 0.74rem; color: var(--muted); font-weight: 700; }
.ohlc-box > b { font-size: 1.12rem; font-weight: 800; color: var(--text); }
.ohlc-box > em { font-size: 0.68rem; color: var(--faint); font-style: normal; }
.ohlc-box.high { border-color: #eab0a6; background: #fdf1ee; }
.ohlc-box.low { border-color: #a9c5e6; background: #eef4fb; }

/* 숫자로 보기 표 */
.chart-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 460px;
}
.chart-table th, .chart-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.chart-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.76rem;
  border-bottom: 1.5px solid var(--border-strong);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.chart-table td.ct-label, .chart-table th:first-child { text-align: left; font-weight: 700; }
.chart-table td.ct-val { font-weight: 800; }
.chart-table td.ct-delta.up { color: #d64545; font-weight: 700; }
.chart-table td.ct-delta.down { color: #3b74c9; font-weight: 700; }
.chart-table td.ct-delta.flat { color: var(--faint); }
.chart-table td.ct-hi { color: #b5503f; }
.chart-table td.ct-lo { color: #365f96; }
.chart-table tbody tr:hover { background: var(--brand-soft); }
.chart-table em { font-size: 0.7rem; color: var(--faint); font-style: normal; }
.chart-note {
  font-size: 0.76rem;
  margin: 10px 0 0;
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--gold-soft);
  border-radius: 8px;
}
.chart-note code {
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ---------- 모바일 앱 보완 ---------- */
/* 더블탭 확대 방지 + 가로 오버스크롤(스와이프 시 깜박임 원인) 차단.
   주의: overflow-x에 hidden을 쓰면 iOS에서 position:sticky가 전부 풀리므로 clip을 사용한다. */
html, body {
  touch-action: pan-x pan-y;
  overflow-x: clip;
  overscroll-behavior-x: none;
  /* 세로 오버스크롤(브라우저 기본 당겨서 새로고침=리로드+검정 파도) 억제. 실제 차단은 JS preventDefault,
     이건 보조. 대신 커스텀 당겨서 새로고침(제자리 재렌더, 네비게이션 없음)이 동작한다. */
  overscroll-behavior-y: contain;
}
/* 오버스크롤/로딩 시 노출되는 루트 배경을 앱 크림색으로 — '검정' 방지 */
html { background: var(--bg); }

/* 커스텀 당겨서 새로고침 지시자(동글 스피너). 네비게이션 없이 데이터만 재렌더 → 파도 전환 없음 */
.ptr {
  position: fixed;
  top: -44px;
  left: 50%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.ptr-spin {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
}
.ptr.ready .ptr-spin { border-top-color: var(--brand-strong); }
.ptr.loading .ptr-spin { animation: refresh-spin 0.7s linear infinite; }
/* 새로고침 버튼 제거: 당겨서 새로고침으로 대체 */
#headerRefreshBtn, .range-refresh, #chartRefreshBtn, #dashRecoRefresh, #mineRefreshBtn { display: none !important; }
/* 추천번호 생성: 포함수/제외수는 왼쪽 좁게, 추천 개수·규칙·생성은 오른쪽으로 그룹 배치 */
.reco-control-row { align-items: flex-end; gap: 10px; }
.reco-control-row .field { flex: 0 1 auto; }
/* 포함수·제외수: 규칙·생성 박스 밖·위. 아이폰17 폭에서 두 필드가 한 줄에 들어오도록 컴팩트하게.
   입력+추가+초기화가 안 접히고 나란히, 칩은 아래로 wrap. */
/* 포함/제외수 전용 네모박스(고정 안 함). 규칙·생성 sticky 카드와 간격만 준다. */
.reco-incexc-card { margin-bottom: 8px; }
.reco-incexc-row { align-items: flex-start; flex-wrap: nowrap; gap: 10px; }
.reco-incexc-row .reco-incexc-field { flex: 1 1 0; min-width: 0; }
.reco-incexc-field > label { font-size: 0.76rem; margin-bottom: 1px; }
.incexc-add { display: flex; align-items: center; gap: 4px; }
.incexc-add input[type="number"] { width: 44px; flex: 0 1 44px; min-width: 30px; padding: 8px 6px; box-sizing: border-box; -moz-appearance: textfield; appearance: textfield; }
.incexc-add input[type="number"]::-webkit-outer-spin-button,
.incexc-add input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.incexc-add .btn.mini { padding: 6px 9px; font-size: 0.74rem; flex: 0 0 auto; }
.incexc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 26px; align-items: center; }
.incexc-empty { color: var(--muted); font-size: 0.8rem; }
.incexc-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px 4px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 0.85rem; font-weight: 650; line-height: 1; cursor: pointer;
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease), transform 0.08s var(--ease);
}
.incexc-chip:active { transform: scale(0.93); }
.incexc-chip .chip-x { font-size: 1rem; font-weight: 800; opacity: 0.6; }
.incexc-chip:hover .chip-x { opacity: 1; }
.incexc-chip.inc { border-color: #d8bd9c; background: #fbf2e8; color: #8a5626; }
.incexc-chip.exc { border-color: #e4b4ae; background: #fdece9; color: #b0433a; }
/* 포함수·제외수 행을 규칙/생성 행 위에 배치. 두 행 사이 간격 */
.reco-generate-row { margin-top: 0; }
/* 번호별 점수 그래프 카드 */
.score-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.score-chart-head h3 { margin: 0; font-size: 1rem; }
#scoreCard .chart { margin-bottom: 20px; }
/* 상위 20 번호 접이식 토글 */
.score-top-details > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-2);
}
/* 회차분석: 회차별 당첨번호를 날짜 아래 작은 박스로 표시 */
.round-draw-numbers-box {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  font-weight: 700;
  font-size: 0.72rem;
  white-space: nowrap;
}

/* ---------- 시작 안내 팝업 (화면 40% 크기 · 중앙) ---------- */
.welcome-overlay[hidden] { display: none !important; } /* hidden이 display:flex에 덮이면 투명 오버레이가 클릭을 차단함 */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 35, 29, 0.28);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.welcome-overlay.show { opacity: 1; }
.welcome-popup {
  position: relative;
  width: min(86vw, 440px);
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 30px 26px;
  text-align: center;
  transform: translateY(12px) scale(0.96);
  transition: transform 0.3s var(--ease);
}
.welcome-overlay.show .welcome-popup { transform: translateY(0) scale(1); }
.welcome-emoji { font-size: 3rem; line-height: 1; }
.welcome-popup p { margin: 0; font-size: 1.05rem; line-height: 1.7; color: var(--text); font-weight: 600; }
.welcome-popup b { color: var(--brand-strong); }
.welcome-wish { font-size: 1.2rem; }
.welcome-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  padding: 9px;
  cursor: pointer;
  border-radius: 10px;
}
.welcome-close:hover { background: var(--brand-soft); color: var(--text); }

/* ---------- 규칙 설정 버튼 강조 ---------- */
/* 모든 메뉴의 "규칙"(규칙 토글 설정) 버튼을 브랜드 컬러 포인트로 표시해 눈에 잘 띄게 */
#summaryRuleBtn, #stickyRuleBtn, #individualRuleBtn, #btEditBtn, #simRuleBtn, #roundRuleBtn {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-strong);
  font-weight: 750;
  box-shadow: 0 1px 4px var(--shadow-brand);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#summaryRuleBtn::before, #stickyRuleBtn::before, #individualRuleBtn::before,
#btEditBtn::before, #simRuleBtn::before, #roundRuleBtn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  flex: none;
}
#summaryRuleBtn:hover, #stickyRuleBtn:hover, #individualRuleBtn:hover,
#btEditBtn:hover, #simRuleBtn:hover, #roundRuleBtn:hover {
  background: #f7dcc9;
  border-color: var(--brand-strong);
}
