/* 코스모스 테마 — 다크는 퓨어 블랙(2026-07-14 대표 채택: 시안 C), 라이트는 종이빛.
   패널은 순흑에 가까운 무채색 + 헤어라인 보더로만 구분하고, 색은 포인트(활성·버튼·별)에만 쓴다. */
:root, :root[data-theme="dark"] {
  --bg: #050507;
  --panel: #121216;      /* 카드·패널 — 배경보다 한 톤 밝게 띄워 블록 경계가 보이게 */
  --panel-2: #0b0b0e;    /* 사이드바 — 배경과 카드 사이 중간 톤 */
  --text: #e6eaf6;
  --text-dim: #8b94b8;
  --text-faint: #5d6688;
  --line: rgba(255,255,255,.10);
  --accent: #7583cf;
  --accent-soft: rgba(117,131,207,.12);
  --gold: #e8c476;
  --btn-grad: linear-gradient(135deg, #4a58b8, #7583cf);
  --danger: #e0776a;
  --warn: #d9b24a;
  --hl: rgba(232,196,118,.18);
  --hl-line: #b99a33;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.5);
  --glass: blur(8px) saturate(1.1);
}
:root[data-theme="light"] {
  --bg: #f4f2ec;
  --panel: #ffffff;
  --panel-2: #faf8f2;
  --text: #2b3048;
  --text-dim: #6b7190;
  --text-faint: #9096b0;
  --line: #e6e2d6;
  --accent: #5b6ee8;
  --accent-soft: #ecedf9;
  --gold: #b98a2e;
  --btn-grad: linear-gradient(135deg, #5b6ee8, #7d8cf0);
  --danger: #c0392b;
  --warn: #b8860b;
  --hl: #fbf1cf;
  --hl-line: #e2b93b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --glass: blur(8px) saturate(1.05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
/* 성운 radial 제거 — 배경은 순흑, 깊이감은 별먼지 캔버스가 담당 */
:root[data-theme="dark"] body {
  background: #050507;
  background-attachment: fixed;
}
/* 배경 별먼지 캔버스 — 콘텐츠 뒤 고정 */
#stardust { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
header, .layout, .bottom-nav { position: relative; z-index: 1; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 13px; transition: background .12s, border-color .12s; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--btn-grad); color: #fff; border-color: transparent; box-shadow: 0 2px 10px rgba(74,88,184,.24); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--panel-2); border-color: var(--line); }
button.danger { color: var(--danger); border-color: var(--line); }
button.danger:hover { border-color: var(--danger); background: transparent; }
input, textarea, select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; width: 100%; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
header {
  height: 56px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
}
/* 헤더 아이콘 버튼 (사이드바 토글 등) */
.icon-btn { width: 32px; height: 32px; padding: 0; border-radius: 8px; border: 1px solid transparent; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--text-dim); flex-shrink: 0; }
.icon-btn:hover { color: var(--accent); background: var(--panel-2); border-color: var(--line); }
.icon-btn svg { width: 19px; height: 19px; display: block; }
.brand { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 8px; }
.brand:hover { opacity: .85; }
.brand-logo { width: 20px; height: 20px; border-radius: 5px; display: block; box-shadow: 0 0 0 1px var(--line); }
/* 헤더 축약 버튼: 저장(+)은 정사각 프라이머리, 로그인은 G 로고 + (로그인 후) 이름 */
.icon-add { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-add svg { width: 18px; height: 18px; display: block; }
.auth-btn { display: inline-flex; align-items: center; gap: 7px; }
.auth-btn .g-logo { width: 15px; height: 15px; display: block; flex-shrink: 0; }
.auth-label:empty { display: none; }
.brand .star { color: var(--gold); font-size: 15px; text-shadow: 0 0 8px rgba(232,196,118,.55); }

/* 반원 테마 토글 아이콘 (원을 세로로 반 갈라 좌측 채움) */
.theme-toggle { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .half { fill: var(--text); }
.theme-toggle .ring { fill: none; stroke: var(--text-dim); stroke-width: 1.6; }
.search-wrap { flex: 1; max-width: 560px; position: relative; }
.search-wrap input { padding-left: 34px; }
.search-wrap::before { content: ""; position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%);
  background: var(--text-dim); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M15.5 14h-.79l-.28-.27a6.5 6.5 0 1 0-.7.7l.27.28v.79l5 5 1.5-1.5-5-5zm-6 0A4.5 4.5 0 1 1 14 9.5 4.5 4.5 0 0 1 9.5 14z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M15.5 14h-.79l-.28-.27a6.5 6.5 0 1 0-.7.7l.27.28v.79l5 5 1.5-1.5-5-5zm-6 0A4.5 4.5 0 1 1 14 9.5 4.5 4.5 0 0 1 9.5 14z'/%3E%3C/svg%3E") center/contain no-repeat; }
.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
select.mini { width: auto; padding: 6px 9px; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 56px); transition: grid-template-columns .2s ease; }
/* 사이드바는 헤더 아래 고정 — 본문을 스크롤해도 메뉴가 따라 사라지지 않는다 (자체 스크롤) */
.sidebar { border-right: 1px solid var(--line); background: var(--panel-2); padding: 14px 10px; backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass); overflow-y: auto; overflow-x: hidden; position: sticky; top: 56px; height: calc(100vh - 56px); }
.side-group { margin-bottom: 18px; }
.side-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); padding: 0 8px 6px; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px; cursor: pointer; color: var(--text); white-space: nowrap; }
.nav-item:hover { background: var(--panel); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-item .nav-ico { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-dim); }
.nav-item.active .nav-ico { color: var(--accent); }
.nav-item .nav-ico svg { width: 18px; height: 18px; display: block; }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { font-size: 11px; color: var(--text-dim); background: var(--panel); border-radius: 10px; padding: 1px 7px; flex-shrink: 0; }
.nav-item.active .count { color: var(--accent); }

/* 아이콘 레일 (접힘) — 보기 메뉴 아이콘만 남기고 나머지 섹션은 숨긴다.
   데스크톱 전용: 모바일(<=720px)에서는 사이드바가 필터 시트로 열리므로
   레일 상태가 저장돼 있어도 숨김 규칙이 적용되면 안 된다. */
@media (min-width: 721px) {
  .layout.rail { grid-template-columns: 54px 1fr; }
  .layout.rail .sidebar { padding: 14px 6px; }
  .layout.rail .side-cal,
  .layout.rail .side-group:not(.nav-views),
  .layout.rail .nav-views .side-title,
  .layout.rail .nav-item .nav-label,
  .layout.rail .nav-item .count { display: none; }
  .layout.rail .nav-item { justify-content: center; gap: 0; padding: 9px 0; }
}

.content { padding: 22px 26px; overflow: auto; }
.content-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.content-head h2 { margin: 0; font-size: 19px; font-weight: 620; letter-spacing: -0.01em; }
.content-head .sub { color: var(--text-dim); font-size: 13px; }
.toolbar { display: flex; gap: 8px; margin-left: auto; }

/* Cards — 마소닉(신문 스크랩) 레이아웃 */
.cards { column-width: 300px; column-gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 9px; transition: border-color .12s, transform .12s, box-shadow .12s; break-inside: avoid; margin-bottom: 14px; backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass); }
.card:hover { border-color: rgba(117,131,207,.4); transform: translateY(-1px); box-shadow: 0 8px 26px rgba(3,6,20,.45); }
/* 가이드 배지 · 연결 별빛 */
.guide-badge { font-size: 11px; font-weight: 650; color: var(--gold); letter-spacing: .02em; }
.card-foot .link-star { color: var(--gold); }
.card .meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim); }
.src { text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; padding: 1px 7px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; }
.ty { font-size: 11px; color: var(--text-dim); border: 1px dashed var(--line); border-radius: 5px; padding: 1px 7px; }
.card-quote { background: var(--panel-2); }
.quote-text { margin: 0; font-size: 15px; line-height: 1.6; font-style: italic; border-left: 3px solid var(--accent); padding-left: 12px; }
/* 재발견 배너 */
.seren { border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--panel); border-radius: var(--radius); padding: 13px 16px; margin-bottom: 16px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .12s; }
.seren:hover { border-color: var(--accent); }
.seren-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); font-weight: 650; margin-bottom: 3px; }
.seren-title { font-weight: 620; font-size: 15px; }
.seren-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.card h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.card .summary { color: var(--text-dim); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 1px 7px; }
.pill-cat { font-size: 11px; color: var(--text-dim); border: 1px solid var(--line); border-radius: 20px; padding: 1px 9px; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.empty { text-align: center; color: var(--text-dim); padding: 60px 20px; }
.empty h3 { color: var(--text); font-weight: 600; }

/* Detail drawer */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .15s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 520px; max-width: 92vw; background: var(--panel); border-left: 1px solid var(--line); z-index: 50; transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.show { transform: translateX(0); }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-body { padding: 18px 20px; overflow: auto; flex: 1; }
.drawer-body h1 { font-size: 20px; margin: 0 0 6px; line-height: 1.3; }
.section { margin: 18px 0; }
.section .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 6px; }
.summary-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.content-text { white-space: pre-wrap; word-break: break-word; }
.related-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.related-item:hover { border-color: var(--accent); background: var(--panel-2); }
.related-item .score { margin-left: auto; font-size: 11px; color: var(--text-dim); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Modal */
/* 팝업 뒤에는 딤을 깔아 팝업이 배경과 확실히 구분되게 한다 */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 60; background: rgba(0,0,0,.55); }
.modal.show { display: flex; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 620px; max-width: 94vw; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; display: flex; align-items: center; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* Graph */
.graph-wrap { position: relative; height: calc(100vh - 150px); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
#graphCanvas { width: 100%; height: 100%; display: block; color: var(--text); }
.legend { position: absolute; top: 12px; left: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; max-height: 60%; overflow: auto; box-shadow: var(--shadow); }
.legend-row { display: flex; align-items: center; gap: 7px; margin: 3px 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* Highlights */
.hl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.hl-head button { padding: 4px 9px; font-size: 12px; }
mark.hl { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 2px; }
.hl-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.hl-row button { padding: 4px 9px; font-size: 12px; flex-shrink: 0; }
.hl-quote { flex: 1; margin: 0; font-size: 13px; line-height: 1.6; border-left: 3px solid var(--hl-line); padding-left: 11px; color: var(--text); }

/* misc */
.banner { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.banner .grow { flex: 1; }
.checkline { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.checkline input[type=checkbox] { width: auto; }
.checkline .grow { flex: 1; min-width: 0; }
.checkline .t { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--text-dim); font-size: 12px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; opacity: 0; transition: all .2s; z-index: 80; font-size: 13px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.kbd { font-family: ui-monospace, monospace; font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
/* import preview */
.ip-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.ip-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.ip-row:hover { background: var(--panel); }
.ip-row input[type=checkbox] { width: auto; margin-top: 3px; flex-shrink: 0; }
.ip-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ip-meta { font-size: 11px; color: var(--text-dim); }
.ip-text { font-size: 13px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all; }

/* 빈 상태 태그라인 */
.empty .tagline { font-size: 15px; color: var(--gold); margin-top: 14px; letter-spacing: .01em; }
.empty .tagline .star { text-shadow: 0 0 10px rgba(232,196,118,.5); }

/* 드로어·모달 글래스 */
.drawer, .modal-card { backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass); }
/* 퓨어 블랙 위 "트레이싱지" — 순흑에 옅은 백색 막을 한 겹 얹은 반투명 패널 (구 남색 하드코딩 제거) */
:root[data-theme="dark"] .drawer {
  background: linear-gradient(rgba(255,255,255,.05), rgba(255,255,255,.05)), rgba(7,7,9,.9);
}
/* 팝업(모달)은 드로어보다 한 톤 밝고 보더도 진하게 — 배경과 즉시 구분되게 */
:root[data-theme="dark"] .modal-card {
  background: linear-gradient(rgba(255,255,255,.075), rgba(255,255,255,.075)), rgba(9,9,12,.97);
  border-color: rgba(255,255,255,.17);
}

/* 그래프 재생(타임랩스) 버튼 */
.graph-controls { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 3; }
.graph-play { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 12px; color: var(--text); backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass); }
.graph-play:hover { border-color: var(--accent); }
.graph-play svg { width: 12px; height: 12px; fill: var(--gold); }
.graph-hint { position: absolute; bottom: 12px; right: 14px; font-size: 11px; color: var(--text-faint); z-index: 3; }
.legend { backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass); }
.legend-dot { box-shadow: 0 0 6px currentColor; }

/* 사이드바 미니 캘린더 (옵시디언식 좌측 레일) */
.side-cal { margin: 0 2px 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.mcal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; padding: 0 2px; }
.mcal-title { font-weight: 620; font-size: 12.5px; letter-spacing: 0.01em; color: var(--text); }
.mcal-nav { width: 22px; height: 22px; border-radius: 6px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1; color: var(--text-dim); }
.mcal-nav:hover { color: var(--accent); background: var(--panel-2); }
.mcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mcal-dow { text-align: center; font-size: 9.5px; color: var(--text-faint); padding-bottom: 3px; }
.mcal-cell { position: relative; height: 26px; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border: 1px solid transparent; cursor: default; }
.mcal-cell.has { cursor: pointer; }
.mcal-cell.has:hover { background: var(--accent-soft); }
.mcal-cell.empty-day { visibility: hidden; }
.mcal-num { font-size: 10.5px; color: var(--text-dim); line-height: 1; }
.mcal-cell.has .mcal-num { color: var(--text); }
.mcal-cell.today { background: var(--accent-soft); }
.mcal-cell.today .mcal-num { color: var(--accent); font-weight: 700; }
.mcal-cell.sel { border-color: var(--gold); }
.mcal-star { border-radius: 50%; background: var(--gold); width: 4px; height: 4px; }
.mcal-star.lvl1 { width: 3px; height: 3px; opacity: .6; }
.mcal-star.lvl2 { width: 4.5px; height: 4.5px; opacity: .85; box-shadow: 0 0 4px rgba(232,196,118,.5); }
.mcal-star.lvl3 { width: 6px; height: 6px; opacity: 1; box-shadow: 0 0 6px rgba(232,196,118,.75); }
/* 미니 캘린더에서 이동한 날짜 그룹 강조 */
.tl-day.flash .tl-day-label { animation: dayflash 1.2s ease; }
@keyframes dayflash { 0%, 100% { color: var(--text); } 30% { color: var(--gold); } }
/* 타임라인 일간·주간·월간 세그먼트 토글 */
.tl-seg { margin-left: auto; align-self: center; display: inline-flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.tl-seg-btn { border: none; background: transparent; border-radius: 7px; padding: 4px 13px; font-size: 12.5px; color: var(--text-dim); }
.tl-seg-btn:hover { color: var(--text); background: transparent; border-color: transparent; }
.tl-seg-btn.active { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }

button, .nav-item { touch-action: manipulation; }
.drawer-body, .modal-card, .sidebar.mobile-open { overscroll-behavior: contain; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* auth · sync 상태 */
.sync-status { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.sync-status[data-state="ok"] { color: #2f9e44; }
.sync-status[data-state="error"] { color: #e03131; }
.sync-status[data-state="syncing"] { color: var(--accent); }
#authBtn.signed { border-color: var(--accent); color: var(--accent); }

/* 보안 잠금 */
.lock-badge { font-size: 11px; border: 1px solid rgba(232,89,12,.4); border-radius: 5px; padding: 1px 7px; color: #e8590c; }
.lock-note { margin-top: 8px; font-size: 12px; color: #e8590c; background: rgba(232,89,12,.08); border: 1px solid rgba(232,89,12,.25); border-radius: 8px; padding: 8px 10px; line-height: 1.5; }
.lock-row { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--text-dim); cursor: pointer; line-height: 1.5; }
.lock-row input[type=checkbox] { width: auto; margin-top: 2px; flex-shrink: 0; }

.masked { font-family: inherit; font-size: inherit; letter-spacing: 1px; color: #e8590c; background: rgba(232,89,12,.10); border: 1px dashed rgba(232,89,12,.45); border-radius: 6px; padding: 0 6px; cursor: pointer; vertical-align: baseline; }
.masked:hover { background: rgba(232,89,12,.18); }
.revealed { background: var(--hl); border-radius: 4px; padding: 0 3px; }
.lock-placeholder { font-size: 13px; color: #e8590c; background: rgba(232,89,12,.07); border: 1px dashed rgba(232,89,12,.3); border-radius: 8px; padding: 10px 12px; }

.card-thumb { width: 100%; max-height: 220px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.detail-media { width: 100%; max-height: 420px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); margin-top: 4px; }

/* 타임라인 */
.tl-day { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; }
.tl-day:first-of-type { margin-top: 4px; }
.tl-day-label { font-weight: 650; font-size: 15px; }
.tl-day-count { font-size: 12px; color: var(--text-dim); }

/* 모바일 하단 내비 */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; }
.bottom-nav button { flex: 1; background: none; border: none; color: var(--text-dim); font-size: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; cursor: pointer; border-radius: 8px; }
.bottom-nav button.active { color: var(--accent); }
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav .bnav-main { color: #fff; background: var(--accent); border-radius: 12px; max-width: 64px; margin: 0 4px; }

/* 상세 접기(») 버튼 — 데스크톱 도킹 패널에서만 노출 */
.drawer-collapse { display: none; width: 30px; height: 30px; padding: 0; align-items: center; justify-content: center; flex-shrink: 0; }
.drawer-collapse svg { width: 17px; height: 17px; display: block; }

/* 데스크톱(>=1100px): 상세를 헤더 아래 우측에 도킹된 패널로 연다.
   본문(.layout)이 패널 폭만큼 밀려나고, 오버레이 딤은 쓰지 않아 목록이 계속 조작 가능하다.
   1100px 미만(모바일·태블릿)에서는 아래 규칙이 적용되지 않아 기존 오버레이 드로어가 유지된다. */
@media (min-width: 1100px) {
  .drawer { width: 400px; max-width: 400px; top: 56px; height: calc(100vh - 56px); box-shadow: var(--shadow); }
  .overlay { display: none; }
  body.detail-open .layout { margin-right: 400px; transition: margin-right .2s ease; }
  .drawer-collapse { display: inline-flex; }
}

@media (max-width: 720px) {
  header { flex-wrap: wrap; height: auto; min-height: 56px; gap: 8px; padding: 10px 12px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .header-right { margin-left: auto; gap: 6px; }
  /* 모바일에서는 하단 내비가 저장·설정을 맡는다 — 헤더는 브랜드+로그인만 */
  #themeBtn, .sync-status, #profileSel, #settingsBtn, #addBtn, #sidebarToggle { display: none; }
  .layout { min-height: auto; }
  /* 사이드바 레일은 데스크톱 전용 — 모바일에서는 무력화(사이드바는 필터 시트로 열림) */
  .layout, .layout.rail { grid-template-columns: 1fr; }
  /* 사이드바(카테고리·소스 필터)는 하단 내비의 "필터"로 여는 전체 화면 시트가 된다 */
  .sidebar { display: none; }
  .sidebar.mobile-open { display: block; position: fixed; inset: 0; z-index: 45; overflow: auto; padding: 18px 16px calc(76px + env(safe-area-inset-bottom)); background: var(--bg); border: none; }
  .content { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .cards { column-width: auto; column-count: 1; }
  .drawer { width: 100vw; max-width: 100vw; }
  .modal { align-items: flex-end; }
  .modal-card { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .bottom-nav { display: flex; }
}

