/* ============================================================
 * Work is 1 app shell — sidebar + topbar + content area
 * ============================================================ */

body { margin: 0; font-family: var(--font-sans); color: var(--fg-primary); background: var(--surface-background-alt); }
* { box-sizing: border-box; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.side {
  background: var(--chrome-bg);
  border-right: 1px solid var(--chrome-border);
  display: flex; flex-direction: column;
  height: 100vh;
  align-self: start;
  position: sticky; top: 0;
  z-index: 5;
}
.side__inner { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; height: 100%; overflow-y: auto; }

/* Workspace switcher */
.side__ws-switcher { position: relative; margin-bottom: 6px; }
.side__ws-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: 10px; background: transparent;
  cursor: pointer; border: 0; color: var(--fg-primary);
}
.side__ws-btn:hover { background: var(--chrome-hover); }
.side__ws-btn .ws-name { flex: 1; text-align: left; font-weight: 700; font-size: 14px; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side__ws-btn .chev { color: var(--fg-tertiary); }

.ws-dot { display: inline-block; width: 14px; height: 14px; border-radius: 5px; flex-shrink: 0; }
.ws-dot--sm { width: 10px; height: 10px; border-radius: 4px; }
.ws-dot--ghost { background: transparent; border: 1.5px dashed var(--border-default); color: var(--fg-tertiary); width: 14px; height: 14px; line-height: 12px; text-align: center; font-size: 13px; font-weight: 700; }

.side__ws-pop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface-elevated); border: 1px solid var(--border-default); border-radius: 12px;
  box-shadow: var(--shadow-3);
  padding: 6px;
  z-index: 20;
  max-height: 60vh; overflow-y: auto;
}
.side__ws-pop-group { font-size: 10px; font-weight: 600; color: var(--fg-tertiary); letter-spacing: .06em; text-transform: uppercase; padding: 8px 10px 4px; }
.side__ws-pop-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }
.side__ws-item-form { display: block; }
.side__ws-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; background: transparent; border: 0; cursor: pointer;
  font-size: 13px; color: var(--fg-primary); text-decoration: none;
}
.side__ws-item:hover { background: var(--chrome-hover); }
.side__ws-item.is-current { background: var(--chrome-active-bg); color: var(--chrome-active-fg); font-weight: 600; }
.side__ws-item .ws-name { flex: 1; }
.side__ws-item .ws-role { font-size: 10px; color: var(--fg-tertiary); padding: 1px 6px; background: var(--alpha-neutral-08); border-radius: 999px; }
.side__ws-item--cta { color: var(--brand-primary); font-weight: 500; }

/* Nav links */
.side__link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  font-size: 13px; color: var(--fg-secondary); text-decoration: none;
  font-weight: 500;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.side__link:hover { background: var(--chrome-hover); color: var(--fg-primary); }
.side__link.is-active { background: var(--chrome-active-bg); color: var(--chrome-active-fg); font-weight: 600; }
.side__link svg { color: var(--fg-tertiary); flex-shrink: 0; }
.side__link.is-active svg { color: var(--chrome-active-fg); }

.side__link--project { padding-left: 14px; }
.side__link--project .proj-name { flex: 1; font-weight: 500; }
.side__link--project .proj-count { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--alpha-neutral-08); color: var(--fg-tertiary); }

/* Section group label */
.side__group {
  font-size: 10px; font-weight: 700; color: var(--fg-tertiary);
  letter-spacing: .06em; text-transform: uppercase;
  padding: 14px 10px 4px; display: flex; align-items: center; justify-content: space-between;
}
.side__group-add { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: var(--fg-tertiary); cursor: pointer; background: transparent; border: 0; }
.side__group-add:hover { background: var(--chrome-hover); color: var(--fg-primary); }
.side__group-add.is-active { background: var(--brand-primary-soft); color: var(--brand-primary); }

/* 프로젝트 순서 변경 모드 */
.side__grip { display: none; align-items: center; color: var(--fg-tertiary); margin-right: 2px; flex: 0 0 auto; }
.side__projects.is-reorder .side__grip { display: inline-flex; }
.side__projects.is-reorder .side__link--project { cursor: grab; border: 1px dashed var(--border-default); border-radius: 7px; margin: 2px 0; background: var(--surface-elevated); }
.side__projects.is-reorder .side__link--project.is-dragging { opacity: .45; }
.side__projects.is-reorder .side__link--project .proj-count { display: none; }
/* 정렬 중에는 프로젝트가 아닌 하위 링크(문서 등) 숨김 */
.side__projects.is-reorder .side__link:not(.side__link--project) { display: none; }
.side__reorder-done { margin: 6px 10px 0; padding: 7px 10px; width: calc(100% - 20px); border: 0; border-radius: 7px;
  background: var(--brand-primary); color: #fff; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.side__reorder-done:hover { background: var(--brand-primary-hover); }

.side__projects { display: flex; flex-direction: column; gap: 1px; }
.side__empty { font-size: 12px; color: var(--fg-tertiary); padding: 8px 12px; font-style: italic; }

.side__foot { margin-top: auto; padding-top: 12px; position: relative; }
.side__me {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer; text-align: left;
}
.side__me:hover { background: var(--chrome-hover); }
.me-avatar {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand-primary); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.me-name { font-size: 13px; font-weight: 600; color: var(--fg-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-email { font-size: 11px; color: var(--fg-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side__me-pop {
  position: absolute; bottom: calc(100% + 6px); left: 12px; right: 12px;
  background: var(--surface-elevated); border: 1px solid var(--border-default); border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow-4);
  z-index: 50;  /* 운영 #12: 사이드바 내부 다른 메뉴 위로 확실히 올라가도록 */
  display: flex; flex-direction: column; gap: 1px;
}
/* 운영 #12 재: display:flex 가 HTML hidden 속성을 무시하던 문제 — attribute selector 로 override */
.side__me-pop[hidden] { display: none !important; }
/* 운영 #12: me-btn 펼쳐진 상태 시각 표시 */
.side__me[aria-expanded="true"] { background: var(--chrome-hover); }
.side__me-pop a, .side__me-pop button {
  display: block; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--fg-primary);
  text-decoration: none; background: transparent; border: 0; cursor: pointer; text-align: left; width: 100%;
}
.side__me-pop a:hover, .side__me-pop button:hover { background: var(--chrome-hover); }
.side__me-pop form { display: block; border-top: 1px solid var(--border-subtle); margin-top: 4px; padding-top: 4px; }
.side__me-pop button { color: var(--status-danger); }

/* ---------------- Main ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--surface-background); border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 4;
}
.topbar__hamburger { display: none; width: 32px; height: 32px; border-radius: 7px; align-items: center; justify-content: center; color: var(--fg-secondary); }
.topbar__hamburger:hover { background: var(--chrome-hover); color: var(--fg-primary); }
.topbar__crumbs { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-secondary); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.crumb:hover { background: var(--chrome-hover); color: var(--fg-primary); }
.crumb--current { color: var(--fg-primary); font-weight: 600; }
.crumb__sep { color: var(--fg-tertiary); font-size: 12px; }

.topbar__search {
  margin-left: 16px; flex: 1; max-width: 480px;
  display: flex; align-items: center; gap: 8px;
  background: var(--chrome-bg); border: 1px solid var(--border-subtle); border-radius: 10px;
  padding: 0 12px; height: 36px;
  color: var(--fg-tertiary);
}
.topbar__search input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--fg-primary); font: 13px var(--font-sans); }
.topbar__search input::placeholder { color: var(--fg-tertiary); }
.topbar__search .kbd { font-size: 10px; color: var(--fg-tertiary); padding: 2px 6px; background: var(--alpha-neutral-08); border-radius: 4px; border: 1px solid var(--border-subtle); font-family: var(--font-mono); }

.topbar__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar__icon {
  height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 10px; background: var(--brand-primary); color: #fff;
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.topbar__icon:hover { background: var(--brand-primary-hover); }
.topbar__icon--ghost { background: transparent; color: var(--fg-secondary); padding: 0 8px; width: 36px; justify-content: center; }
.topbar__icon--ghost:hover { background: var(--chrome-hover); color: var(--fg-primary); }
.topbar__icon-label { display: inline-block; }

.content { padding: 28px 32px; max-width: 1200px; width: 100%; }

/* ---------------- Mobile ---------------- */
.side-fab {
  position: fixed; bottom: 20px; right: 20px;
  width: 52px; height: 52px; border-radius: 999px;
  background: var(--brand-primary); color: #fff;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-3); z-index: 30;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .25s ease; z-index: 60; height: 100dvh; height: 100vh; }
  .shell.is-side-open .side { transform: translateX(0); }
  /* 운영 #30: 사이드바 열림 시 backdrop — 외부 클릭/시각 분리 */
  .shell.is-side-open::before {
    content: ''; position: fixed; inset: 0;
    background: rgba(11,16,32,.45);
    z-index: 55; animation: fadeIn .15s ease-out;
  }
  .topbar__hamburger { display: grid; }
  .topbar__icon-label { display: none; }
  .content { padding: 18px; }

  /* 운영 #29: 모바일 breadcrumb — 워크스페이스 / 프로젝트 두 줄 (헤더 높이 56px 유지)
     .topbar 의 flex 안에서 .topbar__crumbs 만 column 으로, 햄버거 옆 가로 배치 */
  .topbar { flex-wrap: nowrap; gap: 8px; padding: 0 12px; }
  .topbar__hamburger { align-self: center; flex-shrink: 0; }
  .topbar__crumbs {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    align-self: center;  /* 햄버거 옆에서 세로 중앙 */
    justify-content: center;
    gap: 1px;
    line-height: 1.15;
    font-size: 12.5px;
    min-width: 0;
    overflow: hidden;
  }
  .topbar__crumbs .crumb { padding: 0 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar__crumbs .crumb__sep { display: none; }  /* 두 줄이므로 / 구분자 숨김 */
  .topbar__actions { flex-shrink: 0; }
}
@media (max-width: 480px) {
  .topbar__search { display: none; }
}

/* 운영 #29: 모바일에서 task 상세의 URL 추가 form input 폭 확대 + 버튼 축소 */
@media (max-width: 600px) {
  .att-url-form { gap: 4px !important; }
  .att-url-form input[type=url] { font-size: 14px !important; padding: 9px 10px !important; min-width: 0; flex: 1 1 auto; }
  .att-url-form button { padding: 0 10px !important; font-size: 12px !important; flex-shrink: 0; }
}

/* ============================================================
 * 모바일 가로 스크롤 방지 안전망
 *  - <body>/<html> 가로 overflow 차단
 *  - 긴 영문/URL/경로가 박스 깨던 문제: overflow-wrap: anywhere + min-width:0
 *  - 첨부 파일명/코드 블록/이미지 박스 안전화
 * ============================================================ */
html, body { overflow-x: hidden; max-width: 100%; }
.shell, .main { min-width: 0; max-width: 100vw; }
/* overflow-x: clip — hidden 은 overflow-y 를 auto 로 승격해 .main 을 스크롤
   컨테이너로 만들어 자식 .topbar{position:sticky} 를 깨뜨림. clip 은 스크롤
   컨테이너를 만들지 않아 헤더 고정(sticky)을 보존하면서 가로 넘침만 차단. (devplan012) */
.main { overflow-x: clip; }

@media (max-width: 900px) {
  /* 텍스트 블록 — 긴 영문/식별자/URL/한글 강제 줄바꿈 */
  .td__title, .td__body, .panel, .panel *, .side-panel, .side-panel *,
  .dash__head *, .dash__panel *, .dt-table td, [class*=comment] {
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
  }
  /* code/pre 박스는 가로 스크롤로 격리 (전체 페이지 가로 스크롤 안 만듦) */
  pre, code, .dt-code, [class*=__code] {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-break: normal;
  }
  /* 이미지/비디오/iframe */
  img, video, iframe, embed { max-width: 100%; height: auto; }
}

/* ============================================================
 * Mention autocomplete (planreq010 / devplan017)
 * ============================================================ */
.mention-pop {
  position: absolute; z-index: 1200;
  background: var(--surface-elevated); border: 1px solid var(--border-default);
  border-radius: 10px; box-shadow: var(--shadow-3);
  max-height: 240px; overflow-y: auto; padding: 4px;
}
.mention-pop__item {
  display: flex; flex-direction: column; gap: 1px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
}
.mention-pop__item.is-active, .mention-pop__item:hover { background: var(--chrome-hover); }
.mention-pop__name { font-size: 13px; font-weight: 600; color: var(--fg-primary); }
.mention-pop__email { font-size: 11px; color: var(--fg-tertiary); }
/* 표시 코멘트의 실제 멘션 강조 */
.cmt-mention { color: var(--brand-primary); font-weight: 600; }

/* ============================================================
 * Notification bell dropdown
 * ============================================================ */
.notif-pop {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 360px; max-width: 92vw;
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  z-index: 30;
  overflow: hidden;
}
.notif-pop__head { display:flex; align-items:center; justify-content:space-between; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); }
.notif-pop__body { max-height: 360px; overflow-y: auto; }
.notif-pop__row { display: flex; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border-subtle); text-decoration: none; color: inherit; align-items: flex-start; }
.notif-pop__row:first-of-type { border-top: 0; }
.notif-pop__row:hover { background: var(--chrome-hover); }
.notif-pop__row.is-unread { background: var(--brand-primary-soft); }
.notif-pop__dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; flex-shrink: 0; margin-top: 6px; }
.notif-pop__row.is-unread .notif-pop__dot { background: var(--brand-primary); }
.notif-pop__msg { font-size: 13px; line-height: 1.45; color: var(--fg-primary); }
.notif-pop__time { font-size: 11px; color: var(--fg-tertiary); margin-top: 3px; }
.notif-pop__foot { padding: 10px 14px; border-top: 1px solid var(--border-subtle); text-align: center; }

/* 모바일: 벨 버튼 우측에 다른 아이콘이 더 있어 right:0(=#bell-wrap 기준) 으로는
   360px 팝업이 화면 왼쪽으로 넘침(#270). 좁은 화면에선 뷰포트에 고정해 항상 화면 안에 표시. */
@media (max-width: 640px) {
  .notif-pop {
    position: fixed;
    top: 60px;            /* 토바(56px) 바로 아래 */
    left: 8px; right: 8px;
    width: auto; max-width: none;
  }
  .notif-pop__body { max-height: calc(100vh - 160px); }
}

/* ============================================================
 * Onboarding balloon tour
 * ============================================================ */
.tour-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.4);
  pointer-events: none;
}
.tour-hl {
  position: absolute;
  border-radius: 10px;
  box-shadow: 0 0 0 4px rgba(79,70,229,.6), 0 0 0 9999px rgba(0,0,0,.45);
  transition: all .25s ease;
  pointer-events: none;
}
.tour-balloon {
  position: absolute; z-index: 1000;
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  padding: 14px 16px;
  max-width: 320px;
  pointer-events: auto;
}
.tour-balloon h4 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.tour-balloon p { margin: 0; font-size: 13px; color: var(--fg-secondary); line-height: 1.5; }
.tour-balloon__progress { font-size: 11px; color: var(--fg-tertiary); margin-bottom: 6px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.tour-balloon__actions { display: flex; gap: 6px; margin-top: 12px; justify-content: flex-end; }
.tour-btn {
  height: 30px; padding: 0 12px; border-radius: 8px; font-weight: 600; font-size: 12px; cursor: pointer;
  background: var(--brand-primary); color: #fff; border: 0;
}
.tour-btn:hover { background: var(--brand-primary-hover); }
.tour-btn--ghost { background: transparent; color: var(--fg-secondary); }
.tour-btn--ghost:hover { background: var(--chrome-hover); color: var(--fg-primary); }
.tour-balloon__arrow { position: absolute; width: 14px; height: 14px; background: var(--surface-elevated); border: 1px solid var(--border-default); transform: rotate(45deg); }

/* ============================================================
 * Quick-add modal (project/task)
 * ============================================================ */
.qa-backdrop {
  position: fixed; inset: 0; background: rgba(11,16,32,.6);
  /* Must be above .tour-overlay (z:999) and .tour-balloon (z:1000) so that
     modals opened during the onboarding tour appear on top, not greyed out. */
  z-index: 1100; display: grid; place-items: center; padding: 20px;
  animation: fadeIn .12s ease-out;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.qa-modal {
  position: relative; z-index: 1101;
  width: 100%; max-width: 480px;
  background: var(--surface-elevated); border: 1px solid var(--border-default);
  border-radius: 14px; box-shadow: var(--shadow-4);
  overflow: hidden;
  /* 모달이 화면보다 길어도 내부 스크롤 (head/foot 고정, body 스크롤) */
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
/* body/foot 는 <form> 으로 감싸여 있으므로 form 도 flex 컬럼이어야 body 가 줄어들며 스크롤됨 */
.qa-modal > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.qa-modal__head { padding: 18px 20px 8px; flex: 0 0 auto; }
.qa-modal__head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qa-top-submit { display: none; height: 32px; padding: 0 14px; } /* 모바일 전용(아래 미디어쿼리에서 노출) */
.qa-modal__head h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.qa-modal__head p { margin: 0; font-size: 13px; color: var(--fg-secondary); }
.qa-modal__body { padding: 12px 20px; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; min-height: 0; -webkit-overflow-scrolling: touch; }
.qa-modal__field { margin-bottom: 12px; }
.qa-modal__field label { display: block; font-size: 11px; font-weight: 600; color: var(--fg-secondary); margin-bottom: 5px; letter-spacing: .04em; text-transform: uppercase; }
.qa-modal__field input, .qa-modal__field select, .qa-modal__field textarea {
  width: 100%; max-width: 100%; padding: 9px 12px; border: 1px solid var(--border-default); border-radius: 8px;
  background: var(--surface-background); color: var(--fg-primary); font: 13.5px var(--font-sans);
}
.qa-modal__field input:focus, .qa-modal__field select:focus, .qa-modal__field textarea:focus {
  outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--alpha-primary-16);
}
.qa-modal__field textarea { min-height: 80px; resize: vertical; overflow-wrap: anywhere; word-break: break-word; }
.qa-modal__colors { display: flex; gap: 6px; flex-wrap: wrap; }
.qa-color { width: 26px; height: 26px; border-radius: 7px; cursor: pointer; border: 2px solid transparent; }
.qa-color.is-active { border-color: var(--fg-primary); transform: scale(1.06); }
.qa-modal__foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; background: var(--chrome-bg); border-top: 1px solid var(--border-subtle); flex: 0 0 auto; }
.qa-btn { height: 36px; padding: 0 16px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; background: var(--brand-primary); color: #fff; border: 0; }
.qa-btn:hover { background: var(--brand-primary-hover); }
.qa-btn--ghost { background: transparent; color: var(--fg-secondary); border: 1px solid var(--border-default); }
.qa-btn--ghost:hover { background: var(--chrome-hover); color: var(--fg-primary); }
.qa-priority { display: flex; gap: 6px; }
.qa-prio-chip { padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; background: var(--chrome-bg); border: 1px solid var(--border-subtle); color: var(--fg-secondary); }
.qa-prio-chip.is-urgent.is-active { background: var(--priority-urgent-soft); color: var(--priority-urgent); border-color: var(--priority-urgent); }
.qa-prio-chip.is-high.is-active   { background: var(--priority-high-soft);   color: var(--priority-high);   border-color: var(--priority-high); }
.qa-prio-chip.is-normal.is-active { background: var(--alpha-neutral-08); color: var(--fg-primary); border-color: var(--border-strong); }

/* ============================================================
 * Mobile modal — 운영 #8 (재발): 모달 모바일 화면 깨짐 강화 보강
 * - dvh 단위로 iOS Safari 주소창 토글 시 점프 방지
 * - safe-area-inset 대응 (노치/홈인디케이터)
 * - 320px iPhone SE 까지 보장 (overflow 없음)
 * - 모달 자체에 max-height 적용 (긴 폼 우상단/하단 잘림 방지)
 * - iOS 자동 줌 방지 (input font-size:16px)
 * - 우선순위 칩 flex-wrap (3개 한 줄 보장)
 * ============================================================ */
@media (max-width: 600px) {
  .qa-backdrop {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    align-items: flex-start;
  }
  .qa-modal {
    max-width: 100%;
    width: 100%;
    border-radius: 12px;
    /* #294: vh 를 먼저(폴백), dvh 를 나중에 둬서 지원 브라우저에선 dvh 가 우선 적용되도록.
       (이전엔 dvh 다음에 vh 가 와서 iOS 에서 vh 가 이겨 하단 등록버튼이 주소창/툴바 뒤로 가려짐) */
    max-height: calc(100vh - 24px);   /* 폴백 */
    max-height: calc(100dvh - 24px);  /* iOS 주소창/툴바 토글 안전 — 지원 시 우선 */
    display: flex;
    flex-direction: column;
    overflow-x: hidden;  /* 운영 #199: 아이폰 모달 본문 좌우 스크롤 방지 */
  }
  .qa-modal__body { overflow-x: hidden; }
  .qa-modal__head { padding: 14px 14px 6px; flex: 0 0 auto; }
  .qa-top-submit { display: inline-flex; align-items: center; }  /* #294: 모바일 상단 등록 버튼 노출 */
  .qa-modal__head h3 { font-size: 15px; }
  .qa-modal__head p { font-size: 12.5px; }
  .qa-modal__body {
    padding: 10px 14px;
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;  /* flex child scroll fix */
  }
  .qa-modal__foot { padding: 10px 14px 14px; flex: 0 0 auto; }
  .qa-modal__field { margin-bottom: 10px; }
  .qa-modal__field input,
  .qa-modal__field select,
  .qa-modal__field textarea {
    font-size: 16px;  /* iOS Safari 포커스 자동 줌 방지 (16px 미만은 줌 들어감) */
    padding: 10px 12px;
  }
  .qa-modal__field textarea { min-height: 64px; }
  .qa-priority { flex-wrap: wrap; }
  .qa-prio-chip { font-size: 12px; padding: 6px 10px; }
  /* 색상 스와치(프로젝트 만들기) 도 좁은 폭에서 잘 보이게 */
  .qa-modal__colors { gap: 5px; }
  .qa-color { width: 24px; height: 24px; }
}

/* 320px (iPhone SE 1세대) 더 좁은 폭 보장 */
@media (max-width: 360px) {
  .qa-backdrop { padding: 8px; }
  .qa-modal__head { padding: 12px 12px 4px; }
  .qa-modal__body { padding: 8px 12px; }
  .qa-modal__foot { padding: 8px 12px 12px; }
}

/* ============================================================
 * Dashboard
 * ============================================================ */
.dash__head { margin-bottom: 18px; }
.dash__hello { font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
.dash__sub { font-size: 13.5px; color: var(--fg-secondary); margin: 0; }

.dash__kpis { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 12px; margin-bottom: 22px; }
.kpi-card { background: var(--surface-elevated); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 16px 18px; }
.kpi-card__l { font-size: 12px; color: var(--fg-tertiary); margin-bottom: 4px; }
.kpi-card__v { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.kpi-card__sub { font-size: 11px; color: var(--fg-tertiary); margin-top: 2px; }

.dash__grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .dash__grid { grid-template-columns: 1fr; } }
.panel { background: var(--surface-elevated); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 18px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel__title { font-size: 14px; font-weight: 700; margin: 0; }
.panel__action { font-size: 12px; color: var(--brand-primary); cursor: pointer; }

.task-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--border-subtle); }
.task-row:first-of-type { border-top: 0; }
.task-row__prio { width: 4px; height: 22px; border-radius: 2px; flex-shrink: 0; }
.task-row__prio.is-urgent { background: var(--priority-urgent); }
.task-row__prio.is-high   { background: var(--priority-high); }
.task-row__prio.is-normal { background: var(--border-default); }
.task-row__title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; color: var(--fg-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* #317: 대시보드 목록의 프로젝트 표시(색 점 + 이름) */
.task-row__proj { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--fg-secondary); }
.task-row__proj-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
@media (max-width: 600px) { .task-row__proj { max-width: 84px; } }
.task-row__due { font-size: 11px; color: var(--fg-tertiary); }
.task-row__due.is-late { color: var(--priority-urgent); font-weight: 600; }

/* #325→하자보수: 모바일에서 목록 우측(배지·마감일) 잘림 방지.
   근본원인 = 그리드 blowout. .dash__grid 의 열(그리드 아이템)은 기본 min-width:auto 라
   긴 제목의 min-content 폭이 열을 화면 밖으로 밀어내 우측이 잘렸다. 그리드 아이템을
   min-width:0 으로 풀면 열이 트랙(모바일 1fr) 안으로 수축하고, 그 아래 flex 제목
   (flex:1; min-width:0)이 비로소 말줄임(…) 처리되어 배지·마감일이 항상 화면 안에 남는다. */
.dash__grid > * { min-width: 0; }
.task-scroll { max-width: 100%; overflow-x: hidden; }
.task-scroll .task-row { max-width: 100%; }
@media (max-width: 700px) {
  /* 좁은 화면: 프로젝트명 폭을 더 줄여 제목/배지/마감 표시 공간 확보 */
  .task-scroll .task-row__proj { max-width: 72px; }
}
@media (max-width: 400px) {
  .task-scroll .task-row { gap: 7px; }
  .task-scroll .task-row__proj { max-width: 56px; }
}
/* #325: 대시보드 프로젝트 목록 — 태스크 제목과 동일 글자크기, 우측 카운트 항상 노출, 긴 이름 줄바꿈 */
.proj-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--border-subtle); }
.proj-row__name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; color: var(--fg-primary); word-break: break-word; }
.proj-row__count { flex-shrink: 0; font-size: 11px; color: var(--fg-tertiary); }

.empty { text-align: center; padding: 32px 16px; color: var(--fg-tertiary); }
.empty h4 { color: var(--fg-primary); font-size: 14px; margin: 12px 0 4px; }
.empty p { font-size: 13px; margin: 0; }
.empty .qa-btn { margin-top: 14px; }

.invite-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--brand-primary-soft); margin-bottom: 8px; border: 1px solid rgba(79,70,229,.15); }
.invite-card .invite-ws { font-weight: 700; font-size: 13px; }
.invite-card .invite-by { font-size: 11.5px; color: var(--fg-secondary); }

/* ============================================================
 * Project page (basic — to be expanded in Phase 3)
 * ============================================================ */
.proj-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.proj-head__color { width: 8px; height: 36px; border-radius: 3px; flex-shrink: 0; }
.proj-head__name { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.proj-head__sub { font-size: 13px; color: var(--fg-secondary); }
.proj-head__title { min-width: 0; }
.proj-head__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* 운영 #29 재: 모바일 — 프로젝트명 ↑ / 액션 3개 ↓ 두 줄 */
@media (max-width: 700px) {
  .proj-head { flex-wrap: wrap; gap: 10px; }
  .proj-head__title { flex: 1 1 calc(100% - 22px); }  /* 색상점(8px) + gap(14px) 제외 한 줄 차지 */
  .proj-head__name { font-size: 18px; word-break: break-word; }
  .proj-head__actions { flex: 1 1 100%; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
  .proj-head__actions a, .proj-head__actions button { font-size: 12px !important; padding: 6px 10px !important; flex: 0 0 auto; }
  .proj-head__actions #proj-new-task { margin-left: auto; }
}

.col-board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; }
@media (max-width: 900px) {
  .col-board { grid-template-columns: repeat(5, 280px); }
}
.col {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  min-height: 240px;
}
.col__head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 12px; font-weight: 700; }
.col__dot { width: 7px; height: 7px; border-radius: 50%; }
.col__count { font-size: 10px; padding: 1px 6px; background: var(--alpha-neutral-08); border-radius: 999px; color: var(--fg-tertiary); }
.col__head.is-intake .col__dot { background: var(--status-intake); }
.col__head.is-pending .col__dot { background: var(--status-pending); }
.col__head.is-progress .col__dot { background: var(--status-progress); }
.col__head.is-review .col__dot { background: var(--status-review); }
.col__head.is-rejected .col__dot { background: var(--status-rejected); }

.task-card { background: var(--chrome-bg); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; position: relative; cursor: pointer; }
.task-card:hover { box-shadow: var(--shadow-1); }
.task-card__title { font-size: 13px; font-weight: 600; color: var(--fg-primary); margin: 0 0 6px; line-height: 1.35; }
.task-card__meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--fg-tertiary); }
.task-card__strip { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 10px 0 0 10px; }
.task-card__strip.is-urgent { background: var(--priority-urgent); }
.task-card__strip.is-high   { background: var(--priority-high); }
.task-card__strip.is-normal { background: transparent; }
