/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 다크 테마 (기본) ── */
:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #293548;
  --border: #334155;
  --text: #f1f5f9;
  --text1: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #4f46e520;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --sidebar-w: 240px;
}

/* ── 화이트 테마 ── */
[data-theme="white"] {
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text1: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* ── 그레이 테마 ── */
[data-theme="gray"] {
  --bg: #e2e8f0;
  --bg2: #f1f5f9;
  --bg3: #e8eef4;
  --border: #cbd5e1;
  --text: #1e293b;
  --text1: #1e293b;
  --text2: #475569;
  --text3: #64748b;
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
}

html { font-size: 14px; background: var(--bg); }
body { background: var(--bg); color: var(--text); font-family: -apple-system, 'Pretendard', 'Noto Sans KR', sans-serif; line-height: 1.6; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea, select { font: inherit; color: inherit; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; width: 100%; transition: border-color .2s; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 100px; }
.hidden { display: none !important; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== BUTTONS ===== */
.btn-primary { background: var(--primary); color: white; border-radius: var(--radius-sm); padding: 10px 20px; font-weight: 600; transition: background .2s, transform .1s; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 18px; font-weight: 500; transition: background .2s; }
.btn-secondary:hover { background: var(--bg2); }
.btn-danger { background: var(--danger); color: white; border-radius: var(--radius-sm); padding: 9px 18px; font-weight: 500; transition: background .2s; }
.btn-danger:hover { background: #dc2626; }
.btn-full { width: 100%; display: block; text-align: center; }
.btn-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background .2s; color: var(--text2); }
.btn-icon:hover { background: var(--bg3); color: var(--text); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon-sm { width: 26px; height: 26px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; cursor: pointer; font-size: 14px; color: var(--text3); transition: background .15s; }
.btn-icon-sm:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 6px; }
.btn-ghost { color: var(--text2); border-radius: var(--radius-sm); padding: 8px 14px; transition: background .2s, color .2s; }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

/* ===== AUTH MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-overlay.active { display: flex; }
.modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 420px; position: relative; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
.auth-box { max-width: 380px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 24px; font-size: 20px; font-weight: 700; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg3); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 24px; }
.auth-tab { flex: 1; padding: 8px; border-radius: 6px; font-weight: 600; color: var(--text2); transition: all .2s; }
.auth-tab.active { background: var(--primary); color: white; }
.auth-form { display: none; flex-direction: column; gap: 16px; }
.auth-form.active { display: flex; }
.auth-error { color: var(--danger); font-size: 12px; min-height: 16px; text-align: center; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== LAYOUT ===== */
#app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg2); border-right: 0; display: flex; flex-direction: column; transition: transform .3s; z-index: 100; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text2); font-weight: 500; transition: all .2s; cursor: pointer; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; border-radius: var(--radius-sm); padding: 8px; transition: background .2s; min-width: 0; }
.user-info:hover { background: var(--bg3); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: white; flex-shrink: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.user-meta { min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { display: block; font-size: 11px; color: var(--text3); }
.btn-logout { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text3); transition: all .2s; flex-shrink: 0; }
.btn-logout:hover { background: var(--danger)20; color: var(--danger); }
.btn-logout svg { width: 16px; height: 16px; }
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; margin-left: calc(var(--sidebar-w) - 1px); border-left: 1px solid var(--border); }
.top-header { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; position: sticky; top: 0; z-index: 90; }
.page-title { font-size: 16px; font-weight: 700; flex: 1; }
.hamburger { display: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.notif-btn { position: relative; }
.notif-badge { position: absolute; top: 4px; right: 4px; background: var(--danger); color: white; border-radius: 50%; width: 16px; height: 16px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; }
.notif-panel { position: absolute; top: 56px; right: 12px; width: 340px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200; max-height: 400px; overflow-y: auto; }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.notif-header button { font-size: 11px; color: var(--primary); }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 12px; }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-time { color: var(--text3); margin-top: 2px; }
.page-content { flex: 1; overflow-y: auto; padding: 24px 20px 12px; }

/* ===== CARDS ===== */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text2); }

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ===== STATS CARD ===== */
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value.up { color: var(--success); }
.stat-value.down { color: var(--danger); }
.stat-change { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ===== DASHBOARD ===== */
.dashboard-grid { display: flex; flex-direction: column; gap: 20px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 14px; font-weight: 700; }

/* ===== TRADE TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; text-align: left; color: var(--text3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--border)80; vertical-align: middle; }
tr:hover td { background: var(--bg3)50; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge.buy { background: var(--danger)20; color: var(--danger); }
.badge.sell { background: var(--success)20; color: var(--success); }
.badge.public { background: var(--primary)20; color: var(--primary); }
.badge.private { background: var(--bg3); color: var(--text3); }
.ticker { font-weight: 700; font-family: 'Courier New', monospace; font-size: 13px; }
.pnl { font-variant-numeric: tabular-nums; }
.pnl.pos { color: var(--success); font-weight: 600; }
.pnl.neg { color: var(--danger); font-weight: 600; }
.pnl.zero { color: var(--text3); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .3; display: block; }
.empty-state p { font-size: 14px; }

/* ===== FILTERS ===== */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; min-width: 140px; }
.filter-bar input { flex: 1; max-width: 240px; }

/* ===== TRADE FORM ===== */
.trade-type-toggle { display: flex; gap: 4px; background: var(--bg3); border-radius: var(--radius-sm); padding: 4px; }
.trade-type-btn { flex: 1; padding: 8px; border-radius: 6px; font-weight: 600; text-align: center; color: var(--text2); transition: all .2s; }
.trade-type-btn.active.buy { background: var(--danger); color: white; }
.trade-type-btn.active.sell { background: var(--success); color: white; }

/* ===== POSTS ===== */
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: border-color .2s, transform .1s; }
.post-card:hover { border-color: var(--primary)60; transform: translateY(-1px); }

/* 지식쌓기(stockNoteCard) 본문 영역 — 제목 아래 좌측에 80×80 썸네일, 우측 excerpt (있을 때만) */
.snc-body { display: flex; gap: 10px; align-items: flex-start; }
.snc-body .post-card-excerpt { flex: 1; min-width: 0; }
.snc-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
  background: var(--bg3);
}
/* 이미지 로드 실패 시: img 제거되어 .snc-body 자식 1개(excerpt) → 자연스럽게 전체 폭 */
@media (max-width: 400px) {
  .snc-thumb { width: 64px; height: 64px; }
}
.post-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.post-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.post-excerpt { font-size: 13px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-footer { display: flex; align-items: center; gap: 16px; margin-top: 12px; color: var(--text3); font-size: 12px; }
.post-edited { font-size: 11px; color: var(--text3); padding: 1px 6px; background: var(--bg3); border-radius: 4px; margin-left: 6px; }
.post-footer span { display: flex; align-items: center; gap: 4px; }
.post-footer svg { width: 13px; height: 13px; }
.category-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.cat-general { background: var(--bg3); color: var(--text2); }
.cat-analysis { background: #0891b220; color: #0891b2; }
.cat-news { background: #d9770620; color: #d97706; }
.cat-question { background: #7c3aed20; color: #7c3aed; }

/* ===== POST DETAIL ===== */
.post-detail-header { margin-bottom: 20px; }
.post-detail-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.post-content { font-size: 14px; line-height: 1.8; color: var(--text); word-break: break-word; }
.post-actions { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 20px 0; }
.like-btn { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border); font-size: 13px; font-weight: 600; transition: all .2s; }
.like-btn:hover { border-color: var(--danger); color: var(--danger); }
.like-btn.liked { background: var(--danger)20; border-color: var(--danger); color: var(--danger); }
.like-btn svg { width: 16px; height: 16px; }
.comment-section { margin-top: 24px; }
.comment-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; }
.comment-item { display: flex; gap: 10px; margin-bottom: 16px; }
.comment-body { flex: 1; }
.comment-author { font-size: 12px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.comment-time { color: var(--text3); font-weight: 400; }
.comment-text { font-size: 13px; color: var(--text2); }
.comment-form { display: flex; gap: 10px; margin-top: 16px; }
.comment-form textarea { min-height: 70px; }
.comment-form .btn-primary { align-self: flex-end; white-space: nowrap; }

/* ===== GROUPS ===== */
.group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.group-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; cursor: pointer; transition: border-color .2s, transform .1s; }
.group-card:hover { border-color: var(--primary)60; transform: translateY(-1px); }
.group-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.group-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.group-desc { font-size: 12px; color: var(--text2); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.group-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text3); }
.group-meta span { display: flex; align-items: center; gap: 4px; }
.group-meta svg { width: 13px; height: 13px; }
.group-detail-tabs { display: flex; gap: 4px; background: var(--bg3); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 20px; }
.group-tab { flex: 1; padding: 8px; border-radius: 6px; font-weight: 600; color: var(--text2); text-align: center; transition: all .2s; }
.group-tab.active { background: var(--primary); color: white; }
.member-list { display: flex; flex-direction: column; gap: 10px; }
.member-item { display: flex; align-items: center; gap: 10px; }
.member-item .role-badge { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 4px; }
.role-badge.admin { background: var(--primary)20; color: var(--primary); }
.role-badge.member { background: var(--bg3); color: var(--text3); }
.invite-box { background: var(--bg3); border-radius: var(--radius-sm); padding: 14px; margin-top: 12px; }
.invite-code { font-family: 'Courier New', monospace; font-size: 22px; font-weight: 700; letter-spacing: 4px; text-align: center; color: var(--primary); margin: 8px 0; }
.invite-hint { font-size: 11px; color: var(--text3); text-align: center; }

/* ===== PORTFOLIO ===== */
.portfolio-table td:first-child { font-weight: 700; }
.progress-bar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--primary); }

/* ===== PROFILE ===== */
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.profile-stats { display: flex; gap: 24px; margin-top: 8px; }
.profile-stat { text-align: center; }
.profile-stat .val { font-size: 20px; font-weight: 700; }
.profile-stat .lbl { font-size: 11px; color: var(--text3); }

/* ===== MODAL ===== */
.modal-overlay.hidden { display: none; }
.modal-close { position: absolute; top: 16px; right: 16px; font-size: 20px; color: var(--text2); transition: color .2s; width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; z-index: 5; cursor: pointer; }
.modal-close:hover { color: var(--text); background: var(--bg3); }
/* 모바일: 44px 최소 터치 타깃 + 우측 본문 침범 방지 강화 */
@media (max-width: 768px) {
  .modal-close { width: 44px; height: 44px; top: 8px; right: 8px; font-size: 24px; }
  .modal-actions { margin-right: 52px !important; }
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }

/* ⭐ Phase 2 — 토스 스타일 라운드 캡슐 버튼 (2026-05-03) */
.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-pill:hover {
  background: var(--bg2);
  color: var(--text);
  border-color: var(--text3);
}
.btn-pill.btn-pill-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-pill-sm {
  padding: 4px 10px;
  font-size: 11px;
}
.modal-actions {
  display: flex;
  gap: 6px;
  margin-right: 40px;
  margin-left: auto;
}
.card-actions {
  display: flex;
  gap: 4px;
}
/* Phase 2-B — 카드 우측 액션 (인라인 배치) */
.card-actions-pill {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .btn-pill { padding: 5px 11px; font-size: 11px; }
  .btn-pill-sm { padding: 3px 8px; font-size: 10px; }
  .card-actions-pill { gap: 3px; }
}

/* ===== CHART ===== */
.chart-container { height: 180px; position: relative; }
.chart-bar-wrap { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 0 4px; }
.chart-bar { flex: 1; border-radius: 4px 4px 0 0; min-height: 4px; transition: opacity .2s; cursor: pointer; position: relative; }
.chart-bar:hover { opacity: .8; }
.chart-labels { display: flex; gap: 4px; padding: 4px; }
.chart-label { flex: 1; text-align: center; font-size: 10px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tooltip { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 11px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 10; }
.chart-bar:hover .chart-tooltip { opacity: 1; }

/* ===== COPY BTN ===== */
.copy-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--primary); padding: 4px 10px; border-radius: 6px; transition: background .2s; }
.copy-btn:hover { background: var(--primary-light); }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 18px; font-size: 13px; box-shadow: var(--shadow); animation: slideIn .3s ease; pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: 320px; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.success::before { content: '✓'; color: var(--success); font-weight: 700; }
.toast.error::before { content: '✗'; color: var(--danger); font-weight: 700; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ===== OVERLAY ===== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }

/* ===== 애니메이션 줄이기 선호 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== RESPONSIVE 900px ===== */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ===== RESPONSIVE 768px (모바일) ===== */
@media (max-width: 768px) {
  /* 사이드바: 슬라이드 오버레이 */
  .sidebar { transform: translateX(-100%); z-index: 200; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main-content { margin-left: 0; border-left: 0; }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity .3s; }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

  /* 햄버거 */
  .hamburger { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
  .hamburger svg { width: 22px; height: 22px; }

  /* 그리드 1열 */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* 여백 */
  .page-content { padding: 12px 14px 80px; } /* 하단 탭바 + FAB 공간 */
  .form-row { grid-template-columns: 1fr; }

  /* 알림 패널 풀너비 */
  .notif-panel { right: 0; left: 0; width: 100%; border-radius: var(--radius) var(--radius) 0 0; }

  /* 모달 풀스크린 */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box { max-width: 100% !important; width: 100%; border-radius: var(--radius) var(--radius) 0 0; max-height: 92dvh; overflow-y: auto; padding: 20px 18px 32px; }

  /* iOS 자동줌 방지: input 16px */
  input, textarea, select { font-size: 16px !important; }

  /* 44px 최소 터치 타깃 */
  .btn-primary, .btn-secondary, .btn-ghost { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 36px; }
  .nav-item { min-height: 44px; }
  .btn-icon { width: 44px; height: 44px; }

  /* 하단 탭바 공간 확보 */
  #app { padding-bottom: 0; }

  /* 테이블 스크롤 */
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* 포럼 필터바 */
  .forum-filter-bar { gap: 6px; }
  .forum-imp-btns { flex-wrap: wrap; }

  /* 카드 패딩 */
  .post-card { padding: 14px; }
  .card { padding: 14px; }

  /* 섹션 헤더 */
  .section-header { flex-wrap: wrap; gap: 8px; }
}

/* ===== RESPONSIVE 480px ===== */
@media (max-width: 480px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select { width: 100%; max-width: none; }
  .page-content { padding: 10px 12px 80px; }
  .qa-question-title { font-size: 16px; }
}

/* ===== 하단 탭바 ===== */
.bottom-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-tab-bar .tab-items {
  display: flex;
  align-items: stretch;
}
.bottom-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  min-height: 54px;
  color: var(--text3);
  font-size: 10px;
  font-weight: 600;
  transition: color .2s;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
.bottom-tab-item svg { width: 22px; height: 22px; }
.bottom-tab-item.active { color: var(--primary); }
.bottom-tab-item:active { background: var(--bg3); }
@media (max-width: 768px) {
  .bottom-tab-bar { display: block; }
}

/* ===== FAB (Floating Action Button) ===== */
.fab {
  display: none;
  position: fixed;
  right: 18px;
  bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  width: 52px; height: 52px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(79,70,229,.5);
  align-items: center;
  justify-content: center;
  z-index: 140;
  transition: transform .2s, box-shadow .2s;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(.93); box-shadow: 0 2px 8px rgba(79,70,229,.4); }
@media (max-width: 768px) {
  .fab { display: flex; }
}
.fab.hidden { display: none !important; }

/* ===== 태블릿(640px↑): 사이드바 자동 표시 ===== */
@media (min-width: 640px) {
  .sidebar { transform: none !important; box-shadow: none !important; }
  .hamburger { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .bottom-tab-bar { display: none !important; }
  .main-content { margin-left: calc(var(--sidebar-w) - 1px); }
  .page-content { padding-bottom: 24px; }
  .fab { bottom: 24px; }
}

/* ===== Pull-to-Refresh ===== */
.ptr-indicator {
  position: fixed;
  top: 56px; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  overflow: hidden;
  background: var(--bg2);
  transition: height .2s;
  z-index: 120;
  color: var(--text3);
  font-size: 12px;
  gap: 8px;
}
.ptr-indicator.visible { height: 44px; }
.ptr-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== DIVIDER ===== */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted { color: var(--text2); }
.text-sm { font-size: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.fw-bold { font-weight: 700; }

/* ===== NAV DIVIDER ===== */
.nav-divider { height: 1px; background: var(--border); margin: 8px 12px; }

/* ===== TABS ===== */
.tab-bar { display: flex; gap: 3px; background: var(--bg3); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { padding: 7px 14px; border-radius: 6px; font-weight: 600; color: var(--text2); text-align: center; transition: all .2s; font-size: 13px; white-space: nowrap; }
.tab-btn.active { background: var(--primary); color: white; }
.tab-btn:hover:not(.active) { background: var(--bg2); color: var(--text); }

/* ===== PAGINATION ===== */
.pagination-bar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* ===== STUDY CARD ===== */
.study-cat-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; background: #4f46e520; color: #818cf8; }
.study-sub-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; background: #10b98120; color: #10b981; }
.study-ticker-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sentiment-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.study-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.study-link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 3px 9px; border-radius: 4px; background: var(--bg3); color: var(--text2); border: 1px solid var(--border); transition: all .2s; text-decoration: none; }
.study-link-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ===== SENTIMENT TOGGLE BTNS ===== */
.sentiment-btn { padding: 8px 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text2); font-weight: 600; font-size: 13px; transition: all .2s; }
.sentiment-btn:hover { border-color: var(--text2); color: var(--text); }

/* ===== FORUM ===== */
.forum-filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.forum-filter-bar input, .forum-filter-bar select { width: auto; }
.forum-filter-bar input { flex: 1; min-width: 120px; max-width: 200px; }
.forum-imp-btns { display: flex; gap: 4px; }
.forum-imp-btn { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text2); transition: all .2s; white-space: nowrap; }
.forum-imp-btn:hover { border-color: var(--text2); color: var(--text); }
.forum-imp-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Forum Thread List */
.forum-thread { display:flex; gap:16px; padding:16px; border:1px solid var(--border); border-radius:12px; margin-bottom:10px; background:var(--bg2); transition:border-color .15s; cursor:pointer; }
.forum-thread:hover { border-color:var(--accent); }
.forum-vote { display:flex; flex-direction:column; align-items:center; min-width:48px; gap:4px; }
.vote-count { font-size:20px; font-weight:700; color:var(--accent); }
.vote-label { font-size:10px; color:var(--text3); }
.comment-count { font-size:12px; color:var(--text2); margin-top:4px; }
.forum-body { flex:1; min-width:0; }
.forum-title { font-size:15px; font-weight:600; margin:4px 0; line-height:1.4; }
.forum-meta { font-size:12px; color:var(--text2); margin-bottom:6px; }
.forum-summary { font-size:13px; color:var(--text3); line-height:1.5; }
.forum-status-badge { display:inline-block; font-size:11px; padding:2px 8px; border-radius:99px; margin-bottom:4px; }
.forum-tags { margin-top:6px; display:flex; gap:4px; flex-wrap:wrap; }
.tag-badge { font-size:11px; padding:2px 8px; border-radius:4px; background:var(--primary)20; color:var(--primary); font-weight:600; }

/* QA Detail */
.forum-detail-nav { display: flex; align-items: center; margin-bottom: 20px; }
.qa-question-box { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.qa-question-title { font-size: 20px; font-weight: 700; margin-bottom: 14px; line-height: 1.5; }
.qa-question-content { font-size: 14px; line-height: 1.9; word-break: break-word; color: var(--text); }
.qa-answers-header { font-size: 14px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 20px; }
.qa-answer-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--success)20; color: var(--success); font-weight: 600; }
.qa-answer-item { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 12px; }
.qa-answer-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.qa-answer-content { font-size: 13px; line-height: 1.8; color: var(--text2); word-break: break-word; }
.qa-write-box { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-top: 20px; }
.qa-write-box textarea { min-height: 100px; width: 100%; box-sizing: border-box; }
.qa-write-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--text2); }

/* ===== 파일 첨부 ===== */
.file-pick-btn { display:inline-flex; align-items:center; gap:6px; padding:7px 14px; border:1px dashed var(--border); border-radius:6px; font-size:12px; font-weight:600; color:var(--text2); cursor:pointer; transition:all .2s; }
.file-pick-btn:hover { border-color:var(--primary); color:var(--primary); background:var(--primary)08; }
.file-preview-list { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.file-chip { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; background:var(--bg3); border:1px solid var(--border); border-radius:20px; font-size:11px; color:var(--text2); }

/* 첨부파일 표시 (상세) */
.attach-section { margin:20px 0; padding:16px; background:var(--bg3); border:1px solid var(--border); border-radius:var(--radius-sm); }
.attach-header { font-size:12px; font-weight:700; color:var(--text3); text-transform:uppercase; letter-spacing:.05em; margin-bottom:12px; display:flex; align-items:center; gap:6px; }
.attach-count { font-size:11px; padding:1px 7px; border-radius:10px; background:var(--primary)20; color:var(--primary); font-weight:600; }
.attach-grid { display:flex; flex-wrap:wrap; gap:10px; }
.attach-item { position:relative; display:flex; align-items:center; }
.attach-thumb { display:block; width:80px; height:80px; border-radius:6px; overflow:hidden; border:1px solid var(--border); }
.attach-thumb img { width:100%; height:100%; object-fit:cover; }
.attach-doc { display:inline-flex; align-items:center; gap:8px; padding:8px 14px; background:var(--bg2); border:1px solid var(--border); border-radius:8px; font-size:12px; color:var(--text2); text-decoration:none; transition:border-color .2s; max-width:220px; }
.attach-doc:hover { border-color:var(--primary); color:var(--primary); }
.attach-doc span:first-of-type { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.attach-del-btn { position:absolute; top:-6px; right:-6px; width:18px; height:18px; border-radius:50%; background:var(--danger); color:#fff; font-size:12px; line-height:18px; text-align:center; border:none; cursor:pointer; display:none; padding:0; }
.attach-item:hover .attach-del-btn { display:block; }

/* ===== 프로필 색상 스와치 ===== */
.color-swatches { display:flex; flex-wrap:wrap; gap:8px; margin-top:6px; }
.color-swatch { width:28px; height:28px; border-radius:50%; cursor:pointer; border:3px solid transparent; transition:transform .15s, border-color .15s; }
.color-swatch:hover { transform:scale(1.15); }
.color-swatch.selected { border-color:#fff; transform:scale(1.1); box-shadow:0 0 0 2px var(--primary); }

/* ===== 프로필 수정 (테이블 스타일) ===== */
.profile-table-wrap { background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
.profile-table-title { padding:12px 18px; font-size:14px; font-weight:700; background:var(--bg3); border-bottom:1px solid var(--border); letter-spacing:.02em; }
.profile-table { width:100%; border-collapse:collapse; }
.profile-table th { width:130px; padding:12px 16px; text-align:left; font-size:12px; font-weight:600; color:var(--text3); background:var(--bg3); border-bottom:1px solid var(--border); border-right:1px solid var(--border); white-space:nowrap; vertical-align:middle; }
.profile-table td { padding:10px 16px; border-bottom:1px solid var(--border); vertical-align:middle; }
.profile-table tr:last-child th,
.profile-table tr:last-child td { border-bottom:none; }
.pf-readonly { font-size:13px; color:var(--text2); user-select:all; }
.pf-sublabel { font-size:11px; color:var(--text3); width:30px; flex-shrink:0; }
.pf-save-btn { min-width:120px; padding:10px 28px; font-size:14px; }

/* 아바타 업로드 */
.avatar-upload-row { display:flex; align-items:center; gap:16px; }
.avatar-preview-box { width:80px; height:80px; border-radius:50%; overflow:hidden; border:2px solid var(--border); background:var(--bg3); flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.avatar-preview-box img { width:100%; height:100%; object-fit:cover; }
.avatar-placeholder { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:28px; font-weight:700; color:#fff; background:var(--primary); }
.avatar-upload-btns { display:flex; flex-direction:column; gap:6px; }
.btn-sm { padding:5px 12px; font-size:12px; font-weight:600; border-radius:6px; border:none; cursor:pointer; transition:opacity .2s; }
.btn-secondary.btn-sm { background:var(--bg3); color:var(--text2); border:1px solid var(--border); }
.btn-secondary.btn-sm:hover { border-color:var(--primary); color:var(--primary); }
.btn-danger.btn-sm { background:#dc2626; color:#fff; }
.btn-danger.btn-sm:hover { opacity:.85; }

/* ===== 종목 자동완성 드롭다운 ===== */
.stock-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--bg2);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  z-index: 9999;
  max-height: 280px;
  overflow-y: auto;
}
.stock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.stock-item:last-child { border-bottom: none; }
.stock-item:hover, .stock-item.active { background: var(--bg3); }
.stock-name { flex: 1; font-size: 13px; color: var(--text1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-ticker { font-size: 11px; font-weight: 700; color: var(--text3); font-family: monospace; flex-shrink: 0; }
.stock-badge {
  font-size: 10px; font-weight: 700; padding: 2px 6px;
  border-radius: 4px; flex-shrink: 0; letter-spacing: .03em;
}
.stock-badge.kr      { background: #1e40af22; color: #60a5fa; }
.stock-badge.kr-etf  { background: #1e40af11; color: #93c5fd; }
.stock-badge.nas     { background: #16a34a22; color: #4ade80; }
.stock-badge.nyse    { background: #7c3aed22; color: #a78bfa; }
.stock-badge.amex    { background: #b4530022; color: #fb923c; }
.stock-badge.us-etf  { background: #0f766e22; color: #2dd4bf; }
.stock-badge.other   { background: var(--bg3); color: var(--text3); }

/* ===== 모바일 매매카드 ===== */
/* ── 매매일지 카드 리스트 ── */
.trades-list { max-width: 680px; }
@media (min-width: 1024px) { .trades-list { max-width: 720px; } }

.trade-card {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.trade-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(59,130,246,.08);
}

/* 헤더행 */
.tc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.tc-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.tc-type {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  flex-shrink: 0;
}
.tc-buy  { background: rgba(239,68,68,.15);  color: #ef4444; }
.tc-sell { background: rgba(16,185,129,.15); color: #10b981; }
.tc-stock {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-ticker {
  font-size: 12px;
  color: var(--text3);
  flex-shrink: 0;
  white-space: nowrap;
}

/* 관리 버튼 */
.tc-mgmt { display: flex; gap: 4px; flex-shrink: 0; }
.tc-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg3);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.tc-btn:hover { background: var(--bg4, var(--border)); }

/* 날짜행 */
.tc-date {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 12px;
}

/* 수치행 */
.tc-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 12px;
}
.tc-stat { display: flex; flex-direction: column; gap: 2px; }
.tc-stat-label { font-size: 11px; color: var(--text3); }
.tc-stat-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 하단행 */
.tc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.tc-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.tc-author { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tc-footer-left .tc-username { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
@media (max-width: 400px) {
  .tc-footer-left .tc-username { max-width: 64px; }
}
.tc-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.tc-username { font-size: 12px; color: var(--text2); }

/* 공개범위 배지 */
.tc-vis {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 500;
}
.tc-vis-pub { background: rgba(59,130,246,.12);  color: #3b82f6; }
.tc-vis-grp { background: rgba(139,92,246,.12);  color: #8b5cf6; }
.tc-vis-spc { background: rgba(245,158,11,.12);  color: #f59e0b; }
.tc-vis-prv { background: rgba(148,163,184,.12); color: #94a3b8; }

/* 수치 색상 (pos/neg는 전역에도 있지만 여기도 보강) */
.tc-stat-value.pos { color: #ef4444; }
.tc-stat-value.neg { color: #10b981; }

/* ===== 매매일지 상세 모달 ===== */
.trade-detail-info { margin-bottom: 16px; }
.trade-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.trade-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.trade-detail-table th {
  color: var(--text3);
  font-weight: 500;
  text-align: left;
  padding: 6px 10px 6px 0;
  white-space: nowrap;
  width: 56px;
}
.trade-detail-table td {
  color: var(--text1);
  padding: 6px 14px 6px 0;
}

/* ===== 매매일지 상세 모달 (td = trade-detail) ===== */
.td-header { margin-bottom: 16px; }
.td-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.td-type-badge { font-size: 12px !important; padding: 3px 10px !important; }
.td-ticker { font-size: 20px; font-weight: 800; color: var(--text1); letter-spacing: .03em; }
.td-stockname { font-size: 14px; color: var(--text3); }

.td-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin-bottom: 14px;
}
.td-cell {
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px 12px;
}
.td-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; font-weight: 500; }
.td-value { font-size: 15px; font-weight: 600; color: var(--text1); }
.td-total { font-size: 17px; }
.td-unit { font-size: 11px; color: var(--text3); margin-left: 2px; font-weight: 400; }

.td-notes {
  font-size: 13px;
  color: var(--text2);
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-word;
  margin-bottom: 14px;
  line-height: 1.6;
}

.td-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.td-like-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--text3);
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
}
.td-like-btn:hover { border-color: #ef4444; color: #ef4444; }
.td-like-btn.liked { border-color: #ef4444; color: #ef4444; }
.td-view {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text3);
}
.td-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 16px;
}

/* 댓글 카드 스타일 강화 */
#trade-comment-list .comment-item {
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* ===== visibility 배지 ===== */
.badge.vis-public  { background: #1d4ed822; color: #60a5fa; }
.badge.vis-group   { background: #16a34a22; color: #4ade80; }
.badge.vis-private { background: var(--bg3); color: var(--text3); }

/* ===== visibility 필터 탭 ===== */
/* ===== 매매일지 상단 시장 위젯 (지수 + 거래대금 상위) ===== */
.trade-market-widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tmw-indices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tmw-index {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tmw-index-placeholder { opacity: 0.55; }
.tmw-idx-name { font-weight: 700; color: var(--text); }
.tmw-idx-val  { font-weight: 600; color: var(--text2); }
.tmw-idx-chg  { font-weight: 600; }
.tmw-top-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  min-width: 0;
}
.tmw-top-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  flex-shrink: 0;
}
.tmw-top {
  display: flex;
  flex: 1;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  min-width: 0;
}
.tmw-top::-webkit-scrollbar { height: 6px; }
.tmw-top::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tmw-top-item {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tmw-top-item:hover { background: var(--primary-light); border-color: var(--primary); }
.tmw-top-name { font-weight: 600; }
.tmw-top-chg  { font-weight: 600; font-size: 11px; }
.tmw-loading, .tmw-empty {
  color: var(--text3);
  font-size: 12px;
  padding: 2px 4px;
}
@media (max-width: 768px) {
  .trade-market-widget { padding: 8px 10px; }
  .tmw-indices { gap: 6px; }
  .tmw-index { padding: 3px 8px; font-size: 11px; }
}

/* ===== 매매일지 상단 심플 바 ===== */
.trade-top-bar {
  margin-bottom: 10px;
}
.trade-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.trade-search-row input,
.trade-search-row select {
  height: 38px;
  padding: 0 12px;
}
.trade-search-row .btn-secondary,
.trade-search-row .btn-primary {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
}
.trade-vis-filters {
  display: flex;
  gap: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tvf-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 10px 14px;
  height: 40px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tvf-btn + .tvf-btn { border-left: 1px solid var(--border); }
.tvf-btn:hover:not(.active) { color: var(--primary); }
.tvf-btn.active { background: var(--primary); color: #fff; }

/* ===== 로딩 스피너 ===== */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 아바타 xs ===== */
.avatar-xs {
  width: 24px !important;
  height: 24px !important;
  font-size: 11px !important;
  flex-shrink: 0;
}

/* ===== 상세 모달 개선 ===== */
/* 큰 매수/매도 배지 */
.td-big-badge {
  display: inline-block;
  padding: 5px 16px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
.td-big-badge.buy  { background: var(--danger)25;  color: var(--danger);  }
.td-big-badge.sell { background: var(--success)25; color: var(--success); }

/* 타이틀 행 */
.td-title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* 한국주식: 종목명 크게 앞, 코드 작게 뒤 */
.td-stockname-main { font-size: 22px; font-weight: 800; color: var(--text1); }
.td-ticker-sub     { font-size: 13px; color: var(--text3); font-family: monospace; }

/* 미국주식: 티커 크게 앞, 종목명 작게 뒤 */
.td-ticker-main    { font-size: 22px; font-weight: 800; color: var(--text1); letter-spacing: .04em; }
.td-stockname-sub  { font-size: 13px; color: var(--text3); }

/* 그리드 셀 정렬 */
.td-cell.td-center { text-align: center; }
.td-cell.td-right  { text-align: right; }
.td-cell.td-center .td-label,
.td-cell.td-right  .td-label { text-align: inherit; }

/* 카드 작성자 */
.trade-card-user { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text3); }

/* ===== 매매일지 상세 모달 리뉴얼 (tdm-*) ===== */
.tdm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.tdm-badge {
  flex-shrink: 0;
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .05em;
}
.tdm-badge.buy  { background: var(--danger)25;  color: var(--danger);  }
.tdm-badge.sell { background: var(--success)25; color: var(--success); }

.tdm-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.tdm-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tdm-code {
  font-size: 12px;
  color: var(--text3);
  font-family: monospace;
  letter-spacing: .03em;
}

/* 2열 그리드 */
.tdm-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

/* 3열 그리드 */
.tdm-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

/* 공통 셀 */
.tdm-cell {
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px 12px;
}
.tdm-lbl {
  font-size: 11px;
  color: var(--text3);
  opacity: .75;
  margin-bottom: 5px;
  font-weight: 500;
}
.tdm-val {
  font-size: 16px;
  font-weight: 600;
  color: var(--text1);
  line-height: 1.2;
}
.tdm-unit {
  font-size: 11px;
  color: var(--text3);
  font-weight: 400;
  margin-left: 2px;
}

/* 숫자 셀: 오른쪽 정렬 */
.tdm-num { text-align: right; }
.tdm-num .tdm-lbl { text-align: right; }

/* 총금액 셀: 값 강조 */
.tdm-total .tdm-val { font-size: 18px; }

/* 손익 행 */
.tdm-pnl-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.tdm-pnl-row .tdm-lbl { margin-bottom: 0; opacity: .75; }

/* 메모 박스 */
.tdm-notes {
  font-size: 13px;
  color: var(--text2);
  background: var(--bg3);
  border-radius: 8px;
  padding: 12px 14px;
  word-break: break-word;
  margin-bottom: 14px;
  line-height: 1.7;
}

/* ===== 매매일지 유형 배지 (상세 모달 등 레거시 호환) ===== */
.trade-type-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.trade-type-pill.buy  { background: #ef4444; }
.trade-type-pill.sell { background: #10b981; }

/* ===== 매매일지 상세 모달 작성자 행 ===== */
.tdm-author-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 14px;
}
.tdm-author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.tdm-author-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.tdm-author-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text1);
}
.tdm-author-me {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  color: var(--primary);
  background: rgba(99,102,241,.12);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}
.tdm-author-time {
  font-size: 12px;
  color: var(--text3);
  margin-left: auto;
}

/* ===== 대시보드 그룹 카드 ===== */
.dash-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 4px 0;
}
.dash-group-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.dash-group-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(99,102,241,.12);
}
.dash-group-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-group-meta {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 8px;
}
.dash-group-role {
  display: flex;
  align-items: center;
}

/* ===== 공부일지 구분 배지 ===== */
.study-source-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f59e0b20;
  color: #f59e0b;
}
.study-source-main {
  background: #6366f120;
  color: #6366f1;
}

/* ===== 테마 선택 UI ===== */
.theme-selector {
  display: flex;
  gap: 10px;
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.theme-swatch {
  width: 48px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid var(--border);
  transition: border-color .15s;
  position: relative;
  overflow: hidden;
}
.theme-swatch.dark  { background: linear-gradient(135deg, #0f172a 50%, #1e293b 50%); }
.theme-swatch.white { background: linear-gradient(135deg, #f8fafc 50%, #ffffff 50%); }
.theme-swatch.gray  { background: linear-gradient(135deg, #e2e8f0 50%, #f1f5f9 50%); }
.theme-option.active .theme-swatch { border-color: var(--primary); }
.theme-option input[type=radio] { display: none; }
.theme-label { font-size: 11px; color: var(--text2); }
.theme-option.active .theme-label { color: var(--primary); font-weight: 600; }

/* ===== YouTube 썸네일 ===== */
.yt-thumb-wrap {
  display: block;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 6px;
  line-height: 0;
}
.yt-thumb-wrap img {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
  border-radius: 8px;
}
.yt-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.65);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.yt-play-icon svg { margin-left: 3px; }

/* ===== 서브카테고리 드롭다운 ===== */
.study-subcat-select { width: 100%; }

/* ===== 자료실 ===== */
.res-top-bar { display:flex; flex-direction:column; gap:10px; margin-bottom:16px; }
.res-search-row { display:flex; gap:8px; align-items:center; }
.res-search-row input { flex:1; min-width:0; }
.resources-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
@media(max-width:768px) { .resources-grid { grid-template-columns:repeat(2,1fr); } }
@media(max-width:360px) { .resources-grid { grid-template-columns:1fr; } }
.resource-card { background:var(--bg2); border:1px solid var(--border); border-radius:12px; overflow:hidden; cursor:pointer; transition:border-color .15s; }
.resource-card:hover { border-color:var(--accent); }
.resource-thumb { width:100%; aspect-ratio:16/9; background:var(--bg3); display:flex; align-items:center; justify-content:center; font-size:32px; overflow:hidden; }
.resource-thumb img { width:100%; height:100%; object-fit:cover; }
.resource-info { padding:10px 12px; }
.resource-title { font-size:13px; font-weight:500; line-height:1.4; margin-bottom:4px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.resource-meta { font-size:11px; color:var(--text3); margin-bottom:4px; }
.resource-link { font-size:11px; color:var(--accent); text-decoration:none; display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.res-source-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #10b98120;
  color: #10b981;
}
.res-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3);
}
@media (max-width: 640px) {
  .res-search-row { flex-wrap: wrap; }
}

/* ===== 종목분석 ===== */
.analysis-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.analysis-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.analysis-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.analysis-rec-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  white-space: nowrap;
}
.analysis-excerpt {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.analysis-card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ===== 주요이슈 ===== */
.issue-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.issue-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.issue-direction-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
}
.issue-market-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg3);
  color: var(--text3);
}
.issue-title { font-size: 14px; font-weight: 600; color: var(--text1); margin-bottom: 4px; }
.issue-summary { font-size: 13px; color: var(--text2); line-height: 1.5; }
.issue-footer { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--text3); }

/* ===== 홈페이지 수정요청 ===== */
.feedback-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.feedback-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.feedback-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
}
.feedback-category-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: #818cf820;
  color: #818cf8;
}
.feedback-title { font-size: 14px; font-weight: 600; color: var(--text1); margin-bottom: 4px; }
.feedback-footer { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--text3); }
.admin-reply-box {
  background: var(--bg3);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text2);
}
.admin-reply-box .reply-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ===== 대시보드 리디자인 ===== */

/* 인사말 */
.dash-greeting-title { font-size: 20px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 4px; }
.dash-greeting-sub   { font-size: 13px; color: var(--text2); }

/* 통계 카드 컬러 라인 */
.stat-card { position: relative; overflow: hidden; transition: border-color .15s; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--primary); }
.stat-card.sc-green::before  { background: var(--success); }
.stat-card.sc-red::before    { background: var(--danger); }
.stat-card.sc-yellow::before { background: var(--warning); }
.stat-card:hover { border-color: var(--text3); }
.c-pos  { color: var(--success); font-weight: 600; }
.c-neg  { color: var(--danger);  font-weight: 600; }
.c-zero { color: var(--text3); }

/* 대시보드 그리드 */
.dash-stats-grid  { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.dash-widget-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 16px; }
/* 마지막 위젯 그리드는 하단 마진 제거 — page-content padding-bottom(64px)만으로 탭바와 자연 간격 */
.dash-widget-grid:last-child { margin-bottom: 0; }

/* 위젯 카드 */
.dw-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: border-color .15s; }
.dw-card:hover { border-color: var(--text3); }
.dw-head  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dw-title { font-size: 11px; font-weight: 700; color: var(--text2); letter-spacing: .5px; text-transform: uppercase; }
.dw-more  { font-size: 11px; color: var(--primary); cursor: pointer; }
.dw-more:hover { text-decoration: underline; }

/* 매매 아이템 */
.dash-trade-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: opacity .15s; }
.dash-trade-row:last-of-type { border-bottom: none; }
.dash-trade-row:hover { opacity: .72; }
.dash-trade-pill      { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; flex-shrink: 0; }
.dash-trade-pill.buy  { background: rgba(239,68,68,.14);  color: var(--danger); }
.dash-trade-pill.sell { background: rgba(16,185,129,.14); color: var(--success); }

/* 게시글 아이템 */
.dash-post-row { padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: opacity .15s; }
.dash-post-row:last-of-type { border-bottom: none; }
.dash-post-row:hover { opacity: .72; }
.dash-post-cat  { font-size: 10px; color: var(--primary); font-weight: 600; margin-bottom: 2px; }
.dash-post-ttl  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; line-height: 1.4; }
.dash-post-meta { font-size: 11px; color: var(--text3); display: flex; gap: 8px; }

/* 종목 랭킹 아이템 */
.dash-rnk-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.dash-rnk-row:last-of-type { border-bottom: none; }
.dash-rnk-num      { font-size: 12px; font-weight: 700; color: var(--text3); width: 16px; flex-shrink: 0; text-align: center; }
.dash-rnk-num.top  { color: var(--warning); }
.dash-rnk-info     { flex: 1; min-width: 0; }
.dash-rnk-name     { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-rnk-code     { font-size: 10px; color: var(--text2); }
.dash-rnk-bar      { height: 3px; background: var(--bg3); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.dash-rnk-fill     { height: 100%; background: var(--primary); border-radius: 2px; }
.dash-rnk-cnt      { font-size: 12px; color: var(--text2); font-weight: 500; flex-shrink: 0; white-space: nowrap; }

/* 이슈 아이템 */
.dash-issue-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: opacity .15s; }
.dash-issue-row:last-of-type { border-bottom: none; }
.dash-issue-row:hover { opacity: .72; }
.dash-issue-dir      { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; white-space: nowrap; margin-top: 2px; height: fit-content; }
.dash-issue-dir.긍정 { background: rgba(16,185,129,.15); color: var(--success); }
.dash-issue-dir.중립 { background: rgba(245,158,11,.13); color: var(--warning); }
.dash-issue-dir.부정 { background: rgba(239,68,68,.13);  color: var(--danger); }
.dash-issue-ttl  { font-size: 12px; font-weight: 500; line-height: 1.4; margin-bottom: 2px; }
.dash-issue-meta { font-size: 10px; color: var(--text3); }

/* 포트폴리오 아이템 */
.dash-port-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: opacity .15s; }
.dash-port-row:last-of-type { border-bottom: none; }
.dash-port-row:hover { opacity: .72; }
.dash-port-name { font-size: 12px; font-weight: 700; }
.dash-port-qty  { font-size: 10px; color: var(--text2); }
.dash-port-amt  { font-size: 12px; font-weight: 700; }

/* 그룹 아이템 */
.dash-grp-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: opacity .15s; }
.dash-grp-row:last-of-type { border-bottom: none; }
.dash-grp-row:hover { opacity: .72; }
.dash-grp-icon  { width: 26px; height: 26px; border-radius: 6px; background: rgba(139,92,246,.15); display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.dash-grp-name  { font-size: 12px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-grp-cnt   { font-size: 10px; color: var(--text2); flex-shrink: 0; }
.dash-grp-badge { font-size: 10px; padding: 1px 6px; border-radius: 4px; flex-shrink: 0; }
.dash-grp-badge.admin  { background: rgba(79,70,229,.15); color: var(--primary); }
.dash-grp-badge.member { background: rgba(16,185,129,.12); color: var(--success); }

/* 미니 바 차트 */
.dash-mini-bars { display: flex; align-items: flex-end; gap: 2px; height: 36px; margin-top: 12px; }
.dash-mini-bar  { flex: 1; border-radius: 2px 2px 0 0; min-height: 3px; transition: opacity .15s; }
.dash-mini-bar:hover { opacity: .7; }

/* 반응형 */
@media (max-width: 1100px) {
  .dash-stats-grid  { grid-template-columns: repeat(2,1fr); }
  .dash-widget-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  .dash-stats-grid  { grid-template-columns: repeat(2,1fr); }
  .dash-widget-grid { grid-template-columns: 1fr; }
}

/* ── 소셜 로그인 버튼 ─────────────────────── */
.social-btns { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.social-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.social-btn:hover { opacity: .88; }
.social-kakao  { background: #FEE500; color: #3C1E1E; }
.social-naver  { background: #03C75A; color: #fff; }
.social-google { background: #fff; color: #3c4043; border: 1px solid #dadce0; }
[data-theme="dark"] .social-google { background: #2d2d2d; color: #e8eaed; border-color: #444; }

.auth-divider {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 10px;
  color: var(--text3); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── 관리자 2단 레이아웃 ──────────────────── */
.admin-topnav {
  display: flex;
  gap: 0;
  padding: 12px 0 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.admin-topnav::-webkit-scrollbar { display: none; }
.admin-tab {
  padding: 5px 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.admin-tab:hover { color: var(--text); background: var(--bg3); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.admin-tab-content { min-height: 400px; }
.admin-tab-separator {
  display: inline-block;
  width: 1px;
  background: var(--border);
  margin: 4px 4px;
  align-self: stretch;
  flex-shrink: 0;
}

/* 관리자 아코디언 */
.admin-accordion { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.admin-accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer; background: var(--card-bg);
  font-size: 14px; font-weight: 600; user-select: none;
}
.admin-accordion-header:hover { background: var(--hover); }
.admin-accordion-body { padding: 16px; background: var(--card-bg); border-top: 1px solid var(--border); display: none; }
.admin-accordion-body.open { display: block; }

/* 소셜 배지 */
.badge-kakao  { background: #FEE50020; color: #b8860b; }
.badge-naver  { background: #03C75A20; color: #016a30; }
.badge-google { background: #4285F420; color: #1a56c4; }
.badge-direct { background: var(--border); color: var(--text2); }
.badge-role   { display:inline-block; padding:2px 8px; border-radius:4px; font-size:12px; font-weight:600; }
.badge-role.role-dev    { background:#7c3aed20; color:#7c3aed; }
.badge-role.role-admin  { background:var(--primary-light,#3b82f620); color:var(--primary); }
.badge-role.role-member { background:var(--border); color:var(--text3); }

/* 토글 스위치 */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 22px; transition: .2s; }
.toggle-slider:before { content:''; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* 환경설정 secret 입력 행 */
.cfg-secret-row { position: relative; }
.cfg-secret-row input { padding-right: 36px; }
.cfg-eye-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text2); font-size: 15px; padding: 0; }

/* admin 테이블 */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.admin-table th { color: var(--text2); font-weight: 600; font-size: 12px; }

/* ===== 개발자 설정 UI ===== */
.help-icon { display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; border-radius:50%; background:var(--text3); color:var(--bg2); font-size:10px; font-weight:700; cursor:pointer; margin-left:4px; flex-shrink:0; transition:background .15s; vertical-align:middle; }
.help-icon:hover { background:var(--primary); }
.dev-section { background:var(--bg2); border:1px solid var(--border); border-radius:12px; padding:20px; margin-bottom:16px; }
.dev-section h3 { font-size:15px; font-weight:600; margin-bottom:16px; padding-bottom:8px; border-bottom:1px solid var(--border); }
.dev-row { display:flex; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--border); }
.dev-row:last-of-type { border-bottom:none; }
.dev-row-label { flex:1; font-size:13px; font-weight:500; display:flex; align-items:center; }
.dev-row-input { flex-shrink:0; }
.color-preview { width:32px; height:32px; border-radius:6px; border:1px solid var(--border); flex-shrink:0; }

@media (max-width: 640px) {
  .admin-tab { padding: 5px 5px; font-size: 11px; }
  .admin-tab-separator { margin: 3px 2px; }
}

/* ── 문서 페이지 (소개·약관·방침) ── */
.docs-page { max-width: 760px; margin: 0 auto; padding-bottom: 60px; }
.docs-page h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.docs-updated { font-size: 12px; color: var(--text3); margin-bottom: 28px; }
.docs-section { margin-bottom: 28px; }
.docs-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.docs-section p, .docs-section li { font-size: 14px; line-height: 1.8; color: var(--text2); }
.docs-section ul, .docs-section ol { padding-left: 20px; }
.docs-section li { margin-bottom: 4px; }
.docs-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.docs-table th, .docs-table td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.docs-table th { background: var(--bg3); font-weight: 600; color: var(--text1); }
.docs-table td { color: var(--text2); }
.docs-menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 600px) { .docs-menu-grid { grid-template-columns: 1fr; } }
.docs-menu-item { display: flex; gap: 12px; padding: 12px; background: var(--bg3); border-radius: 10px; }
.docs-icon { font-size: 22px; flex-shrink: 0; }
.docs-menu-item strong { font-size: 13px; display: block; margin-bottom: 4px; color: var(--text1); }
.docs-menu-item p { font-size: 12px; color: var(--text3); margin: 0; line-height: 1.6; }
.docs-warning { background: rgba(245,158,11,.06); border: 1px solid rgba(245,158,11,.2); border-radius: 10px; padding: 14px 16px; }
.docs-warning h3 { border-bottom: none; padding-bottom: 0; color: #f59e0b; }

/* ── AI 고지문 ── */
.ai-disclaimer {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 16px;
  background: rgba(139,92,246,.06);
  border: 1px solid rgba(139,92,246,.2);
  border-radius: 10px;
}
.ai-disclaimer-icon { font-size: 22px; flex-shrink: 0; }
.ai-disclaimer strong { font-size: 13px; display: block; margin-bottom: 4px; color: #8b5cf6; }
.ai-disclaimer p { font-size: 12px; line-height: 1.7; color: var(--text2); margin: 0; }

/* ── 종목분석 폼 ── */
.aform-group { margin-bottom: 18px; }
.aform-label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.aform-label .req { color: var(--accent); margin-left: 2px; }
.aform-input { width: 100%; padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; box-sizing: border-box; }
.aform-input:focus { outline: none; border-color: var(--accent); }
.aform-textarea { width: 100%; padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; resize: vertical; box-sizing: border-box; }
.aform-textarea:focus { outline: none; border-color: var(--accent); }
.aform-link-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* 투자추천 그리드 */
.rec-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rec-item input[type=radio] { display: none; }
.rec-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all .15s; background: var(--bg3); }
.rec-icon { font-size: 16px; font-weight: 700; line-height: 1; }
.rec-text { font-size: 11px; font-weight: 500; text-align: center; white-space: nowrap; }
.rec-item input:checked + .rec-card { border-width: 2px; }

/* 투자추천 색상 */
.rec-strong-buy .rec-card { color: #ef4444; }
.rec-strong-buy input:checked + .rec-card { background: rgba(239,68,68,.12); border-color: #ef4444; }
.rec-buy .rec-card { color: #f97316; }
.rec-buy input:checked + .rec-card { background: rgba(249,115,22,.12); border-color: #f97316; }
.rec-neutral .rec-card { color: var(--text2); }
.rec-neutral input:checked + .rec-card { background: rgba(100,116,139,.12); border-color: var(--text2); }
.rec-sell .rec-card { color: #3b82f6; }
.rec-sell input:checked + .rec-card { background: rgba(59,130,246,.12); border-color: #3b82f6; }
.rec-strong-sell .rec-card { color: #6366f1; }
.rec-strong-sell input:checked + .rec-card { background: rgba(99,102,241,.12); border-color: #6366f1; }

/* 하단 옵션 */
.aform-footer { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.aform-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); cursor: pointer; }
.aform-check input { width: 15px; height: 15px; flex-shrink: 0; }
.aform-check small { font-size: 11px; color: var(--text3); }
.aform-check-ai { color: #8b5cf6; }

/* 종목분석 모달 너비 */
.modal-analysis { max-width: 520px; width: 95vw; }

@media (max-width: 480px) {
  .rec-text { font-size: 10px; }
  .rec-card { padding: 8px 2px; }
}

/* ===== 사이트 푸터 ===== */
.site-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  margin-top: 40px;
}
.footer-links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.footer-link { font-size: 12px; color: var(--text3); cursor: pointer; }
.footer-link:hover { color: var(--accent); text-decoration: underline; }
.footer-sep { font-size: 12px; color: var(--border); }
.footer-copy { font-size: 11px; color: var(--text3); }

/* ===== 동적 링크 추가 UI ===== */
.btn-add-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); background: rgba(79,70,229,.08); border: 1px dashed var(--primary); border-radius: 8px; padding: 6px 14px; cursor: pointer; margin-top: 6px; }
.btn-add-link:hover { background: rgba(79,70,229,.14); }
.btn-remove-link { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 18px; padding: 0 4px; line-height: 1; flex-shrink: 0; }
.btn-remove-link:hover { color: var(--danger); }
.link-row { margin-bottom: 6px; }
.link-row .aform-link-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }

/* ===== 탐구생활 댓글 미리보기 ===== */
.forum-comments-preview { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.fcp-item { display: flex; align-items: flex-start; gap: 8px; }
.fcp-avatar { width: 20px; height: 20px; border-radius: 50%; background: #4f46e5; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; font-weight: 600; flex-shrink: 0; overflow: hidden; }
.fcp-body { flex: 1; font-size: 12px; line-height: 1.5; min-width: 0; }
.fcp-author { font-weight: 500; color: var(--text2); margin-right: 6px; }
.fcp-content { color: var(--text3); }
.fcp-time { font-size: 11px; color: var(--text3); flex-shrink: 0; }

/* ===== IRP 스타일 ===== */
.irp-calc { display:flex; gap:24px; padding:10px 14px; background:var(--bg3); border-radius:8px; margin:8px 0; font-size:13px; }
.irp-port-section { background:var(--bg3); border-radius:10px; padding:12px; }
.irp-port-label { font-size:12px; font-weight:600; margin-bottom:8px; color:var(--text2); }
.irp-port-row { display:grid; grid-template-columns:1fr 80px; gap:6px; margin-bottom:6px; }
.irp-total { font-size:13px; font-weight:500; padding:8px 12px; background:var(--bg3); border-radius:8px; margin-top:8px; }
.card-box { background:var(--bg2); border:1px solid var(--border); border-radius:12px; padding:16px; }
.irp-port-note { font-size:12px; color:var(--text3); margin-bottom:8px; }
.irp-fund-summary { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.irp-fund-badge { display:inline-flex; align-items:center; gap:4px; font-size:11px; padding:2px 8px; background:var(--bg3); border:1px solid var(--border); border-radius:99px; }
.irp-fund-badge em { font-style:normal; font-weight:600; }
.irp-fund-badge small { color:var(--text3); }
.woori-asset-badge { font-size:10px; padding:2px 7px; border-radius:99px; font-weight:600; }
.badge-risk { background:rgba(239,68,68,.12); color:#ef4444; }
.badge-safe { background:rgba(16,185,129,.12); color:#10b981; }

/* IRP 뷰 탭 active 상태 */
.irp-view-tab.active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* 모달 large 너비 조정 */
.modal-box.large {
  max-width: min(720px, 98vw);
  width: 95vw;
  padding: clamp(12px, 3vw, 32px);
}

/* ===== 포트폴리오 탭 그룹 ===== */
.portfolio-tab-group { margin-bottom: 6px; }
.tab-group-label {
  font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.private-group .tab-group-label { color: #f59e0b; }
.private-group .tab-btn { border-color: rgba(245,158,11,.2); }
.private-group .tab-btn:hover { background: rgba(245,158,11,.06); }
.private-group .tab-btn.active {
  background: rgba(245,158,11,.12); color: #f59e0b; border-color: #f59e0b;
}
.private-badge {
  font-size: 10px; padding: 2px 7px;
  background: rgba(245,158,11,.12); color: #f59e0b;
  border-radius: 99px; font-weight: 500; letter-spacing: 0;
}

/* ===== 모바일 추가 최적화 ===== */
@media (max-width: 640px) {
  .trade-card, .widget, .stat-card, .forum-thread, .resource-card { border-radius: 10px; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .hide-mobile { display: none !important; }
  .modal-box.large { max-width: 100%; }
}

/* ===== 모바일 전체 최적화 (추가) ===== */
@media (max-width: 768px) {
  /* 모달 */
  .modal-box {
    padding: 20px 16px;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    margin: auto 0 0;
    max-height: 92vh;
  }
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box.large {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 16px 12px;
    max-height: 92vh;
  }

  /* 알림 패널 */
  .notif-panel {
    width: calc(100vw - 24px);
    right: 0;
    left: 12px;
  }

  /* 폼 2열 → 1열 */
  .form-row { grid-template-columns: 1fr; }
  .aform-link-row { grid-template-columns: 1fr auto !important; }

  /* 탭 버튼 */
  .tab-btn { font-size: 12px; padding: 7px 10px; }
  .tabs { gap: 4px; }

  /* 테이블 스크롤 */
  .docs-table, table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* stat 카드 */
  .stat-card { padding: 12px; }
  .stat-value { font-size: 18px !important; }

  /* IRP 모달 */
  .irp-calc { flex-direction: column; gap: 8px; }
  .irp-port-row { grid-template-columns: 1fr 70px; }

  /* 페이지 패딩 */
  .page-content { padding: 16px 12px; }

  /* 링크 행 */
  .link-row .aform-link-row { grid-template-columns: 1fr auto; }

  /* 헤더 */
  .top-header { padding: 0 12px; }

  /* 위젯 그리드 */
  .widget-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  /* 모달 패딩 더 줄이기 */
  .modal-box { padding: 16px 12px; }
  .modal-box.large { padding: 12px 10px; }

  /* 버튼 */
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 11px; }

  /* 제목 */
  .modal-title { font-size: 15px; }
  .page-title { font-size: 14px; }

  /* IRP 도넛 차트 */
  canvas { max-width: 160px !important; max-height: 160px !important; }

  /* 탭 더 작게 */
  .tab-btn { font-size: 11px; padding: 6px 8px; }

  /* stat 그리드 1열 */
  [style*="grid-template-columns:repeat(auto-fill,minmax(160px"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* 페이지 패딩 최소화 */
  .page-content { padding: 12px 10px; }
}

@media (max-width: 360px) {
  .modal-box { padding: 12px 10px; }
  .tab-btn { font-size: 10px; padding: 5px 6px; }
  .stat-value { font-size: 15px !important; }
}

/* ===== 지식쌓기 2단 탭 + 그룹핑 헤더 ===== */
.study-group-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
  padding: 12px 4px 8px;
  border-bottom: 1px solid var(--border);
  margin-top: 16px;
}
.study-group-header:first-child { margin-top: 0; }

#study-main-tabs { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
#study-sub-tabs { margin-top: 8px; padding-top: 4px; }
#study-sub-tabs.scrollable {
  overflow-x: auto;
  flex-wrap: nowrap;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
#study-sub-tabs.scrollable .tab-btn { flex-shrink: 0; }

/* ===== 관리자: 카테고리 관리 (Phase 4) ===== */
.cat-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 13px;
}
.cat-table th, .cat-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.cat-table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg3);
  font-weight: 600;
}
.cat-table .cat-order   { width: 60px;  text-align: center; }
.cat-table .cat-status  { width: 60px;  text-align: center; }
.cat-table .cat-actions { width: 200px; text-align: right; }
.cat-table tr.cat-inactive { opacity: 0.5; }
.cat-table .badge-default {
  display: inline-block;
  background: var(--warning, #f59e0b);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.cat-section { margin-bottom: 24px; }
.cat-section h3, .cat-section h4 { margin-bottom: 8px; }

/* 후속 패치: 시스템 보호 + 드래그앤드롭 */
.badge-system {
  display: inline-block;
  background: var(--primary, #4f46e5);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.cat-section-note {
  font-size: 13px;
  color: var(--text2);
  font-weight: 400;
}
.cat-system-note {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(79, 70, 229, 0.08);
  border-left: 3px solid var(--primary, #4f46e5);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text2);
}
.cat-table tr.cat-system { background: rgba(79, 70, 229, 0.04); }
.cat-drag-handle {
  display: inline-block;
  cursor: grab;
  color: var(--text3);
  font-size: 14px;
  padding: 2px 4px;
  user-select: none;
  letter-spacing: -2px;
}
.cat-drag-handle:active { cursor: grabbing; }
.cat-table tr[draggable="true"]:hover .cat-drag-handle { color: var(--primary, #4f46e5); }
.cat-table tr.dragging { opacity: 0.4; }
.cat-table tr.drag-over {
  border-top: 2px solid var(--primary, #4f46e5);
  background: rgba(79, 70, 229, 0.08);
}

/* ===== Phase 5: 게시판권한 매트릭스 + 어드민 dev 배지 ===== */
.admin-tab .dev-badge {
  display: inline-block;
  background: var(--warning, #f59e0b);
  color: white;
  font-size: 8px;
  padding: 1px 3px;
  border-radius: 3px;
  margin-left: 3px;
  font-weight: 700;
  vertical-align: middle;
}
.bp-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.bp-toolbar input { flex: 1; min-width: 200px; max-width: 360px; }
.bp-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  -webkit-overflow-scrolling: touch;
}
.bp-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.bp-matrix-table th, .bp-matrix-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.bp-matrix-table th {
  background: var(--bg3);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.bp-matrix-table .bp-user-col   { width: 110px; text-align: left; }
.bp-matrix-table .bp-role-col   { width: 70px; }
.bp-matrix-table .bp-perm-col   { width: 24px; font-size: 10px; color: var(--text3); }
.bp-matrix-table .bp-board-header {
  border-right: 2px solid var(--border);
  font-size: 11px;
}
.bp-matrix-table .bp-user-name { text-align: left; font-weight: 500; }
.bp-matrix-table input[type=checkbox] { cursor: pointer; width: 16px; height: 16px; }
.badge-dev {
  background: var(--warning, #f59e0b);
  color: white;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}
.badge-admin {
  background: var(--primary, #4f46e5);
  color: white;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}

/* === 안 A: 게시판권한 요약 뷰 + 모달 편집 === */
.bp-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bp-summary-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg3);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text3);
  font-weight: 600;
}
.bp-summary-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.bp-summary-table .bp-col-name    { width: 160px; }
.bp-summary-table .bp-col-role    { width: 70px; }
.bp-summary-table .bp-col-actions { width: 90px; text-align: right; }
.bp-summary-table tbody tr:hover  { background: var(--bg3); }
.bp-summary-table .bp-row-name    { font-weight: 500; }
.bp-allowed-mark { color: var(--success, #10b981); font-weight: 500; font-size: 13px; }
.bp-blocked-mark { color: var(--warning, #f59e0b); font-weight: 500; font-size: 13px; }
.bp-summary-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text2);
}
.legend-allowed { color: var(--success, #10b981); }
.legend-blocked { color: var(--warning, #f59e0b); }
.bp-row-role .bp-role-member { color: var(--text3); font-size: 12px; }

/* 편집 모달 */
.bp-modal-header h3 { margin: 0 0 16px 0; font-size: 16px; }
.bp-modal-bulk {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm, 6px);
  flex-wrap: wrap;
}
.bp-modal-help {
  font-size: 11px;
  color: var(--text3);
  margin-left: auto;
}
.bp-edit-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}
.bp-edit-table th, .bp-edit-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.bp-edit-table th {
  background: var(--bg3);
  font-size: 12px;
  font-weight: 600;
}
.bp-edit-table th small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text3);
}
.bp-edit-table .bp-edit-board {
  text-align: left;
  font-weight: 500;
  width: 35%;
}
.bp-edit-table input[type=checkbox] {
  width: 18px; height: 18px; cursor: pointer;
}
.bp-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.bp-modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.modal-box.bp-edit-modal {
  max-width: 540px;
  width: 95vw;
}

@media (max-width: 640px) {
  .bp-summary-table .bp-col-role,
  .bp-summary-table .bp-row-role { display: none; }
  .bp-modal-bulk { flex-direction: column; align-items: stretch; }
  .bp-modal-help { margin-left: 0; }
}


/* ============================================================
   포인트 시스템 (2026-05-03 Phase 4)
   ============================================================ */

/* 포인트 위젯 (헤더 우측, 알림 아이콘 옆) */
.point-widget {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}
.point-widget:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.point-widget .pw-icon { font-size: 14px; }
.point-widget.low {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239,68,68,0.1);
}

/* 포인트 모달 - 요약 영역 */
.point-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.point-summary-card {
  padding: 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  text-align: center;
}
.point-summary-card .label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.point-summary-card .value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.point-summary-card.balance .value { color: var(--primary); }
.point-summary-card.earned .value { color: var(--success); }
.point-summary-card.spent .value { color: var(--text2); }

/* 트랜잭션 리스트 */
.point-tx-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}
.point-tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.point-tx-item .tx-info { flex: 1; min-width: 0; }
.point-tx-item .tx-reason { color: var(--text); margin-bottom: 2px; }
.point-tx-item .tx-date { font-size: 11px; color: var(--text3); }
.point-tx-item .tx-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 12px;
}
.point-tx-item .tx-amount.pos { color: var(--success); }
.point-tx-item .tx-amount.neg { color: var(--danger); }
.point-tx-item .tx-balance {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
  text-align: right;
}
.point-tx-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

/* 카드 마스킹 (잔액 부족 시) */
.point-locked {
  position: relative;
  cursor: not-allowed;
  user-select: none;
}
.point-locked .card-body,
.point-locked .post-content,
.point-locked .trade-info,
.point-locked .stock-info,
.point-locked .price-info,
.point-locked .quantity-info,
.point-locked .pnl,
.point-locked .post-preview,
.point-locked .trade-amount,
.point-locked .note-content,
.point-locked .post-body {
  filter: blur(5px);
  pointer-events: none;
}
.point-locked::after {
  content: "🔒 포인트 부족 — 글을 작성하면 적립돼요";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.7);
  color: white;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius);
  pointer-events: none;
  text-align: center;
  padding: 8px;
  z-index: 5;
}

/* 적립 토스트 - 일반 토스트보다 화려하게 */
.toast.point {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  border: none;
  font-weight: 600;
}
.toast.point::before {
  content: "💎 ";
  margin-right: 4px;
}

/* 모바일 */
@media (max-width: 640px) {
  .point-widget {
    padding: 5px 10px;
    font-size: 12px;
    margin-right: 4px;
  }
  .point-summary {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .point-tx-list {
    max-height: 60vh;
  }
}

/* ============================================================
   Phase 5 — 회원관리 통합 + 대시보드 (2026-05-03)
   ============================================================ */

/* 회원관리 레이아웃 */
.user-mgmt-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  position: relative;
}
.user-mgmt-layout.with-panel {
  grid-template-columns: 1fr 480px;
}
@media (max-width: 1100px) {
  .user-mgmt-layout.with-panel { grid-template-columns: 1fr; }
}

.user-mgmt-table { width: 100%; border-collapse: collapse; }
.user-mgmt-table th, .user-mgmt-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  text-align: left; font-size: 13px;
}
.user-mgmt-table th {
  background: var(--bg3); font-size: 11px;
  text-transform: uppercase; color: var(--text3);
}
.user-mgmt-table tr { cursor: pointer; }
.user-mgmt-table tr:hover { background: var(--bg3); }
.user-mgmt-table tr.selected { background: var(--primary-light); }
.user-mgmt-table .um-points {
  font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--primary);
}

/* 우측 슬라이드 패널 */
.user-detail-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky; top: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.udp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.udp-header h3 { margin: 0; font-size: 18px; }
.udp-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 16px; flex-wrap: wrap;
}
.udp-tab {
  padding: 8px 12px; cursor: pointer;
  border: none; background: transparent;
  color: var(--text2); font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.udp-tab:hover { color: var(--text); }
.udp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.udp-section { margin-bottom: 16px; }
.udp-section h4 {
  margin: 0 0 8px; font-size: 12px;
  text-transform: uppercase; color: var(--text3);
}
.udp-info-row {
  display: grid; grid-template-columns: 100px 1fr;
  padding: 6px 0; font-size: 13px; border-bottom: 1px dashed var(--border);
}
.udp-info-row:last-child { border-bottom: none; }
.udp-info-row .label { color: var(--text3); }

/* 포인트 탭 */
.udp-point-summary {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 12px;
}
.udp-point-card {
  padding: 10px; background: var(--bg3); border-radius: var(--radius-sm);
  text-align: center;
}
.udp-point-card .label { font-size: 10px; color: var(--text3); }
.udp-point-card .value {
  font-size: 16px; font-weight: 700; color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.udp-grant-form {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 10px; background: var(--bg3); border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.udp-grant-form input { flex: 1; min-width: 100px; }
.udp-close { padding: 4px 8px; }

/* 관리자 대시보드 */
.admin-dashboard {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.dash-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.dash-card h3 {
  margin: 0 0 12px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.dash-stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 8px;
}
.dash-stat {
  text-align: center; padding: 8px; background: var(--bg3); border-radius: var(--radius-sm);
}
.dash-stat .label { font-size: 10px; color: var(--text3); text-transform: uppercase; }
.dash-stat .value {
  font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dash-stat.primary .value { color: var(--primary); }
.dash-stat.success .value { color: var(--success); }

.dash-board-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; font-size: 12px; border-bottom: 1px dashed var(--border);
  gap: 8px;
}
.dash-board-row:last-child { border-bottom: none; }
.dash-board-row .name { color: var(--text2); flex-shrink: 0; min-width: 70px; }
.dash-board-row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-board-row .new-mark {
  background: var(--danger); color: white; font-size: 9px;
  padding: 1px 5px; border-radius: 3px; margin-left: 4px;
  font-weight: 600;
}
.dash-board-row .empty { color: var(--text3); font-style: italic; }

.dash-signup-chart { width: 100%; height: 80px; }
.dash-signup-chart path.fill { fill: var(--primary); fill-opacity: 0.2; }
.dash-signup-chart path.line { fill: none; stroke: var(--primary); stroke-width: 2; }

/* ============================================================
   Rate Limit 관리 UI (2026-05-03)
   ============================================================ */
.rate-limit-policies {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.rate-limit-policy {
  padding: 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
}
.rate-limit-policy .name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.rate-limit-policy .detail {
  font-size: 11px;
  color: var(--text3);
}
.rate-limit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
}
.rate-limit-actions input {
  flex: 1;
  min-width: 150px;
}

/* ============================================================
   회원관리 권한 탭 인라인 편집 (2026-05-03)
   ============================================================ */
.udp-perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 8px;
}
.udp-perm-table th,
.udp-perm-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.udp-perm-table th {
  background: var(--bg3);
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
}
.udp-perm-table th:first-child,
.udp-perm-table td:first-child {
  text-align: left;
  font-weight: 500;
}
.udp-perm-table input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.udp-menu-perms-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.udp-menu-perm-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}
.udp-menu-perm-item input[type=checkbox] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.udp-menu-perm-item:hover {
  background: var(--primary-light);
}

/* ============================================================
   공부일지(돈공부) 필터 — 2라인 그리드 (2026-05-13)
   ============================================================ */
.sp-filter-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.sp-filter-row1, .sp-filter-row2 {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sp-filter-row1 .sp-filter-select {
  flex: 0 0 auto;
  width: 130px;
  max-width: 140px;
}
.sp-filter-row1 .sp-search-input {
  flex: 1;
  min-width: 0;
  max-width: none;
}
.sp-filter-row2 > button {
  flex: 1;
  white-space: nowrap;
}
@media (min-width: 641px) {
  /* 데스크톱: row1 + row2를 1줄로 합침. row2를 display:contents로 투명화해
     버튼 2개가 .sp-filter-row의 flex 자식으로 직접 참여. */
  .sp-filter-row {
    flex-direction: row;
    flex-wrap: nowrap;
    max-width: 960px;
  }
  .sp-filter-row1 { flex: 1; min-width: 0; }
  .sp-filter-row2 { display: contents; }
  .sp-filter-row2 > button {
    flex: 0 0 auto;
    width: auto;
    min-width: 90px;
    max-width: none;
  }
}

/* ============================================================
   공부일지(돈공부) 카드 — 제목 우선 위계 (2026-05-13)
   ============================================================ */
.spc .spc-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.spc .spc-title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.spc .spc-sent { flex-shrink: 0; margin-top: 2px; }
.spc .spc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.spc .spc-meta-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.spc .spc-meta-right {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.spc .spc-username {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
@media (max-width: 400px) {
  .spc .spc-username { max-width: 64px; }
}

/* ============================================================
   우리은행 IRP 자동 등록 가이드 (2026-05-03)
   ============================================================ */
.woori-guide {
  margin-bottom: 16px;
}
.woori-guide-toggle {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.2s;
}
.woori-guide-toggle:hover {
  background: var(--primary-light);
}
.woori-guide-content {
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 8px;
}
.woori-guide-content h4 {
  margin: 0 0 8px;
  font-size: 14px;
}
.woori-step {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
}
.woori-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.woori-step-body { flex: 1; }
.woori-step-body strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.woori-step-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  display: block;
}
.woori-tip {
  padding: 10px 12px;
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text2);
  margin-top: 8px;
}

@media (max-width: 480px) {
  .woori-step {
    flex-direction: column;
    gap: 8px;
  }
}

/* ============================================================
   WYSIWYG 에디터 (Quill.js) — 2026-05-03
   ============================================================ */
.post-content-editor {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  min-height: 250px;
}
.ql-toolbar.ql-snow {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg3);
}
.ql-container.ql-snow {
  border: 1px solid var(--border) !important;
  border-top: none !important;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--bg2);
  min-height: 200px;
}
.ql-editor {
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 200px;
}
.ql-editor.ql-blank::before {
  color: var(--text3);
  font-style: normal;
}
.ql-toolbar.ql-snow .ql-stroke { stroke: var(--text2); }
.ql-toolbar.ql-snow .ql-fill { fill: var(--text2); }
.ql-toolbar.ql-snow button:hover .ql-stroke,
.ql-toolbar.ql-snow .ql-picker-label:hover .ql-stroke,
.ql-toolbar.ql-snow button.ql-active .ql-stroke,
.ql-toolbar.ql-snow .ql-picker-label.ql-active .ql-stroke { stroke: var(--primary); }
.ql-toolbar.ql-snow button:hover .ql-fill,
.ql-toolbar.ql-snow .ql-picker-label:hover .ql-fill,
.ql-toolbar.ql-snow button.ql-active .ql-fill,
.ql-toolbar.ql-snow .ql-picker-label.ql-active .ql-fill { fill: var(--primary); }
.ql-snow .ql-picker { color: var(--text2); }
.ql-snow .ql-picker-options {
  background: var(--bg2);
  border: 1px solid var(--border);
}

/* 게시글 출력 */
.post-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}
.post-content p { margin: 0 0 8px 0; }
.post-content h1 { font-size: 20px; font-weight: 700; margin: 16px 0 8px; }
.post-content h2 { font-size: 17px; font-weight: 600; margin: 14px 0 6px; }
.post-content h3 { font-size: 15px; font-weight: 600; margin: 12px 0 6px; }
.post-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 4px 12px;
  margin: 8px 0;
  background: var(--bg3);
  color: var(--text2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.post-content pre {
  background: var(--bg3);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}
.post-content code {
  background: var(--bg3);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}
.post-content ul, .post-content ol { padding-left: 24px; margin: 8px 0; }
.post-content li { margin: 2px 0; }
.post-content a { color: var(--primary); text-decoration: underline; }
.post-content img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* 모바일 — iOS 자동줌 방지 (16px) + 툴바 압축 */
@media (max-width: 640px) {
  .ql-editor { font-size: 16px !important; min-height: 180px; }
  .ql-toolbar.ql-snow { padding: 4px; }
  .ql-toolbar.ql-snow .ql-formats { margin-right: 6px !important; }
  .ql-toolbar.ql-snow button { width: 28px !important; height: 28px !important; padding: 3px !important; }
  .post-content-editor { min-height: 200px; }
  .post-content { font-size: 14px; }
  .post-content h1 { font-size: 18px; }
  .post-content h2 { font-size: 16px; }
  .post-content h3 { font-size: 15px; }
}
@media (max-width: 480px) {
  .modal-box .ql-editor { min-height: 150px; }
}

/* ============================================================
   IRP 비작성자 안내 배지 (2026-05-03)
   ============================================================ */
.irp-private-notice {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text2);
  margin: 6px 0;
  line-height: 1.4;
}

.masked {
  color: var(--text3);
  font-size: 13px;
  opacity: 0.7;
}

/* ============================================================
   지식쌓기 댓글 (2026-05-03)
   ============================================================ */
.sn-comments-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sn-comments-section h4 {
  margin: 0 0 12px;
  font-size: 14px;
}
.sn-comments-list { margin-bottom: 12px; }
.sn-comments-empty {
  padding: 16px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}
.sn-comment-item {
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.sn-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text2);
}
.sn-comment-header strong { color: var(--text); }
.sn-comment-header .avatar-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: white;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.sn-comment-time {
  font-size: 11px;
  color: var(--text3);
  margin-left: auto;
  margin-right: 4px;
}
.sn-comment-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}
.sn-comment-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.sn-comment-form textarea {
  flex: 1;
  min-height: 50px;
  resize: vertical;
  padding: 8px;
  font-size: 13px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.sn-comment-form button { flex-shrink: 0; }

/* ===== 24h 상단 고정 핀 배지 ===== */
.pin-badge {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 2px 6px;
  line-height: 1;
}
[data-theme="dark"] .pin-badge {
  background: #422006;
  color: #fcd34d;
  border-color: #78350f;
}

/* ===== IRP 펀드 테이블 컬럼 너비 (table-layout: fixed) ===== */
.irp-fund-table { table-layout: fixed; width: 100%; min-width: 480px; border-collapse: collapse; font-size: 12px; }
.irp-fund-table th { padding: 7px 8px; font-weight: 600; color: var(--text2); border-bottom: 1px solid var(--border); }
.irp-fund-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); }
.irp-fund-table th.col-name, .irp-fund-table td.col-name { text-align: left; }
.irp-fund-table th.col-type, .irp-fund-table td.col-type { width: 90px; text-align: center; padding-left: 4px; padding-right: 4px; }
.irp-fund-table th.col-weight, .irp-fund-table td.col-weight { width: 70px; text-align: right; white-space: nowrap; font-weight: 700; font-size: 13px; }
.irp-fund-table th.col-eval, .irp-fund-table td.col-eval { width: 110px; text-align: right; white-space: nowrap; font-size: 12px; }
.irp-fund-table th.col-return, .irp-fund-table td.col-return { width: 90px; text-align: right; white-space: nowrap; line-height: 1.6; }
.irp-fund-table td.col-name { white-space: normal; word-break: break-word; }
.irp-fund-table tr.irp-fund-total { border-top: 2px solid var(--border); background: var(--bg3); }
.irp-fund-table tr.irp-fund-total td { padding: 7px 8px; font-weight: 600; }
.irp-fund-table .fund-color-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; margin-top: 3px; }

/* ===== 비공개 배지 (펀드 셀 하단) ===== */
.badge-private-fund {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10px;
  color: var(--text3);
  font-weight: 500;
}

/* ===== 프로필 카드 모달 ===== */
.profile-card { text-align: center; padding: 16px; }
.profile-card-avatar { margin-bottom: 12px; display: flex; justify-content: center; }
.profile-card-name { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.profile-card-role {
  display: inline-block;
  margin-bottom: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: var(--accent);
  color: white;
}
.profile-card-bio {
  padding: 12px;
  background: var(--bg3);
  border-radius: 8px;
  color: var(--text2);
  font-size: 14px;
  min-height: 40px;
  margin-top: 8px;
}
.profile-card-joined { margin-top: 10px; font-size: 11px; color: var(--text3); }
.profile-card-actions { margin-top: 16px; display: flex; justify-content: center; gap: 8px; }

/* ===== 클릭 가능한 작성자 영역 ===== */
.clickable-author { cursor: pointer; transition: opacity 0.15s; }
.clickable-author:hover { opacity: 0.7; }

/* ===== 예/적금 (savings) ===== */
.savings-card .savings-current {
  padding: 12px;
  background: var(--bg3);
  border-radius: 8px;
}
.savings-row:last-child { border-bottom: none !important; }

/* ============================================================
   ⭐ 모바일 통합 디자인 시스템 (Phase 2-A — 2026-05-06)
   ============================================================ */

/* 가로 스크롤 가능한 탭 컨테이너 — 줄바꿈 방지 */
.tabs-scrollable {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 0;
  white-space: nowrap;
}
.tabs-scrollable::-webkit-scrollbar { display: none; }
.tabs-scrollable .tab-btn { flex-shrink: 0; }

/* 작성자 영역 — 세로 쪼개짐 방지 */
.author-block {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 0;
}
.author-block .author-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* 모바일 헤더 행 (제목 + 액션 묶음) */
.modal-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

/* 모바일 최적화: 640px 이하 (Phase 2-A 일괄) */
@media (max-width: 640px) {

  /* 1. 필터/탭 바 — 가로 스크롤 강제 (줄바꿈 X) */
  .filter-bar,
  .tab-bar:not(.no-mobile-scroll),
  .vis-filter-tabs,
  .study-main-tabs,
  .study-sub-tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 0;
  }
  .filter-bar::-webkit-scrollbar,
  .tab-bar::-webkit-scrollbar,
  .vis-filter-tabs::-webkit-scrollbar,
  .study-main-tabs::-webkit-scrollbar,
  .study-sub-tabs::-webkit-scrollbar { display: none; }

  .filter-bar > *,
  .tab-bar > .tab-btn,
  .vis-filter-tabs > *,
  .study-main-tabs > *,
  .study-sub-tabs > * {
    flex-shrink: 0 !important;
    white-space: nowrap;
  }

  /* 2. 작성자 영역 — 세로 쪼개짐 방지 (모바일 강제 가로) */
  .author-block,
  .card-author,
  .post-author,
  .trade-author,
  .study-author,
  .memo-author,
  .sn-author,
  [class*="-author"] {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    white-space: nowrap !important;
    min-width: 0;
  }
  .author-block .author-name,
  [class*="-author"] .username {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
  }

  /* 3. 카드 패딩 압축 */
  .post-card,
  .trade-card,
  .study-card,
  .memo-card,
  .sn-card,
  .resource-card,
  .issue-card {
    padding: 12px !important;
    margin-bottom: 10px !important;
  }

  /* 4. 카드 헤더 폰트 크기 균형 */
  .post-card h3,
  .trade-card h3,
  .study-card h3,
  .sn-card h3 {
    font-size: 15px !important;
    line-height: 1.3 !important;
  }

  /* 5. 풀너비 액션 버튼 압축 (검색/작성) */
  .form-actions-row {
    display: flex;
    gap: 8px;
  }
  .form-actions-row > .btn-primary {
    flex: 1;
    padding: 10px 16px !important;
    font-size: 14px !important;
  }

  /* 6. + 작성 버튼이 화면 밖으로 안 나가게 */
  .filter-bar .btn-primary,
  .filter-bar .btn-write,
  [class*="-filter-row"] .btn-primary {
    flex-shrink: 0;
    padding: 8px 12px !important;
    font-size: 13px !important;
    white-space: nowrap;
  }

  /* 7. FAB — 하단 탭바와 안 겹치게 */
  .fab {
    bottom: 76px !important; /* 하단 탭바(56px) + 여유(20px) */
    right: 16px !important;
    width: 52px !important;
    height: 52px !important;
  }

  /* 8. 그룹핑 헤더 압축 */
  .group-header,
  .study-group-header,
  .sn-group-header,
  [class*="-group-header"] {
    font-size: 13px !important;
    padding: 8px 12px !important;
    margin-top: 12px !important;
    margin-bottom: 6px !important;
  }

  /* 9. IRP 도넛/펀드 리스트 — 잘림 방지 */
  .irp-portfolio-card .donut-wrap,
  .irp-portfolio-card .fund-list {
    max-width: 100%;
    overflow: hidden;
  }
  .irp-portfolio-card .fund-list {
    font-size: 11px;
  }
  .irp-portfolio-card .fund-list .fund-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
  }

  /* 10. 모달 메타 행 (작성자 + 날짜 + 배지) */
  .modal-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 12px;
  }

  /* 11. 폼 라벨/입력 모바일 압축 + iOS 자동 줌 방지 */
  .form-group label {
    font-size: 13px;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px !important;
  }
}

/* 480px 이하 (작은 폰) */
@media (max-width: 480px) {
  .post-card h3,
  .trade-card h3,
  .study-card h3,
  .sn-card h3 {
    font-size: 14px !important;
  }
  .filter-bar > *,
  .tab-bar > .tab-btn {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }
  .fab {
    width: 48px !important;
    height: 48px !important;
    bottom: 72px !important;
  }
}

/* ============================================================
   ⭐ 모바일 통합 디자인 시스템 (Phase 2-B — 2026-05-06)
   ============================================================ */

/* 모바일(640px 이하): 구조 분기 */
@media (max-width: 640px) {

  /* 2. IRP 카드 — 도넛/펀드 리스트 세로 배치 */
  /* 모바일에서도 좌(도넛) + 우(펀드리스트) 가로 배치 유지 */
  .irp-portfolio-card .irp-card-inner {
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    flex-wrap: nowrap !important;
  }
  .irp-portfolio-card .donut-wrap {
    flex-shrink: 0;
    width: 110px;
  }
  .irp-portfolio-card .donut-wrap svg {
    width: 100px !important;
    height: 100px !important;
  }
  .irp-portfolio-card .fund-list {
    flex: 1 !important;
    min-width: 0 !important;
    font-size: 11px !important;
  }
  /* 모바일에서는 비중% 숨겨 펀드명 공간 최대 확보 (데이터는 데스크톱에서 그대로 표시) */
  .irp-portfolio-card .fund-list .fund-pct { display: none !important; }
  /* 펀드명 — JS에서 18자 자르기 + CSS 이중 안전망 */
  .irp-portfolio-card .fund-list .fund-name {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: keep-all !important;
  }
  /* fund-row 자체도 부모 초과 안 함 */
  .irp-portfolio-card .fund-list .fund-row { max-width: 100%; overflow: hidden; }

  /* 3. 지식쌓기/공부일지/포럼 카드 본문 — line-clamp 2 (거대화 방지) */
  .post-card .post-excerpt {
    -webkit-line-clamp: 2 !important;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px !important;
    line-height: 1.5 !important;
  }
  .post-card .post-meta {
    font-size: 12px !important;
    gap: 4px !important;
    flex-wrap: wrap;
  }
  .post-card .post-footer {
    font-size: 11px !important;
    gap: 8px !important;
    margin-top: 6px !important;
  }
  .study-group-header {
    font-size: 13px !important;
    font-weight: 600;
    padding: 6px 10px !important;
  }

  /* 4. 공부일지 필터 행 — 모바일 버튼 폰트 축소 (구조는 .sp-filter-row1/row2가 처리) */
  .sp-filter-row2 > button {
    padding: 9px 12px !important;
    font-size: 13px !important;
  }
}

/* ============================================================
   ⭐ 컨텐츠 상세 모달 헤더 (Phase modalui — 2026-05-06)
   ============================================================ */
.post-detail-header { position: relative; }
.post-detail-header .modal-actions {
  position: absolute;
  top: 0;
  right: 40px;  /* 모달 X 버튼 자리 비움 */
  display: flex;
  gap: 6px;
}
.modal-meta-row .meta-author {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--text);
}
.modal-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.modal-meta-badges .category-badge {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px;
}
@media (max-width: 640px) {
  .post-detail-header .modal-actions {
    position: static;
    margin-bottom: 6px;
  }
  .modal-meta-row { gap: 4px; }
  .modal-meta-badges { gap: 4px; font-size: 11px; }
}

/* ============================================================
   ⭐ 내자산 모듈 재설계 (Phase 3 — 2026-05-06)
   ============================================================ */

/* 자산현황 stat 카드 그리드 */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 640px) {
  .stat-cards-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* 보유종목 시점 카드 그리드 */
.holdings-snapshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.holdings-snapshot-card .hs-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.holdings-snapshot-card .hs-card-meta {
  font-size: 11px;
  color: var(--text3);
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.holdings-snapshot-card .hs-donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  width: 70px;
}
.holdings-snapshot-card .hs-donut-eval {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}
.holdings-snapshot-card .hs-donut-rate {
  font-size: 10px;
  margin-top: 3px;
}
.holdings-snapshot-card .hs-fund-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
}
.holdings-snapshot-card .hs-fund-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.holdings-snapshot-card .hs-fund-color {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.holdings-snapshot-card .hs-fund-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.holdings-snapshot-card .hs-fund-weight {
  flex-shrink: 0;
  font-weight: 600;
  font-size: 11px;
  color: var(--text2);
}
.holdings-snapshot-card .hs-fund-more {
  color: var(--text3);
  font-size: 11px;
  padding: 3px 0;
}
.holdings-snapshot-card .hs-empty-items {
  color: var(--text3);
  font-size: 11px;
  font-style: italic;
}
@media (max-width: 640px) {
  .holdings-snapshot-grid { grid-template-columns: 1fr; }
  .holdings-snapshot-card .hs-card-inner {
    flex-direction: column !important;
    align-items: stretch !important;
  }
}

/* 자산흐름 페이지 */
.flow-charts-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 768px) {
  .flow-charts-grid { grid-template-columns: 1fr; }
}
.chart-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.flow-donut-legend, .flow-line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--text2);
  margin-top: 10px;
  justify-content: center;
}
.flow-donut-legend > div { display: flex; align-items: center; gap: 4px; }
.lg-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 3px;
}
.flow-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.flow-table th, .flow-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.flow-table th { background: var(--bg3); color: var(--text2); font-weight: 600; }
.flow-table .pos { color: var(--success, #10b981); }
.flow-table .neg { color: var(--danger, #ef4444); }
.flow-table-wrap { margin-top: 12px; }

/* 2026-05-06 — 매매일지 데스크톱 다컬럼 그리드 (모바일 단일 컬럼 default 유지) */
/* 기존 .trades-list { max-width: 680px } 제약은 모바일/단일컬럼용 — 그리드 시 해제 */
@media (min-width: 768px) {
  .trades-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: none;
  }
}
@media (min-width: 1280px) {
  .trades-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* 2026-05-07 — Phase 2: Pill Ghost 버튼 (수정/삭제 토스 스타일 통일 — 매매일지 우선 적용) */
.btn-toss-pill {
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 18px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: all 0.15s ease;
}
.btn-toss-pill:hover {
  background: var(--bg3);
  color: var(--text);
}
.btn-toss-pill.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-toss-pill-sm {
  padding: 3px 10px;
  font-size: 11px;
}

/* 2026-05-07 — Phase 3-1: 지식쌓기 카드 간격 (지식쌓기 한정 — #sn-study-list 부모 컨테이너) */
/* .post-card는 공유 클래스라 부모 ID로 한정. trades 카드 10px과 일관성 */
/* 2026-05-18 — last-child margin-bottom:0 제거: 마지막 카드가 푸터에 붙는 문제. 공부일지(#sp-list)와 동일하게 마지막 카드도 동일 margin 유지 */
#sn-study-list .post-card {
  margin-bottom: 10px;
}

/* 2026-05-07 — Phase 3-4: 지식쌓기 메인 ↔ 서브 카테고리 탭 구분선 */
#study-main-tabs {
  border-bottom: 0.5px solid var(--border);
  padding-bottom: 8px;
  /* margin-bottom은 인라인 style(8px)이 우선 — 그대로 유지 */
}

/* ===== 실시간 채팅방 (2026-05-16) ===== */
.chat-container {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 480px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.chat-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}
.chat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning, #d97706);
  display: inline-block;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg1, var(--bg2));
}
.chat-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  padding: 8px 0;
}
.chat-system {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  font-style: italic;
}
.chat-msg {
  max-width: 80%;
  align-self: flex-start;
}
.chat-msg.mine {
  align-self: flex-end;
}
.chat-msg-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 11px;
}
.chat-msg.mine .chat-msg-header { justify-content: flex-end; }
.chat-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-msg.mine .chat-avatar { background: var(--success); }
.chat-username {
  font-weight: 600;
  color: var(--text1);
}
.chat-time {
  color: var(--text3);
}
.chat-msg-body {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg3);
  color: var(--text1);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-msg.mine .chat-msg-body {
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  color: var(--text1);
}
.chat-jump-bottom {
  position: absolute;
  right: 24px;
  bottom: 80px;
  padding: 6px 14px;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  z-index: 5;
}
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  position: relative;
}
.chat-input-bar input {
  flex: 1;
  min-width: 0;
  /* 레거시/일부 브라우저용 한글 IME 활성화 힌트. 현대 브라우저는 무시(deprecated)되지만
     Firefox/일부 Android IME에서 효과가 보고된 적 있어 손해 없이 추가. */
  ime-mode: active;
  -webkit-ime-mode: active;
  -ms-ime-mode: active;
}
.chat-emoji-btn {
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  font-size: 18px;
  padding: 0 10px;
  line-height: 1;
}
.chat-emoji-btn:hover { background: var(--bg2); border-color: var(--primary); }
.chat-emoji-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 12px;
  right: 12px;
  max-width: 380px;
  background: var(--bg1, var(--bg2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  z-index: 100;
  overflow: hidden;
}
.chat-emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg2);
}
.chat-emoji-tabs::-webkit-scrollbar { display: none; }
.chat-emoji-tab {
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-size: 20px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
}
.chat-emoji-tab:hover { background: var(--bg3); }
.chat-emoji-tab.active {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  box-shadow: inset 0 -2px 0 0 var(--primary);
}
.chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.chat-emoji-item {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 6px 0;
  border-radius: 6px;
  line-height: 1;
}
.chat-emoji-item:hover { background: var(--bg2); }
@media (max-width: 640px) {
  /* 채팅 페이지: 하단 탭바 + footer 자체 숨김 (모바일에서 채팅이 화면 전체 점유) */
  body.on-chat .bottom-tab-bar,
  body.on-chat .site-footer { display: none !important; }
  /* 내지식 페이지: 워크스페이스가 화면 점유 — 탭바/푸터 숨김 */
  body.page-myknowledge .bottom-tab-bar,
  body.page-myknowledge .site-footer { display: none !important; }
  body.page-myknowledge .page-content { padding: 0 !important; }
  /* page-content 기본 padding 상쇄 — 채팅이 헤더 바로 아래부터 시작 */
  body.on-chat .page-content { padding: 0 !important; }
  .chat-container {
    /* 탭바 없으니 헤더만 차감 — 100dvh로 키보드 올라올 때 자동 축소 */
    height: calc(100dvh - 56px);
    min-height: 0;
    border-radius: 0;
    border: none;
    margin: 0;
  }
  .chat-messages { padding: 12px; }
  .chat-msg { max-width: 86%; }
  .chat-jump-bottom { right: 12px; bottom: 80px; }
  .chat-emoji-popup { left: 6px; right: 6px; }
  .chat-emoji-grid { grid-template-columns: repeat(7, 1fr); max-height: 200px; }
  .chat-emoji-item { font-size: 20px; padding: 5px 0; }
  /* 입력바: 노치 safe-area만 추가 (탭바 padding 제거 — 탭바 자체가 숨겨졌으므로) */
  .chat-input-bar {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

/* ===== 내일정 (1-1: 구글 캘린더 월간 뷰) ===== */
.ms-page { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.ms-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.ms-card-center { text-align: center; }
.ms-card-warn {
  background: linear-gradient(135deg, rgba(245,158,11,0.10), var(--bg2));
  border-color: #f59e0b; text-align: center;
}
.ms-warn-icon { font-size: 30px; }
.ms-icon-big { font-size: 44px; margin-bottom: 10px; }
.ms-h { font-size: 18px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
.ms-desc { font-size: 13px; color: var(--text2); line-height: 1.6; margin: 0 0 10px; }

/* 2-A: 옛 source 탭 제거 (HTML에서 안 그림). 잔존 셀렉터는 비활성 */
.ms-source-tabs, .ms-source-tab { display: none !important; }

/* 출처 토글 한 줄 — 구글 캘린더들 + 4개 고정 */
.ms-src-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 0 4px;
  margin-bottom: 4px;
}
.ms-src-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 14px; padding: 5px 12px;
  cursor: pointer; font-size: 12px; color: var(--text3);
  user-select: none;
}
.ms-src-chip input { width: auto !important; margin: 0; accent-color: var(--src-color, var(--primary)); }
.ms-src-chip.on { color: var(--text); background: var(--bg2); border-color: var(--src-color, var(--primary)); }
.ms-src-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ms-src-name { white-space: nowrap; }

/* 월 헤더 */
.ms-cal-head { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.ms-cal-title { font-size: 16px; font-weight: 700; min-width: 130px; text-align: center; }
.ms-cal-nav, .ms-cal-today, .ms-cal-refresh, .ms-add-event {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; height: 32px;
  cursor: pointer; color: var(--text2); font-size: 13px;
}
.ms-cal-nav:hover, .ms-cal-today:hover, .ms-cal-refresh:hover { background: var(--primary-light); color: var(--primary); }
.ms-add-event {
  background: var(--primary); color: white; border-color: var(--primary); font-weight: 600;
}
.ms-add-event:hover { background: var(--primary); opacity: 0.9; }
.ms-cal-spacer { flex: 1; }

/* 캘린더 필터 칩 */
.ms-cal-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
.ms-cal-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 14px; padding: 4px 10px;
  cursor: pointer; font-size: 12px; color: var(--text2);
}
.ms-cal-chip input { width: auto !important; margin: 0; accent-color: var(--cal-color, var(--primary)); }
.ms-cal-chip.active { background: var(--bg2); color: var(--text); }
.ms-chip-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ms-chip-name { white-space: nowrap; }

/* 주중 헤더 */
.ms-cal-weekrow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  font-size: 12px; font-weight: 600; color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.ms-cal-wd { padding: 7px 0; text-align: center; }
.ms-cal-sun { color: var(--danger); }
.ms-cal-sat { color: #3b82f6; }

/* 월간 그리드 */
.ms-cal-grid {
  display: grid;
  /* minmax(0, 1fr) 필수 — 콘텐츠가 grid trk를 강제 확장해 7열 깨지는 것 방지 */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--bg2);
  border: 1px solid var(--border); border-top: 0;
}
.ms-cal-loading { grid-column: 1 / -1; padding: 24px; text-align: center; color: var(--text3); font-size: 12px; }
.ms-cal-cell {
  min-height: 132px; padding: 4px 5px;  /* 카운트 wrap + 미리보기 3줄 + "+N 더보기" */
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer; transition: background .12s;
  min-width: 0;       /* 자식 ellipsis가 부모 폭에 맞춰지도록 */
  overflow: hidden;   /* 콘텐츠가 셀 밖으로 새어나가 다른 셀 밀지 않게 */
}
.ms-cal-cell:hover:not(.ms-cal-empty) { background: var(--bg3); }
.ms-cal-cell:nth-child(7n) { border-right: 0; }
.ms-cal-empty { background: transparent; cursor: default; }
.ms-cal-red  .ms-cal-daynum { color: var(--danger); }
.ms-cal-blue .ms-cal-daynum { color: #3b82f6; }
.ms-cal-today-cell { background: var(--primary-light); }
.ms-cal-daynum-row { display: flex; align-items: baseline; gap: 4px; min-height: 16px; }
.ms-cal-daynum { font-size: 12px; font-weight: 600; }
/* 셀 ➕ 버튼 — hover 시에만 노출 (모바일은 항상) */
.ms-cal-add {
  margin-left: auto; font-size: 11px; color: var(--text3);
  cursor: pointer; padding: 0 4px; border-radius: 3px;
  opacity: 0; transition: opacity .12s;
}
.ms-cal-cell:hover .ms-cal-add { opacity: 1; }
.ms-cal-add:hover { background: var(--primary-light); color: var(--primary); }
.ms-cal-holiday {
  font-size: 9px; color: var(--danger); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
/* 2-A: 셀 출처 카운트 + 미리보기 */
.ms-cell-counts {
  display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px;
}
.ms-cell-cnt {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 600; padding: 1px 5px;
  border-radius: 8px; background: var(--bg3); color: var(--c, var(--text2));
  border: 1px solid var(--c, var(--border));
  line-height: 1.3;
}
.ms-cell-prev {
  font-size: 10px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 1px 2px; line-height: 1.3;
  border-radius: 3px;
  max-width: 100%; display: block;  /* 셀 폭을 초과하지 않게 강제 */
}
/* 카운트 칩 행 — 줄바꿈 허용 + 최대 3줄까지 (4줄 이상은 +N 압축 칩으로 처리) */
.ms-cell-counts {
  display: flex; flex-wrap: wrap; gap: 3px;
  min-width: 0; max-width: 100%;
  align-content: flex-start;
}
.ms-cell-cnt { white-space: nowrap; }
.ms-cell-cnt-more {
  background: var(--text3); color: white;
}
.ms-prev-icon { font-size: 10px; }
.ms-cell-more {
  font-size: 10px; color: var(--text3); font-weight: 600;
  padding: 1px 2px; line-height: 1.3;
}

.ms-cal-events { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.ms-cal-evt {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; line-height: 1.3;
  background: var(--bg3); border-left: 3px solid var(--primary);
  padding: 2px 5px; border-radius: 3px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.ms-evt-time { color: var(--text3); font-size: 10px; flex-shrink: 0; }
.ms-evt-emoji { font-size: 10px; flex-shrink: 0; }
.ms-evt-title { overflow: hidden; text-overflow: ellipsis; }
.ms-cal-more { font-size: 10px; color: var(--primary); padding: 1px 5px; font-weight: 600; }
.ms-evt-invest { background: var(--bg2); border-left-width: 3px; }

/* 사이드 위젯 (1-3) */
.ms-side-widgets {
  margin-top: 8px; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.ms-widget {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.ms-widget-title { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 6px;
  padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.ms-widget-body { font-size: 12px; color: var(--text2); display: flex; flex-direction: column; gap: 4px; }
.ms-wg-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 4px; border-radius: 4px; cursor: pointer;
}
.ms-wg-row:hover { background: var(--bg3); }
.ms-wg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ms-wg-main { flex: 1; min-width: 0; }
.ms-wg-title { font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-wg-meta  { font-size: 10px; color: var(--text3); margin-top: 2px; }
.ms-wg-empty { font-size: 11px; color: var(--text3); padding: 6px 0; text-align: center; }
.ms-wg-sentiments { display: flex; gap: 6px; flex-wrap: wrap; cursor: pointer; }
.ms-wg-sent { font-size: 11px; padding: 3px 9px; border-radius: 10px; font-weight: 600; }
.ms-wg-sent.pos { background: rgba(239,68,68,0.15); color: var(--danger); }
.ms-wg-sent.neu { background: var(--bg3); color: var(--text3); }
.ms-wg-sent.neg { background: rgba(16,185,129,0.15); color: var(--success, #10b981); }

/* 예약 알림 종 + 배지 */
#snotif-btn { font-size: 16px; line-height: 1; }
.snotif-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* 알림 패널 모달 */
.snotif-list-actions { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; }
.snotif-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.snotif-empty { padding: 20px; text-align: center; color: var(--text3); font-size: 13px; }
.snotif-item {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer;
  transition: background .12s;
}
.snotif-item:hover { background: var(--bg2); }
.snotif-item.read { opacity: 0.65; }
.snotif-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.snotif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.snotif-desc  { font-size: 12px; color: var(--text2); margin-top: 4px; line-height: 1.5; }
.snotif-when  { font-size: 10px; color: var(--text3); margin-top: 4px; }

/* 알림 설정 모달 */
.notif-set-section { margin-bottom: 14px; }
.notif-set-h { font-size: 14px; font-weight: 700; margin: 0 0 8px; color: var(--text); }

/* 1-2 모달 — 시간 + 종일 한 줄 (좁아져도 wrap 금지) */
.ic-time-row { display: flex; align-items: center; gap: 8px; }
.ic-time-row #ic-time { flex: 1; min-width: 0; }
.ic-allday-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
}
.ic-allday-toggle input { width: auto !important; margin: 0; }

/* 1-2 모달 — 알림 옵션 (컴팩트, 박스 padding 축소) */
.ic-notify-section {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.ic-notify-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; white-space: nowrap;
  font-size: 13px;
}
.ic-notify-toggle input { width: auto !important; margin: 0; }
.ic-notify-section select { width: 100%; }

/* ===== 홈 상단 차트 (KOSPI + 시총 상위) ===== */
.home-chart-wrap { margin-bottom: 18px; }
.hc-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  align-items: stretch;  /* grid 기본값 명시 — 사이드 패널이 차트 패널 높이로 stretch */
}
/* 데스크톱: 사이드 패널 최대 높이 강제 + 자체 스크롤 (40행이 더 길어도 그 안에서만 스크롤) */
@media (min-width: 769px) {
  .hc-grid { max-height: 360px; }
  .hc-side { max-height: 360px; overflow-y: auto; }
}
.hc-chart-panel, .hc-side {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
}
/* 사이드 — 차트 패널 높이만큼 stretch(grid 기본). 내부에서 헤더 고정 + 리스트 스크롤 */
.hc-side { display: flex; flex-direction: column; min-height: 0; }
.hc-side-head { flex-shrink: 0; }
.hc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.hc-title { font-size: 14px; font-weight: 700; color: var(--text); }
.hc-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hc-units { display: inline-flex; background: var(--bg3); border-radius: var(--radius-sm); padding: 2px; }
.hc-unit {
  background: transparent; border: 0;
  padding: 4px 10px; cursor: pointer; font-size: 12px;
  color: var(--text3); border-radius: 4px; font-weight: 600;
}
.hc-unit.active { background: var(--bg2); color: var(--primary); }
.hc-btn-ghost {
  background: var(--bg3); border: 1px solid var(--border);
  padding: 4px 10px; height: 28px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text2); font-size: 12px; font-weight: 600;
}
.hc-btn-ghost:hover { background: var(--primary-light); color: var(--primary); }

.hc-canvas {
  width: 100%; height: 380px;  /* 가격 220 + 거래량 70 + RSI 70 + 패딩 */
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  user-select: none;  /* 드래그 팬 중 텍스트 선택 방지 */
  touch-action: none; /* 핀치 줌 시 페이지 줌 방지 */
}
/* 모바일 RSI on/off 토글 — 기본 숨김 (데스크톱은 항상 RSI 표시) */
.hc-mobile-only { display: none; }
.hc-btn-ghost.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.hc-loading { color: var(--text3); font-size: 12px; }
.hc-info {
  display: flex; align-items: baseline; gap: 10px;
  margin-top: 8px; font-variant-numeric: tabular-nums;
}
.hc-last { font-size: 18px; font-weight: 700; color: var(--text); }
.hc-delta { font-size: 13px; font-weight: 600; }
.hc-date  { font-size: 11px; color: var(--text3); margin-left: auto; }
.hc-up { color: var(--danger); }       /* 한국 관례: 상승=빨강 */
.hc-down { color: #3b82f6; }            /* 하락=파랑 */

.hc-side-head { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.hc-side-sub { font-size: 10px; color: var(--text3); font-weight: 400; margin-left: 6px; }
.hc-top20 {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; min-height: 0; overflow-y: auto;  /* 사이드 남은 공간 차지 + 40행 스크롤 */
}
.hc-top20-row {
  display: grid; grid-template-columns: 22px 1fr auto auto; gap: 6px;
  align-items: center;
  padding: 5px 6px; border-radius: 4px;
  cursor: pointer; font-size: 12px;
}
.hc-top20-row:hover { background: var(--bg3); }
.hc-rank { color: var(--text3); font-weight: 600; text-align: center; }
.hc-name { font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-price { font-variant-numeric: tabular-nums; color: var(--text2); }
.hc-chg { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; }
.hc-empty { padding: 10px; color: var(--text3); font-size: 12px; text-align: center; }

@media (max-width: 768px) {
  .hc-grid { grid-template-columns: 1fr; }
  /* 모바일은 차트 아래 스택 — 사이드는 자연 높이, 리스트만 스크롤 영역 제한 */
  .hc-side { max-height: 400px; }
  .hc-canvas { height: 240px; }
  body:has(#hc-rsi-toggle.active) .hc-canvas { height: 310px; }
  .hc-top20 { max-height: 320px; flex: none; }
  .hc-mobile-only { display: inline-flex; align-items: center; }
}

/* 내지식 헤더 ➕ — 어디에 만들까요? 모달 */
.mk-add-form { display: flex; flex-direction: column; gap: 14px; }
.mk-add-form .form-group label { font-size: 12px; font-weight: 600; color: var(--text3); }
.mk-add-form select { width: 100%; padding: 9px 10px; font-size: 14px; }
.mk-add-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.mk-add-actions .btn-primary {
  flex: 1; min-width: 100px; min-height: 44px;
  font-size: 13px;
}

/* 일자별 일정 모달 — 헤더(타이틀 + [+ 새 일정]) */
.ms-day-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
}

/* 일자별 일정 모달 */
.ms-day-section { margin-top: 10px; }
.ms-day-section-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; color: var(--text2);
  padding: 4px 2px 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.ms-day-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.ms-day-empty { font-size: 12px; color: var(--text3); padding: 8px; text-align: center; margin: 0; }
.ms-day-evt {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.ms-day-invest { background: var(--bg2); }
.ms-day-evt-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.ms-day-evt-body { flex: 1; min-width: 0; }
.ms-day-evt-title { font-size: 14px; font-weight: 600; color: var(--text); }
.ms-day-evt-meta  { font-size: 11px; color: var(--text3); margin-top: 4px; }
.ms-day-evt-memo  { font-size: 12px; color: var(--text2); margin-top: 6px; padding: 6px 8px; background: var(--bg3); border-radius: 4px; }
.ms-day-evt-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

@media (max-width: 768px) {
  .ms-cal-cell { min-height: 78px; padding: 3px; }
  .ms-cal-evt { font-size: 10px; padding: 1px 4px; }
  .ms-evt-time { display: none; } /* 모바일은 시간 생략 */
  .ms-cal-holiday { display: none; }
  .ms-cal-title { font-size: 14px; min-width: 100px; }
  .ms-cal-head { flex-wrap: wrap; }
  .ms-cal-add { opacity: 1; } /* 모바일은 hover 없으니 항상 노출 */
  .ms-day-evt { flex-wrap: wrap; }
  .ms-day-evt-actions { flex-direction: row; width: 100%; justify-content: flex-end; margin-top: 4px; }
}

/* ===== 내지식 — 안내 화면 ===== */
.mk-page { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.mk-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.mk-card-center { text-align: center; }
.mk-icon-big { font-size: 48px; margin-bottom: 10px; }
.mk-h { font-size: 20px; font-weight: 700; margin: 0 0 8px; color: var(--text); }
.mk-desc { font-size: 13px; color: var(--text2); line-height: 1.6; margin: 0; }
.mk-desc b { color: var(--text); }
.mk-desc code { background: var(--bg3); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

.mk-hero {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, var(--primary-light), var(--bg2));
  border-color: var(--primary);
}
.mk-hero-icon { font-size: 44px; flex-shrink: 0; }
.mk-hero-body { flex: 1; min-width: 0; }

.mk-steps {
  display: flex; flex-direction: column; gap: 10px;
}
.mk-step {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.mk-step-num {
  flex-shrink: 0;
  width: 32px; height: 32px;
  background: var(--primary); color: white;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.mk-step-body { flex: 1; min-width: 0; }
.mk-step-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.mk-step-desc  { font-size: 12px; color: var(--text3); line-height: 1.5; }

.mk-cta {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  text-align: center;
}
.mk-connect-btn { font-size: 14px; padding: 12px; }
.mk-connect-btn:disabled { opacity: .55; cursor: not-allowed; }
.mk-soon { font-size: 11px; font-weight: 500; opacity: .8; margin-left: 4px; }
.mk-foot { font-size: 11px; color: var(--text3); margin: 10px 0 0; }

.mk-connected {
  background: linear-gradient(135deg, rgba(16,185,129,0.10), var(--bg2));
  border-color: var(--success, #10b981);
}

/* access 게이트 상태별 */
.mk-gate-pending  { background: linear-gradient(135deg, rgba(245,158,11,0.10), var(--bg2)); border-color: #f59e0b; }
.mk-gate-rejected { background: linear-gradient(135deg, rgba(239,68,68,0.10),  var(--bg2)); border-color: var(--danger); }
.mk-gate-approved { background: linear-gradient(135deg, rgba(16,185,129,0.10), var(--bg2)); border-color: var(--success, #10b981); }
.mk-gate-icon  { font-size: 32px; text-align: center; margin-bottom: 6px; }
.mk-gate-title { font-size: 15px; font-weight: 700; text-align: center; margin-bottom: 6px; color: var(--text); }

.mk-req-form { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.mk-req-form .aform-input { flex: 1; padding: 9px 12px; font-size: 13px; }
.mk-req-form .btn-primary { flex-shrink: 0; padding: 9px 14px; font-size: 13px; white-space: nowrap; }

/* 관리자 — 내지식 연동 요청 처리 */
.mk-admin-warn {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(245,158,11,0.08);
  border: 1px solid #f59e0b;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.mk-admin-warn-icon { font-size: 22px; flex-shrink: 0; }
.mk-admin-warn-body { flex: 1; font-size: 13px; line-height: 1.55; color: var(--text); }
.mk-admin-warn-body b { color: #b45309; }

.mk-admin-tabs { display: flex; gap: 6px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.mk-admin-tab {
  background: transparent; border: 0; padding: 8px 14px;
  cursor: pointer; color: var(--text3); font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.mk-admin-tab:hover { color: var(--primary); }
.mk-admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.mk-admin-list { display: flex; flex-direction: column; gap: 8px; }
.mk-admin-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.mk-admin-row-main { flex: 1; min-width: 0; }
.mk-admin-user { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mk-admin-uname { font-weight: 700; color: var(--text); }
.mk-admin-since { font-size: 11px; color: var(--text3); }
.mk-admin-email { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mk-admin-email-val {
  font-family: ui-monospace, monospace;
  background: var(--bg3); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 4px;
  font-size: 13px; color: var(--text);
  user-select: all;
}
.mk-admin-reason { font-size: 11px; color: var(--danger); margin-top: 6px; }
.mk-admin-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mk-admin-status { font-size: 11px; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.mk-admin-status.mk-approved { background: rgba(16,185,129,0.15); color: var(--success, #10b981); }
.mk-admin-status.mk-rejected { background: rgba(239,68,68,0.12); color: var(--danger); }

@media (max-width: 640px) {
  .mk-admin-row { flex-direction: column; align-items: stretch; }
  .mk-admin-actions { justify-content: flex-end; }
  .mk-req-form { flex-direction: column; }
}
.mk-conn-row { display: flex; align-items: center; gap: 14px; }
.mk-conn-icon { font-size: 36px; flex-shrink: 0; }
.mk-conn-body { flex: 1; min-width: 0; }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); }
.btn-ghost.danger:hover { background: var(--danger); color: white; }

@media (max-width: 640px) {
  .mk-hero { flex-direction: column; align-items: flex-start; gap: 8px; }
  .mk-hero-icon { font-size: 36px; }
  .mk-card { padding: 16px; }
  .mk-step { padding: 12px; gap: 10px; }
  .mk-conn-row { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ===== 내지식 3·4단계 — 워크스페이스(트리+편집) ===== */
.mk-ws {
  display: flex; flex-direction: column;
  height: calc(100dvh - 56px - 40px);  /* dvh: 모바일 키보드/주소창 대응 */
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  margin: 0 auto; max-width: 1100px;
}
.mk-ws-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 0;  /* 자식 ellipsis가 동작하도록 */
}
.mk-ws-account {
  font-size: 13px; color: var(--text2);
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 0;
}
.mk-ws-email {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mk-ws-spacer { flex: 1; }
.mk-ws-settings {
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 36px; min-height: 36px;
  cursor: pointer; color: var(--text2); font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mk-ws-settings:hover { background: var(--bg3); color: var(--primary); border-color: var(--primary); }

/* 환경설정 모달 — DESIGN_SYSTEM 카드/풀폭 버튼 */
.mk-settings-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 14px; }
.mk-settings-row {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
}
.mk-settings-key { font-size: 11px; font-weight: 600; color: var(--text3); margin-bottom: 4px; }
.mk-settings-val { font-size: 13px; color: var(--text); word-break: break-all; }
.mk-settings-val code {
  font-family: ui-monospace, monospace; font-size: 12px;
  background: var(--bg2); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px;
}
.mk-settings-actions { display: flex; flex-direction: column; gap: 8px; }
.mk-settings-actions .btn-full { width: 100%; min-height: 44px; }
.mk-ws-body { flex: 1; display: flex; min-height: 0; }

.mk-ws-tree {
  width: 260px; flex-shrink: 0;
  background: var(--bg3); border-right: 1px solid var(--border);
  overflow-y: auto;
}
.mk-tree-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; font-size: 12px; font-weight: 700; color: var(--text2);
  border-bottom: 1px solid var(--border);
  background: var(--bg2); position: sticky; top: 0; z-index: 1;
}

/* 권한 업데이트 필요 카드 (트리 위) */
.mk-reauth-card {
  background: linear-gradient(135deg, rgba(245,158,11,0.12), var(--bg2));
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 8px 4px;
}
.mk-reauth-head { font-size: 13px; font-weight: 700; color: #b45309; margin-bottom: 6px; }
.mk-reauth-desc { font-size: 12px; color: var(--text2); line-height: 1.5; margin: 0 0 8px; }
.mk-reauth-btn  { width: 100%; padding: 8px; font-size: 13px; min-height: 38px; }
.mk-tree-head-spacer { flex: 1; }
.mk-tree-refresh,
.mk-tree-add {
  background: transparent; border: 0; color: var(--text3);
  cursor: pointer; font-size: 13px; padding: 4px 8px; border-radius: 4px;
  min-width: 28px;
}
.mk-tree-refresh:hover,
.mk-tree-add:hover { background: var(--bg3); color: var(--primary); }
.mk-tree-add { font-weight: 700; }

/* 행 우측 ⋯ 액션 버튼 — 데스크톱은 hover 시, 모바일은 항상 노출 */
.mk-row-more {
  background: transparent; border: 0; color: var(--text3);
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
  font-size: 14px; line-height: 1; margin-left: auto; flex-shrink: 0;
  opacity: 0;
  transition: opacity .12s;
}
.mk-tree-row:hover .mk-row-more { opacity: 1; }
.mk-row-more:hover { background: var(--bg2); color: var(--primary); }
.mk-tree-row.active .mk-row-more { opacity: 1; color: var(--primary); }

/* 액션 메뉴 — 데스크톱 드롭다운 */
.mk-action-backdrop {
  position: fixed; inset: 0; background: transparent; z-index: 998;
}
.mk-action-menu {
  position: fixed; z-index: 999;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 200px; padding: 6px;
  display: flex; flex-direction: column;
}
.mk-action-menu-head {
  font-size: 11px; font-weight: 700; color: var(--text3);
  padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mk-action-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0;
  padding: 9px 10px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text); font-size: 13px; text-align: left;
}
.mk-action-item:hover { background: var(--bg3); }
.mk-action-item.danger { color: var(--danger); }
.mk-action-item.danger:hover { background: rgba(239,68,68,0.10); }
.mk-action-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.mk-tree { padding: 6px 4px; }
.mk-tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 4px;
  cursor: pointer; font-size: 13px; color: var(--text);
  user-select: none;
}
.mk-tree-row:hover { background: var(--bg2); }
.mk-tree-row.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.mk-tree-caret { width: 12px; flex-shrink: 0; font-size: 9px; color: var(--text3); }
.mk-tree-icon  { flex-shrink: 0; }
.mk-tree-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-tree-children { padding-left: 14px; }
.mk-tree-loading, .mk-tree-empty, .mk-tree-error {
  padding: 12px; font-size: 12px; color: var(--text3); text-align: center;
}
.mk-tree-error { color: var(--danger); }

.mk-ws-main {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--bg);
}
.mk-file-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border); background: var(--bg2);
  font-size: 13px; font-weight: 600; color: var(--text);
  flex-shrink: 0;
}
.mk-back-tree {
  display: none;  /* 데스크톱은 숨김. 모바일에선 보임 */
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px;
  cursor: pointer; color: var(--text2); font-size: 13px; font-weight: 600;
}
.mk-file-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mk-status {
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 10px;
  background: var(--bg3); color: var(--text3);
  white-space: nowrap; flex-shrink: 0;
}
.mk-status[data-state="dirty"]    { background: rgba(245,158,11,0.18); color: #f59e0b; }
.mk-status[data-state="saving"]   { background: rgba(79,70,229,0.18);  color: var(--primary); }
.mk-status[data-state="saved"]    { background: rgba(16,185,129,0.18); color: var(--success, #10b981); }
.mk-status[data-state="conflict"],
.mk-status[data-state="error"]    { background: rgba(239,68,68,0.18);  color: var(--danger); }

.mk-file-content {
  flex: 1;
  width: 100%; resize: none; border: 0;
  padding: 16px 18px;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  font-size: 16px;  /* 모바일 입력 시 iOS 자동 줌인 방지 — 16px 사수 */
  line-height: 1.6;
  background: var(--bg); color: var(--text);
  outline: none;
}
.mk-file-content:focus { background: var(--bg); }
.mk-file-content:disabled { background: var(--bg2); color: var(--text3); cursor: not-allowed; }
/* CM6 마운트 후 textarea 완전 숨김 (호환 위해 DOM에는 남김) */
.mk-file-content-hidden { display: none !important; }

/* ===== 내업무 Phase 7: 멤버 + 미니 타이머 + 토스트 + 칸반 도트 ===== */
/* 프로젝트 멤버 */
.mw-members-head { margin-bottom: 12px; }
.mw-members-add {
  position: relative; display: flex; gap: 6px; align-items: center;
  background: var(--bg2); padding: 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.mw-members-add input {
  flex: 1; padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 13px;
}
.mw-members-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.mw-members-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); padding: 8px 10px; border-radius: 4px;
}
.mw-members-name { flex: 1; min-width: 0; color: var(--text); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.mw-members-role {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}

/* 미니 타이머 (헤더 또는 우상단 고정) */
.mw-mini-timer {
  position: fixed; right: 16px; bottom: 76px; z-index: 1000;
  background: rgba(239,68,68,0.92); color: white;
  border: 0; cursor: pointer;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: mw-pulse 2s ease-in-out infinite;
}
.mw-mini-timer:hover { background: #ef4444; }
@keyframes mw-pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
  50%      { box-shadow: 0 4px 20px rgba(239,68,68,0.6); }
}

/* 클릭 가능 토스트 (인앱 알림) */
.mw-toast-clickable {
  position: fixed; top: 76px; right: 16px; z-index: 1100;
  max-width: 320px;
  background: var(--bg2); border: 1px solid var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  cursor: pointer;
  animation: mw-toast-slide-in 0.3s ease-out;
}
.mw-toast-clickable:hover { background: var(--bg3); }
.mw-toast-title { font-weight: 700; color: var(--text); font-size: 13px; margin-bottom: 3px; }
.mw-toast-body  { font-size: 12px; color: var(--text2); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@keyframes mw-toast-slide-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* 칸반 컬럼 도트 (모바일만) */
.mw-kb-dots {
  display: none;
  justify-content: center; gap: 6px;
  margin-top: 8px;
}
.mw-kb-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border);
  transition: background 0.2s, transform 0.2s;
}
.mw-kb-dot.active { background: var(--primary); transform: scale(1.4); }
@media (max-width: 768px) {
  .mw-kb-dots { display: flex; }
}

/* 액션 일괄 변환 */
.mw-actions-selall { font-size: 11px; color: var(--text3); display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.mw-actions-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mw-actions-check { width: 14px; height: 14px; flex-shrink: 0; }

/* ===== 내업무 Phase 6: 댓글 + 검색 + 모바일 ===== */
/* 댓글 */
.mw-comments { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mw-comments-head { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.mw-comments-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.mw-comment-row {
  background: var(--bg3); padding: 8px 10px; border-radius: 6px;
}
.mw-comment-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; margin-bottom: 4px;
}
.mw-comment-author { font-weight: 600; color: var(--text); }
.mw-comment-time { font-size: 10px; color: var(--text3); }
.mw-comment-spacer { flex: 1; }
.mw-comment-action {
  background: transparent; border: 0; cursor: pointer;
  font-size: 11px; color: var(--text3);
  padding: 2px 5px; border-radius: 3px;
}
.mw-comment-action:hover { background: var(--bg2); color: var(--text); }
.mw-comment-content { font-size: 13px; line-height: 1.5; color: var(--text); }
.mw-comment-add {
  display: flex; flex-direction: column; gap: 6px;
}
.mw-comment-add textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 13px; resize: vertical;
}
.mw-comment-replying { font-size: 11px; color: var(--text3); padding: 4px 8px; background: var(--bg3); border-radius: 4px; align-self: flex-start; }

/* 전역 검색 */
.mw-search-toggle { margin-left: auto; }
.mw-search-box {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px;
}
.mw-search-box input[type="search"] {
  width: 100%; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 14px;
}
.mw-search-results { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.mw-search-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 6px 8px; border-radius: 4px;
  cursor: pointer;
}
.mw-search-item:hover { background: var(--bg3); }
.mw-search-icon { font-size: 16px; flex-shrink: 0; }
.mw-search-body { flex: 1; min-width: 0; }
.mw-search-title { font-weight: 600; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-search-snippet { font-size: 11px; color: var(--text3); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mw-search-snippet b { color: var(--primary); }

/* 풀스크린 태스크 모달 (모바일) */
@media (max-width: 768px) {
  .modal-box.mw-task-modal {
    max-width: 100vw !important;
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    border-radius: 0;
    margin: 0;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }
  /* 스와이프 시 transition은 JS에서 inline 제어 */
  .mw-card { will-change: transform; }
}

/* ===== 내업무 Phase 5: 시간 추적 + 명언 + 활동 필터 ===== */
/* 시간 추적 (모달 섹션) */
.mw-time { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mw-time-head { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.mw-time-controls {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--bg3); padding: 8px 10px; border-radius: 4px; margin-bottom: 8px;
}
.mw-time-display {
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary);
  min-width: 50px; text-align: center;
}
.mw-time-divider { color: var(--border); }
.mw-time-input { width: 70px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font-size: 12px; }
.mw-time-note  { flex: 1; min-width: 80px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font-size: 12px; }
.mw-time-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.mw-time-row {
  display: grid; grid-template-columns: 80px 60px 1fr auto auto; gap: 6px;
  align-items: center; font-size: 12px;
  background: var(--bg3); padding: 4px 8px; border-radius: 4px;
}
.mw-time-date { color: var(--text3); font-variant-numeric: tabular-nums; }
.mw-time-mins { color: var(--primary); font-weight: 700; font-variant-numeric: tabular-nums; }
.mw-time-memo { color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 명언 위젯 */
.mw-quote {
  margin: 0; padding: 8px 4px;
  font-style: italic; color: var(--text);
  text-align: center;
}
.mw-quote-mark { font-size: 28px; color: var(--primary); opacity: 0.6; vertical-align: top; }
.mw-quote-text { font-size: 15px; line-height: 1.6; }
.mw-quote-author { text-align: right; font-style: normal; color: var(--text3); font-size: 12px; margin-top: 6px; }

/* 활동 로그 필터 + 무한스크롤 */
.mw-activity-filter {
  display: flex; gap: 4px; margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.mw-act-icon { display: inline-block; width: 18px; text-align: center; flex-shrink: 0; }

/* ===== 내업무 Phase 4: 회의록 + 첨부파일 + 활동 로그 ===== */
/* 회의록 */
.mw-minutes-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.mw-minutes-head select { flex: 1; }
.mw-minutes-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer;
}
.mw-minutes-card:hover { border-color: var(--primary); }
.mw-minutes-card-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px;
}
.mw-minutes-card-head h4 { margin: 0; font-size: 14px; color: var(--text); }
.mw-minutes-card-snippet {
  color: var(--text2); font-size: 12px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mw-minutes-card-foot { margin-top: 6px; font-size: 11px; }
.mw-minutes-detail {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.mw-minutes-detail-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.mw-minutes-title-input {
  flex: 1; min-width: 200px;
  border: 0; background: transparent;
  font-size: 18px; font-weight: 700; color: var(--text);
  padding: 4px 0;
}
.mw-minutes-title-input:focus { outline: 1px dashed var(--primary); }
.mw-minutes-status { font-size: 11px; color: var(--success, #10b981); margin: 0 4px; }
.mw-minutes-actions { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mw-actions-head { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.mw-actions-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.mw-actions-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); padding: 6px 10px; border-radius: 4px;
  font-size: 13px;
}
.mw-actions-text { flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-actions-converted { font-size: 11px; color: var(--success, #10b981); }
.mw-actions-converted a { cursor: pointer; }

/* 첨부파일 */
.mw-attach { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mw-attach-head { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.mw-attach-list { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.mw-attach-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3); padding: 6px 10px; border-radius: 4px;
  font-size: 12px;
}
.mw-attach-icon { font-size: 14px; flex-shrink: 0; }
.mw-attach-name { flex: 1; min-width: 0; color: var(--primary);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-attach-name:hover { text-decoration: underline; }
.mw-attach-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 활동 로그 */
.mw-activity { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mw-activity-head { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.mw-activity-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.mw-activity-list-page { max-height: none; }
.mw-activity-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; padding: 4px 0;
  color: var(--text2);
}
.mw-act-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.mw-act-name { font-weight: 600; color: var(--text); }
.mw-act-msg { flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-act-time { font-size: 10px; color: var(--text3); flex-shrink: 0; }
.mw-act-task { color: var(--primary); cursor: pointer; }
.mw-act-task:hover { text-decoration: underline; }

/* ===== 내업무 Phase 3: 대시보드 위젯 6종 ===== */
.mw-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.mw-widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column;
  min-height: 0;
}
.mw-widget-wide { grid-column: 1 / -1; }
.mw-widget-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.mw-widget-header h3 { margin: 0; font-size: 14px; color: var(--text); }
.mw-widget-body { flex: 1; min-height: 0; }

/* 위젯 1: 오늘 */
.mw-overdue-banner {
  background: rgba(239,68,68,0.12); color: #ef4444;
  padding: 6px 10px; border-radius: 4px; font-size: 12px; font-weight: 600;
  margin-bottom: 8px;
}
.mw-today-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.mw-today-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); padding: 6px 10px; border-radius: 4px;
  font-size: 13px;
}
.mw-today-title { flex: 1; min-width: 0; cursor: pointer; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-today-title:hover { color: var(--primary); }
.mw-dday-tag {
  display: inline-block;
  font-size: 10px; font-weight: 700; color: white;
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}

/* 위젯 2: 매트릭스 */
.mw-matrix-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin-bottom: 6px;
}
.mw-matrix-cell {
  background: var(--bg);
  border-left: 3px solid var(--mw-q-color, #9ca3af);
  border-radius: 4px;
  padding: 8px 10px;
  min-height: 90px;
}
.mw-matrix-cell-head { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.mw-matrix-tasks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.mw-matrix-tasks li {
  font-size: 11px; color: var(--text2); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mw-matrix-tasks li:hover { color: var(--primary); }
.mw-matrix-axes {
  display: flex; justify-content: space-between;
  font-size: 10px; padding: 0 4px;
}

/* 위젯 3: 프로젝트 */
.mw-proj-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.mw-proj-row {
  display: grid;
  grid-template-columns: 6px 1fr 120px 60px;
  align-items: center; gap: 10px;
  background: var(--bg); padding: 8px 10px; border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.mw-proj-row:hover { background: var(--bg3); }
.mw-proj-dot { width: 6px; height: 24px; border-radius: 3px; }
.mw-proj-name { color: var(--text); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-proj-progress { display: flex; align-items: center; gap: 6px; }
.mw-proj-progress .mw-progress { flex: 1; }
.mw-proj-pct { font-size: 11px; color: var(--text3); font-variant-numeric: tabular-nums; }
.mw-proj-dday { font-size: 11px; color: var(--text3); text-align: right; }

/* 위젯 4: 번다운 */
.mw-bd-info { font-size: 12px; color: var(--text3); margin-bottom: 4px; }

/* 위젯 5: 시간 */
.mw-ts-total {
  font-size: 24px; font-weight: 700; color: var(--primary);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.mw-ts-proj-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.mw-ts-proj {
  display: grid; grid-template-columns: 8px 1fr auto auto; gap: 8px;
  align-items: center; font-size: 12px;
}
.mw-ts-proj-dot { width: 8px; height: 8px; border-radius: 50%; }
.mw-ts-proj-name { color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-ts-proj-time { color: var(--text3); font-variant-numeric: tabular-nums; }
.mw-ts-proj-pct { color: var(--text); font-weight: 600; min-width: 36px; text-align: right; }

/* 위젯 6: 포모도로 */
.mw-pomo {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.mw-pomo-svg { width: 140px; height: 140px; }
.mw-pomo-sessions { font-size: 14px; min-height: 18px; }
.mw-pomo-actions { display: flex; gap: 6px; }

@media (max-width: 768px) {
  .mw-dashboard-grid { grid-template-columns: 1fr; }
  .mw-proj-row { grid-template-columns: 6px 1fr 80px 50px; gap: 6px; font-size: 12px; }
  .mw-proj-name { font-size: 12px; }
}

/* ===== 내업무 Phase 2: 간트 + 캘린더 + assignee + 의존성 ===== */
/* 간트 */
.mw-gantt { overflow-x: auto; user-select: none; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.mw-gantt svg { display: block; min-width: 100%; }
.mw-gantt-bar { cursor: pointer; transition: opacity 0.1s ease; }
.mw-gantt-bar:hover { opacity: 0.85; }
.mw-gantt-bar.dragging { opacity: 0.7; cursor: grabbing; }

/* 캘린더 */
.mw-cal-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.mw-cal-title { margin-left: auto; font-weight: 700; color: var(--text); font-size: 14px; }
.mw-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; margin-bottom: 1px; }
.mw-cal-wd {
  text-align: center; padding: 6px 4px;
  font-size: 11px; font-weight: 700; color: var(--text2);
  background: var(--bg2);
}
.mw-cal-wd.red { color: #ef4444; }
.mw-cal-wd.blue { color: #3b82f6; }
.mw-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--border);
}
.mw-cal-cell {
  background: var(--bg);
  min-height: 90px;
  padding: 4px 6px;
  cursor: pointer;
  display: flex; flex-direction: column;
}
.mw-cal-cell:hover { background: var(--bg3); }
.mw-cal-cell-empty { background: var(--bg2); cursor: default; }
.mw-cal-cell.mw-cal-today { background: var(--primary-light); }
.mw-cal-cell.mw-cal-red .mw-cal-daynum { color: #ef4444; }
.mw-cal-cell.mw-cal-blue .mw-cal-daynum { color: #3b82f6; }
.mw-cal-daynum { font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.mw-cal-tasks { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.mw-cal-task {
  font-size: 11px; line-height: 1.3;
  padding: 2px 6px; border-radius: 3px;
  color: white; font-weight: 600;
  cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mw-cal-task:hover { filter: brightness(1.1); }
.mw-cal-more { font-size: 10px; color: var(--text3); padding: 1px 4px; }

/* assignee 자동완성 */
.mw-assignee-wrap input[type="text"] {
  width: 100%; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-size: 13px;
}
.mw-assignee-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-light); color: var(--primary);
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.mw-assignee-dd {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-top: 2px;
  max-height: 220px; overflow-y: auto;
  z-index: 100; padding: 4px;
}
.mw-assignee-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px;
  cursor: pointer; font-size: 13px;
}
.mw-assignee-item:hover { background: var(--bg3); }

/* 의존성 섹션 */
.mw-deps { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mw-deps-head { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.mw-deps-list { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.mw-deps-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3); padding: 6px 10px; border-radius: 4px;
  font-size: 12px;
}
.mw-deps-type { font-weight: 600; color: var(--text2); flex-shrink: 0; }
.mw-deps-title { flex: 1; min-width: 0; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-deps-title:hover { color: var(--primary); }
.mw-deps-status { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.mw-deps-add { position: relative; display: flex; gap: 6px; align-items: center; }
.mw-deps-add input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font-size: 13px; }

@media (max-width: 768px) {
  .mw-cal-cell { min-height: 60px; padding: 2px 4px; }
  .mw-cal-task { font-size: 10px; padding: 1px 4px; }
}

/* ===== 내업무 1.5-D: 콘텐츠 카드에 📋 배지 ===== */
.mywork-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 10px;
  background: rgba(79, 70, 229, 0.15);  /* primary 15% — 3테마 모두 자연스러움 */
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
  margin-left: 6px;
  flex-shrink: 0;
}
.mywork-badge:hover {
  background: rgba(79, 70, 229, 0.25);
}

/* ===== 내업무 (Phase 0 placeholder) ===== */
.mywork-placeholder {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; padding: 20px;
}
.mywork-placeholder-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 32px;
  max-width: 480px; text-align: center;
}
.mywork-placeholder-icon { font-size: 56px; margin-bottom: 8px; }
.mywork-placeholder-title { margin: 8px 0 12px; color: var(--text); font-size: 20px; }
.mywork-placeholder-desc { color: var(--text2); font-size: 14px; line-height: 1.6; margin: 0 0 14px; }
.mywork-placeholder-stage {
  display: inline-block;
  font-size: 11px; font-weight: 600; color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px; border-radius: 999px;
  margin: 0;
}

/* ===== 내업무 Phase 1 — 탭 SPA + 칸반 + 인박스 ===== */
.mw-shell { display: flex; flex-direction: column; gap: 12px; }
.mw-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
.mw-tab {
  background: transparent; border: 0;
  padding: 10px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text3); cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.mw-tab:hover { color: var(--text); }
.mw-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.mw-body { min-height: 60vh; }
.mw-loading, .mw-empty {
  color: var(--text3); font-size: 13px;
  padding: 24px; text-align: center;
}

.mw-section { margin-bottom: 24px; }
.mw-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.mw-section-head h3 { margin: 0; font-size: 15px; color: var(--text); }

/* 프로젝트 카드 */
.mw-projects-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.mw-projects-head h3 { margin: 0; font-size: 16px; color: var(--text); }
.mw-project-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.mw-project-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-left: 3px solid var(--mw-accent, var(--primary));
  border-radius: var(--radius); padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.mw-project-card:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.mw-project-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.mw-project-icon { font-size: 16px; }
.mw-project-name { font-weight: 700; color: var(--text); flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-dday {
  font-size: 10px; font-weight: 700;
  background: var(--primary-light); color: var(--primary);
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.mw-project-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; font-size: 11px; color: var(--text3);
}
.mw-muted { color: var(--text3); }
.mw-vis { font-size: 10px; }

/* 진행률 바 */
.mw-progress { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.mw-progress-fill { height: 100%; background: var(--primary); transition: width 0.3s ease; }

/* 우선순위 배지 */
.mw-prio-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  color: white;
}
.mw-priority-urgent { background: #ef4444; }
.mw-priority-high   { background: #f59e0b; }
.mw-priority-medium { background: #3b82f6; }
.mw-priority-low    { background: #9ca3af; }

/* 오늘 마감 리스트 (대시보드) */
.mw-due-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.mw-due-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
}
.mw-due-title { flex: 1; color: var(--text); font-size: 13px; }
.mw-due-date { font-size: 11px; color: var(--text3); font-variant-numeric: tabular-nums; }

/* 인박스 */
.mw-inbox-wrap { display: flex; flex-direction: column; gap: 10px; }
.mw-inbox-input-row { display: flex; }
.mw-inbox-input {
  flex: 1; height: 44px; padding: 0 14px;
  font-size: 14px; color: var(--text);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mw-inbox-input:focus { outline: none; border-color: var(--primary); }
.mw-inbox-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.mw-inbox-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.mw-inbox-title { flex: 1; cursor: pointer; color: var(--text); font-size: 14px;
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-inbox-title:hover { color: var(--primary); }
.mw-inline-select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 4px 6px;
  font-size: 12px; height: 30px;
}
.mw-icon-btn {
  background: transparent; border: 0; cursor: pointer;
  width: 28px; height: 28px; border-radius: 4px;
  color: var(--text3); font-size: 14px;
}
.mw-icon-btn:hover { background: var(--bg3); color: var(--danger); }

/* 프로젝트 상세 */
.mw-detail-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.mw-detail-head h3 {
  margin: 0; font-size: 18px; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
  border-left: 3px solid var(--mw-accent, var(--primary));
  padding-left: 10px;
}
.mw-detail-spacer { flex: 1; }
.mw-view-tabs {
  display: inline-flex; background: var(--bg3);
  border-radius: var(--radius-sm); padding: 2px;
}
.mw-vt {
  background: transparent; border: 0;
  padding: 5px 12px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--text3);
  border-radius: 4px;
}
.mw-vt.active { background: var(--bg2); color: var(--primary); }

/* 칸반 */
.mw-kanban {
  display: flex; gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.mw-col {
  flex-shrink: 0;
  width: 260px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  scroll-snap-align: start;
  max-height: calc(100vh - 220px);
}
.mw-col.drag-over { border: 2px dashed var(--primary); background: var(--primary-light); }
.mw-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
}
.mw-col-count {
  font-size: 11px; color: var(--text3);
  background: var(--bg3); padding: 2px 7px; border-radius: 999px;
}
.mw-col-body {
  flex: 1; overflow-y: auto;
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.mw-col-add {
  flex-shrink: 0;
  border: 0; border-top: 1px dashed var(--border);
  background: transparent; padding: 8px;
  color: var(--text3); font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.mw-col-add:hover { color: var(--primary); background: var(--bg3); }

.mw-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  cursor: grab; transition: box-shadow 0.1s ease;
}
.mw-card:hover { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.mw-card.dragging { opacity: 0.5; cursor: grabbing; }
.mw-card-title { font-size: 13px; color: var(--text); font-weight: 500; margin-bottom: 6px; line-height: 1.4; }
.mw-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 10px; color: var(--text3); }
.mw-card-due { font-variant-numeric: tabular-nums; }
.mw-card-sub { color: var(--text3); }

/* 리스트 뷰 / 태스크 탭 */
.mw-list-head { margin-bottom: 10px; }
.mw-list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mw-list-table thead th {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text3); font-weight: 600; font-size: 12px;
  background: var(--bg2);
}
.mw-list-table tbody tr { cursor: pointer; }
.mw-list-table tbody tr:hover { background: var(--bg3); }
.mw-list-table tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); }

/* 태스크 탭 필터 */
.mw-tasks-head {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 12px;
}
.mw-tasks-head select {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 10px;
  font-size: 12px;
}
.mw-check { font-size: 12px; color: var(--text2); display: inline-flex; align-items: center; gap: 4px; }

/* 서브태스크 */
.mw-subtask-list { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 4px; }
.mw-subtask-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); padding: 6px 10px; border-radius: 4px;
}
.mw-subtask-content { flex: 1; font-size: 13px; color: var(--text); }
.mw-subtask-content.done { text-decoration: line-through; color: var(--text3); }
.mw-subtask-add { margin-top: 6px; }
.mw-subtask-add input {
  width: 100%; height: 32px; padding: 0 10px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: 13px;
}

/* 1.5-B: 연결된 콘텐츠 + cross-post 토글 */
.mw-linked-content {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.mw-linked-head {
  font-size: 12px; font-weight: 700; color: var(--text2);
  margin-bottom: 8px;
}
.mw-linked-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.mw-linked-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3);
  padding: 6px 10px; border-radius: 4px;
  font-size: 12px;
}
.mw-linked-badge {
  display: inline-block;
  background: rgba(99,102,241,0.18); color: #6366f1;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.mw-linked-title {
  flex: 1; min-width: 0;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mw-crosspost {
  margin-top: 14px; padding: 12px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mw-crosspost-head {
  font-size: 12px; font-weight: 700; color: var(--text2);
  margin-bottom: 10px;
}
.mw-cp-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
  margin-bottom: 6px; cursor: pointer;
}
.mw-cp-row input[type="checkbox"] { width: 16px; height: 16px; }
.mw-cp-sub {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-left: 24px; margin-top: 4px;
  font-size: 12px;
}
.mw-cp-radio {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text2); cursor: pointer;
}

/* 폼 행 (모달 공용) */
.mw-shell + * .form-row,
.modal-box .form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.modal-box .form-row label { font-size: 12px; color: var(--text3); font-weight: 600; }
.modal-box .form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.modal-box .form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* 모바일 */
@media (max-width: 768px) {
  .mw-kanban {
    scroll-snap-type: x mandatory;
    margin: 0 -12px; padding: 0 12px 8px;
  }
  .mw-col { width: 80vw; max-width: 280px; max-height: calc(100vh - 260px); scroll-snap-align: start; }
  .mw-project-grid { grid-template-columns: 1fr; }
  .mw-inline-select { font-size: 11px; padding: 2px 4px; height: 26px; }
  .mw-list-table { font-size: 12px; }
  .mw-list-table thead th, .mw-list-table tbody td { padding: 6px 8px; }
}

/* ===== 내지식 — CodeMirror 6 통합 (툴바 + 분할 프리뷰 + TOC) ===== */
.mk-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.mk-tb-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--text2);
  width: 30px; height: 30px;
  border-radius: 5px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.mk-tb-btn:hover { background: var(--bg3); color: var(--text); }
.mk-tb-btn.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.mk-tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.mk-tb-spacer { flex: 1; }

.mk-editor-pane {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;  /* TOC(있을 때 width 220) + 에디터 */
  min-height: 0;
  position: relative;
}
.mk-editor-pane.mk-split {
  grid-template-columns: auto 1fr 1fr;  /* TOC + 에디터 + 프리뷰 */
}
.mk-toc {
  border-right: 1px solid var(--border);
  background: var(--bg2);
  overflow-y: auto;
  width: 220px;
  padding: 10px 8px 16px;
}
.mk-toc[hidden] { display: none; }
.mk-toc-head { font-size: 11px; font-weight: 700; color: var(--text3); margin-bottom: 6px; padding: 0 4px; }
.mk-toc-list { list-style: none; padding: 0; margin: 0; }
.mk-toc-item {
  padding: 4px 6px; border-radius: 4px;
  font-size: 12px; line-height: 1.4;
  color: var(--text2); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mk-toc-item:hover { background: var(--bg3); color: var(--text); }
.mk-toc-l1 { font-weight: 700; color: var(--text); }
.mk-toc-l2 { padding-left: 14px; }
.mk-toc-l3 { padding-left: 24px; }
.mk-toc-l4, .mk-toc-l5, .mk-toc-l6 { padding-left: 34px; color: var(--text3); }
.mk-toc-empty { font-size: 12px; color: var(--text3); padding: 6px; }

.mk-cm-host {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.mk-cm-host:empty::before {
  content: attr(data-empty);
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 13px;
  pointer-events: none;
}
/* CodeMirror 6 — StockNote 테마 변수 매핑 */
.mk-cm-host .cm-editor { height: 100%; background: var(--bg); color: var(--text); }
.mk-cm-host .cm-editor.cm-focused { outline: none; }
.mk-cm-host .cm-cursor, .mk-cm-host .cm-dropCursor { border-left-color: var(--primary); }
/* 마크다운 헤딩/볼드/이탤릭/코드 — defaultHighlightStyle 위에 색만 보강 */
.mk-cm-host .cm-line .tok-heading1, .mk-cm-host .cm-line .ͼheading1 { color: var(--primary); font-weight: 700; font-size: 1.25em; }
.mk-cm-host .cm-line .tok-heading2 { color: var(--primary); font-weight: 700; }
.mk-cm-host .cm-line strong, .mk-cm-host .cm-line .tok-strong { color: var(--text); font-weight: 700; }
.mk-cm-host .cm-line em, .mk-cm-host .cm-line .tok-emphasis { color: var(--text); font-style: italic; }
.mk-cm-host .cm-line code, .mk-cm-host .cm-line .tok-monospace {
  background: var(--bg3); color: var(--primary);
  padding: 0 4px; border-radius: 3px; font-family: ui-monospace, monospace;
}

.mk-preview {
  border-left: 1px solid var(--border);
  background: var(--bg);
  padding: 16px 20px;
  overflow-y: auto;
  font-size: 14px; line-height: 1.7;
  color: var(--text);
  min-width: 0;
}
.mk-preview[hidden] { display: none; }
.mk-preview h1 { font-size: 1.6em; margin: 0.6em 0 0.4em; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.mk-preview h2 { font-size: 1.35em; margin: 0.6em 0 0.3em; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.mk-preview h3 { font-size: 1.15em; margin: 0.5em 0 0.3em; }
.mk-preview h4, .mk-preview h5, .mk-preview h6 { margin: 0.5em 0 0.3em; }
.mk-preview p  { margin: 0.5em 0; }
.mk-preview ul, .mk-preview ol { padding-left: 1.3em; margin: 0.4em 0; }
.mk-preview blockquote {
  border-left: 3px solid var(--primary);
  padding: 4px 12px; margin: 0.6em 0;
  background: var(--bg2); color: var(--text2);
}
.mk-preview code {
  background: var(--bg3); padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, monospace; font-size: 0.92em;
  color: var(--primary);
}
.mk-preview pre {
  background: var(--bg2); padding: 10px 12px; border-radius: 6px;
  overflow-x: auto; border: 1px solid var(--border);
}
.mk-preview pre code { background: transparent; padding: 0; color: var(--text); }
.mk-preview hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }
.mk-preview table { border-collapse: collapse; margin: 0.6em 0; }
.mk-preview th, .mk-preview td { border: 1px solid var(--border); padding: 4px 8px; }
.mk-preview-err { color: var(--danger); font-size: 12px; }

/* 모바일: TOC/프리뷰는 토글하면 에디터를 덮는 단일 패널로 — 분할 X */
@media (max-width: 768px) {
  .mk-editor-pane,
  .mk-editor-pane.mk-split {
    display: block; position: relative;
  }
  .mk-toc {
    position: absolute; top: 0; bottom: 0; left: 0; right: 0;
    width: auto; z-index: 4;
  }
  .mk-preview {
    position: absolute; top: 0; bottom: 0; left: 0; right: 0;
    border-left: 0; z-index: 5;
  }
  .mk-cm-host { height: 100%; }
  .mk-tb-btn { width: 36px; height: 36px; }  /* 터치 타겟 확보 */
}

/* 하단 저장바 — 모바일에서 엄지 닿는 위치 + 데스크톱에선 작게 보조 */
.mk-savebar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.mk-savebar-status {
  flex: 1; min-width: 0;
  font-size: 12px; font-weight: 500; color: var(--text3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mk-savebar-status[data-state="dirty"]    { color: #f59e0b; }
.mk-savebar-status[data-state="saving"]   { color: var(--primary); }
.mk-savebar-status[data-state="saved"]    { color: var(--success, #10b981); }
.mk-savebar-status[data-state="conflict"],
.mk-savebar-status[data-state="error"]    { color: var(--danger); }
.mk-save-btn { flex-shrink: 0; padding: 8px 16px; font-size: 13px; min-height: 36px; }
.mk-save-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 데스크톱(769px↑) — 기존 2분할 유지 */
@media (min-width: 769px) {
  .mk-back-tree { display: none; }  /* 데스크톱은 ← 파일 불필요 */
}

/* 모바일(≤768px) — 풀스크린 전환. body class로 트리/에디터 둘 중 하나만 표시 */
@media (max-width: 768px) {
  .mk-ws {
    max-width: none;
    height: calc(100dvh - 56px - 12px);  /* 하단 탭바 숨김으로 가용 영역 확보 */
  }
  .mk-back-tree { display: inline-flex; align-items: center; min-height: 36px; }
  .mk-ws-body { display: block; position: relative; }
  .mk-ws-tree, .mk-ws-main {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
  }
  .mk-ws-tree { border-right: 0; }
  .mk-tree-row { min-height: 44px; padding: 8px 10px; font-size: 14px; }
  .mk-tree-caret { font-size: 11px; width: 16px; }

  /* body class 분기: mk-mobile-tree → 트리만, mk-mobile-editor → 에디터만 */
  body.mk-mobile-tree   .mk-ws-tree  { display: block; }
  body.mk-mobile-tree   .mk-ws-main  { display: none; }
  body.mk-mobile-editor .mk-ws-tree  { display: none; }
  body.mk-mobile-editor .mk-ws-main  { display: flex; flex-direction: column; }

  /* 모바일 툴바: 컴팩트 + 이메일 ellipsis */
  .mk-ws-toolbar { padding: 8px 10px; }
  .mk-ws-account { font-size: 12px; flex: 1; min-width: 0; }
  .mk-ws-email   { max-width: 100%; }

  /* 모바일: ⋯ 항상 노출 (hover 없는 환경) + 터치 타깃 키움 */
  .mk-row-more { opacity: 1; min-width: 36px; min-height: 36px; padding: 6px; font-size: 16px; }
  .mk-tree-add, .mk-tree-refresh { min-width: 36px; min-height: 36px; padding: 6px; }

  /* 모바일 액션 메뉴: 바텀시트 */
  .mk-action-menu {
    position: fixed !important;
    left: 0 !important; right: 0; bottom: 0; top: auto !important;
    width: 100%; min-width: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 12px 8px calc(12px + env(safe-area-inset-bottom, 0px));
    max-height: 60vh; overflow-y: auto;
  }
  .mk-action-backdrop { background: rgba(0,0,0,0.35); }
  .mk-action-item { padding: 14px 12px; font-size: 14px; min-height: 48px; }
  .mk-action-menu-head { font-size: 12px; padding: 4px 12px 10px; }

  /* 하단 저장바 — 모바일 엄지존 */
  .mk-savebar { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .mk-save-btn { min-height: 44px; padding: 10px 18px; font-size: 14px; }
  .mk-file-head { padding: 8px 10px; gap: 6px; font-size: 13px; }
  .mk-file-name { font-size: 13px; }
  .mk-status { font-size: 10px; }
  .mk-file-content { padding: 14px 16px; }
}

/* ===== 계산기 (배치 4/4) ===== */
/* 수익=빨강, 손실=초록 (한국 관례) */
.calc-up   { color: var(--danger); }
.calc-down { color: var(--success, #10b981); }

.calc-page { max-width: 720px; margin: 0 auto; }
.calc-tabs {
  display: flex; gap: 4px;
  overflow-x: auto; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}
.calc-tab {
  flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 12px;
  cursor: pointer; color: var(--text2);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.calc-tab:hover { background: var(--primary-light); color: var(--primary); }
.calc-tab.active {
  background: var(--primary); color: white;
  border-color: var(--primary);
}
.calc-tab.active .calc-tab-icon { filter: grayscale(0); }

.calc-body { margin-bottom: 14px; }
.calc-form { display: flex; flex-direction: column; gap: 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; }
.calc-form .form-row { display: flex; gap: 10px; }
.calc-form .form-row .form-group { flex: 1; }
.calc-form input[type="number"],
.calc-form input[type="text"].calc-num-input {
  width: 100%; padding: 8px 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 16px;
  text-align: right;  /* 강화1: 숫자 우정렬 */
  font-variant-numeric: tabular-nums;
}
.calc-form label { font-size: 12px; color: var(--text3); font-weight: 600; text-align: left; }

/* 강화2/3: 금액·% 슬라이더 컴포넌트 */
.calc-money, .calc-range { display: flex; flex-direction: column; gap: 6px; }
.calc-money-row {
  display: flex; align-items: center; gap: 10px;
}
.calc-money-row label {
  flex-shrink: 0; min-width: 80px;
}
.calc-money-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 10px 0 0;
}
.calc-money-input-wrap input {
  background: transparent !important; border: 0 !important;
  padding: 8px 10px !important; flex: 1; min-width: 0;
  outline: none;
}
.calc-unit {
  flex-shrink: 0; font-size: 12px; color: var(--text3); font-weight: 500;
}
.calc-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; background: var(--bg3);
  border-radius: 2px; outline: none;
  margin: 4px 0;
}
.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); cursor: pointer;
  border: 2px solid var(--bg2); box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.calc-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); cursor: pointer;
  border: 2px solid var(--bg2); box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.calc-quick {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.calc-quick-chip {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 14px; padding: 4px 10px;
  cursor: pointer; color: var(--text2); font-size: 11px; font-weight: 600;
  min-height: 28px;
}
.calc-quick-chip:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.calc-money-overflow {
  font-size: 11px; color: #b45309; padding: 2px 4px;
}

/* 종목 자동완성 드롭다운 */
.calc-stock-field .stock-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 240px; overflow-y: auto; z-index: 10;
  margin-top: 2px;
}

/* 결과 카드의 값(b)도 우정렬·tabular */
.calc-kv b { font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .calc-money-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .calc-money-row label { min-width: 0; }
  .calc-slider { height: 6px; }
  .calc-slider::-webkit-slider-thumb { width: 22px; height: 22px; }
  .calc-slider::-moz-range-thumb { width: 22px; height: 22px; }
  .calc-quick-chip { min-height: 36px; padding: 7px 12px; font-size: 12px; }
}

.calc-result { margin-bottom: 14px; min-height: 0; }
.calc-result-card {
  background: var(--bg2); border: 1px solid var(--primary);
  border-radius: var(--radius); padding: 14px;
}
.calc-result-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; color: var(--primary); }
.calc-kv {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; font-size: 13px;
  border-bottom: 1px dashed var(--border);
}
.calc-kv:last-child { border-bottom: 0; }
.calc-kv span { color: var(--text3); }
.calc-kv b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

.calc-table { width: 100%; font-size: 12px; border-collapse: collapse; margin-top: 8px; }
.calc-table th { background: var(--bg3); color: var(--text3); font-weight: 600; padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); }
.calc-table th:first-child { text-align: center; }
.calc-table td { padding: 5px 8px; text-align: right; border-bottom: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.calc-table td:first-child { text-align: center; color: var(--text3); }

.calc-save-row {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; margin-bottom: 14px;
}
.calc-save-row .aform-input { padding: 8px 10px; font-size: 13px; }
#calc-save-btn { white-space: nowrap; flex-shrink: 0; padding: 8px 14px; font-size: 13px; }
#calc-save-btn:disabled { opacity: .5; cursor: not-allowed; }

.calc-history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.calc-history { display: flex; flex-direction: column; gap: 6px; }
.calc-empty { padding: 18px; text-align: center; color: var(--text3); font-size: 13px;
  background: var(--bg2); border: 1px dashed var(--border); border-radius: var(--radius); }
.calc-hist-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px;
}
.calc-hist-when { flex-shrink: 0; color: var(--text3); width: 70px; font-size: 11px; }
.calc-hist-body { flex: 1; min-width: 0; }
.calc-hist-summary { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calc-hist-memo { color: var(--text3); font-size: 11px; margin-top: 3px; }
.calc-hist-del {
  flex-shrink: 0;
  width: 24px; height: 24px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 50%; cursor: pointer; color: var(--text3);
  font-size: 14px; line-height: 1;
}
.calc-hist-del:hover { background: var(--danger); color: white; border-color: var(--danger); }

@media (max-width: 640px) {
  .calc-form .form-row { flex-direction: column; gap: 8px; }
  .calc-save-row { flex-direction: column; align-items: stretch; }
  #calc-save-btn { width: 100%; }
  .calc-hist-when { width: auto; }
  .calc-table { font-size: 11px; }
}

/* ===== 공부일지 일자 필터 칩 + 전체보기 버튼 ===== */
.sp-clear-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-weight: 600;
  padding: 7px 14px; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  font-size: 13px;
}
.sp-clear-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.sp-filter-chip-wrap { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; min-height: 0; }
.sp-filter-chip-wrap:empty { display: none; }
.sp-filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 14px; padding: 3px 10px;
  cursor: pointer; transition: background .12s;
}
.sp-filter-chip:hover { background: var(--primary); color: white; }
.sp-filter-chip-x { font-size: 14px; line-height: 1; margin-left: 2px; opacity: .8; }

/* ===== 공부일지 리스트 4줄 형식 (배치 3/4) ===== */
/* sp-list 내부 — 카드 갭 제거. 행이 직접 쌓이는 표 형식 */
#sp-list { gap: 0 !important; }

.sp-day-header {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 6px 6px;
  border-bottom: 1px solid var(--border);
  margin-top: 6px;
  font-size: 13px; color: var(--text2);
}
.sp-day-header:first-child { margin-top: 0; }
.sp-day-num { font-weight: 700; font-size: 14px; color: var(--text); }
.sp-day-wd  { font-size: 12px; color: var(--text3); }
.sp-day-holiday {
  font-size: 11px; color: var(--danger); font-weight: 600;
  background: var(--bg3); border-radius: 10px; padding: 1px 8px;
}
.sp-day-red  .sp-day-num,
.sp-day-red  .sp-day-wd { color: var(--danger); }
.sp-day-blue .sp-day-num,
.sp-day-blue .sp-day-wd { color: #3b82f6; }
.sp-day-spacer { flex: 1; }

.sp-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg2);
  font-size: 13px;
  transition: background .15s;
}
.sp-row:hover { background: var(--bg3); }
.sp-row-time {
  flex-shrink: 0; width: 42px;
  font-size: 11px; color: var(--text3);
  font-variant-numeric: tabular-nums;
}
.sp-row-pin { flex-shrink: 0; font-size: 11px; }
.sp-row-author {
  display: inline-flex; align-items: center; gap: 5px;
  flex-shrink: 0; max-width: 110px;
  cursor: pointer;
}
.sp-row-name {
  font-size: 12px; color: var(--text2); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-row-title {
  flex: 1; min-width: 0;
  font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-row-sent {
  flex-shrink: 0;
  width: 8px; height: 8px; border-radius: 50%;
}
.sp-row-cat {
  flex-shrink: 0;
  font-size: 11px; color: var(--text3);
  background: var(--bg3); border-radius: 10px;
  padding: 2px 8px;
}
.sp-row-vis {
  flex-shrink: 0;
  width: 6px; height: 6px; border-radius: 50%;
}
.sp-row-stats {
  flex-shrink: 0;
  display: inline-flex; gap: 8px;
  font-size: 11px; color: var(--text3);
  font-variant-numeric: tabular-nums;
}

/* 모바일 — 작성자명/카테고리 숨김, 시간 폭 축소 */
@media (max-width: 640px) {
  .sp-row { gap: 6px; padding: 7px 8px; font-size: 12px; }
  .sp-row-time { width: 36px; font-size: 10px; }
  .sp-row-name { display: none; }
  .sp-row-cat { display: none; }
  .sp-row-stats { gap: 5px; font-size: 10px; }
  .sp-day-header { padding: 8px 4px 4px; }
}

/* ===== 공부일지 상단 달력 위젯 (배치 2/4) ===== */
#sp-calendar-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}
.sp-cal-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.sp-cal-title {
  font-size: 15px; font-weight: 700; min-width: 110px; text-align: center;
}
.sp-cal-nav {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 30px; height: 30px;
  cursor: pointer; color: var(--text); font-size: 13px;
}
.sp-cal-nav:hover { background: var(--primary-light); color: var(--primary); }
.sp-cal-today {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 10px; height: 30px;
  cursor: pointer; color: var(--text2); font-size: 12px;
}
.sp-cal-today:hover { background: var(--primary-light); color: var(--primary); }
.sp-cal-legend {
  margin-left: auto; display: flex; gap: 12px;
  font-size: 11px; color: var(--text3);
}
.sp-cal-legend span { display: inline-flex; align-items: center; gap: 4px; }
.sp-cal-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sp-cal-dot-mine    { background: var(--primary); }
.sp-cal-dot-visible { background: #10b981; }
.sp-cal-dot-hidden  { background: #94a3b8; }

.sp-cal-weekrow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  font-size: 11px; font-weight: 600; color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.sp-cal-wd { padding: 6px 0; text-align: center; }
.sp-cal-sun { color: var(--danger); }
.sp-cal-sat { color: #3b82f6; }

.sp-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 0; min-height: 200px;
}
.sp-cal-loading {
  grid-column: 1 / -1; padding: 24px; text-align: center;
  color: var(--text3); font-size: 12px;
}
.sp-cal-cell {
  min-height: 64px; padding: 4px 5px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer; transition: background .12s;
}
.sp-cal-cell:hover:not(.sp-cal-empty) { background: var(--bg3); }
.sp-cal-cell.sp-cal-selected {
  background: var(--primary-light);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.sp-cal-cell:nth-child(7n) { border-right: 0; }
.sp-cal-empty { background: transparent; cursor: default; }
.sp-cal-red .sp-cal-daynum { color: var(--danger); }
.sp-cal-blue .sp-cal-daynum { color: #3b82f6; }
.sp-cal-today-cell { background: var(--primary-light); }

.sp-cal-daynum-row {
  display: flex; align-items: baseline; gap: 4px;
  font-size: 11px; min-height: 14px;
}
.sp-cal-daynum { font-weight: 600; }
.sp-cal-holiday {
  font-size: 9px; color: var(--danger); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}

.sp-cal-counts {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto;
}
.sp-cal-counts-empty { min-height: 22px; }
.sp-cal-cnt { display: inline-flex; align-items: center; }
.sp-cal-cnt-hidden { cursor: pointer; }
.sp-cal-cnt-hidden:hover .sp-cal-donut { transform: scale(1.1); }

.sp-cal-donut {
  --p: 0%;
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(var(--dc) var(--p), var(--bg3) 0);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.sp-cal-cnt-mine    .sp-cal-donut { --dc: var(--primary); }
.sp-cal-cnt-visible .sp-cal-donut { --dc: #10b981; }
.sp-cal-cnt-hidden  .sp-cal-donut { --dc: #94a3b8; }
.sp-cal-donut-hole {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg2);
  font-size: 9px; font-weight: 700; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* hidden 글 목록 모달 */
.sp-cal-hidden-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.sp-cal-hidden-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--bg3);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.sp-cal-hidden-title { font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-cal-hidden-meta  { font-size: 11px; color: var(--text3); margin-top: 2px; }
.sp-cal-hidden-lock  { font-size: 14px; color: var(--text3); }

/* 모바일 — 칸 축약 */
@media (max-width: 640px) {
  #sp-calendar-wrap { padding: 8px; }
  .sp-cal-legend { flex-basis: 100%; order: 10; margin-left: 0; gap: 8px; }
  .sp-cal-cell { min-height: 54px; padding: 3px; }
  .sp-cal-donut { width: 18px; height: 18px; }
  .sp-cal-donut-hole { width: 11px; height: 11px; font-size: 8px; }
  .sp-cal-holiday { display: none; } /* 모바일은 색만 / 이름 생략 */
}

/* ===== 사이드바 메뉴 옆 글 개수 — 약한 보조 텍스트색 ===== */
.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { color: var(--primary); opacity: 0.7; }

/* ===== 사이드바 nav 뱃지 (쪽지 미읽음) ===== */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: auto;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ===== 쪽지(DM) 페이지 ===== */
.dm-page {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  height: calc(100vh - 160px);
  min-height: 480px;
}
.dm-list-pane {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dm-list-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.dm-list {
  flex: 1;
  overflow-y: auto;
}
.dm-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.dm-list-item:hover { background: var(--bg3); }
.dm-list-item.active { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.dm-list-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.dm-list-body { flex: 1; min-width: 0; }
.dm-list-row1 { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.dm-list-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-list-time { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.dm-list-row2 { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
.dm-list-preview { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-list-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.dm-thread-pane {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.dm-thread-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 13px;
}
.dm-thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.dm-back-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text1);
  display: none;
  padding: 0 4px;
}
.dm-thread-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.dm-thread-name { font-weight: 700; font-size: 14px; }
.dm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dm-msg {
  max-width: 80%;
  align-self: flex-start;
}
.dm-msg.mine { align-self: flex-end; }
.dm-msg-body {
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--bg3);
  color: var(--text1);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.dm-msg.mine .dm-msg-body {
  background: color-mix(in srgb, var(--primary) 24%, transparent);
}
.dm-msg-meta {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
  padding: 0 4px;
}
.dm-msg.mine .dm-msg-meta { text-align: right; }
.dm-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  position: relative;
}
.dm-input-bar input { flex: 1; min-width: 0; }

@media (max-width: 640px) {
  .dm-page {
    grid-template-columns: 1fr;
    height: calc(100vh - 130px);
  }
  .dm-list-pane, .dm-thread-pane { border-radius: 0; }
  .dm-thread-pane { display: none; }
  .dm-page.thread-open .dm-list-pane { display: none; }
  .dm-page.thread-open .dm-thread-pane { display: flex; }
  .dm-back-btn { display: inline-block; }
  .dm-msg { max-width: 86%; }
}

/* ===== 알림 패널 내 쪽지 섹션 (2026-05-16) ===== */
.notif-section-title {
  padding: 10px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.notif-section-action {
  padding: 8px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.notif-section-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.notif-section-btn:hover { text-decoration: underline; }
.notif-dm-item { cursor: pointer; }
.notif-dm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.notif-dm-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.notif-dm-name {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-dm-time { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.notif-dm-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.notif-dm-preview {
  font-size: 12px;
  color: var(--text2);
  padding-left: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 관리자 채팅 로그 — 채팅 버블 스타일 (2026-05-16) ===== */
.cl-wrap { max-width: 800px; }
.cl-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cl-date { display: inline-flex; align-items: center; gap: 8px; }
.cl-date-icon { font-size: 16px; }
.cl-date-text {
  font-size: 15px;
  font-weight: 700;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.cl-date-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}
.cl-paginate { margin-left: auto; font-size: 11px; color: var(--text3); }
.cl-list {
  max-height: 600px;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg1, var(--bg2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cl-empty {
  text-align: center;
  padding: 40px 20px;
  font-size: 13px;
  color: var(--text3);
}
.cl-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.cl-row.continued { margin-bottom: 4px; }
.cl-ava-col { width: 32px; flex-shrink: 0; }
.cl-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.cl-main {
  flex: 1;
  min-width: 0;
  max-width: 70%;
}
.cl-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
  margin-top: 8px;
}
.cl-row:first-child .cl-header { margin-top: 0; }
.cl-name { font-weight: 600; font-size: 13px; color: var(--text1); }
.cl-uid { font-size: 11px; color: var(--text3); font-family: ui-monospace, Menlo, Consolas, monospace; }
.cl-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.cl-bubble {
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text1);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}
.cl-row.continued .cl-bubble { border-radius: 12px; }
.cl-time {
  font-size: 11px;
  color: var(--text3);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .cl-main { max-width: 85%; }
  .cl-list { padding: 10px; max-height: 520px; }
  .cl-nav { padding: 10px; }
  .cl-paginate { width: 100%; text-align: center; margin-left: 0; }
}

/* ===== 헤더 채팅/쪽지 아이콘 + 컴팩트 여백 (2026-05-16) ===== */
.header-chat-btn,
.header-dm-btn {
  font-size: 18px;
  position: relative;
  background: transparent;
  border: none;
  cursor: pointer;
}
.header-dm-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 대시보드 인사말 — 한 줄 강제 (좁은 폭에서 줄바꿈 방지) */
.dash-greeting-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-greeting-sep { margin: 0 6px; color: var(--text3); }
.dash-greeting-period { color: var(--text3); }

/* 모바일 컴팩트 여백 — 하단 탭바 위 콘텐츠 가독성 유지하면서 공간 절약 */
@media (max-width: 640px) {
  /* 헤더 액션 영역 좁은 폭 대응 */
  .header-actions { gap: 4px; }
  .header-chat-btn, .header-dm-btn { width: 40px; height: 40px; font-size: 20px; }
  /* page-content 하단 padding: 탭바(54px) 정확히 + 최소 여유(2px) */
  .page-content { padding: 10px 12px 56px !important; }
  /* 대시보드 인사말 폰트 미세 축소 */
  .dash-greeting-sub { font-size: 12px; }
  /* 사이트 푸터 — 모바일에선 마진/패딩 대폭 축소 (탭바 환경에서 콘텐츠와 탭바 사이 빈 공간 점유 방지) */
  .site-footer { margin-top: 12px; padding: 10px 12px; }
  .footer-copy { font-size: 10px; }
  .footer-link { font-size: 11px; }
}
@media (max-width: 480px) {
  .page-content { padding: 8px 10px 56px !important; }
  .header-chat-btn, .header-dm-btn { width: 38px; height: 38px; font-size: 18px; }
  .dash-greeting-sub { font-size: 11px; }
  .site-footer { margin-top: 8px; padding: 8px 10px; }
}

/* ===== 모바일 헤더 압축 + 가로 스크롤 차단 (2026-05-16) ===== */
@media (max-width: 640px) {
  /* 가로 스크롤 전역 차단 (모바일에서 어떤 자식 요소가 폭 넘쳐도 페이지 자체는 흔들리지 않음) */
  html, body { overflow-x: hidden; max-width: 100vw; }

  /* 헤더: padding/요소 압축 */
  .top-header { padding: 0 12px; gap: 8px; }
  .page-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .header-actions { gap: 4px; flex-shrink: 0; }
  /* 💎 포인트 위젯 압축 */
  .point-widget { padding: 4px 8px !important; font-size: 11px !important; margin-right: 2px !important; }
  .point-widget .pw-icon { font-size: 12px !important; }
  /* 알림 종 / 채팅 / 쪽지 아이콘 — 32px (터치 최소) */
  .btn-icon { width: 36px; height: 36px; }
  .header-chat-btn, .header-dm-btn { width: 36px; height: 36px; font-size: 18px; }

  /* 리스트/카드 박스 강제 — 부모 폭 초과 방지 */
  .trade-card, .post-card, .resource-card, .dw-card { max-width: 100%; box-sizing: border-box; }
  /* 카드 내부 줄 제목/메타 ellipsis 안전망 (이미 있는 셀렉터에 추가 — specificity 동일 또는 더 강하게) */
  .tc-stock, .post-card-title, .dash-trade-stock, .dash-issue-ttl, .dash-port-name, .dash-grp-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* min-width:0 보장 (flex 자식 ellipsis 작동에 필수) */
  .tc-header-left, .post-meta, .dash-trade-row > div { min-width: 0; }
}
@media (max-width: 480px) {
  .top-header { padding: 0 10px; height: 52px; }
  .page-title { font-size: 13px; }
  .point-widget { padding: 3px 7px !important; font-size: 10px !important; }
  .btn-icon { width: 34px; height: 34px; }
  .header-chat-btn, .header-dm-btn { width: 34px; height: 34px; font-size: 17px; }
  .notif-btn svg { width: 16px; height: 16px; }
}

/* ===== IRP 페이지 — 탭 + 등록버튼 한 줄 + 톤 다운 (2026-05-16 v2) ===== */
.irp-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.irp-toolbar .irp-tab-bar {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.irp-toolbar .irp-add-btn { flex-shrink: 0; white-space: nowrap; }

/* IRP 탭 활성 색 톤 다운 — 등록 CTA 버튼과 명도 차별화 */
.irp-tab-bar .tab-btn.active {
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--primary);
  font-weight: 600;
}
.irp-tab-bar .tab-btn { background: transparent; }

/* IRP 카드 좌우 스크롤 방지 — 카드 자체 폭 가드 */
.irp-portfolio-card {
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* ===== IRP 운용현황 그리드 — 모바일 단일 컬럼 강제 (좌우 스크롤 근본 해결) ===== */
.irp-port-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 16px;
}
@media (max-width: 640px) {
  /* 모바일: minmax(480px,1fr)이 viewport 초과 → 단일 컬럼 + 최소 폭 0 */
  .irp-port-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* IRP 카드 내부 모든 요소 폭 안전망 — 어떤 자식이 폭 초과해도 페이지 흔들리지 않음 */
  .irp-portfolio-card,
  .irp-portfolio-card * {
    max-width: 100%;
    box-sizing: border-box;
  }
  /* dev-section 자체 padding 축소 — 좁은 폰에서 내부 공간 확보 */
  .irp-portfolio-card.dev-section {
    padding: 14px;
  }
}

/* ===== 게스트 모드 (외부 API 작성 페이지 등) 2026-05-16 =====
   비로그인 사용자가 study_writer 진입 시 사이드바/탭바/FAB/알림벨 숨김 */
body.guest-mode .sidebar,
body.guest-mode .sidebar-overlay,
body.guest-mode #hamburger,
body.guest-mode .header-chat-btn,
body.guest-mode .header-dm-btn,
body.guest-mode #point-widget,
body.guest-mode .notif-btn,
body.guest-mode .notif-panel,
body.guest-mode .bottom-tab-bar,
body.guest-mode .fab { display: none !important; }
body.guest-mode .main-content { margin-left: 0 !important; }
body.guest-mode .top-header { padding-left: 16px; }

/* ===== study_writer 페이지 ===== */
.sw-wrap { max-width: 640px; margin: 0 auto; padding: 0 4px; }
.sw-hero { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.sw-hero h2 { font-size: 18px; font-weight: 700; margin: 0 0 6px; color: var(--text1); }
.sw-hero p { font-size: 13px; color: var(--text2); margin: 0; line-height: 1.6; }
.sw-key-row { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sw-key-row label { font-size: 12px; font-weight: 600; color: var(--text2); white-space: nowrap; }
.sw-key-row input { flex: 1; min-width: 200px; font-family: ui-monospace,Menlo,Consolas,monospace; font-size: 12px; }
.sw-key-row .sw-key-status { font-size: 12px; color: var(--text2); }
.sw-key-row .sw-key-status.ok { color: #10b981; }
.sw-key-row .sw-key-status.err { color: #ef4444; }
.sw-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.sw-tab { flex: 1; padding: 10px 12px; background: transparent; border: none; color: var(--text2); font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
.sw-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.sw-panel { display: none; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.sw-panel.active { display: block; }
.sw-field { margin-bottom: 12px; }
.sw-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.sw-field input, .sw-field select, .sw-field textarea { width: 100%; }
.sw-field textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.sw-field .sw-hint { font-size: 11px; color: var(--text3); margin-top: 3px; }
.sw-row { display: flex; gap: 10px; }
.sw-row > * { flex: 1; }
.sw-actions { display: flex; gap: 8px; margin-top: 14px; }
.sw-actions button { flex: 1; padding: 12px 16px; font-size: 14px; font-weight: 600; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); background: var(--bg3); color: var(--text1); }
.sw-actions button.primary { background: var(--primary); border-color: var(--primary); color: white; }
.sw-actions button.primary:hover { background: var(--primary-hover); }
.sw-actions button:disabled { opacity: .5; cursor: not-allowed; }
.sw-history { margin-top: 18px; }
.sw-history-item { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; font-size: 12px; }
.sw-history-item .sw-h-title { font-weight: 600; color: var(--text1); }
.sw-history-item .sw-h-meta { color: var(--text2); margin-top: 2px; font-size: 11px; }
.sw-howto { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-top: 20px; font-size: 12px; color: var(--text2); line-height: 1.7; }
.sw-howto h3 { font-size: 13px; font-weight: 700; color: var(--text1); margin: 0 0 8px; }
.sw-howto ol { margin: 0; padding-left: 20px; }
.sw-howto code { background: var(--bg3); padding: 1px 5px; border-radius: 3px; font-family: ui-monospace,Menlo,Consolas,monospace; font-size: 11px; }
@media (max-width: 600px) {
  .sw-row { flex-direction: column; }
}
