/* ── 변수 ──────────────────────────────────────────────────────── */
:root {
  --bg:            #0a0a0a;
  --surface:       #141414;
  --surface-2:     #1e1e1e;
  --surface-3:     #252525;
  --user-bubble:   #8b1520;
  --header-bg:     #0f0f0f;
  --input-bg:      #161616;
  --input-border:  #2a2a2a;
  --text-primary:  #e5e5e5;
  --text-muted:    #9CA3AF;
  --text-chip:     #a0aec0;
  --accent:        #C41E3A;
  --accent-dim:    rgba(196, 30, 58, 0.12);
  --accent-amber:  #F59E0B;
  --border:        #2a2a2a;
  --tab-h:         56px;
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont,
          'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

/* ── 리셋 ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── 앱 컨테이너 ─────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── 화면 시스템 ─────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.screen.active { display: flex; }

/* ── 탭 바 ───────────────────────────────────────────────────── */
#tab-bar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
}
.tab-btn.active   { color: var(--accent); }
.tab-btn--disabled { opacity: 0.3; cursor: default; }

/* ── 공통 페이지 헤더 ────────────────────────────────────────── */
.page-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 16px 10px;
  padding-top: calc(env(safe-area-inset-top) + 10px);
  min-height: calc(52px + env(safe-area-inset-top));
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.page-header--back {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: 10px;
  min-height: 50px;
}

.page-header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}
.page-header-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.back-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  margin-left: -6px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

/* ── 퍼시스턴트 헤더 (모든 탭 공통) ─────────────────────────── */
#header {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: calc(env(safe-area-inset-top) + 10px);
  padding-bottom: 10px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  min-height: calc(52px + env(safe-area-inset-top));
}

#header-left  { display: flex; flex-direction: column; gap: 2px; }
#header-right { display: flex; align-items: center; gap: 8px; }
#header-title { font-size: 16px; font-weight: 700; letter-spacing: -0.4px; }
#header-sub   { font-size: 11px; color: var(--text-muted); }

/* ── 모델 토글 ────────────────────────────────────────────────── */
#model-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 3px;
  gap: 2px;
}
#model-toggle button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 11px 13px;
  border-radius: 19px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  -webkit-tap-highlight-color: transparent;
  min-width: 56px;
  min-height: 44px;
  white-space: nowrap;
}
#model-toggle button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* ── 메시지 영역 ──────────────────────────────────────────────── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
#messages::-webkit-scrollbar { display: none; }

#screen-chat { position: relative; }

/* ── 복사 버튼 ────────────────────────────────────────────────── */
.msg-copy-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  align-self: flex-start;
}
.msg-copy-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.msg-row.ai:hover .msg-copy-btn,
.msg-row.ai:focus-within .msg-copy-btn { display: block; }

/* ── 최신으로 스크롤 버튼 ─────────────────────────────────────── */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 13px;
  padding: 6px 16px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  z-index: 20;
  transition: background 0.15s;
}
.scroll-to-bottom-btn:hover { background: var(--border); }

/* ── 빈 상태 ─────────────────────────────────────────────────── */
#empty-state { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; flex: 1; justify-content: flex-end; padding-bottom: 16px; }

.model-intro-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 16px;
}
.model-intro-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.model-intro-badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: dot-blink 2.4s infinite ease-in-out;
}
.model-intro-text { font-size: 15px; line-height: 1.6; word-break: keep-all; }

/* ── 웰컴 화면 개선 ───────────────────────────────────────────── */
.welcome-intro {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0 2px;
  letter-spacing: 0.01em;
}

.model-compare {
  display: flex;
  gap: 10px;
}

.model-compare-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 13px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, background 0.15s;
}
.model-compare-card:hover {
  border-color: #444;
  background: var(--surface-2);
}
.model-compare-card.active {
  border-color: var(--accent);
  background: rgba(196,30,58,0.06);
}

.mcc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}
.mcc-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.model-compare-card.active .mcc-badge {
  color: var(--accent);
}
.mcc-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 2px 7px;
  white-space: nowrap;
}
.model-compare-card.active .mcc-tag {
  background: rgba(196,30,58,0.12);
  color: var(--accent);
}
.mcc-desc {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: keep-all;
}
.mcc-detail {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
  word-break: keep-all;
}
.mcc-when {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
  word-break: keep-all;
  margin-top: 2px;
}
.model-compare-card.active .mcc-when {
  color: var(--accent);
  opacity: 0.85;
}

/* ── 메시지 공통 ──────────────────────────────────────────────── */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  gap: 5px;
  animation: msg-in 0.2s ease both;
}
.msg-row.user { align-self: flex-end;   align-items: flex-end; }
.msg-row.ai   { align-self: flex-start; align-items: flex-start; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  word-break: keep-all;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg-row.user .bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 5px; }
.msg-row.ai   .bubble { background: var(--surface); color: var(--text-primary); border-bottom-left-radius: 5px; border: 1px solid var(--border); }

.msg-row + .msg-row           { margin-top: 4px; }
.msg-row.user + .msg-row.ai,
.msg-row.ai  + .msg-row.user  { margin-top: 16px; }

/* ── 출처 카드 ────────────────────────────────────────────────── */
.sources-wrapper { display: flex; flex-direction: column; gap: 4px; padding-left: 2px; }

.sources-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 4px 10px 4px 8px;
  border-radius: 10px; font-size: 12px; font-family: var(--font);
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.sources-toggle:hover { background: var(--surface-2); border-color: #3a3a3a; color: var(--text-primary); }
.sources-chevron { transition: transform 0.2s ease; flex-shrink: 0; }
.sources-toggle.expanded .sources-chevron { transform: rotate(180deg); }

.sources-list {
  overflow: hidden; max-height: 0; opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.sources-list.open { max-height: 300px; opacity: 1; }

.source-item {
  display: flex; align-items: flex-start; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
  font-size: 12px; color: var(--text-muted);
  line-height: 1.4; word-break: break-all;
}
.source-item svg { flex-shrink: 0; margin-top: 1px; color: var(--accent); opacity: 0.7; }

/* ── 웹 출처 ──────────────────────────────────────────────────── */
.web-sources-wrapper { display: flex; flex-direction: column; gap: 4px; padding-left: 2px; margin-top: 2px; }
.web-source-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-muted); text-decoration: none;
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface);
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.web-source-item:hover { background: var(--surface-2); color: var(--text-primary); }
.web-source-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }

/* ── 관련 주제 칩 ─────────────────────────────────────────────── */
@keyframes chip-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.related-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-left: 2px;
  animation: chip-fadein 0.3s ease both;
}
.chips-hint {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-chip);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1.4;
  padding: 4px 12px;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  opacity: 0;
  animation: chip-fadein 0.3s ease forwards;
  /* 말줄임 */
  min-width: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.related-chips.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── 예시 칩 ──────────────────────────────────────────────────── */
#chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center;
  background: transparent; border: 1px solid #333340;
  color: var(--text-chip); padding: 8px 14px;
  border-radius: 20px; font-size: 13.5px; font-family: var(--font);
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  /* 말줄임 — flex 아이템은 min-width:0 필수 */
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip:hover  { background: var(--surface-2); border-color: #3a3a45; color: var(--text-primary); }
.chip:active { background: var(--accent-dim); border-color: var(--accent); color: var(--text-primary); }

/* ── 로딩 점 ──────────────────────────────────────────────────── */
.loading-dots { display: flex; gap: 5px; align-items: center; padding: 2px 0; }
.loading-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  animation: dot-blink 1.4s infinite ease-in-out;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-blink {
  0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); }
  30%            { opacity: 1;   transform: scale(1.1); }
}

/* ── 입력창 영역 ──────────────────────────────────────────────── */
#input-area {
  flex-shrink: 0;
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 16px;
  background: var(--header-bg);
  border-top: 1px solid var(--border);
}
#input {
  flex: 1;
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 22px; padding: 11px 16px;
  font-size: 16px; font-family: var(--font);
  color: var(--text-primary); outline: none;
  caret-color: var(--accent);
  transition: border-color 0.15s; -webkit-appearance: none;
  resize: none; overflow-y: auto; line-height: 1.5;
  max-height: calc(5 * 1.5em + 22px);
}
#input::placeholder { color: var(--text-muted); }
#input:focus        { border-color: rgba(196, 30, 58, 0.5); }

#send-btn {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, transform 0.1s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#send-btn:hover    { background: #a8192f; }
#send-btn:active   { background: #921527; transform: scale(0.93); }
#send-btn:disabled { background: #2a1a1e; opacity: 0.5; cursor: default; }

/* ═══════════════════════════════════════════════════════════════
   자료실
════════════════════════════════════════════════════════════════ */

/* ── 카테고리 칩 가로 스크롤 ────────────────────────────────── */
.lib-categories {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
}
.lib-categories::-webkit-scrollbar { display: none; }

.lib-cat-btn {
  flex-shrink: 0;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 6px 14px;
  border-radius: 20px; font-size: 13px; font-family: var(--font);
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.lib-cat-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600;
}

/* ── 피드 스크롤 컨테이너 ────────────────────────────────────── */
.lib-feed {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.lib-feed::-webkit-scrollbar { display: none; }

#lib-cards { display: flex; flex-direction: column; gap: 1px; padding: 12px 16px; gap: 12px; }

/* ── 자료 카드 ───────────────────────────────────────────────── */
.lib-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  animation: msg-in 0.2s ease both;
}
.lib-card:active { transform: scale(0.985); border-color: #3a3a3a; }

.lib-card-thumb {
  width: 100%; height: 180px;
  object-fit: cover; display: block;
  border-bottom: 1px solid var(--border);
}

.lib-card-body { padding: 14px 16px 16px; }

.lib-card-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.lib-cat-badge {
  font-size: 11px; font-weight: 600;
  color: var(--accent); background: var(--accent-dim);
  padding: 2px 8px; border-radius: 10px;
  letter-spacing: 0.3px;
}
.lib-card-date { font-size: 11px; color: var(--text-muted); }

.lib-card-title {
  font-size: 15px; font-weight: 600; line-height: 1.4;
  color: var(--text-primary); margin-bottom: 6px;
  word-break: keep-all;
}
.lib-card-excerpt {
  font-size: 13px; line-height: 1.55;
  color: var(--text-muted); word-break: keep-all;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* ── 스켈레톤 ────────────────────────────────────────────────── */
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite linear;
  border-radius: 6px;
}
.skel-thumb  { height: 180px; border-radius: 0; border-bottom: 1px solid var(--border); }
.skel-line   { height: 14px; margin-bottom: 8px; }
.skel-line.w-30 { width: 30%; }
.skel-line.w-60 { width: 60%; }
.skel-line.w-80 { width: 80%; }
.skel-line.w-90 { width: 90%; }

/* ── 빈 상태 / 에러 ─────────────────────────────────────────── */
.lib-empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}
.lib-empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

/* ── 더 보기 버튼 ────────────────────────────────────────────── */
.load-more-btn {
  display: block; width: calc(100% - 32px);
  margin: 4px 16px 16px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 12px;
  border-radius: 12px; font-size: 14px; font-family: var(--font);
  cursor: pointer; transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.load-more-btn:hover { background: var(--surface-2); color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════════════
   자료 상세
════════════════════════════════════════════════════════════════ */

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.detail-scroll::-webkit-scrollbar { display: none; }

.detail-body { padding: 20px 16px 32px; }

.detail-thumb {
  width: 100%; max-height: 240px;
  object-fit: cover; border-radius: 14px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.detail-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.detail-title {
  font-size: 20px; font-weight: 700; line-height: 1.35;
  color: var(--text-primary); margin-bottom: 20px;
  word-break: keep-all; letter-spacing: -0.3px;
}
.detail-content { font-size: 15px; line-height: 1.75; color: #d0d0d0; word-break: keep-all; }
.detail-content p { margin-bottom: 14px; }
.detail-content p:last-child { margin-bottom: 0; }
.dc-h2 { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 24px 0 8px; letter-spacing: -0.3px; }
.dc-h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 18px 0 6px; letter-spacing: -0.2px; }
.dc-list { margin: 0 0 14px 18px; padding: 0; }
.dc-list li { font-size: 15px; line-height: 1.75; color: #d0d0d0; margin-bottom: 6px; }
.detail-content strong { color: var(--text-primary); font-weight: 700; }
.detail-content em { font-style: italic; color: #c0c0c0; }

.detail-cta {
  margin-top: 32px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px;
}
.detail-cta-label {
  font-size: 12px; color: var(--text-muted); margin-bottom: 10px;
}
.detail-cta-btn {
  width: 100%; background: var(--accent); border: none;
  color: #fff; padding: 13px 16px; border-radius: 12px;
  font-size: 15px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.detail-cta-btn:hover  { background: #a8192f; }
.detail-cta-btn:active { background: #921527; }

/* ═══════════════════════════════════════════════════════════════
   어드민
════════════════════════════════════════════════════════════════ */

#admin-container { display: flex; flex-direction: column; min-height: 100%; }

/* 어드민 공통 헤더 */
.admin-header {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  min-height: 52px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}
.admin-header-left { display: flex; align-items: center; gap: 10px; }
.admin-header-title { font-size: 16px; font-weight: 700; }
.admin-header-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* 어드민 버튼 공통 */
.admin-btn {
  background: var(--accent); border: none;
  color: #fff; padding: 8px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.admin-btn:hover    { background: #a8192f; }
.admin-btn--ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted);
}
.admin-btn--ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.admin-btn--danger {
  background: transparent; border: 1px solid #5a1a20;
  color: #e05060;
}
.admin-btn--danger:hover { background: rgba(220,60,80,0.1); }

/* ── 어드민 로그인 ───────────────────────────────────────────── */
.admin-login {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px;
  gap: 20px;
}
.admin-login-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.admin-login-sub   { font-size: 14px; color: var(--text-muted); text-align: center; }

.admin-input {
  width: 100%;
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 12px; padding: 13px 16px;
  font-size: 15px; font-family: var(--font);
  color: var(--text-primary); outline: none;
  transition: border-color 0.15s; -webkit-appearance: none;
}
.admin-input:focus { border-color: rgba(196,30,58,0.5); }
.admin-input::placeholder { color: var(--text-muted); }

.admin-login-btn {
  width: 100%; background: var(--accent); border: none;
  color: #fff; padding: 14px; border-radius: 12px;
  font-size: 15px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background 0.15s;
}
.admin-login-btn:hover  { background: #a8192f; }
.admin-login-btn:active { background: #921527; }

.admin-login-err {
  font-size: 13px; color: #e05060; text-align: center;
  display: none;
}
.admin-login-err.show { display: block; }

/* ── 어드민 목록 ─────────────────────────────────────────────── */
.admin-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 24px;
}
.admin-body::-webkit-scrollbar { display: none; }

.admin-post-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex; align-items: flex-start; gap: 10px;
}
.admin-post-info { flex: 1; min-width: 0; }
.admin-post-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.admin-post-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-post-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-muted);
}
.admin-post-badge.published { background: rgba(34,197,94,0.12); color: #4ade80; }
.admin-post-badge.draft     { background: rgba(251,191,36,0.12); color: #fbbf24; }
.admin-post-actions { display: flex; gap: 6px; flex-shrink: 0; margin-top: 2px; }
.admin-post-actions button {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 4px 10px;
  border-radius: 7px; font-size: 12px; font-family: var(--font);
  cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.admin-post-actions .edit-btn:hover   { border-color: var(--accent); color: var(--accent); }
.admin-post-actions .delete-btn:hover { border-color: #e05060; color: #e05060; }

/* ── 어드민 폼 ───────────────────────────────────────────────── */
.admin-form-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 32px;
}
.admin-form-body::-webkit-scrollbar { display: none; }

.admin-form-group { margin-bottom: 16px; }
.admin-form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
  letter-spacing: 0.3px; text-transform: uppercase;
}
.admin-form-label span { color: var(--accent); }

.admin-select {
  width: 100%;
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 10px; padding: 11px 12px;
  font-size: 14px; font-family: var(--font);
  color: var(--text-primary); outline: none;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.admin-select:focus { border-color: rgba(196,30,58,0.5); }

.admin-textarea {
  width: 100%;
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 10px; padding: 11px 12px;
  font-size: 14px; font-family: var(--font); line-height: 1.55;
  color: var(--text-primary); outline: none; resize: vertical;
  min-height: 80px;
}
.admin-textarea.tall { min-height: 200px; }
.admin-textarea:focus { border-color: rgba(196,30,58,0.5); }

/* 썸네일 업로드 */
.admin-upload-area {
  border: 1.5px dashed var(--border);
  border-radius: 10px; padding: 20px;
  text-align: center; cursor: pointer;
  transition: border-color 0.15s; position: relative;
}
.admin-upload-area:hover { border-color: #3a3a3a; }
.admin-upload-area input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.admin-upload-label { font-size: 13px; color: var(--text-muted); }
.admin-upload-label strong { color: var(--accent); }

.admin-thumb-preview {
  width: 100%; max-height: 160px; object-fit: cover;
  border-radius: 8px; margin-top: 10px; display: none;
  border: 1px solid var(--border);
}
.admin-thumb-preview.show { display: block; }

.admin-thumb-url {
  font-size: 11px; color: var(--text-muted);
  word-break: break-all; margin-top: 6px;
  display: none;
}
.admin-thumb-url.show { display: block; }

/* published 토글 */
.admin-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
}
.admin-toggle-label { font-size: 14px; color: var(--text-primary); }

/* ── 태블릿/데스크탑 ─────────────────────────────────────────── */
@media (min-width: 600px) {
  #app {
    max-width: 560px;
    margin: 0 auto;
    border-left:  1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
@media (min-width: 900px) {
  #app {
    max-width: 680px;
  }
}

/* ── 접근성: 모션 감소 ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .msg-row, .lib-card       { animation: none; }
  .sources-list             { transition: none; }
  .sources-chevron          { transition: none; }
  .loading-dots span        { animation: none; opacity: 0.6; }
  .model-intro-badge-dot    { animation: none; }
  .skeleton                 { animation: none; background: var(--surface-2); }
}

/* ══════════════════════════════════════════════════════════════
   인증 UI
══════════════════════════════════════════════════════════════ */

/* ── 헤더 인증 버튼 ──────────────────────────────────────────── */
.auth-header-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.auth-header-btn:hover    { background: var(--surface); }
.auth-header-btn.logged-in { color: var(--text); border-color: var(--accent); }

/* ── 인증 모달 오버레이 ──────────────────────────────────────── */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.auth-modal[hidden] { display: none; }

.auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  animation: auth-fade-in 0.2s ease;
}

/* ── 바텀 시트 ────────────────────────────────────────────────── */
.auth-sheet {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  animation: auth-slide-up 0.28s cubic-bezier(0.34, 1.1, 0.64, 1);
  max-height: 90dvh;
  overflow-y: auto;
}
.auth-sheet-drag {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}
.auth-sheet-body {
  padding: 20px 20px 8px;
}
.auth-sheet-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin: 12px 0 8px;
}
.auth-sheet-desc {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.65;
  margin-bottom: 24px;
}

/* ── OAuth 버튼 ───────────────────────────────────────────────── */
.auth-oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, filter 0.15s;
  margin-bottom: 10px;
}
.auth-oauth-btn:active { opacity: 0.8; }

/* ── OR 구분선 ────────────────────────────────────────────────── */
.auth-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-or::before,
.auth-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── 이메일 버튼 ──────────────────────────────────────────────── */
.auth-email-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-email-btn:hover { background: var(--bg); }

/* ── 이메일 폼 ────────────────────────────────────────────────── */
.auth-email-form {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.auth-field-input {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.auth-field-input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-field-input::placeholder { color: var(--text-muted); }

.auth-form-submit {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}
.auth-form-submit:disabled { opacity: 0.6; cursor: default; }

.auth-form-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-form-toggle button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 4px;
}

.auth-reset-link {
  display: block;
  margin: 0 auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-align: center;
}

.auth-form-msg {
  font-size: 13px;
  text-align: center;
  padding: 9px 12px;
  border-radius: 8px;
  line-height: 1.5;
}
.auth-form-msg.error   { color: #e05060; background: rgba(224,80,96,0.1); }
.auth-form-msg.success { color: #4caf50; background: rgba(76,175,80,0.1); }

.auth-terms-notice {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin: 4px 0 0;
  line-height: 1.5;
}
.auth-terms-notice a { color: var(--text-muted); text-decoration: underline; }

/* ── 유저 메뉴 시트 ────────────────────────────────────────────── */
.auth-user-sheet-body {
  padding: 20px 20px 8px;
  text-align: center;
}
.auth-user-nick {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-user-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  word-break: break-all;
}
.auth-logout-btn {
  width: 100%;
  padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-logout-btn:hover { background: var(--bg); }

/* ── 키프레임 ────────────────────────────────────────────────── */
@keyframes auth-fade-in  { from { opacity: 0; }            to { opacity: 1; }            }
@keyframes auth-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .auth-backdrop { animation: none; }
  .auth-sheet    { animation: none; }
}

/* ══════════════════════════════════════════════════════════════
   번역 화면
   ══════════════════════════════════════════════════════════════ */
#screen-translate {
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.translate-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px calc(var(--tab-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── 업로드 패널 ── */
.translate-upload-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.translate-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 40px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text-muted);
  text-align: center;
}
.translate-drop:hover,
.translate-drop.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-primary);
}
.translate-drop-label {
  font-size: 14px;
  line-height: 1.6;
}
.translate-drop-label span {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}
.translate-drop-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── 진행 바 ── */
.translate-progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.translate-progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
@keyframes tr-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
.translate-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  width: 5%;
  transition: width 0.6s ease;
  animation: tr-pulse 1.4s ease-in-out infinite;
}
.translate-progress-label {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ── 로그인 유도 ── */
.translate-login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}
.translate-login-prompt strong { color: var(--text-primary); }
.translate-login-btn {
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.translate-login-btn:hover { opacity: 0.85; }

/* ── 영상 플레이어 + 자막 오버레이 ── */
.tr-video-wrap {
  position: relative;
  background: #000;
  border-bottom: 1px solid var(--border);
  line-height: 0;
  /* 세로 영상 기준: 화면 높이의 60% 이하, 최대 480px */
  max-height: min(60svh, 480px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tr-video {
  width: 100%;
  height: 100%;
  max-height: min(60svh, 480px);
  display: block;
  object-fit: contain;
}
.subtitle-overlay {
  position: absolute;
  bottom: 10%;
  left: 10%;
  width: 80%;
  text-align: center;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,0.9);
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 10px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.subtitle-overlay.visible { opacity: 1; }

.tr-video-wrap.portrait { max-height: 70svh; }
.tr-video-wrap.portrait .tr-video { width: auto; max-width: 100%; height: 70svh; max-height: none; }
.tr-video-wrap.portrait .subtitle-overlay { font-size: 18px; }

/* ── 결과 ── */
.translate-result {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}
.tr-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.tr-result-filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.tr-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tr-new-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s;
}
.tr-new-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.tr-srt-btn {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  transition: background 0.15s;
}
.tr-srt-btn:hover { background: var(--accent-dim); }

.tr-cols-head {
  display: grid;
  grid-template-columns: 56px 1fr 1fr;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tr-rows {
  max-height: 420px;
  overflow-y: auto;
}
.tr-row {
  display: grid;
  grid-template-columns: 56px 1fr 1fr;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--surface-2);
  align-items: start;
  font-size: 13px;
  line-height: 1.5;
}
.tr-row:last-child { border-bottom: none; }
.tr-ts   { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.tr-orig { color: var(--text-muted); }
.tr-ko   { color: var(--text-primary); }
.tr-empty { padding: 20px 16px; color: var(--text-muted); font-size: 13px; }
.tr-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: #f87171;
  font-size: 13px;
}

/* ── 기록 ── */
.translate-history { display: flex; flex-direction: column; gap: 10px; }
.translate-history-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.translate-history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tr-hist-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}
.tr-hist-item:hover { background: var(--surface-2); }
.tr-hist-name  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.tr-hist-date  { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.tr-hist-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.tr-hist-done  .tr-hist-status { background: rgba(52,211,153,0.15); color: #34d399; }
.tr-hist-fail  .tr-hist-status { background: rgba(248,113,113,0.15); color: #f87171; }
.tr-hist-proc  .tr-hist-status { background: rgba(251,191,36,0.15);  color: #fbbf24; }
.tr-hist-pend  .tr-hist-status { background: var(--surface-2);       color: var(--text-muted); }
.tr-hist-srt {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
}
.tr-hist-srt:hover { background: var(--accent-dim); }

/* ══════════════════════════════════════════════════════════════
   어드민 오버레이 패널
   ══════════════════════════════════════════════════════════════ */
.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.admin-panel[hidden] { display: none; }

.admin-panel-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  padding-top: calc(env(safe-area-inset-top) + 10px);
  padding-bottom: 10px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  min-height: calc(52px + env(safe-area-inset-top));
}
.admin-panel-logo {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.admin-panel-tabs {
  display: flex;
  gap: 6px;
  flex: 1;
}
.apt {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.apt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.admin-panel-close {
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 16px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.admin-panel-close:hover { background: var(--surface-3); }

.admin-panel-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}
.admin-tab-pane {
  display: none;
  min-height: 100%;
}
.admin-tab-pane.active,
.admin-tab-pane[style*="display: block"],
.admin-tab-pane[style*="display:block"] { display: block; }

/* ── 어드민 시크릿 모달 ── */
.admin-secret-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
}
.admin-secret-modal[hidden] { display: none; }
.admin-secret-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.admin-secret-sheet {
  position: relative;
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: auth-slide-up 0.22s ease;
}
.admin-secret-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}
.admin-secret-desc {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.admin-secret-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.admin-secret-input:focus { border-color: var(--accent); }
.admin-secret-err {
  font-size: 13px;
  color: #f87171;
  text-align: center;
}
.admin-secret-err[hidden] { display: none; }
.admin-secret-btn {
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.admin-secret-btn:hover { opacity: 0.85; }
.admin-secret-btn:disabled { opacity: 0.5; cursor: default; }

/* ══════════════════════════════════════════════════════════════
   번역 기록 어드민 카드
   ══════════════════════════════════════════════════════════════ */
#admin-tr-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.atr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.atr-card.tr-hist-done  { border-left: 3px solid #34d399; }
.atr-card.tr-hist-fail  { border-left: 3px solid #f87171; }
.atr-card.tr-hist-proc  { border-left: 3px solid #fbbf24; }
.atr-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.atr-filename {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.atr-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  flex-shrink: 0;
}
.tr-hist-done .atr-status { background: rgba(52,211,153,0.15); color: #34d399; }
.tr-hist-fail .atr-status { background: rgba(248,113,113,0.15); color: #f87171; }
.tr-hist-proc .atr-status { background: rgba(251,191,36,0.15);  color: #fbbf24; }
.atr-card-meta {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.atr-err {
  font-size: 12px;
  color: #f87171;
  background: rgba(248,113,113,0.08);
  border-radius: 6px;
  padding: 6px 10px;
}
.atr-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.atr-btn {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  padding: 7px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.atr-btn:hover { background: var(--surface-3); }
.atr-btn:disabled { opacity: 0.4; cursor: default; }
.atr-btn--accent { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.atr-btn--accent:hover { background: rgba(196,30,58,0.2); }
.atr-btn--danger { background: rgba(248,113,113,0.08); border-color: #f87171; color: #f87171; }
.atr-btn--danger:hover { background: rgba(248,113,113,0.18); }
.atr-corpus-badge { font-size: 10px; padding: 2px 6px; background: rgba(52,211,153,0.12); border: 1px solid #34d399; color: #34d399; border-radius: 4px; white-space: nowrap; }

/* ── 스크립트 뷰 ── */
.atr-script-view {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.atr-script-tabs {
  display: flex;
  gap: 6px;
}
.ast-tab {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font);
  padding: 4px 12px;
  cursor: pointer;
}
.ast-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ast-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ast-content {
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}
.ast-seg-row {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--surface-3);
  font-size: 12px;
}
.ast-seg-ts   { color: var(--text-muted); white-space: nowrap; min-width: 44px; }
.ast-seg-text { color: var(--text-primary); }
.ast-seg { max-height: 240px; overflow-y: auto; }

/* ── 캡션 박스 ── */
.atr-caption-box {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.atr-caption-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap;
}
.atr-copy-btn {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  padding: 6px 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
}

/* ── 자막 영상 박스 ── */
.atr-burn-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
  flex-wrap: wrap;
}
.atr-burn-note {
  font-size: 11px;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════
   도구 허브
   ══════════════════════════════════════════════════════════════ */
#screen-tools { flex-direction: column; }

.tools-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px calc(var(--tab-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Coming Soon 섹션 구분 ── */
.tools-section--soon {
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.tools-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 12px;
}

.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  font-family: var(--font);
}
.tool-card:hover:not([disabled]) { background: var(--surface-2); border-color: var(--accent); }
.tool-card--disabled { opacity: 0.45; cursor: default; }

.tool-card-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--surface-2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.tool-card--disabled .tool-card-icon { color: var(--text-muted); }

.tool-card-info { flex: 1; min-width: 0; }
.tool-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.tool-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.tool-card-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  flex-shrink: 0;
}

/* ── 도구 오버레이 ── */
.tool-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.tool-overlay[hidden] { display: none; }

.tool-overlay-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  min-height: calc(52px + env(safe-area-inset-top));
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}
.tool-overlay-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.tool-overlay-body {
  flex: 1;
  overflow-y: auto;
}

/* ── 계산기 공통 ── */
.calc-wrap {
  padding: 24px 16px calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.calc-step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.calc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.calc-field { display: flex; flex-direction: column; gap: 6px; }
.calc-field--full { grid-column: 1 / -1; }
.calc-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.calc-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
}
.calc-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text-primary);
  padding: 11px 0;
  min-width: 0;
}
.calc-input::placeholder { color: var(--text-muted); }
.calc-unit { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }

.calc-select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.calc-seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.seg-btn {
  flex: 1;
  padding: 10px 4px;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.calc-submit {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 4px;
}
.calc-submit:hover { opacity: 0.88; }

.calc-reset {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.calc-reset:hover { background: var(--surface-2); }

.calc-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  padding: 0 8px;
}

/* ── TDEE 목표 버튼 (리뉴얼) ── */
.tdee-goal-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tdee-goal-btn {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 3px;
}
.tdee-goal-btn:hover { border-color: rgba(196,30,58,0.5); background: var(--surface-2); }
.tdee-goal-btn.active { border-color: var(--accent); background: rgba(196,30,58,0.07); }
.tdee-goal-btn-label {
  font-size: 15px;
  font-weight: 700;
  grid-column: 1;
  grid-row: 1;
}
.tdee-goal-btn.active .tdee-goal-btn-label { color: var(--accent); }
.tdee-goal-btn-adj {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  background: rgba(196,30,58,0.1);
  padding: 2px 8px;
  border-radius: 6px;
}
.tdee-goal-btn-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  grid-column: 1 / -1;
  grid-row: 2;
}
.calc-back-btn {
  background: transparent;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0 12px;
  text-align: left;
}
.calc-back-btn:hover { color: var(--text-primary); }

/* ── 공통 안전 경고 ── */
.calc-safety-warn {
  background: rgba(245,166,35,0.08);
  border: 1px solid rgba(245,166,35,0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: #F5A623;
  line-height: 1.55;
  margin-bottom: 12px;
}

/* ── TDEE 결과 ── */
.tdee-result-main {
  text-align: center;
  padding: 20px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tdee-result-goal {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}
.tdee-result-kcal {
  font-size: 52px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}
.tdee-result-unit {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
}
.tdee-result-refs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.tdee-ref-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  font-size: 13px;
  padding: 11px 14px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.tdee-ref-row > span:first-child { color: var(--text-muted); font-weight: 600; grid-column:1; grid-row:1; }
.tdee-ref-sub { font-size: 11px; color: var(--text-muted); opacity: 0.7; grid-column:1; grid-row:2; }
.tdee-ref-row > b { color: var(--text-primary); font-weight: 700; grid-column:2; grid-row:1/3; align-self:center; white-space:nowrap; }
.tdee-ref-badge {
  display: inline-block;
  font-style: normal;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(196,30,58,0.1);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── 매크로 계산기 — TDEE 연동 배지 ── */
.mc-from-tdee-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(196,30,58,0.07);
  border: 1px solid rgba(196,30,58,0.2);
  border-radius: 8px;
  padding: 7px 12px;
  margin-bottom: 4px;
}
.mc-from-tdee-badge::before { content: '→'; }

/* ── 매크로 도넛 섹션 ── */
.mc-donut-section {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.mc-donut-chart {
  position: relative;
  flex-shrink: 0;
}
.mc-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.mc-donut-kcal {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.mc-donut-unit {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
.mc-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.mc-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.mc-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mc-legend-protein .mc-legend-dot { background: #E8304A; }
.mc-legend-fat     .mc-legend-dot { background: #F5A623; }
.mc-legend-carb    .mc-legend-dot { background: #4A8FE8; }
.mc-legend-lbl { color: var(--text-muted); flex: 1; }
.mc-legend-pct { font-weight: 700; color: var(--text-primary); }

/* ── 매크로 카드 ── */
.mc-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.mc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 2px 12px;
}
.mc-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1;
  grid-row: 1;
}
.mc-card-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.mc-card-pct {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
}
.mc-card--protein .mc-card-pct { color: #E8304A; background: rgba(232,48,74,0.1); }
.mc-card--fat     .mc-card-pct { color: #F5A623; background: rgba(245,166,35,0.1); }
.mc-card--carb    .mc-card-pct { color: #4A8FE8; background: rgba(74,143,232,0.1); }
.mc-card-amount {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  color: var(--text-primary);
  white-space: nowrap;
}
.mc-card--protein .mc-card-amount { color: #E8304A; }
.mc-card--fat     .mc-card-amount { color: #F5A623; }
.mc-card--carb    .mc-card-amount { color: #4A8FE8; }
.mc-card-unit {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.7;
}
.mc-card-kcal {
  font-size: 12px;
  color: var(--text-muted);
  grid-column: 1;
  grid-row: 2;
}
.mc-card-insight {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.75;
  line-height: 1.45;
  grid-column: 1 / -1;
  grid-row: 3;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── 매크로 검산 행 ── */
.mc-verify-row {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  padding: 4px 0 8px;
}
.mc-verify-ok {
  color: #4ade80;
  font-weight: 600;
  margin-left: 6px;
}

/* ── 구버전 mc-item 스타일 (하위호환 — 칼로리 트래커 등) ── */
.mc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}
.mc-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 10px 12px;
  text-align: center;
}
.mc-item-name {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.mc-item-g { font-size: 28px; font-weight: 800; line-height: 1; color: var(--text-primary); }
.mc-item-unit { font-size: 13px; font-weight: 600; }
.mc-item-kcal { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.mc-item-note { font-size: 10px; color: var(--text-muted); opacity: 0.65; margin-top: 3px; }
.mc-protein .mc-item-g { color: var(--accent); }

/* ── 투구 피로 결과 ── */
.pf-result-main {
  text-align: center;
  padding: 28px 0 20px;
}
.pf-fatigue-num {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}
.pf-low  { color: #4ade80; }
.pf-mid  { color: #facc15; }
.pf-high { color: #fb923c; }
.pf-max  { color: #f87171; }
.pf-fatigue-label {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 16px;
}
.pf-recovery {
  font-size: 18px;
  color: var(--text-primary);
  font-weight: 500;
}
.pf-recovery b { font-weight: 800; color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════════
   트래킹 공통
   ══════════════════════════════════════════════════════════════ */
.track-wrap { padding-bottom: 32px; }
.track-loading, .track-error { text-align: center; color: var(--text-muted); padding: 32px 0; font-size: 14px; }
.track-error { color: var(--accent); }
.track-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 16px 0; }

/* 로그인 게이트 */
.track-login-gate {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 40px 16px; text-align: center;
}
.track-login-msg { font-size: 15px; color: var(--text-muted); }
.track-login-btn {
  padding: 12px 28px; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600; border: none; cursor: pointer;
}

/* 아이템 행 */
.track-items { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.track-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: 8px; padding: 10px 12px;
}
.track-item-label { flex: 1; font-size: 14px; color: var(--text-primary); }
.track-item-kcal  { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.track-item-del   {
  background: none; border: none; color: var(--text-muted); font-size: 13px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.track-item-del:hover { color: var(--accent); }

/* 입력 행 */
.track-add-row { display: flex; gap: 8px; margin: 8px 0; }
.track-input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
  color: var(--text-primary); font-family: inherit;
}
.track-input::placeholder { color: var(--text-muted); }
.track-input--num { flex: 0 0 80px; text-align: right; }
.track-add-btn {
  padding: 10px 16px; border-radius: 8px; background: var(--accent);
  color: #fff; font-size: 14px; font-weight: 600; border: none; cursor: pointer;
  white-space: nowrap;
}

/* ── 칼로리 트래킹 ── */
.track-today-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.track-today-date  { font-size: 13px; color: var(--text-muted); }
.track-today-total { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.track-goal-row    { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 28px; }
.track-goal-remain { font-size: 13px; color: var(--text-muted); }
.track-goal-remain.over { color: var(--accent); }
.track-goal-set-btn {
  font-size: 12px; color: var(--accent); background: none; border: 1px solid var(--accent);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.track-bar {
  height: 6px; border-radius: 3px; background: var(--surface-3);
  overflow: hidden; margin-bottom: 12px;
}
.track-bar-fill     { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.track-bar-fill--over { height: 100%; background: #e85c5c; border-radius: 3px; transition: width .3s; }

/* 최근 7일 미니 막대 */
.track-mini-chart { margin-top: 20px; }
.track-mini-title { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.track-mini-bars  { display: flex; align-items: flex-end; gap: 4px; height: 68px; }
.track-mini-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.track-mini-bar {
  width: 100%; background: var(--surface-3); border-radius: 3px 3px 0 0;
  min-height: 4px; transition: height .3s;
}
.track-mini-bar.today { background: var(--accent); }
.track-mini-label { font-size: 10px; color: var(--text-muted); }

/* ── 빅3 트래킹 ── */
.b3-summary {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.b3-sum-card {
  flex: 1; background: var(--surface-2); border-radius: 8px;
  padding: 10px 8px; text-align: center;
}
.b3-sum-lift { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.b3-sum-1rm  { display: block; font-size: 14px; font-weight: 700; color: var(--text-primary); }
.b3-tabs {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.b3-tab {
  flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 13px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer;
}
.b3-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.b3-best {
  font-size: 13px; color: var(--text-muted); margin-bottom: 8px; text-align: center;
}
.b3-best strong { color: var(--text-primary); font-weight: 700; }
.b3-1rm-preview {
  font-size: 13px; color: var(--accent); text-align: right; min-height: 20px;
  margin-bottom: 4px; font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   모션 리포트 (_mr)
   ══════════════════════════════════════════════════════════════ */

#screen-motion {
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.motion-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px calc(var(--tab-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 비로그인 */
.motion-login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.motion-login-prompt svg { color: var(--text-muted); opacity: 0.6; }
.motion-login-prompt p { font-size: 15px; line-height: 1.6; }
.motion-login-prompt strong { color: var(--text-primary); }

.motion-login-btn {
  padding: 12px 32px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  min-height: 44px;
}
.motion-login-btn:hover { opacity: 0.85; }

/* 업로드 패널 */
.motion-upload-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.motion-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 40px 24px;
  cursor: pointer;
  transition: border-color 200ms, background 200ms;
  color: var(--text-muted);
  min-height: 44px;
}
.motion-drop:hover,
.motion-drop.drag-over {
  border-color: var(--accent);
  background: rgba(196, 30, 58, 0.05);
}
.motion-drop-label {
  font-size: 15px;
  text-align: center;
  line-height: 1.6;
}
.motion-drop-label span { color: var(--accent); font-weight: 600; }
.motion-drop-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* 처리 중 스피너 */
.motion-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 16px;
}

.motion-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: mr-spin 0.9s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .motion-spinner { animation: none; border-top-color: var(--accent); }
}
@keyframes mr-spin {
  to { transform: rotate(360deg); }
}

.motion-progress-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.motion-progress-sub {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* 결과 카드 */
.motion-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: mr-fadein 250ms ease;
}
@keyframes mr-fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.mr-card-header {
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mr-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.mr-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── 가로 타임라인 ── */
.mr-timeline {
  position: relative;
  margin: 8px 16px 8px;
  height: 88px; /* 위 40px + 트랙 2px + 아래 46px */
}

.mr-tl-track {
  position: absolute;
  top: 40px;
  left: 5%;
  right: 5%;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
}

.mr-tl-step {
  position: absolute;
  top: 40px; /* 기본: 트랙 위에 */
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.mr-tl-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  transition: background 200ms, border-color 200ms;
  flex-shrink: 0;
}
.mr-tl-dot--ok {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.2);
}

/* ── v0.8: step 교차 배치 (근위=위, 원위=아래) ── */
.mr-tl-step--above {
  /* dot 위쪽에 labels: flex-direction column-reverse (dot이 맨 아래, 라벨 위) */
  top: auto;
  bottom: calc(100% - 40px); /* 40px = 트랙 top. 컨테이너 88px → bottom = 48px */
  flex-direction: column-reverse;
}
.mr-tl-step--below {
  top: 42px; /* 트랙(40px) + dot(2px 간격) */
  bottom: auto;
  flex-direction: column;
}
.mr-tl-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  margin-top: 2px;
}
.mr-tl-time {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── v0.8: FP/REL 이벤트 마커 ── */
.mr-tl-event {
  position: absolute;
  top: 14px;   /* 마커 시작: 트랙 위 26px */
  bottom: 8px; /* 트랙 아래 */
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.mr-tl-event-line {
  width: 1px;
  flex: 1;
  background: var(--text-muted);
  opacity: 0.35;
}
.mr-tl-event-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.6;
  letter-spacing: 0.3px;
  padding: 1px 3px;
}
.mr-tl-event--rel .mr-tl-event-line { background: var(--accent); opacity: 0.5; }
.mr-tl-event--rel .mr-tl-event-label { color: var(--accent); opacity: 0.8; }

/* ── v0.8: 축 라벨 ── */
.mr-tl-axis-label {
  display: flex;
  justify-content: space-between;
  padding: 2px 16px 6px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.55;
}

/* ── 판정 ── */
.mr-verdict {
  margin: 0 16px 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.mr-verdict--ok {
  border: 1px solid rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.08);
  color: #22c55e;
}
.mr-verdict--ok svg { color: #22c55e; flex-shrink: 0; margin-top: 1px; }
.mr-verdict--warn { border: 1px solid rgba(196, 30, 58, 0.2); }
.mr-verdict--warn svg { color: var(--accent); flex-shrink: 0; margin-top: 2px; }

.mr-notes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mr-notes li::before { content: "• "; color: var(--accent); }

/* ── 피크 상세 (details) ── */
.mr-details {
  border-top: 1px solid var(--border);
  padding: 0;
}
.mr-details summary {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.mr-details summary::after {
  content: '▸';
  margin-left: auto;
  font-size: 11px;
  transition: transform 200ms;
}
.mr-details[open] summary::after { transform: rotate(90deg); }

.mr-peak-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 16px 4px;
  display: table;
}
.mr-peak-table th {
  padding: 4px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
}
.mr-peak-table td {
  padding: 4px 16px;
  border-top: 1px solid var(--border);
}

.mr-meta {
  padding: 8px 16px 14px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── 에러 카드 ── */
.mr-error-card {
  background: var(--surface);
  border: 1px solid rgba(196, 30, 58, 0.25);
  border-radius: 16px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.mr-error-msg {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
}
.mr-retry-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  align-self: flex-start;
  margin-top: 4px;
}
.mr-retry-guide {
  align-self: flex-start;
  padding: 0;
  margin: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mr-retry-guide li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 14px;
  position: relative;
}
.mr-retry-guide li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.mr-retry-btn {
  margin-top: 8px;
  padding: 10px 28px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}
.mr-retry-btn:hover { border-color: var(--accent); color: var(--text-primary); }

/* ── 새 영상 분석 버튼 ── */
.mr-new-btn {
  padding: 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  min-height: 44px;
  transition: border-color 200ms, color 200ms;
}
.mr-new-btn:hover { border-color: var(--accent); color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════════
   스켈레톤 플레이어 + 필름스트립  (v0.5)
══════════════════════════════════════════════════════════════ */

/* ── 플레이어 전체 래퍼 ── */
.mr-player-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.mr-player-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── 토글 모드 버튼 ── */
.mr-player-toggle {
  display: flex;
  gap: 6px;
}
.mr-toggle-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: 'Pretendard', sans-serif;
  cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
  min-height: 36px;
}
.mr-toggle-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.mr-toggle-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── 비디오 + 캔버스 컨테이너 ── */
.mr-player-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16/9;
}
.mr-player-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.mr-player-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── 스켈레톤 only 모드: 비디오 숨김 ── */
.mr-player-container.skeleton-only video {
  visibility: hidden;
}

/* ── 필름스트립 ── */
.mr-filmstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.mr-filmstrip:empty { display: none; }

.mr-filmstrip-thumb {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 150ms;
  background: #111;
}
.mr-filmstrip-thumb:hover { border-color: var(--accent); }
.mr-filmstrip-thumb canvas {
  display: block;
  border-radius: 6px 6px 0 0;
}
.mr-filmstrip-label {
  padding: 4px 6px 6px;
  text-align: center;
  line-height: 1.3;
}
.mr-filmstrip-en {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}
.mr-filmstrip-ko {
  display: block;
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 600;
}

/* ── 플레이어 로딩 오버레이 ── */
.mr-player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  color: var(--text-secondary);
  font-size: 13px;
  gap: 8px;
  border-radius: 10px;
}
.mr-player-loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: mr-spin 0.8s linear infinite;
}

/* ── 커스텀 플레이어 컨트롤 (skeleton-only 모드에도 항상 표시) ── */
.mr-player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 4px;
}
.mr-ctrl-play {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.mr-ctrl-play:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.mr-ctrl-seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.mr-ctrl-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.mr-ctrl-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
.mr-ctrl-time {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── 야구 특화 섹션 ── */
.mr-baseball-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* 신뢰도 낮음 배너 */
.mr-confidence-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(196,30,58,0.08);
  border: 1px solid rgba(196,30,58,0.25);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* 지표 카드 행 */
.mr-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 480px) { .mr-metrics-row { grid-template-columns: 1fr; } }

.mr-metric-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mr-metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mr-metric-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mr-metric-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.mr-metric-caption {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* 분리 밴드 배지 */
.mr-band-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}
.mr-band--ok   { background: rgba(34,197,94,0.15);  color: #4ade80; }
.mr-band--warn { background: rgba(234,179,8,0.15);  color: #facc15; }
.mr-band--bad  { background: rgba(196,30,58,0.15);  color: #f87171; }
.mr-band--info { background: rgba(99,102,241,0.12); color: #a5b4fc; }

/* 등급 배지 */
.mr-grade-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  display: inline-block;
}
.mr-grade--ok   { background: rgba(34,197,94,0.15);  color: #4ade80; }
.mr-grade--warn { background: rgba(196,30,58,0.15);  color: #f87171; }

/* 훈련 방향 */
.mr-rec-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.mr-rec-heading {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.mr-rec-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mr-rec-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.mr-rec-item--warn {
  border-color: rgba(196,30,58,0.3);
  background: rgba(196,30,58,0.05);
}
.mr-rec-cat {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-secondary);
  width: 36px;
  padding-top: 2px;
}
.mr-rec-cat svg { color: var(--accent); }
.mr-rec-item--warn .mr-rec-cat svg { color: #f87171; }
.mr-rec-title-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  align-self: end;
}
.mr-rec-why {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  align-self: start;
}
.mr-rec-disclaimer {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  opacity: 0.7;
}

/* ── v0.7: 타임라인 원위 흐리기 ── */
.mr-tl-step--dim { opacity: 0.45; }
.mr-tl-dot--dim {
  background: var(--surface-2);
  border-color: var(--border);
  box-shadow: none;
}
.mr-tl-conf-low {
  display: inline-block;
  margin-left: 3px;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.75;
}
.mr-row-dim { opacity: 0.5; }

/* ── v0.7: 원위 신뢰도 주의 배너 ── */
.mr-distal-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── v0.7: 코칭 받기 버튼 ── */
.mr-coaching-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.mr-coaching-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 22px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 150ms, transform 100ms;
}
.mr-coaching-btn:hover  { opacity: 0.9; }
.mr-coaching-btn:active { transform: scale(0.97); }

/* ── v0.7: 프리셋 칩 ── */
.mr-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.mr-chip {
  padding: 6px 13px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.mr-chip:hover {
  background: var(--surface-3, rgba(255,255,255,0.08));
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ── v0.7: 메시지 버블 컨텍스트 배지 ── */
.msg-context-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  background: rgba(196,30,58,0.18);
  color: var(--accent);
  font-weight: 500;
  vertical-align: middle;
}

/* ── 모션 컨텍스트 채팅 배너 ── */
.motion-ctx-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 7px 12px;
  background: rgba(196,30,58,0.09);
  border-bottom: 1px solid rgba(196,30,58,0.18);
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  line-height: 1.3;
}
.motion-ctx-banner span { flex: 1; }
.motion-ctx-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.7;
  border-radius: 4px;
  transition: opacity 120ms;
}
.motion-ctx-dismiss:hover { opacity: 1; }

/* ── v0.8: pitch_window 배너 ── */
.mr-pw-banner {
  margin: 0 16px 8px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(255,170,0,0.08);
  border: 1px solid rgba(255,170,0,0.25);
  color: #c8950a;
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  gap: 7px;
  align-items: flex-start;
}
.mr-pw-banner svg { flex-shrink: 0; margin-top: 1px; }

/* ── v0.8: 측정 불안정 ── */
.mr-metric-unstable {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: -0.2px;
}

/* ── v0.8: pct 행 ── */
.mr-pct-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
  align-items: center;
}
.mr-pct-item { font-size: 11px; color: var(--text-2); }
.mr-pct-ref  { color: var(--text-muted); }
.mr-pct-sep  { color: var(--border); font-size: 11px; }

/* ══ v0.9+: 각속도 그래프 ══════════════════════════════════════ */
.mr-vel-graph {
  position: relative;
  margin: 4px 0 0;
  padding: 0 4px;
  overflow: visible;
}
.mr-vel-graph svg { overflow: visible; display: block; }
.mr-vel-graph-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2px;
}
.vg-reset-btn {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.vg-reset-btn:hover { opacity: 1; }
.vg-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 50;
  background: rgba(10,10,10,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
  line-height: 1.55;
  min-width: 90px;
  max-width: 130px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.vg-tooltip .vg-tt-time {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  margin-bottom: 3px;
}
.vg-tooltip span { display: block; }
.mr-vel-graph-empty {
  margin: 16px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* ══ v0.9: 한눈에 요약 ══════════════════════════════════════ */
.mr-quick-summary {
  margin: 0 16px 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
}
.mr-quick-summary-title {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.mr-quick-summary-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
}

/* ══ v0.9: 지표 설명 텍스트 ════════════════════════════════ */
.mr-metric-what {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}
.mr-metric-explain {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.55;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ══ v0.9: 일관성 가드 (길음+양호 공존 설명) ════════════════ */
.mr-consistency-note {
  margin: 0 16px 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(80,140,255,0.06);
  border: 1px solid rgba(80,140,255,0.2);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.mr-consistency-note svg { flex-shrink: 0; margin-top: 1px; color: rgba(80,140,255,0.7); }

/* ══ v0.9: 용어 설명 (접기/펼치기) ═════════════════════════ */
.mr-glossary {
  margin: 12px 16px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.mr-glossary-summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
}
.mr-glossary-summary::-webkit-details-marker { display: none; }
.mr-glossary-summary::before {
  content: '▸ ';
  font-size: 10px;
  opacity: 0.6;
}
details.mr-glossary[open] .mr-glossary-summary::before { content: '▾ '; }
.mr-glossary-list {
  margin: 0;
  padding: 0 14px 12px;
  display: grid;
  gap: 0;
}
.mr-glossary-list dt {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  margin-top: 8px;
}
.mr-glossary-list dd {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── v0.9 로딩 스켈레톤: 운동 사슬 파동 ────────────────────── */
.mr-skel-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.mr-skel-svg { overflow: visible; }

/* 뼈대: 희미하게 고정 — 관절 파동이 부각되도록 */
.skel-bn {
  stroke: #C41E3A;
  stroke-width: 2.2;
  stroke-linecap: round;
  opacity: 0.28;
}

/* 관절: 기본 dim 상태, CSS 변수 --pd로 delay 지정 */
.skel-jt {
  fill: #ffffff;
  opacity: 0.22;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: skel-jt-wave 2.6s ease-in-out infinite;
  animation-delay: var(--pd, 0s);
}

/* 발→머리 파동: 각 관절이 순서대로 밝아졌다 사라짐 */
@keyframes skel-jt-wave {
  0%, 100% { opacity: 0.18; transform: scale(0.78); }
  42%, 58% { opacity: 0.95; transform: scale(1.08); }
}

/* 전체 뼈대: 미세 호흡 Y 이동 (리플로우 없는 transform만) */
.skel-body {
  animation: skel-breathe 2.6s ease-in-out infinite;
}
@keyframes skel-breathe {
  0%, 100% { transform: translateY(1.5px); }
  50%       { transform: translateY(-1.5px); }
}

@media (prefers-reduced-motion: reduce) {
  .skel-jt, .skel-body { animation: none; opacity: 0.6; }
}

/* ── v0.9 진행 메시지 페이드 ──────────────────────────────── */
.motion-progress-label {
  transition: opacity 0.3s ease;
}

/* ── v0.9 진행 바 ──────────────────────────────────────────── */
.mr-prog-track {
  width: 148px;
  height: 2px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin: 8px auto 0;
  overflow: hidden;
}
.mr-prog-fill {
  height: 100%;
  width: 0%;
  background: #C41E3A;
  border-radius: 2px;
  transition: width 0.5s linear;
}

/* ══ 서술형 내러티브 (투구·타격 공통) ════════════════════════ */

.mr-narrative-section {
  margin: 0 16px 16px;
}
.mr-narrative-skeleton {
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.06);
  animation: mr-pulse 1.6s ease-in-out infinite;
}
@keyframes mr-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 1;    }
}
.mr-narrative-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.07);
}
.mr-narrative-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.mr-narrative-body p {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text);
  margin: 0 0 10px;
}
.mr-narrative-body p:last-child { margin-bottom: 0; }

/* ══ 분석 참고 스코어 카드 ════════════════════════════════════ */

.score-card {
  margin: 0 16px 16px;
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.07);
}
/* 등급별 accent border */
.score-card.score-s  { border-color: rgba(80,200,120,0.35); }
.score-card.score-a  { border-color: rgba(100,160,255,0.30); }
.score-card.score-b  { border-color: rgba(255,200,60,0.28);  }
.score-card.score-cd { border-color: rgba(196,30,58,0.30);   }

.score-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.score-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.score-num {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.score-s  .score-num { color: #50c878; }
.score-a  .score-num { color: #64a0ff; }
.score-b  .score-num { color: #ffc83c; }
.score-cd .score-num { color: #C41E3A; }
.score-denom {
  font-size: 16px;
  color: var(--muted);
  font-weight: 500;
}
.score-grade {
  font-size: 22px;
  font-weight: 800;
  margin-left: 8px;
}
.score-s  .score-grade { color: #50c878; }
.score-a  .score-grade { color: #64a0ff; }
.score-b  .score-grade { color: #ffc83c; }
.score-cd .score-grade { color: #C41E3A; }

.score-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.score-label-ko {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.score-conf-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,200,60,0.15);
  border: 1px solid rgba(255,200,60,0.3);
  color: #ffc83c;
}
.score-2d-note {
  font-size: 10.5px;
  color: var(--muted);
}

/* 감점 breakdown */
.score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 10px;
  margin-top: 2px;
}
.score-bd-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 1px;
}
.score-bd-item {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  grid-column: 1;
  grid-row: 1;
}
.score-bd-pts {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  grid-column: 2;
  grid-row: 1;
  white-space: nowrap;
}
.score-bd-got  { color: var(--text); font-weight: 600; }
.score-bd-of   { color: var(--muted); }
.score-bd-why {
  font-size: 11px;
  color: var(--muted);
  grid-column: 1 / -1;
  grid-row: 2;
}

/* 스파크라인 */
.score-sparkline-sec {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.score-sparkline-label {
  font-size: 10.5px;
  color: var(--muted);
  flex-shrink: 0;
}
.score-sparkline-svg {
  flex: 1;
  height: 32px;
  overflow: visible;
}
.score-sparkline-placeholder {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.6;
}
.score-sparkline-note {
  font-size: 11px;
  color: var(--muted);
}

/* ══ 타격 리포트 ══════════════════════════════════════════════ */

/* 각도 선택 */
.bt-angle-wrap {
  padding: 16px 16px 0;
  text-align: center;
}
.bt-angle-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.bt-angle-seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 8px;
}
.bt-angle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 20px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}
.bt-angle-btn--active {
  background: var(--accent);
  color: #fff;
}
.bt-angle-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* 각도 배지 (결과 상단) */
.bt-angle-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(196,30,58,0.08);
  border: 1px solid rgba(196,30,58,0.2);
  border-radius: 8px;
  margin: 0 16px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}
.bt-angle-badge-note {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  flex: 1;
  text-align: right;
}

/* 배트 궤적 카드 */
.bt-trail-card {
  margin: 0 16px 16px;
  background: var(--surface);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.06);
}
.bt-trail-svg {
  display: block;
  width: 100%;
  border-radius: 6px;
  margin: 8px 0;
}
.bt-trail-caption {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin: 0;
}
.bt-trail-fallback {
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  margin: 4px 0 0;
  opacity: 0.75;
}
/* 포인트 부족으로 궤적 섹션 숨김 시 인라인 안내 */
.bt-trail-insufficient {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0 16px 14px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* 플레이어 토글 버튼 (배트 궤적 포함) */
.bt-toggle-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}
.bt-toggle-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── 대화 기록 드로어 ────────────────────────────────────────── */

.history-header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.history-header-btn:hover { background: var(--surface-2); color: var(--text-primary); }

/* 백드롭 — 기본 숨김, --open 클래스로 페이드인 */
.history-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
}
.history-backdrop--open {
  opacity: 1;
  pointer-events: auto;
}

/* 드로어 — 기본 왼쪽 오프스크린, --open 클래스로 슬라이드인 */
.history-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 88vw);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 310;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-100%);
  pointer-events: none;
  transition: transform 280ms cubic-bezier(.4, 0, .2, 1);
}
.history-drawer--open {
  transform: translateX(0);
  pointer-events: auto;
}

.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-drawer-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.new-chat-btn {
  padding: 5px 12px;
  border-radius: 14px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}
.new-chat-btn:hover { opacity: 0.85; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* 세션 행: 왼쪽 텍스트 블록 + 오른쪽 케밥 버튼 */
.history-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 0 0 16px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
}
.history-item:hover { background: var(--surface-2); }
.history-item--active {
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

/* 텍스트 블록: 클릭 영역 */
.history-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 0;
  cursor: pointer;
  overflow: hidden;
}

.history-item-time {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.history-item-preview {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 케밥 버튼 */
.history-item-kebab {
  flex-shrink: 0;
  width: 44px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s;
}
.history-item-kebab:hover { color: var(--text-primary); }

/* 인라인 rename input */
.history-rename-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-3);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  padding: 4px 8px;
  outline: none;
  margin: 8px 4px 8px 0;
}

/* 케밥 팝오버 */
.history-kebab-popover {
  position: fixed;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  z-index: 400;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  min-width: 130px;
}

.history-kebab-action {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.history-kebab-action:hover { background: var(--surface-2); }
.history-kebab-action + .history-kebab-action {
  border-top: 1px solid #2a2a2a;
}
.history-kebab-action--danger { color: #C41E3A; }

/* 삭제 확인 다이얼로그 */
.history-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.history-confirm-dialog {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 20px 20px 14px;
  width: 100%;
  max-width: 300px;
}

.history-confirm-msg {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 18px;
}

.history-confirm-btns {
  display: flex;
  gap: 8px;
}

.history-confirm-cancel,
.history-confirm-delete {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid #2a2a2a;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.history-confirm-cancel {
  background: var(--surface-2);
  color: var(--text-primary);
}
.history-confirm-cancel:hover { background: var(--surface-3); }
.history-confirm-delete {
  background: transparent;
  color: #C41E3A;
  border-color: #C41E3A;
}
.history-confirm-delete:hover { background: rgba(196, 30, 58, 0.12); }

/* 토스트 */
.history-toast {
  position: fixed;
  bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  color: var(--text-primary);
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 20px;
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  white-space: nowrap;
}
.history-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.history-state-msg {
  padding: 24px 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
