/* =============================================================
   calm forest · 소재 인박스 웹 — style.css
   ------------------------------------------------------------
   작업 도구(하루 20건 훑기)라 밀도·대비를 장식보다 우선한다.
   토큰은 dashboards/_dash.css 와 같은 철학(그린 쪽으로 기운 뉴트럴 +
   색맹 안전 카테고리 팔레트)을 따르되, 이 페이지는 다크모드 없음(범위 밖).
   ============================================================= */

:root {
  color-scheme: light;
  --surface-0: #f3f6f4;
  --surface-1: #fbfcfb;
  --surface-2: #eef2ef;
  --line:      #dde5e0;
  --line-soft: #e9efeb;
  --ink:       #16241d;
  --ink-2:     #4e5f56;
  --ink-3:     #7d8d84;

  /* 출처 배지 — _dash.css 의 카테고리 시리즈 순서를 그대로 재사용 */
  --s1: #1baf7a;  /* 잡플래닛 */
  --s2: #eb6834;  /* 디시 */
  --s3: #2a78d6;  /* 블라인드 */
  --s4: #eda100;  /* 엠팍 */
  --s5: #4a3aa7;  /* 뉴스 */

  --up:    #217a4e;
  --down:  #c14f3a;
  --brand: #8fd6a0;
  --brand-ink: #1f3b28;

  --shadow: 0 1px 2px rgba(22, 36, 29, .05), 0 4px 14px rgba(22, 36, 29, .06);
  --radius: 14px;
  --font: "Apple SD Gothic Neo", Pretendard, "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface-0);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* 375px 폭에서 가로 스크롤이 생기지 않게 하는 마지막 안전판 */
}
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--s3); outline-offset: 2px; border-radius: 3px; }
.hide { display: none !important; }

/* ── 공통 버튼/배지 ── */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-1); color: var(--ink);
  padding: 8px 14px; font-size: 13px;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.pri:hover:not(:disabled) { filter: brightness(.96); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.xs { padding: 3px 8px; font-size: 11.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }

.badge {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.badge.src-jobplanet { background: rgba(27, 175, 122, .14); color: #0f6b4b; }
.badge.src-blind     { background: rgba(42, 120, 214, .14); color: #1b5aa3; }
.badge.src-dc        { background: rgba(235, 104, 52, .14); color: #a8461f; }
.badge.src-mlb       { background: rgba(237, 161, 0, .16); color: #8a5f00; }
.badge.src-news      { background: rgba(74, 58, 167, .14); color: #382a80; }
.badge.cat { background: var(--surface-2); color: var(--ink-3); }
.badge.status-draft { background: var(--surface-2); color: var(--ink-3); }
.badge.status-ready  { background: rgba(33, 122, 78, .14); color: var(--up); }

.state { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.state.done { color: var(--up); }
.state.dim  { color: var(--ink-3); }

.count { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.empty { color: var(--ink-3); font-size: 13px; padding: 22px 0; text-align: center; }
.empty.small { padding: 10px 0; font-size: 12px; }

/* ── 상단바/탭 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--surface-1); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 800; letter-spacing: -.2px; }
.tabs { display: flex; gap: 6px; }
.tab {
  font: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-1); color: var(--ink-3);
  padding: 7px 13px; border-radius: 10px;
}
.tab.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ── 로그인 화면 ── */
.login-screen { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
  max-width: 360px; width: 100%; text-align: center; background: var(--surface-1);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 26px;
}
.login-card h2 { margin: 0 0 8px; font-size: 18px; }
.login-card p { margin: 0 0 20px; font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }

/* ── 인박스 화면 ── */
#app { padding: 16px; max-width: 1180px; margin: 0 auto; }
.screen { width: 100%; }

.toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.field input[type=date], .field input[type=text], .field textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface-1);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%;
}
.field input[type=date] { width: auto; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; }
.status { font-size: 12.5px; color: var(--ink-3); margin-left: auto; }

/* A안: 좌우 분할. 왼쪽 목록(가변) + 오른쪽 트레이(고정폭, sticky) */
.inbox-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

/* ── 소재 목록 ── */
.topic-col { min-width: 0; } /* 그리드 아이템 — 이게 있어야 긴 텍스트가 트랙을 밀어내지 않는다 */
.topic-list { min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.source-section { min-width: 0; }
.source-heading {
  font-size: 12.5px; font-weight: 800; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: .4px; margin: 0 0 10px;
}
.card-stack { display: flex; flex-direction: column; gap: 10px; }

.topic-card {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 15px; box-shadow: var(--shadow); min-width: 0;
}
.topic-card.is-dismissed { opacity: .55; }

/* 제목은 실측 최대 120자까지 온다 — 절대 한 줄 가정 금지.
   keep-all 로 한국어 어절이 안 깨지게, overflow-wrap 으로 긴 미분리 토큰(URL 등) 안전판. */
.topic-title {
  margin: 0 0 6px; font-size: 14.5px; font-weight: 700; line-height: 1.45; color: var(--ink);
  word-break: keep-all; overflow-wrap: anywhere;
}

/* excerpt 가 빈 문자열이면 app.js 가 이 <p> 자체를 만들지 않는다(빈 자리표시자 금지) */
.topic-excerpt {
  margin: 0 0 10px; font-size: 12.5px; line-height: 1.55; color: var(--ink-2);
  word-break: keep-all; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-clamp: 2; overflow: hidden;
}

.topic-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.src-link { font-size: 11.5px; color: var(--ink-3); text-decoration: none; }
.src-link:hover { text-decoration: underline; color: var(--s3); }
.actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── 트레이(담기) — sticky, 스크롤해도 따라온다 ── */
.tray {
  position: sticky;
  top: 78px; /* 상단바 높이만큼 띄운다 */
  align-self: start;
  min-width: 0; /* 그리드 아이템 방어 — 안의 nowrap 텍스트가 트랙을 밀어내지 않게 */
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.tray-inner {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 15px 16px;
}
.tray-inner h2 { font-size: 14px; margin: 0 0 10px; font-weight: 800; }
.tray-list { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.tray-list li {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border-radius: 9px; padding: 6px 8px 6px 10px;
}
.tray-item-title {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tray-form { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.tray-form textarea { min-height: 64px; resize: vertical; line-height: 1.5; }
.tray-msg { font-size: 12px; color: var(--ink-3); min-height: 1.2em; }

/* ── 묶음 목록 화면 ── */
.bundle-list { display: flex; flex-direction: column; gap: 10px; }
.bundle-card {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.bundle-main { min-width: 0; flex: 1; }
.bundle-title { margin: 0 0 5px; font-size: 14.5px; font-weight: 700; word-break: keep-all; overflow-wrap: anywhere; }
.bundle-memo { margin: 0 0 8px; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; }
.bundle-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.bundle-actions { flex: none; }

/* ── 토스트 ── */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--surface-1); padding: 9px 16px; border-radius: 12px;
  font-size: 13px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none;
  max-width: calc(100vw - 32px); text-align: center; z-index: 50;
}
.toast.on { opacity: 1; }

/* ── 좁은 화면: 1컬럼으로 접히고 트레이가 목록 아래로(A안 접힘 지점) ── */
@media (max-width: 820px) {
  /* bare 1fr 는 minmax(auto,1fr) 라 트레이 안의 nowrap 텍스트(말줄임 트레이 아이템 제목) 의
     min-content 가 트랙을 밀어낸다 — minmax(0,1fr) 로 트랙 최소값을 0 으로 강제해야
     375px 에서 가로 스크롤이 안 생긴다(직접 재서 잡은 버그). */
  .inbox-layout { grid-template-columns: minmax(0, 1fr); }
  .tray { position: static; max-height: none; overflow: visible; }
  .tray-list { max-height: none; }
}

/* ── 모바일 폭 세부 조정(375px 기준) ── */
@media (max-width: 480px) {
  .topbar { padding: 12px; }
  .topbar h1 { font-size: 14.5px; }
  #app { padding: 12px; }
  .toolbar { gap: 10px; }
  .status { margin-left: 0; width: 100%; }
  .topic-card { padding: 12px; }
  .topic-meta { align-items: flex-start; }
  .actions { width: 100%; justify-content: flex-start; }
  .bundle-card { flex-direction: column; align-items: stretch; }
  .bundle-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
