:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #18211f;
  --muted: #66706d;
  --line: #dfe5e2;
  --teal: #185f57;
  --teal-dark: #104a44;
  --teal-soft: #e7f1ef;
  --coral: #c9583f;
  --amber: #b87818;
  --sidebar: #17201e;
  --sidebar-muted: #aeb9b5;
  --shadow: 0 12px 34px rgba(24, 33, 31, .16);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(24, 95, 87, .23);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #fff;
  padding: 24px 14px 18px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 24px; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--coral);
  color: #fff;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; }
.brand small { margin-top: 3px; color: var(--sidebar-muted); font-size: 12px; }
.project-nav { display: grid; gap: 4px; overflow-y: auto; }
.project-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d9e1de;
  padding: 9px 11px;
  cursor: pointer;
  text-align: left;
}
.project-button:hover { background: rgba(255, 255, 255, .07); }
.project-button.active { background: var(--teal); color: #fff; font-weight: 700; }
.project-count { color: var(--sidebar-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.project-button.active .project-count { color: #dcecea; }
.sidebar-foot {
  margin-top: auto;
  padding: 18px 10px 0;
  border-top: 1px solid rgba(255,255,255,.12);
  color: var(--sidebar-muted);
  font-size: 11px;
  line-height: 1.8;
}
.sidebar-foot span { display: block; }

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 14px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 245, .96);
  backdrop-filter: blur(10px);
}
.search-wrap { position: relative; flex: 1; max-width: 760px; }
.search-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 42px;
  border: 1px solid #cfd8d4;
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 7px rgba(24, 33, 31, .04);
}
.search-wrap input::placeholder { color: #8a9491; }
.search-wrap input:focus { border-color: var(--teal); outline: 3px solid rgba(24,95,87,.14); }
.search-icon { position: absolute; left: 15px; top: 9px; color: var(--teal); font-size: 25px; line-height: 1; }
.clear-search {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  visibility: hidden;
}
.clear-search.visible { visibility: visible; }
.clear-search:hover { background: #eef2f0; }
.favorites-button, .reset-button, .secondary-button, .primary-button, .empty-state button {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.favorites-button { border: 1px solid #cfd8d4; background: #fff; color: var(--ink); white-space: nowrap; }
.favorites-button.active { border-color: var(--amber); background: #fff7e8; color: #7a4b00; }
.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 23px;
}
.icon-button:hover { background: #e8eeeb; }
.menu-button { display: none; }

.workspace { max-width: 1520px; margin: 0 auto; padding: 28px clamp(18px, 3vw, 42px) 56px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 5px; color: var(--coral); font-size: 13px; font-weight: 800; }
h1 { margin: 0; font-size: clamp(25px, 2.6vw, 36px); line-height: 1.2; }
.result-count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: thin; }
.category-tab {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid #cfd8d4;
  border-radius: 6px;
  background: var(--surface);
  color: #46504d;
  padding: 0 13px;
  cursor: pointer;
}
.category-tab.active { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-dark); font-weight: 800; }
.category-tab .tab-count { margin-left: 6px; color: #7d8784; font-size: 12px; }
.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.filterbar label { display: grid; gap: 5px; min-width: 154px; }
.filterbar label span { color: var(--muted); font-size: 11px; font-weight: 700; }
.filterbar select {
  height: 38px;
  border: 1px solid #cfd8d4;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 34px 0 10px;
}
.reset-button { border: 0; background: transparent; color: var(--teal); }
.reset-button:hover { background: var(--teal-soft); }
.active-search { margin: -4px 0 18px; color: var(--muted); font-size: 13px; }
.active-search strong { color: var(--ink); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 16px;
}
.result-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.result-card:hover { transform: translateY(-2px); border-color: #bdcbc6; box-shadow: 0 9px 24px rgba(24,33,31,.09); }
.card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 13 / 8;
  border-bottom: 1px solid var(--line);
  background: #e8edeb;
  overflow: hidden;
}
.preview-hit { width: 100%; height: 100%; border: 0; padding: 0; background: transparent; cursor: pointer; }
.preview-hit img { width: 100%; height: 100%; object-fit: cover; display: block; }
.document-preview { width: 100%; height: 100%; display: grid; place-items: center; background: #edf1ef; }
.file-badge {
  min-width: 66px;
  padding: 14px 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid #ccd5d1;
  color: var(--teal-dark);
  box-shadow: 0 5px 16px rgba(24,33,31,.08);
  font-weight: 900;
  font-size: 15px;
}
.quick-favorite {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 50%;
  background: rgba(18,28,26,.72);
  color: #fff;
  font-size: 21px;
  cursor: pointer;
}
.quick-favorite.active { background: #fff4d8; border-color: #e1b24f; color: #8a5700; }
.card-body { display: flex; flex: 1; flex-direction: column; padding: 13px 14px 14px; }
.card-labels { display: flex; flex-wrap: wrap; gap: 5px; min-height: 24px; }
.label { border-radius: 4px; padding: 3px 6px; font-size: 10px; font-weight: 800; }
.label.category { background: var(--teal-soft); color: var(--teal-dark); }
.label.stage { background: #fff0ec; color: #98402d; }
.label.campus { background: #f3eddf; color: #765420; }
.card-title {
  margin: 9px 0 8px;
  min-height: 44px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.card-open { color: var(--teal); border: 0; background: transparent; padding: 3px 0; font-weight: 800; cursor: pointer; }

.empty-state { padding: 64px 16px; text-align: center; color: var(--muted); }
.empty-symbol { font-size: 50px; color: #a3afaa; }
.empty-state h2 { margin: 8px 0 5px; color: var(--ink); font-size: 20px; }
.empty-state p { margin: 0 0 18px; }
.empty-state button { border: 0; background: var(--teal); color: #fff; }

.backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(12,20,18,.44); }
.preview-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.preview-dialog::backdrop { background: rgba(12,20,18,.44); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.dialog-header p { margin: 0 0 5px; color: var(--coral); font-size: 12px; font-weight: 800; }
.dialog-header h2 { margin: 0; max-width: 760px; font-size: 20px; line-height: 1.4; overflow-wrap: anywhere; }
.preview-stage { min-height: 290px; max-height: 56vh; display: grid; place-items: center; overflow: auto; background: #edf1ef; }
.preview-stage img { display: block; max-width: 100%; max-height: 56vh; object-fit: contain; }
.preview-stage object { width: 100%; height: 56vh; border: 0; }
.document-large { display: grid; place-items: center; gap: 10px; min-height: 290px; color: var(--muted); }
.document-large .file-badge { padding: 22px 17px; font-size: 20px; }
.dialog-details { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 14px 22px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.dialog-details strong { color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 22px 20px; }
.secondary-button { border: 1px solid #cfd8d4; background: #fff; color: var(--ink); }
.primary-button { border: 1px solid var(--teal); background: var(--teal); color: #fff; }
.primary-button:hover { background: var(--teal-dark); }

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 250px; transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: grid; flex: 0 0 auto; }
  .topbar { padding: 12px 16px; }
  .favorites-button { width: 42px; padding: 0; font-size: 0; }
  .favorites-button span { font-size: 22px; }
  .workspace { padding: 23px 16px 42px; }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media (max-width: 540px) {
  .topbar { gap: 7px; }
  .search-wrap input { height: 42px; padding-left: 37px; font-size: 14px; }
  .search-icon { left: 12px; top: 8px; }
  .page-heading { align-items: start; margin-bottom: 18px; }
  h1 { font-size: 26px; }
  .filterbar { display: grid; grid-template-columns: 1fr 1fr; }
  .filterbar label { min-width: 0; }
  .filterbar label:nth-child(3) { grid-column: 1 / 2; }
  .reset-button { grid-column: 2 / 3; }
  .results-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card-body { padding: 10px; }
  .card-title { min-height: 40px; font-size: 13px; }
  .label { font-size: 9px; }
  .card-meta { font-size: 10px; }
  .preview-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .dialog-header { padding: 16px; }
  .dialog-header h2 { font-size: 17px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; padding: 12px 16px 16px; }
  .dialog-actions .primary-button { grid-column: 1 / 3; }
}

@media (max-width: 390px) {
  .results-grid { grid-template-columns: 1fr; }
  .card-title { min-height: auto; }
}
