:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --line: #d5dce3;
  --text: #17212b;
  --muted: #5f6c7a;
  --primary: #1f3a57;
  --primary-2: #0f766e;
  --accent: #b36a16;
  --danger: #8f1d1d;
  --file-red: #b3261e;
  --chip-bg: #eaf0f4;
  --highlight: #ffe066;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border-radius: 6px;
  border: 1px solid transparent;
  height: 38px;
  padding: 0 14px;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.primary-btn:hover {
  background: #19324b;
}

.ghost-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.ghost-btn:hover {
  border-color: var(--primary-2);
  color: var(--primary-2);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(15, 118, 110, .55);
  outline-offset: 2px;
}

.icon-btn {
  width: 38px;
  padding: 0;
  background: transparent;
  border-color: var(--line);
  font-size: 20px;
  line-height: 1;
}

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(rgba(31, 58, 87, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 58, 87, .045) 1px, transparent 1px),
    var(--bg);
  background-size: 26px 26px;
}

.main-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

.sidebar {
  width: 212px;
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 92px);
  overflow: auto;
  padding: 10px 8px 12px;
}

.sidebar-title {
  padding: 4px 10px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-nav {
  display: grid;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 13px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: #f3f6f8;
  color: var(--primary);
}

.nav-item.active {
  background: var(--chip-bg);
  border-color: rgba(15, 118, 110, .28);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: var(--primary-2);
}

.nav-item .nav-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sidebar-stats {
  margin-top: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.login-panel {
  width: 360px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, .12);
  padding: 32px 28px 24px;
}

.login-mark,
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  border-radius: 7px;
}

.login-mark {
  width: 44px;
  height: 44px;
  font-size: 22px;
}

.login-panel h1 {
  margin: 16px 0 4px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: .5px;
}

.login-sub {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-panel input,
.filters input,
.filters select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.login-panel input:focus,
.filters input:focus,
.filters select:focus,
.search-wrap input:focus {
  outline: 2px solid rgba(14, 124, 134, .35);
  border-color: var(--primary-2);
}

.error-text {
  color: var(--danger);
  margin: 12px 0 0;
  text-align: center;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: repeating-linear-gradient(45deg, #f7c948 0 8px, #17212b 8px 16px);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  font-size: 19px;
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.search-wrap {
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}

.search-field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 36px 0 36px;
  background: #fff;
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-field::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary-2);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .25s ease;
  pointer-events: none;
}

.search-field:focus-within::after {
  transform: scaleX(1);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.search-clear:hover {
  background: #edf2f4;
  color: var(--danger);
}

main {
  flex: 1;
  min-width: 0;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.mode-switch {
  display: inline-flex;
  gap: 4px;
  background: #e9eef2;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 12px;
}

.mode-btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.mode-btn.active {
  background: #fff;
  border-color: var(--line);
  color: var(--primary);
  box-shadow: var(--shadow);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-row select,
.filter-row input[type="text"] {
  width: 150px;
  border-radius: 6px;
}

.filter-row input[type="text"] {
  flex: 1;
  min-width: 170px;
}

.active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  max-width: 320px;
  padding: 0 4px 0 10px;
  border: 1px solid rgba(14, 124, 134, .28);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--primary);
  font-size: 12px;
  transition: border-color .15s ease;
}

.filter-chip:hover {
  border-color: var(--primary-2);
}

.chip-label {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
}

.filter-chip:hover .chip-x {
  color: var(--danger);
}

.clear-all-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.clear-all-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  color: var(--muted);
  white-space: nowrap;
}

.stat-line {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.result-count {
  margin-left: auto;
  color: var(--text);
}

.rebuild-progress {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.rebuild-progress-text {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.rebuild-progress-track {
  height: 6px;
  border-radius: 999px;
  background: #e4e9ee;
  overflow: hidden;
}

.rebuild-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--primary-2);
  transition: width .3s ease;
}

.results {
  display: grid;
  gap: 10px;
}

.result-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  align-items: start;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.result-item:hover {
  border-color: rgba(15, 118, 110, .5);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .09);
  transform: translateY(-1px);
}

.file-badge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background-color: var(--file-red);
  background-image:
    radial-gradient(circle 2px at 8px 8px, rgba(255, 255, 255, .95) 99%, transparent),
    radial-gradient(circle 2px at calc(100% - 8px) 8px, rgba(255, 255, 255, .95) 99%, transparent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  word-break: break-all;
  overflow: hidden;
}

.file-badge::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-bottom: 8px solid var(--panel);
}

.file-info {
  min-width: 0;
}

.file-name {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

.file-meta {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.file-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.file-delete {
  height: 40px;
  min-width: 88px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 700;
  background: var(--file-red);
  border-color: var(--file-red);
  color: #fff;
}

.file-delete:hover,
.file-delete:active {
  background: var(--file-red);
  border-color: var(--file-red);
  color: #fff;
}

.chip-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--primary);
  font-size: 12px;
}

.chip.dup {
  background: #fdf0e6;
  color: var(--accent);
}

.snippet {
  margin-top: 8px;
  padding: 8px 10px;
  background: #f7f9fa;
  border-left: 3px solid var(--primary-2);
  border-radius: 0 6px 6px 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

mark {
  background: var(--highlight);
  color: #4a3a00;
  border-radius: 3px;
  padding: 0 1px;
}

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
}

.empty-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 10px;
  background: var(--chip-bg);
  color: var(--primary);
  font-size: 24px;
  font-weight: 700;
}

.empty-state h2 {
  margin: 16px 0 6px;
  color: var(--text);
  font-size: 18px;
}

.empty-state p {
  margin: 4px 0;
}

.empty-state code {
  background: #eef1f4;
  border-radius: 4px;
  padding: 1px 6px;
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
}

.viewer-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 200;
  background: #17212b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, .25);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, .45);
}

.modal-panel {
  width: 540px;
  max-width: 100%;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .2);
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.user-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  margin-bottom: 14px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.user-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.user-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.mini-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.mini-btn:hover {
  border-color: var(--primary-2);
  color: var(--primary-2);
}

.mini-btn.danger-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.mini-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.user-add-form {
  display: grid;
  grid-template-columns: 1fr 1fr 120px auto;
  gap: 8px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.user-add-form input,
.user-add-form select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.user-add-form button {
  height: 36px;
  white-space: nowrap;
}

.history-pop {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
  padding: 6px;
}

.history-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.history-item:hover {
  background: var(--chip-bg);
  color: var(--primary);
}

.history-clear {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 6px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  text-align: left;
}

.quick-area {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.quick-group {
  display: grid;
  gap: 6px;
}

.quick-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.quick-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.quick-item {
  flex: 0 0 auto;
  max-width: 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  overflow: hidden;
}

.quick-item:hover {
  border-color: var(--primary-2);
  color: var(--primary);
}

.quick-item .quick-file {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-item .quick-badge {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--file-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.file-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.file-title-row .file-name {
  flex: 1;
  min-width: 0;
}

.fav-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.fav-btn:hover {
  color: var(--accent);
}

.fav-btn.active {
  color: var(--accent);
}

.modal-wide {
  width: 760px;
}

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.log-toolbar select {
  height: 32px;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
}

.log-list {
  display: grid;
  gap: 6px;
  max-height: 420px;
  overflow: auto;
}

.log-row,
.trash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.log-main,
.trash-main {
  min-width: 0;
}

.log-main strong,
.trash-main strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 13px;
  word-break: break-all;
}

.log-main .muted,
.trash-main .muted {
  word-break: break-all;
}

@media (max-width: 760px) {
  .layout {
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .sidebar {
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
    padding: 8px;
  }

  .sidebar-title {
    padding: 2px 4px 6px;
  }

  .category-nav {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sidebar-stats {
    display: none;
  }

  .mode-switch {
    display: flex;
  }

  .mode-btn {
    flex: 1;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }

  .brand {
    min-width: 0;
  }

  .search-wrap {
    flex-wrap: wrap;
  }

  .search-field {
    flex-basis: 100%;
  }

  .filter-row select,
  .filter-row input[type="text"] {
    width: 100%;
  }

  .filter-chip {
    max-width: 100%;
  }

  .chip-label {
    max-width: calc(100vw - 120px);
  }

  .result-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .file-badge {
    width: 42px;
    height: 42px;
    font-size: 11px;
  }

  .user-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-add-form {
    grid-template-columns: 1fr;
  }

  .quick-item {
    max-width: 220px;
  }

  .log-row,
  .trash-row {
    align-items: flex-start;
    flex-direction: column;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
