/* Shared visual system for the existing vanilla HTML pages. */
:root {
  --bg: #f4f1eb;
  --card: #fffdfa;
  --line: #d8c5aa;
  --line-soft: #ebe1d5;
  --text: #2d2924;
  --sub: #70675d;
  --brand: #8d5e30;
  --brand-soft: #f3e7d8;
  --ok: #28734a;
  --err: #b64035;
  --surface-muted: #f8f4ee;
  --shadow-card: 0 4px 16px rgba(71, 49, 27, .055);
  color-scheme: light;
}

* { -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(141, 94, 48, .28);
  outline-offset: 2px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand) !important; box-shadow: 0 0 0 3px rgba(141, 94, 48, .1); }

/* User workspace */
.page-header { min-height: 78px; }
.page-header-brand { gap: 10px; }
.page-header img.logo-site { box-shadow: 0 2px 8px rgba(56, 39, 22, .12); }
.page-title { color: #28231e; letter-spacing: -.025em; }
.page-title-sub { color: var(--brand); }
.page-header-right .contact-trigger { color: var(--brand); }
.side-btn {
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(71, 49, 27, .035);
}
.side-btn.active { box-shadow: 0 4px 12px rgba(141, 94, 48, .18); }
.card {
  background: var(--card);
  border-color: var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}
.card h2 { color: #2d2924; letter-spacing: -.01em; }
.search-panel {
  display: grid;
  grid-template-columns: repeat(7, minmax(85px, 1fr)) repeat(2, minmax(122px, 1.2fr)) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border-color: var(--line-soft);
  background: var(--card);
  box-shadow: var(--shadow-card);
}
.search-panel .field { min-width: 0; flex: initial; }
.search-panel .field-range { min-width: 0; flex: initial; }
.search-panel .actions { grid-column: auto; flex: initial; justify-content: flex-end; white-space: nowrap; }
.search-panel .field label { color: #635a50; font-size: 12px; font-weight: 700; }
.search-panel input, .search-panel select, .search-panel .city-select-btn {
  min-height: 38px;
  border-color: #ded0be;
  background: #fff;
  color: var(--text);
}
.search-panel .btn-primary, .btn-primary { background: var(--brand); font-weight: 700; }
.btn-primary:hover { background: #754a22; box-shadow: 0 3px 10px rgba(94, 59, 26, .2); }
.btn-light { border: 1px solid var(--line-soft); background: #f7efe4; color: #76502b; }
.btn-light:hover { border-color: var(--line); background: #efe1cf; }

@media (min-width: 901px) and (max-width: 1199px) {
  .search-panel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .search-panel .field-range, .search-panel .actions { grid-column: span 2; }
  .search-panel .actions { justify-self: end; }
}
.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 32px;
  margin: 14px 2px 0;
  color: #5e574f;
  font-size: 12px;
}
.table-card {
  border-color: var(--line-soft);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  scrollbar-color: #c6b299 #f4ede4;
}
.table-card th { background: #f0e4d3; color: #3d3328; }
.table-card tbody tr:hover td { background-color: #fbf3e7; }
.mcard { border-color: var(--line-soft); box-shadow: var(--shadow-card); }
.mcard-head { border-color: #e7dac9; }
.ci-card {
  min-height: 72px;
  border-color: var(--line-soft);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(71, 49, 27, .035);
}
.ci-card:hover, .ci-card:focus-visible { transform: translateY(-1px); box-shadow: var(--shadow-card); }
.ci-campus-card, .major-job-card { border-color: var(--line-soft); border-radius: 12px; }
.ci-campus-head { color: var(--brand); }
.mj-directory { border-color: var(--line-soft); border-radius: 12px; box-shadow: var(--shadow-card); }
.mj-column-heading, .mj-list-heading { background: #f2e9dd; border-color: var(--line-soft); }
.mj-major-card { border-color: var(--line-soft); border-radius: 12px; box-shadow: 0 1px 4px rgba(71, 49, 27, .035); }
.ana-block { border-color: var(--line-soft); border-radius: 12px; box-shadow: var(--shadow-card); }
.pagination button { min-height: 34px; }
.site-footer { color: #6e665c; }
.mobile-filter-toolbar { display: none; }
.mobile-filter-backdrop, .filter-drawer { display: contents; }
.mobile-filter-header { display: none; }
.active-filter-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 0; }
.active-filter-chips.has-filters { padding: 8px 2px 8px; }
.filter-chip-label { margin-right: 2px; color: #777066; font-size: 12px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 280px;
  padding: 5px 9px;
  border: 1px solid #e5d6c4;
  border-radius: 999px;
  background: #fffaf4;
  color: #684a2c;
  font-size: 12px;
}
.filter-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chip b { font-size: 15px; font-weight: 500; line-height: 1; }
.filter-chip:hover { border-color: var(--brand); background: var(--brand-soft); }
.mj-school-list .mj-group-major-details { display: none; }

/* Admin workspace */
.wrap { max-width: 1440px; }
.top { margin-bottom: 16px; }
.title { color: #28231e; letter-spacing: -.02em; }
.tabs {
  position: sticky;
  top: 8px;
  z-index: 30;
  width: fit-content;
  max-width: 100%;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(255, 253, 250, .94);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
}
.tab-btn { border-color: transparent; color: #5a5148; font-weight: 600; }
.tab-btn:hover { background: var(--brand-soft); color: var(--brand); }
.tab-btn.active { box-shadow: 0 2px 7px rgba(94, 59, 26, .17); }
.admin .card, #panel-public.card { border-color: var(--line-soft); }
input, select, textarea { border-color: #ded0be; background-color: #fffdfa; }
button { font-weight: 600; }
.table-wrap { border-color: var(--line-soft); box-shadow: var(--shadow-card); scrollbar-color: #c6b299 #f4ede4; }
.table-wrap th { background: #f0e4d3; color: #3d3328; }
.table-wrap tbody tr:nth-child(even) { background: #fbf8f3; }

/* Login and dataset selection */
.login-main > .card, body > .card {
  border-color: var(--line-soft);
  background: rgba(255, 253, 250, .96);
  box-shadow: 0 16px 42px rgba(71, 49, 27, .1);
}
label.opt { border-color: var(--line-soft); background: #fff; }
label.opt.opt-on { border-color: var(--brand); background: #fbf3e8; box-shadow: 0 2px 8px rgba(141, 94, 48, .08); }

@media (max-width: 900px) {
  html { overflow-x: hidden; }
  body.app-shell { padding: 10px 10px calc(88px + env(safe-area-inset-bottom)); }
  .app-shell .layout, .app-shell .content { width: 100%; min-width: 0; max-width: 100%; }
  .app-shell .panel-pane, .app-shell .ci-panel, .app-shell .mobile-list { min-width: 0; max-width: 100%; }
  .ci-search input { min-width: 0; width: 0; }
  .ci-search button { flex-shrink: 0; }
  .ci-basic, .ci-campus-block .v, .mj-school-list, .mcard { overflow-wrap: anywhere; }
  .mj-school-list span { min-width: 0; max-width: 100%; white-space: normal; }
  .mobile-filter-open { flex-shrink: 0; }
  .mobile-filter-hint { min-width: 0; white-space: normal; overflow-wrap: anywhere; text-align: right; }
  .mrow .mlabel { white-space: normal; overflow: visible; text-overflow: clip; }
  .mrow .mval-nowrap { display: flex; flex-wrap: wrap; gap: 4px 12px; white-space: normal; overflow: visible; text-overflow: clip; }
  .mval-nowrap .year-value { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .page-header { margin-bottom: 4px; }
  .sidebar {
    position: fixed;
    z-index: 1000;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    height: auto;
    width: auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    padding: 6px;
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    background: rgba(255, 253, 250, .97);
    box-shadow: 0 8px 28px rgba(44, 33, 20, .16);
    backdrop-filter: blur(12px);
  }
  .side-btn { min-width: 0; padding: 9px 2px; border-color: transparent; border-radius: 10px; font-size: 11px; }
  .side-btn.active::before { left: 50%; top: 4px; width: 18px; height: 2px; transform: translateX(-50%); }
  .mobile-filter-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 6px; }
  .mobile-filter-open { min-height: 40px; padding: 8px 14px; border-color: var(--line); font-size: 13px; }
  .filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 2px; border-radius: 999px; background: #fffdfa; color: var(--brand); font-size: 11px; }
  .mobile-filter-hint { color: #787067; font-size: 11px; }
  .mobile-filter-backdrop { display: none; }
  .mobile-filter-backdrop.open {
    position: fixed;
    z-index: 1200;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-top: 8vh;
    background: rgba(35, 29, 22, .4);
    backdrop-filter: blur(2px);
  }
  body.filter-drawer-open { overflow: hidden; }
  .filter-drawer {
    display: flex;
    flex-direction: column;
    width: min(100%, 600px);
    max-height: 92dvh;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line-soft);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    background: var(--card);
    box-shadow: 0 -8px 32px rgba(35, 29, 22, .18);
    animation: filter-sheet-in .18s ease-out;
  }
  @keyframes filter-sheet-in { from { transform: translateY(18px); opacity: .7; } to { transform: none; opacity: 1; } }
  .mobile-filter-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 0 14px; }
  .mobile-filter-header strong { display: block; font-size: 17px; }
  .mobile-filter-header span { display: block; margin-top: 3px; color: #777066; font-size: 12px; }
  .drawer-close { flex: 0 0 36px; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line-soft); border-radius: 50%; background: #f7f1e8; color: #51483e; font-size: 24px; line-height: 1; }
  .search-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .search-panel .field { min-width: 0; }
  .search-panel .field-range, .search-panel #searchFieldFeature, .search-panel .actions { grid-column: 1 / -1; }
  .search-panel .field label { font-size: 12px; }
  .search-panel input, .search-panel select, .search-panel .city-select-btn { min-height: 42px; border-radius: 10px; font-size: 13px; }
  .search-panel .actions { position: sticky; bottom: 0; z-index: 2; margin: 4px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-soft); background: rgba(255, 253, 250, .98); }
  .search-panel .actions button { min-height: 44px; flex: 1; }
  .active-filter-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .active-filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip-label { flex: 0 0 auto; }
  .filter-chip { flex: 0 0 auto; max-width: 220px; }
  .meta { margin-top: 12px; }
  .mj-directory { grid-template-columns: minmax(0, 1fr); }
  .mj-nav-panel { border-right: 0; border-bottom: 1px solid var(--line-soft); padding: 0 12px 12px; }
  .mj-nav-panel .mj-column-heading { min-height: 0; padding: 10px 12px 4px; border-bottom: 0; background: transparent; }
  .mj-nav-list { display: none; }
  .mj-nav-select { display: block; }
  .mj-school-list { display: none; }
  .mj-school-mobile-picker { display: grid; gap: 8px; }
  .mj-school-mobile-picker label { color: var(--sub); font-size: 12px; }
  .mj-mobile-college-groups { min-width: 0; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 8px; background: #fffdf9; }
  .mj-mobile-college-groups .mj-group-major-details { display: block; }
  .mj-list-panel { border-top: 0; }
  .mcard { padding: 13px; border-radius: 13px; }
  .mcard-title { font-size: 15px; }
  #backTop { right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); }

  .tabs { position: relative; top: auto; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .tabs .tab-btn { flex: 0 0 auto; white-space: nowrap; }
  .wrap > .top { display: flex; align-items: center; }
  .wrap > .top .title { font-size: 23px; }
}

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