:root {
  --ink: #222222;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --paper: #f3f3f3;
  --card: #ffffff;
  --brand: #2f7a38;
  --tag: #f4f4f4;
  --pay: #f6f6f6;
  --sel: #2f7a38;
  --danger: #c24a32;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --header-h: 68px;
  --touch: 44px;
}
* { box-sizing: border-box; }
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
.site {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  padding-top: var(--safe-top);
  height: calc(var(--header-h) + var(--safe-top));
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 20;
}
.logo { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; min-width: 0; }
.logo span { min-width: 0; }
.logo strong { display: block; font-size: 14px; }
.logo small { display: block; font-size: 11px; color: var(--muted); }
.brand-logo {
  display: block;
  height: 52px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.site button, .btn, .site nav a.btn {
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 12px;
  cursor: pointer;
  min-height: 40px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.site nav a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.site nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.lang { display: flex; border: 1px solid var(--line); flex-shrink: 0; }
.lang button {
  font: inherit; font-size: 12px; padding: 6px 9px; border: 0; border-right: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer;
  min-height: 36px; touch-action: manipulation;
}
.lang button:last-child { border-right: 0; }
.lang button.on { background: var(--brand); color: #fff; }
.lang button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.lang-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.btn.solid { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.ghost { background: #fff; }
.btn.wide { min-width: 160px; font-weight: 700; }
.toolbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 8px;
  flex-shrink: 0;
}
.search {
  display: grid;
  grid-template-columns: 1.2fr minmax(110px, 140px) minmax(120px, 150px) minmax(120px, 150px) minmax(130px, 160px) auto;
  gap: 8px;
}
.search select {
  font: 16px inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  min-width: 0;
  min-height: var(--touch);
  border-radius: 0;
}
.search input, .match input, .match textarea, label input, label textarea, label select {
  font: 16px inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  min-height: var(--touch);
  width: 100%;
  max-width: 100%;
  border-radius: 0;
}
.match textarea { min-height: 72px; }
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  margin-top: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  border-radius: 999px;
  flex: 0 0 auto;
  min-height: 36px;
  touch-action: manipulation;
}
.chip.on { border-color: var(--brand); color: var(--brand); background: #f3f8f3; }
.hot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.hot {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.hot::-webkit-scrollbar { display: none; }
.hot button {
  flex: 0 0 auto;
  max-width: min(80vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  cursor: pointer;
  min-height: 36px;
  touch-action: manipulation;
}
.match-box { margin-top: 6px; font-size: 13px; color: var(--muted); }
.match-box summary {
  cursor: pointer;
  padding: 8px 0;
  min-height: 36px;
  touch-action: manipulation;
}
.match { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 8px; align-items: start; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.split {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 400px) 1fr;
  min-height: 0;
  overflow: hidden;
}
.pane-list, .pane-detail {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.pane-list { border-right: 1px solid var(--line); background: #fafafa; }
.pane-detail { background: #fff; }
.list-head {
  position: sticky;
  top: 0;
  background: #fafafa;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.feed { display: flex; flex-direction: column; }
.job-card {
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 14px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  display: block;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.job-card:hover { background: #f7fbf7; }
.job-card:active { background: #eef6ef; }
.job-card.on {
  background: #fff;
  box-shadow: inset 3px 0 0 var(--brand);
}
.job-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  word-break: break-word;
}
.job-card .co { display: none; }
.job-card .loc { font-size: 12px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 6px; }
.tag {
  font-size: 11px;
  border: 1px solid var(--line);
  background: var(--tag);
  padding: 2px 7px;
  color: #444;
}
.pay {
  background: var(--pay);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 700;
}
.score { color: var(--brand); font-size: 12px; margin-bottom: 4px; }
.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  position: sticky;
  bottom: 0;
  background: #fafafa;
  border-top: 1px solid var(--line);
}
.pager .btn { min-width: 88px; min-height: var(--touch); }
.empty-detail, .empty-list {
  color: var(--muted);
  padding: 48px 24px;
  text-align: center;
}
.detail-head {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px 24px 14px;
  z-index: 2;
}
.back-list { display: none; margin-bottom: 8px; }
.detail-head h1 { font-size: 22px; margin: 0 0 6px; font-weight: 700; line-height: 1.35; word-break: break-word; }
.detail-head .co { margin: 0 0 8px; word-break: break-word; }
.facts { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-bottom: 12px; }
.facts b { font-weight: 600; }
.cta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-body { padding: 8px 24px 40px; max-width: 760px; }
.sec { margin: 18px 0; }
.sec h2 { font-size: 15px; margin: 0 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.body { font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
label { display: grid; gap: 4px; font-size: 12px; margin: 8px 0; color: var(--muted); }
label.meta { display: flex; align-items: flex-start; gap: 10px; }
label.meta input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
}
.error { color: var(--danger); font-size: 13px; }
.ok { color: #2f7d4a; font-size: 13px; }
.modal {
  position: fixed; inset: 0; background: #00000055; place-items: center; padding: 20px; z-index: 40;
  display: none;
  pointer-events: none;
  padding-top: max(20px, var(--safe-top));
  padding-bottom: max(20px, var(--safe-bottom));
}
.modal.is-open { display: grid; pointer-events: auto; }
.sheet {
  background: #fff; max-width: 480px; width: 100%; max-height: 92vh; max-height: 92dvh; overflow: auto; padding: 22px;
  border: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
}
.profile-btn span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-btn[hidden], .profile-view[hidden] { display: none !important; }
.profile-btn img, .avatar-lg, .avatar-sm {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #e8f3ea;
}
.avatar-lg { width: 72px; height: 72px; }
.avatar-fallback {
  display: grid; place-items: center; font-weight: 700; color: var(--brand); font-size: 12px;
}
.profile-view {
  position: fixed;
  inset: calc(var(--header-h) + var(--safe-top)) 0 0;
  background: #f3f3f3;
  z-index: 25;
  overflow: auto;
  padding: 20px 16px calc(48px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
.profile-wrap { max-width: 860px; margin: 0 auto; display: grid; gap: 14px; }
.profile-card { background: #fff; border: 1px solid var(--line); padding: 16px 18px; }
.profile-card h2 { margin: 0 0 10px; font-size: 16px; }
.profile-top { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.job-mini {
  display: block; width: 100%; text-align: left; font: inherit; background: #fff;
  border: 1px solid var(--line); padding: 12px; margin-top: 8px; cursor: pointer;
  min-height: var(--touch); touch-action: manipulation;
}
.job-mini:hover { border-color: var(--brand); }
.pipe { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pipe span { font-size: 11px; padding: 4px 8px; border: 1px solid var(--line); }
.pipe span.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.staff-box { display: grid; gap: 4px; font-size: 13px; }
.staff-box a { color: var(--brand); }

@media (max-width: 860px) {
  :root { --header-h: auto; }

  /* Một trang cuộn dọc: tìm kiếm + list cùng scroll (không khóa toolbar). */
  body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
  }

  .site {
    position: sticky;
    top: 0;
    height: auto;
    min-height: 52px;
    padding: 8px 12px;
    padding-top: max(8px, var(--safe-top));
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  .logo { flex: 1 1 auto; }
  .logo small { display: none; }
  .logo strong { font-size: 13px; line-height: 1.25; }
  .brand-logo { height: 40px; }

  .site nav {
    width: 100%;
    flex-wrap: wrap;
    overflow: visible;
    gap: 6px;
    padding-bottom: 2px;
  }
  .site nav .btn,
  .site nav button {
    flex: 1 1 auto;
    font-size: 13px;
    padding: 10px 12px;
    min-height: 44px;
    white-space: normal;
    line-height: 1.25;
    text-align: center;
  }
  .profile-btn { max-width: none; flex: 1 1 100%; justify-content: center; }
  .profile-btn span:last-child { max-width: none; }

  .toolbar {
    padding: 10px 12px 8px;
    max-height: none;
    overflow: visible;
    flex-shrink: 0;
  }
  .search {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .search input,
  .search select {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    padding: 12px 14px;
  }
  .search .btn.solid {
    grid-column: 1 / -1;
    min-height: 48px;
    width: 100%;
    font-size: 16px;
    font-weight: 700;
  }
  .match { grid-template-columns: 1fr; }
  .match .btn.solid { width: 100%; min-height: var(--touch); }

  .split {
    display: block;
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
  }
  .pane-list {
    overflow: visible;
    border-right: 0;
  }
  .pane-detail { display: none; }
  .list-head { position: static; }
  .pager {
    position: static;
    padding: 12px 12px calc(16px + var(--safe-bottom));
  }

  body.show-detail {
    overflow: hidden;
    height: 100dvh;
  }
  body.show-detail .site { display: none; }
  body.show-detail .pane-list { display: none; }
  body.show-detail .pane-detail {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }
  body.show-detail .toolbar { display: none; }
  body.show-detail .split {
    display: block;
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .back-list {
    display: inline-flex !important;
    align-items: center;
    min-height: var(--touch);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
  }

  .detail-head {
    position: relative;
    padding: 12px 14px 10px;
    flex-shrink: 0;
  }
  .detail-head h1 { font-size: 18px; }
  .facts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    font-size: 13px;
  }
  .facts span {
    background: #f7f7f7;
    padding: 8px 10px;
  }

  body.show-detail .detail-head .cta {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    margin: 0;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  body.show-detail .detail-head .cta .btn.wide {
    min-width: 0;
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  body.show-detail .detail-head .cta #likeBtn {
    min-width: 56px;
    min-height: 48px;
  }
  body.show-detail .detail-body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 14px calc(96px + var(--safe-bottom));
    max-width: none;
  }
  body.show-detail .detail-head .tags {
    max-height: 72px;
    overflow: auto;
  }

  #applyForm .btn.solid {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
  }

  .modal {
    place-items: end center;
    padding: 0;
  }
  .sheet {
    max-width: none;
    width: 100%;
    max-height: 90dvh;
    border: 0;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(20px + var(--safe-bottom));
  }

  .profile-view {
    inset: 0;
    padding-top: max(12px, var(--safe-top));
    z-index: 35;
  }
  .profile-card { padding: 14px; }
  .profile-top { flex-direction: column; align-items: stretch; }
}

@media (max-width: 380px) {
  .logo strong { font-size: 12px; }
  .site nav .btn,
  .site nav button { font-size: 11px; padding: 7px 8px; }
  .detail-head h1 { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* Floating chat CTA (Messenger / LINE / Zalo) */
.chat-fab {
  position: fixed;
  right: max(16px, var(--safe-right));
  bottom: max(16px, var(--safe-bottom));
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(300px, calc(100vw - 32px));
  pointer-events: none;
}
.chat-fab > * { pointer-events: auto; }
.chat-fab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  font: inherit;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(47, 122, 56, 0.35);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.chat-fab-btn:hover { filter: brightness(1.05); }
.chat-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.chat-fab-icon svg { display: block; }
.chat-fab-panel {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}
.chat-fab-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}
.chat-fab-note {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.chat-fab-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-fab-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.chat-fab-link--messenger { background: #0084ff; }
.chat-fab-link--line { background: #06c755; }
.chat-fab-link--zalo { background: #0068ff; }
.chat-fab-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.chat-fab-close {
  margin-top: 10px;
  width: 100%;
  font: inherit;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  min-height: 40px;
  touch-action: manipulation;
}

@media (max-width: 900px) {
  body.show-detail .chat-fab {
    bottom: calc(72px + var(--safe-bottom));
  }
}

@media (max-width: 380px) {
  .chat-fab-btn {
    width: 48px;
    height: 48px;
  }
}
