:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --line: #d9e0e7;
  --text: #1d2733;
  --muted: #647384;
  --primary: #1d6f8f;
  --primary-dark: #15566f;
  --accent: #b25c2e;
  --green: #287a51;
  --danger: #b53b43;
  --shadow: 0 12px 28px rgba(28, 38, 48, 0.13);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.ghost:hover {
  background: var(--surface-2);
}

.danger {
  background: #fff;
  color: var(--danger);
  border-color: rgba(181, 59, 67, 0.35);
}

.danger:hover {
  background: rgba(181, 59, 67, 0.08);
}

.full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(29, 111, 143, 0.1), transparent 42%),
    linear-gradient(320deg, rgba(178, 92, 46, 0.12), transparent 38%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.login-panel h1 {
  margin: 18px 0 22px;
  font-size: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

label span {
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(29, 111, 143, 0.18);
  border-color: rgba(29, 111, 143, 0.5);
}

.login-panel label + label,
.login-panel label + button {
  margin-top: 14px;
}

.form-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  padding: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.sidebar-head {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
}

.sidebar h1 {
  margin: 0;
  font-size: 17px;
}

.sidebar-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  color: var(--text);
  border-color: transparent;
}

.nav-item.active,
.nav-item:hover {
  background: #e9f3f6;
  border-color: rgba(29, 111, 143, 0.12);
}

.sidebar-section {
  margin-top: 26px;
}

.section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 0 10px;
  cursor: pointer;
}

.tag-chip.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.stat-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stat-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
}

.stat-list dt {
  color: var(--muted);
}

.stat-list dd {
  margin: 0;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
}

.topbar {
  min-height: 68px;
  padding: 14px 22px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: rgba(244, 246, 248, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 38px;
  background: var(--surface);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-bar {
  padding: 14px 22px;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 170px)) auto auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.checkbox-pill,
.checkbox-line {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-pill {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--surface);
}

.checkbox-pill input,
.checkbox-line input {
  width: 16px;
  min-height: 16px;
}

.selection-bar {
  margin: 14px 22px 0;
  min-height: 44px;
  border: 1px solid rgba(29, 111, 143, 0.22);
  border-radius: var(--radius);
  background: #eaf5f8;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.selection-bar span {
  margin-right: auto;
  font-weight: 700;
}

.asset-grid {
  padding: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-content: start;
}

.asset-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.asset-card:hover {
  border-color: rgba(29, 111, 143, 0.34);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(28, 38, 48, 0.09);
}

.asset-card.selected {
  outline: 2px solid var(--primary);
}

.asset-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #edf1f4;
  display: grid;
  place-items: center;
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.asset-body {
  padding: 12px;
  display: grid;
  gap: 9px;
}

.asset-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.asset-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.favorite-btn {
  min-width: 34px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.favorite-btn.active {
  color: var(--accent);
  border-color: rgba(178, 92, 46, 0.35);
  background: #fff5ef;
}

.asset-info {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.asset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 22px;
}

.asset-tag,
.badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.badge.public {
  background: #e6f4ed;
  color: var(--green);
}

.badge.locked {
  background: #f9e9eb;
  color: var(--danger);
}

.select-box {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 18px;
  height: 18px;
  z-index: 2;
}

.empty-state {
  align-self: center;
  justify-self: center;
  text-align: center;
  padding: 24px;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0 0 16px;
  color: var(--muted);
}

.modal {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(18, 28, 38, 0.42);
}

.modal > form,
.modal > div,
.share-history {
  padding: 18px;
}

.modal-head {
  min-height: 52px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

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

.icon-btn {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  font-size: 22px;
}

.form-grid,
.detail-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

.file-zone {
  min-height: 98px;
  border: 1px dashed rgba(29, 111, 143, 0.35);
  border-radius: var(--radius);
  background: #f7fbfc;
  padding: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.detail-modal {
  width: min(1160px, calc(100vw - 28px));
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  padding: 18px;
}

.preview-pane {
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef2f5;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-pane img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.meta-list div {
  min-width: 0;
}

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

.meta-list dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.created-share {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.share-history {
  border-top: 1px solid var(--line);
}

.share-list {
  display: grid;
  gap: 8px;
}

.share-row {
  min-height: 46px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}

.share-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 18px;
}

.table-wrap {
  padding: 0 18px 18px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td input,
td select {
  min-width: 120px;
}

.activity-list {
  display: grid;
  gap: 8px;
  max-height: 70vh;
  overflow: auto;
}

.template-hidden {
  display: none !important;
}

.dictionary-form {
  grid-template-columns: 170px 1fr 1fr auto;
}

.dictionary-error {
  padding: 0 18px;
}

.profile-form {
  padding: 18px;
}

.password-form {
  border-top: 1px solid var(--line);
}

.activity-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  gap: 3px;
}

.activity-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  background: #1d2733;
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
}

.muted {
  color: var(--muted);
}

.public-share {
  min-height: 100vh;
}

.public-head {
  min-height: 110px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  display: flex;
  align-items: center;
}

.public-head > div {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: center;
}

.public-head h1 {
  margin: 0;
  font-size: 24px;
}

.public-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.public-share .login-panel {
  margin: 36px auto;
}

.public-preview-pane {
  margin: 18px;
  min-height: min(72vh, 720px);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .asset-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .form-grid,
  .detail-form,
  .meta-list {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .modal-actions,
  .selection-bar {
    flex-wrap: wrap;
  }

  .share-row {
    grid-template-columns: 1fr;
  }
}
