/* ============================================================
   AI Command — 나의 정보 서재
   ------------------------------------------------------------
   디자인 방향
   - 매일 아침 여는 읽기 도구. 장식보다 밀도와 가독성.
   - 수치 색은 한국 시장 관례를 따르고 브리핑 이메일과 통일한다
     (상승 빨강 / 하락 파랑).
   - 3분할(메뉴 / 목록 / 본문)을 유지하되 경계를 선이 아니라
     배경 단계로 구분해 시선 소음을 줄인다.
   ============================================================ */

:root {
  /* 중립 계열 — 살짝 따뜻한 회색 */
  --ink:        #14181f;
  --ink-2:      #2b323c;
  --ink-3:      #55606e;
  --muted:      #6b7480;
  --faint:      #98a1ac;
  --line:       #e3e7ec;
  --line-2:     #eef1f5;
  --surface:    #ffffff;
  --canvas:     #f6f8fa;
  --canvas-2:   #eef1f5;
  --sidebar-bg: #f9fafb;

  /* 강조 */
  --accent:      #0f6f60;
  --accent-ink:  #0a5348;
  --accent-soft: #e7f2f0;
  --accent-line: #bfdcd6;

  /* 상태 */
  --up:        #d92b3a;   /* 상승 */
  --down:      #1f5fd0;   /* 하락 */
  --warn:      #b8730c;
  --warn-soft: #fff6e6;
  --warn-line: #f0d9a8;
  --danger:    #c22a35;
  --info:      #3f7fd0;
  --info-soft: #f2f7fd;

  --unread:   #0f6f60;
  --favorite: #d9a01f;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-1: 0 1px 2px rgba(20, 24, 31, .05);
  --shadow-2: 0 3px 12px rgba(20, 24, 31, .08);
  --shadow-3: 0 12px 36px rgba(20, 24, 31, .16);

  --sans: 'PretendardVariable', Pretendard, 'DM Sans', -apple-system,
          BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 272px;
  --list-w:    minmax(340px, 420px);
  --nav-h:     52px;
}

* { box-sizing: border-box; }

/* display 를 지정한 요소는 hidden 속성만으로 숨겨지지 않는다.
   (.fallback-note 등이 빈 상태로 보이던 원인) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body.inbox-app {
  margin: 0;
  font-family: var(--sans);
  background: var(--canvas);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body.modal-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft); }

/* 숫자는 등폭으로 — 표에서 자리수가 흔들리지 않게 */
.feed-time, .detail-meta, .calendar-day, .dashboard-strip strong,
.nav-item strong, .category-item strong, .detail-position,
.md-table td, .md-num {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   셸 레이아웃
   ============================================================ */

.inbox-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  padding-top: var(--nav-h);
}

/* ============================================================
   사이드바
   ============================================================ */

.inbox-sidebar {
  position: sticky;
  top: var(--nav-h);
  align-self: start;
  /* 그리드 자식의 기본 min-width:auto 때문에 내부 가로 스크롤 영역이
     칼럼 폭을 밀어내 페이지 전체가 가로로 넘치던 문제 */
  min-width: 0;
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 18px 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}

.product-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}
.product-title strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}
.product-title span {
  display: block;
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 1px;
}

/* 빠른 보기 */
.smart-nav { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--ink-3);
  text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--canvas-2); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.nav-item > span:nth-child(2) { flex: 1; min-width: 0; }
.nav-item strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  font-feature-settings: 'tnum';
}
.nav-item.active strong { color: var(--accent); }

.nav-symbol {
  width: 16px;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  flex: none;
}
.nav-item.active .nav-symbol { color: var(--accent); }
.nav-symbol.unread-symbol { color: var(--unread); font-size: 9px; }
.nav-symbol.favorite-symbol { color: var(--favorite); }

/* 캘린더 */
.feed-calendar {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.calendar-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 2px 4px;
  border-radius: 5px;
}
.calendar-toggle:hover { background: var(--canvas-2); }
.calendar-toggle i {
  font-style: normal;
  font-size: 10px;
  color: var(--faint);
  transition: transform .16s;
}
.calendar-toggle[aria-expanded='false'] i { transform: rotate(-90deg); }

.calendar-controls { display: flex; gap: 2px; }
.calendar-controls button {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}
.calendar-controls button:hover { background: var(--canvas-2); color: var(--ink); }

.calendar-body { margin-top: 9px; }
.calendar-body.collapsed { display: none; }

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.calendar-weekdays {
  margin-bottom: 4px;
}
.calendar-weekdays span {
  text-align: center;
  font-size: 10px;
  color: var(--faint);
  padding: 2px 0;
}
.calendar-weekdays span:first-child { color: #c9646d; }

.calendar-blank { aspect-ratio: 1; }

.calendar-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--faint);
  transition: background .12s;
}
.calendar-day:disabled { color: #cdd3da; cursor: default; }
.calendar-day.has-feed { color: var(--ink-2); font-weight: 600; }
.calendar-day.has-feed:hover { background: var(--accent-soft); }
.calendar-day.selected {
  background: var(--accent);
  color: #fff;
}
.calendar-day i {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  font-size: 0;
  line-height: 0;
  overflow: hidden;
  text-indent: -99px;
}
.calendar-day.selected i { background: rgba(255, 255, 255, .85); }

.calendar-clear {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 5px;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--canvas-2);
}
.calendar-clear:hover { color: var(--ink); }

/* 메뉴(카테고리) */
.category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  margin-bottom: -6px;
}
.category-head span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
}
.category-head button {
  font-size: 11.5px;
  color: var(--muted);
  padding: 3px 7px;
  border-radius: 5px;
}
.category-head button:hover { background: var(--canvas-2); color: var(--accent-ink); }

.category-nav { display: flex; flex-direction: column; gap: 1px; }

.category-row {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}
.category-row.dragging { opacity: .45; }

.drag-handle {
  display: none;
  width: 16px;
  flex: none;
  text-align: center;
  color: var(--faint);
  font-size: 11px;
  cursor: grab;
}
.category-nav.editing .drag-handle { display: block; }

.category-item {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-3);
  text-align: left;
  transition: background .12s, color .12s;
}
.category-item:hover { background: var(--canvas-2); color: var(--ink); }
.category-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.category-item > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-item strong { font-size: 11.5px; font-weight: 600; color: var(--faint); }
.category-item.active strong { color: var(--accent); }

.category-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
  flex: none;
}
.category-item.active .dot { background: var(--accent); }

.category-row .edit {
  display: none;
  padding: 4px 6px;
  color: var(--faint);
  font-size: 11px;
  border-radius: 5px;
}
.category-nav.editing .edit { display: block; }
.category-row .edit:hover { background: var(--canvas-2); color: var(--ink); }

.add-category {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--muted);
  border: 1px dashed var(--line);
  text-align: left;
}
.add-category:hover {
  color: var(--accent-ink);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* 사이드바 하단 */
.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
  padding: 0 4px;
}
.sync-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.sync-status.syncing i { background: var(--info); animation: pulse 1.1s ease-in-out infinite; }
.sync-status.ok i      { background: var(--accent); }
.sync-status.warn i    { background: var(--warn); }
.sync-status.error i   { background: var(--danger); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.sidebar-foot > button {
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
}
.sidebar-foot > button:hover { border-color: var(--accent-line); color: var(--accent-ink); }
.sidebar-foot > button:disabled { opacity: .5; cursor: default; }

.mobile-utility-bar { display: none; }

/* ============================================================
   본문 영역
   ============================================================ */

.inbox-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 24px 0;
  gap: 16px;
}

.inbox-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.inbox-header .overline {
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}
.inbox-header h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.022em;
  color: var(--ink);
  line-height: 1.2;
}
.inbox-header > div > p:last-child {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* 검색 */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  height: 38px;
  min-width: 290px;
  box-shadow: var(--shadow-1);
  transition: border-color .14s, box-shadow .14s;
}
.search:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search > span { color: var(--faint); font-size: 14px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 13.5px;
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  background: var(--canvas-2);
  border-radius: 4px;
  padding: 2px 5px;
  flex: none;
}
.search:focus-within kbd { display: none; }

/* 요약 스트립 */
.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.dashboard-strip > * {
  display: block;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  box-shadow: var(--shadow-1);
  transition: border-color .14s, transform .14s;
}
.dashboard-strip > button:hover {
  border-color: var(--accent-line);
  transform: translateY(-1px);
}
.dashboard-strip span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}
.dashboard-strip strong {
  display: block;
  font-size: 23px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -.02em;
  margin: 2px 0 1px;
}
.dashboard-strip small { display: block; font-size: 10.5px; color: var(--faint); }

/* 신선도 배지 — 데이터가 오래됐을 때만 노출 */
.stale-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-line);
}

/* 오늘 비었을 때 안내 */
.fallback-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 13px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  font-size: 12.5px;
  color: #7d5205;
  line-height: 1.55;
}
.fallback-note b { color: var(--warn); }
.fallback-note button {
  margin-left: auto;
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--warn);
  text-decoration: underline;
}

/* ============================================================
   읽기 작업영역 (목록 + 본문)
   ============================================================ */

.reading-workspace {
  display: grid;
  grid-template-columns: var(--list-w) 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  padding-bottom: 22px;
}

.feed-column,
.detail-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
  flex: none;
}
.column-head > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}
.column-head strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}
.column-head span { font-size: 11.5px; color: var(--faint); }
.column-head button {
  flex: none;
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.column-head button:hover { color: var(--accent-ink); border-color: var(--accent-line); }

/* 피드 목록 */
.feed-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.feed-item {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 15px 13px 26px;
  border-bottom: 1px solid var(--line-2);
  transition: background .1s;
}
.feed-item:hover { background: var(--canvas); }
.feed-item.active { background: var(--accent-soft); }
.feed-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}

.feed-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.unread-dot {
  position: absolute;
  left: 12px;
  top: 17px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--unread);
  flex: none;
}
.feed-item.read .unread-dot { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

.feed-category {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 1px 6px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-item.read .feed-category { color: var(--muted); background: var(--canvas-2); }

.favorite-indicator { font-size: 10px; color: var(--favorite); }

.feed-time {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--faint);
  flex: none;
}

.feed-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  letter-spacing: -.008em;
  margin-bottom: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.feed-item.read .feed-title { font-weight: 500; color: var(--ink-3); }

.feed-summary {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.feed-search-context {
  display: block;
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--info-soft);
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.5;
  border-left: 2px solid var(--info);
}

.feed-item mark,
.feed-search-context mark {
  background: #fff2a8;
  color: var(--ink);
  border-radius: 2px;
  padding: 0 1px;
}

.feed-empty,
.feed-loading {
  padding: 42px 24px;
  text-align: center;
  font-size: 12.5px;
  color: var(--faint);
  line-height: 1.7;
}

/* 목록 스켈레톤 */
.skeleton-item {
  padding: 13px 15px 13px 26px;
  border-bottom: 1px solid var(--line-2);
}
.skeleton-line {
  height: 9px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--canvas-2) 25%, var(--line-2) 37%, var(--canvas-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  margin-bottom: 7px;
}
@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ============================================================
   상세 (본문)
   ============================================================ */

.detail-column {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.detail-empty {
  margin: auto;
  padding: 48px 30px;
  text-align: center;
  color: var(--faint);
}
.detail-empty > span { font-size: 26px; display: block; margin-bottom: 12px; color: var(--line); }
.detail-empty strong { display: block; font-size: 14.5px; color: var(--ink-3); margin-bottom: 5px; }
.detail-empty p { margin: 0; font-size: 12.5px; line-height: 1.65; }
.detail-empty small {
  display: inline-block;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  background: var(--canvas);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 5px 10px;
}

.mobile-detail-bar { display: none; }

.reading-progress {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 2px;
  background: var(--line-2);
  flex: none;
}
.reading-progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width .2s;
}

.detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 22px;
  border-bottom: 1px solid var(--line-2);
}
.detail-position { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.detail-nav > span:last-child { display: flex; gap: 6px; }
.detail-nav button {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.detail-nav button:hover:not(:disabled) { border-color: var(--accent-line); color: var(--accent-ink); }
.detail-nav button:disabled { opacity: .4; cursor: default; }

.detail-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 22px 0;
  flex-wrap: wrap;
}
.detail-menu {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 20px;
  padding: 3px 11px;
}
.detail-menu:hover { background: #d9ebe7; }

.detail-actions { display: flex; gap: 6px; }
.detail-action {
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.detail-action:hover { color: var(--ink); border-color: var(--faint); }
.detail-action.active {
  color: var(--accent-ink);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  font-weight: 600;
}

.detail-column h2 {
  margin: 12px 0 0;
  padding: 0 22px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -.022em;
  color: var(--ink);
  outline: none;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 9px 22px 0;
  font-size: 11px;
  color: var(--faint);
}
.detail-meta span { display: inline-flex; align-items: center; }
.detail-meta span + span::before {
  content: '';
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--line);
  margin-right: 10px;
  margin-left: -7px;
}

.detail-utility {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 15px 22px;
  margin-top: 14px;
  border-top: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  background: var(--canvas);
}
.detail-utility button {
  font-size: 11.5px;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 11px;
}
.detail-utility button:hover { border-color: var(--accent-line); color: var(--accent-ink); }
.detail-utility .delete-feed { color: var(--danger); margin-left: auto; }
.detail-utility .delete-feed:hover { border-color: #e8b4b9; background: #fdf2f3; color: var(--danger); }

/* ------------------------------------------------------------
   본문 렌더링 — 표 / 콜아웃 / 구분선
   구 버전은 **굵게** 와 #제목만 처리해서 시황·뉴스가 벽처럼 붙어
   나왔다. 이제 마크다운 표와 사실/해석 블록을 인식한다.
   ------------------------------------------------------------ */

.detail-body {
  padding: 20px 22px 40px;
  font-size: 14px;
  line-height: 1.78;
  color: var(--ink-2);
  word-break: break-word;
}

.detail-body > *:first-child { margin-top: 0; }

.detail-body p { margin: 0 0 13px; }

.detail-body .md-h1,
.detail-body .md-h2,
.detail-body .md-h3 {
  display: block;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.015em;
  line-height: 1.4;
  margin: 24px 0 9px;
}
.detail-body .md-h1 { font-size: 17.5px; }
.detail-body .md-h2 { font-size: 16px; }
.detail-body .md-h3 { font-size: 14.5px; }

/* 섹션 제목 (1) (2) ... */
.detail-body .md-section {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 28px 0 12px;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--ink);
}
.detail-body .md-section b {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-body .md-section span {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.015em;
}

/* 한 줄 결론 */
.detail-body .md-key {
  margin: 0 0 18px;
  padding: 12px 15px;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-left: 4px solid #e0a800;
}
.detail-body .md-key em {
  display: block;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  color: #8a6a00;
  margin-bottom: 4px;
}
.detail-body .md-key span {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.65;
}

/* 사실 / 해석 블록 */
.detail-body .md-labeled {
  margin: 12px 0 16px;
  padding: 11px 15px 8px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.detail-body .md-labeled.fact { background: var(--info-soft); border-left: 3px solid var(--info); }
.detail-body .md-labeled.view { background: var(--warn-soft); border-left: 3px solid var(--warn); }
.detail-body .md-labeled > em {
  display: block;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  margin-bottom: 6px;
}
.detail-body .md-labeled.fact > em { color: var(--info); }
.detail-body .md-labeled.view > em { color: var(--warn); }
.detail-body .md-labeled ul { margin: 0; padding-left: 15px; }
.detail-body .md-labeled li { margin-bottom: 4px; font-size: 13.5px; }

/* 체크포인트 */
.detail-body .md-checks {
  margin: 0 0 20px;
  padding: 14px 16px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--canvas);
}
.detail-body .md-checks > em {
  display: block;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 10px;
}
.detail-body .md-checks ol { margin: 0; padding: 0; list-style: none; counter-reset: chk; }
.detail-body .md-checks li {
  position: relative;
  counter-increment: chk;
  padding-left: 27px;
  margin-bottom: 8px;
  font-size: 13.5px;
  line-height: 1.6;
}
.detail-body .md-checks li::before {
  content: counter(chk);
  position: absolute;
  left: 0; top: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 표 */
.detail-body .md-table-wrap {
  margin: 14px 0 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}
.detail-body .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.detail-body .md-table th {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
}
.detail-body .md-table th.right { text-align: right; }
.detail-body .md-table th.center { text-align: center; }
.detail-body .md-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.55;
}
.detail-body .md-table td.right { text-align: right; white-space: nowrap; }
.detail-body .md-table td.center { text-align: center; }
.detail-body .md-table tbody tr:nth-child(even) { background: var(--canvas); }

/* 수치 색상 — 이메일과 동일한 규칙 */
.detail-body .md-up   { color: var(--up);   font-weight: 600; white-space: nowrap; }
.detail-body .md-down { color: var(--down); font-weight: 600; white-space: nowrap; }

/* 리스트 */
.detail-body ul,
.detail-body ol { margin: 10px 0 15px; padding-left: 20px; }
.detail-body li { margin-bottom: 5px; }
.detail-body li::marker { color: var(--faint); }

/* 구분선 */
.detail-body hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 24px 0;
}

/* 인용 */
.detail-body blockquote {
  margin: 14px 0;
  padding: 3px 0 3px 14px;
  border-left: 3px solid var(--line);
  color: var(--ink-3);
  font-size: 13.5px;
}

.detail-body code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--canvas-2);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink);
}

.detail-body strong { color: var(--ink); font-weight: 600; }

/* 링크 */
.detail-body .body-link {
  color: var(--info);
  text-decoration: none;
  border-bottom: 1px solid rgba(63, 127, 208, .3);
  word-break: break-all;
}
.detail-body .body-link:hover { border-bottom-color: var(--info); }

/* 출처 묶음 */
.detail-body .md-sources {
  margin: 22px 0 0;
  padding: 13px 15px;
  background: var(--canvas);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
}
.detail-body .md-sources > em {
  display: block;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 7px;
}
.detail-body .md-sources ul { margin: 0; padding-left: 15px; }
.detail-body .md-sources li { font-size: 11.5px; margin-bottom: 3px; color: var(--muted); }

/* 유의사항 */
.detail-body .md-disclaimer {
  margin: 20px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--faint);
}
.detail-body .md-disclaimer b { color: var(--muted); }

/* 본문 로딩 */
.body-loading { padding: 30px 0; text-align: center; }
.body-loading span {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.body-error {
  margin: 16px 0;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: #fdf2f3;
  border: 1px solid #f0d3d6;
  font-size: 12.5px;
  color: #8a2b33;
}
.body-error button {
  margin-left: 8px;
  font-weight: 600;
  color: var(--danger);
  text-decoration: underline;
}

/* ============================================================
   로그인
   ============================================================ */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: linear-gradient(160deg, #1b2635, #0f1620);
}
.login-overlay[hidden] { display: none; }

.login-card {
  width: 100%;
  max-width: 348px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 26px 24px;
  box-shadow: var(--shadow-3);
}
.login-card h1 {
  margin: 0 0 5px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
}
.login-card p {
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}
.login-card label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
  font-size: 14px;
}
.login-card input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-card button[type='submit'] {
  width: 100%;
  height: 40px;
  margin-top: 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
}
.login-card button[type='submit']:hover { background: var(--accent-ink); }
.login-card button[type='submit']:disabled { opacity: .6; cursor: default; }

.login-error {
  margin-top: 11px;
  font-size: 12px;
  color: var(--danger);
  min-height: 17px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.login-brand img { width: 22px; height: 22px; border-radius: 5px; }
.login-brand span {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: .02em;
}

/* ============================================================
   모달
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 24, 31, .42);
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }

.dialog {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-3);
}
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}
.dialog-head p {
  margin: 0 0 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
}
.dialog-head h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--ink);
}
.dialog-head button {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 6px;
  color: var(--faint);
  font-size: 17px;
  line-height: 1;
}
.dialog-head button:hover { background: var(--canvas-2); color: var(--ink); }

.dialog-copy {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}

.dialog input[type='text'] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  font-size: 13.5px;
}
.dialog input[type='text']:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.radio-list { display: flex; flex-direction: column; gap: 7px; margin: 13px 0 0; }
.radio-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.radio-list label:has(input:checked) {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}
.radio-list input { accent-color: var(--accent); }

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 18px;
}
.dialog-actions > span { flex: 1; }
.dialog-actions button {
  height: 35px;
  padding: 0 15px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
}
.dialog-actions .primary { background: var(--accent); color: #fff; font-weight: 600; }
.dialog-actions .primary:hover { background: var(--accent-ink); }
.dialog-actions .ghost { color: var(--muted); border: 1px solid var(--line); }
.dialog-actions .ghost:hover { color: var(--ink); }
.dialog-actions .danger { color: var(--danger); border: 1px solid #ecc7cb; }
.dialog-actions .danger:hover { background: #fdf2f3; }

/* ============================================================
   토스트
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  z-index: 300;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 17px;
  border-radius: 22px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   데스크톱·태블릿 독립 스크롤 영역
   ============================================================ */

@media (min-width: 721px) {
  body.inbox-app { overflow: hidden; }

  .inbox-shell {
    height: calc(100vh - var(--global-nav-h));
    min-height: 0;
    padding-top: 0;
  }

  .inbox-sidebar {
    top: var(--global-nav-h);
    height: 100%;
  }

  .inbox-main {
    min-height: 0;
    overflow: hidden;
  }
}

/* ============================================================
   반응형
   ============================================================ */

@media (max-width: 1180px) {
  :root { --list-w: minmax(300px, 360px); }
  .inbox-main { padding: 20px 18px 0; }
}

@media (max-width: 980px) {
  :root { --sidebar-w: 240px; }

  .dashboard-strip { grid-template-columns: repeat(2, 1fr); }
  .dashboard-strip > div:last-child { display: none; }

  /* 목록 ↔ 본문 전환 */
  .reading-workspace { grid-template-columns: 1fr; }
  .reading-workspace .detail-column { display: none; }
  .reading-workspace.detail-open .feed-column { display: none; }
  .reading-workspace.detail-open .detail-column { display: flex; }

  .mobile-detail-bar {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line-2);
    flex: none;
  }
  .mobile-detail-bar button {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent-ink);
  }
  .mobile-detail-bar span { font-size: 11.5px; color: var(--faint); }

  .detail-nav { display: none; }
}

@media (max-width: 720px) {
  .inbox-shell { grid-template-columns: 1fr; }

  .inbox-sidebar {
    position: static;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 14px 16px;
    gap: 14px;
  }

  /* 모바일에서는 빠른 보기를 가로 스크롤 칩으로 */
  .smart-nav {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 3px;
    scrollbar-width: none;
  }
  .smart-nav::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: none;
    width: auto;
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 6px 11px;
    font-size: 12.5px;
    border-radius: 20px;
  }
  .nav-item.active { border-color: var(--accent-line); }

  .category-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
  }
  .category-row { flex: none; }
  .category-item {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 20px;
    padding: 6px 11px;
    font-size: 12.5px;
  }
  .category-item .dot { display: none; }
  .category-item.active { border-color: var(--accent-line); }

  .add-category { align-self: flex-start; }

  .mobile-utility-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }
  .mobile-utility-bar button {
    font-size: 11.5px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 9px;
  }

  .feed-calendar { order: 10; }
  .sidebar-foot { display: none; }

  .inbox-main { padding: 16px 14px 0; gap: 13px; }
  .inbox-header { align-items: stretch; gap: 12px; }
  .inbox-header h1 { font-size: 21px; }
  .search { min-width: 0; width: 100%; }

  .dashboard-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dashboard-strip strong { font-size: 20px; }

  .reading-workspace { padding-bottom: 16px; }
  .feed-column, .detail-column { border-radius: var(--radius); }

  .detail-column h2 { font-size: 18.5px; padding: 0 16px; }
  .detail-menu-row,
  .detail-meta { padding-left: 16px; padding-right: 16px; }
  .detail-utility { padding: 12px 16px; }
  .detail-body { padding: 16px 16px 32px; font-size: 13.5px; }
  .detail-body .md-table { font-size: 12px; }
  .detail-body .md-table th,
  .detail-body .md-table td { padding: 7px 9px; }

  .toast { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* 인쇄 */
@media print {
  .inbox-sidebar, .inbox-header, .dashboard-strip,
  .feed-column, .detail-nav, .detail-utility,
  .mobile-detail-bar, .reading-progress, .toast { display: none !important; }
  .inbox-shell { display: block; padding: 0; }
  .reading-workspace { display: block; }
  .detail-column { border: 0; box-shadow: none; }
}
