/* ---------- Tokens ---------- */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #0ea5e9;
  --accent-ink: #0369a1;
  --accent-soft: #e0f2fe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
  --container: 1100px;
}
[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #0f172a;
  --surface-2: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #1e293b;
  --border-strong: #334155;
  --accent: #38bdf8;
  --accent-ink: #7dd3fc;
  --accent-soft: #0c4a6e;
  --danger-soft: #450a0a;
  --ok-soft: #064e3b;
  --warn-soft: #422006;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.5);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: auto; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  font-size: 15px;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.wrap { max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
h1, h2, h3, h4 { letter-spacing: -0.015em; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; padding: 12px 20px; }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 18px; color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 14px rgba(14,165,233,.35);
}
.nav { margin-left: auto; display: flex; gap: 22px; }
.nav a { color: var(--muted); font-weight: 500; font-size: 14px; }
.nav a:hover { color: var(--text); text-decoration: none; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer;
  color: var(--text);
  display: inline-grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { border-color: var(--border-strong); }

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 28px;
  background:
    radial-gradient(800px 300px at 10% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    radial-gradient(600px 260px at 90% 10%, color-mix(in srgb, #6366f1 10%, transparent), transparent 60%);
}
.hero h1 {
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.15;
  font-weight: 800;
  margin: 0 0 12px;
}
.grad {
  background: linear-gradient(90deg, var(--accent), #6366f1);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.lede { color: var(--muted); font-size: 16px; margin: 0 0 22px; max-width: 640px; }

.searchbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: 640px;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-ic { color: var(--muted); flex-shrink: 0; }
.searchbar input {
  flex: 1; border: 0; outline: 0; background: transparent;
  padding: 14px 0; font-size: 15px; color: var(--text);
  font-family: inherit;
}
/* Hide native browser clear button */
.searchbar input::-webkit-search-cancel-button,
.searchbar input::-webkit-search-decoration {
  display: none;
}
.search-clear {
  flex-shrink: 0; cursor: pointer;
  background: none; border: none; color: var(--muted);
  padding: 4px 8px; font-size: 18px; line-height: 1;
  transition: color .15s, opacity .15s;
  opacity: 0;
  pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.search-clear:hover { color: var(--text); }
.searchbar input:not(:placeholder-shown) ~ .search-clear {
  opacity: 1;
  pointer-events: auto;
}

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-top: 28px;
}
.stats > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stats b { display: block; font-size: 22px; font-weight: 800; }
.stats span { color: var(--muted); font-size: 12px; }

/* ---------- Filters ---------- */
.filterbar {
  position: sticky; top: 58px; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  margin-top: 32px;
}
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding-bottom: 4px;
}
.chips::-webkit-scrollbar { display: none; }
.chips.cats { margin-top: 8px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.active {
  background: var(--text); color: var(--surface); border-color: var(--text);
}

/* ---------- Feed ---------- */
.feed-wrap { padding: 24px 20px 48px; }
.feed-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.feed-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.count { color: var(--muted); font-size: 13px; }

.feed { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 780px) { .feed { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
  display: flex; flex-direction: column; gap: 12px;
}
.card:hover, .card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  outline: none;
}

.card-top { display: flex; gap: 12px; align-items: flex-start; }
.card-logo {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  border: 1px solid var(--border);
}
.card-head { flex: 1; min-width: 0; }
.title {
  margin: 0 0 4px; font-size: 16px; font-weight: 700; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; }
.dot { opacity: .5; }
.org { font-weight: 500; color: var(--text); }

.type-pill {
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  white-space: nowrap; flex-shrink: 0;
}
.type-pill.private { background: var(--ok-soft); color: var(--ok); }

.desc {
  margin: 0; font-size: 14px; color: var(--muted);
}

.card .desc {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-section .desc {
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.6;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; font-weight: 500;
  padding: 3px 9px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.tag:empty { display: none; }

.foot-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.deadline { color: var(--muted); }
.deadline.soon { color: var(--danger); font-weight: 600; }
.badge {
  padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 11px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.badge.soon { background: var(--danger-soft); color: var(--danger); }
.badge.expired { background: var(--surface-2); color: var(--muted); }
.badge.new { background: var(--ok-soft); color: var(--ok); }

/* ---------- Skeleton ---------- */
.skeleton {
  height: 180px; border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer { 0% {background-position: 200% 0;} 100% {background-position: -200% 0;} }
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-container {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.empty-container .empty {
  padding: 0;
  margin: 0;
}
.empty-container .empty strong {
  color: var(--text);
  display: block;
  font-size: 16px;
  margin-bottom: 6px;
}
.empty-container .empty br + br { display: none; }
.clear-search-btn {
  background: var(--accent); color: white;
  border: none; padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
  font-family: inherit;
}
.clear-search-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(4px); animation: fade .2s; }
.modal-panel {
  position: relative; z-index: 1;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: pop .2s ease-out;
}
@keyframes fade { from {opacity: 0;} to {opacity: 1;} }
@keyframes pop { from {opacity: 0; transform: translateY(10px) scale(.98);} to {opacity:1; transform: none;} }
@keyframes fadeOut { from {opacity: 1;} to {opacity: 0;} }
@keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} }
.page-transition-out { animation: fadeOut .3s ease-out forwards; }
.page-transition-in { animation: fadeIn .3s ease-out forwards; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 20px; cursor: pointer; color: var(--text);
  line-height: 1;
}
.modal h3 { margin: 0 0 6px; font-size: 22px; }
.modal .modal-meta { color: var(--muted); margin-bottom: 18px; font-size: 14px; }
.modal .modal-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0;
  padding: 16px; background: var(--surface-2); border-radius: 12px;
}
.modal .modal-grid div b { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; font-weight: 600; }
.modal .apply-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--text); color: var(--surface);
  padding: 12px 22px; border-radius: 999px; font-weight: 600;
  margin-top: 8px;
}
.modal .apply-btn:hover { text-decoration: none; opacity: .9; }
.modal-body-text { font-size: 14.5px; line-height: 1.65; color: var(--text); }

/* ---------- Footer ---------- */
.footer {
  margin-top: 40px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 40px 0 20px;
}
.footer-grid {
  display: grid; grid-template-columns: 1.8fr 0.95fr 1.2fr 0.95fr 0.9fr; gap: 24px;
}
.footer h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.footer ul a { color: var(--text); font-size: 14px; }
.footer ul a:hover { color: var(--accent-ink); text-decoration: none; }
.footer-bottom {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 32px; padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted); flex-wrap: wrap;
}
@media (max-width: 680px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .nav { display: none; }
  .hero { padding: 36px 0 16px; }
}

/* ---------- Job detail page ---------- */
.job-view { padding: 28px 0 48px; }
.job-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 900px) {
  .job-detail { grid-template-columns: 1fr; }
}

.breadcrumb {
  grid-column: 1/-1;
  font-size: 13px; color: var(--muted);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); text-decoration: none; }
.breadcrumb span { opacity: .6; }
.breadcrumb .bc-title { color: var(--text); font-weight: 500; }

.job-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 560px) { .job-main { padding: 22px; } }

.job-header { border-bottom: 1px solid var(--border); padding-bottom: 22px; margin-bottom: 24px; }
.job-header-top { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.job-logo {
  width: 60px; height: 60px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 22px;
  border: 1px solid var(--border);
}
.job-header-text { flex: 1; min-width: 0; }
.job-header-text .type-pill { margin-bottom: 8px; display: inline-block; }
.job-header-text .title {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  line-height: 1.25;
}
.job-org { color: var(--muted); margin: 0; font-size: 15px; }
.job-org .org { color: var(--text); }

.job-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--text); color: var(--surface);
  padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  border: 0; cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.btn-primary:hover { text-decoration: none; opacity: .9; transform: translateY(-1px); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); color: var(--text);
  padding: 12px 18px; border-radius: 999px;
  font-weight: 500; font-size: 14px;
  border: 1px solid var(--border); cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { border-color: var(--border-strong); }

.job-facts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 28px;
}
.job-facts > div { background: var(--surface); padding: 14px 16px; }
.job-facts b { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; font-weight: 600; }
.job-facts span { font-size: 14px; font-weight: 500; }
.job-facts .deadline.soon { color: var(--danger); font-weight: 600; }
@media (max-width: 560px) {
  .job-facts { grid-template-columns: repeat(2, 1fr); }
}

.job-section { margin: 28px 0; }
.job-section h2 {
  font-size: 17px; font-weight: 700; margin: 0 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.job-section h2::before {
  content: ''; width: 4px; height: 18px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), #6366f1);
}
.job-section .desc { font-size: 15px; line-height: 1.75; color: var(--text); margin: 0; white-space: pre-wrap; }

.eligibility-list, .apply-steps {
  margin: 0; padding-left: 20px;
  font-size: 15px; line-height: 1.8;
}
.apply-steps li { padding-left: 6px; margin-bottom: 6px; }
.eligibility-list li { padding-left: 6px; margin-bottom: 4px; }

.source-sec p { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.source-sec a { word-break: break-all; }

.job-cta {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  margin-top: 32px; padding: 22px 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.job-cta h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.job-cta p { margin: 0; font-size: 13px; }

/* Sidebar */
.job-aside { position: sticky; top: 80px; }
@media (max-width: 900px) { .job-aside { position: static; } }
.similar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: default;
}
.similar-card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.similar-card h3 { margin: 0 0 14px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.similar-list { display: flex; flex-direction: column; gap: 4px; }
.similar-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 8px; border-radius: 10px;
  color: var(--text); text-decoration: none;
  transition: background .15s;
}
.similar-item:hover { background: var(--surface-2); text-decoration: none; }
.s-logo {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  border: 1px solid var(--border);
}
.s-text { min-width: 0; flex: 1; }
.s-title { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.s-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Article pages ---------- */
.article {
  max-width: 780px; margin: 40px auto; padding: 0 20px 60px;
}
.article h1 { font-size: clamp(26px, 3.5vw, 36px); margin: 0 0 8px; }
.article .updated { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.article h2 { font-size: 20px; margin: 32px 0 8px; }
.article p, .article li { color: var(--text); font-size: 15px; line-height: 1.75; }
.article ul { padding-left: 20px; }
.article a { color: var(--accent-ink); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  padding: 24px 0;
  flex-wrap: wrap;
  gridColumn: 1 / -1;
}
.pagination-btn, .pagination-page {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.pagination-btn:hover:not(:disabled),
.pagination-page:hover:not(.active) {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.pagination-page.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-2);
}
.pagination-ellipsis {
  padding: 0 6px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 600px) {
  .pagination {
    gap: 4px;
  }
  .pagination-btn, .pagination-page {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 13px;
  }
}
