:root {
  color-scheme: light;
  --page: #f3f8fa;
  --surface: #ffffff;
  --surface-soft: #f7fbfc;
  --text: #102630;
  --muted: #667c86;
  --line: #d7e4e8;
  --line-strong: #bcd0d7;
  --teal: #008d78;
  --teal-strong: #006f60;
  --teal-soft: #e3f6f1;
  --blue: #2e70d1;
  --red: #c93c4a;
  --red-soft: #fff0f2;
  --shadow: 0 20px 60px rgba(20, 53, 68, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 5%, color-mix(in srgb, var(--teal) 10%, transparent), transparent 25rem),
    radial-gradient(circle at 95% 42%, color-mix(in srgb, var(--blue) 7%, transparent), transparent 28rem),
    var(--page);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 16px;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.page-shell {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr auto;
}

.topbar,
main,
footer {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand > strong {
  color: var(--teal);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.11em;
  line-height: 1;
}

.brand > span {
  width: 1px;
  height: 34px;
  background: var(--line-strong);
}

.brand > div {
  display: grid;
  gap: 3px;
}

.brand b {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar-actions,
.workspace-actions,
.modal-actions,
.modal-actions > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease;
}

.theme-button:hover {
  transform: translateY(-1px);
  border-color: var(--teal);
  color: var(--teal-strong);
}

.theme-button svg {
  width: 17px;
  height: 17px;
}

.theme-button .sun-icon {
  display: none;
}

:root[data-theme="dark"] .theme-button .moon-icon {
  display: none;
}

:root[data-theme="dark"] .theme-button .sun-icon {
  display: block;
}

.public-badge,
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  font-size: 0.8rem;
}

.public-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 13%, transparent);
}

.admin-badge {
  border-color: color-mix(in srgb, var(--teal) 35%, var(--line));
  color: var(--teal-strong);
  background: var(--teal-soft);
  font-weight: 700;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 32%, transparent);
  outline-offset: 2px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.button svg {
  width: 17px;
  height: 17px;
}

.button-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--teal) 20%, transparent);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--teal-strong);
  background: var(--teal-strong);
}

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

.button-ghost {
  background: transparent;
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal-strong);
}

.button-danger {
  border-color: color-mix(in srgb, var(--red) 35%, var(--line));
  background: var(--red-soft);
  color: var(--red);
}

main {
  padding: 46px 0 70px;
}

.intro {
  margin-bottom: 30px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.86rem;
}

.back-link:hover {
  color: var(--teal);
}

.intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
}

.intro-copy {
  min-width: 0;
}

.library-heading-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.library-switch {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: 0 10px 28px rgba(24, 58, 71, 0.05);
}

.library-tab {
  min-height: 40px;
  padding: 8px 15px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 750;
  transition:
    background-color 220ms ease,
    color 220ms ease,
    box-shadow 220ms ease,
    transform 220ms ease;
}

.library-tab:hover {
  color: var(--teal-strong);
}

.library-tab.is-active {
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--teal) 22%, transparent);
}

.library-tab:focus-visible,
.theme-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 32%, transparent);
  outline-offset: 2px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.17em;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.12;
}

.lead {
  max-width: 720px;
  margin: 15px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.summary {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
}

.summary > div {
  display: grid;
  min-width: 112px;
  gap: 3px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: 0 10px 28px rgba(24, 58, 71, 0.05);
}

.summary strong {
  color: var(--teal);
  font-size: 1.45rem;
}

.summary span {
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

.workspace.is-switching {
  opacity: 0.32;
  transform: translateY(5px);
}

.workspace-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 26px;
  border-bottom: 1px solid var(--line);
}

.workspace-head h2,
.modal-head h2 {
  margin: 0;
  font-size: 1.24rem;
  letter-spacing: -0.02em;
}

.search-box {
  display: flex;
  width: min(330px, 35vw);
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
}

.search-box svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
}

.search-box input::placeholder,
input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th:last-child,
td:last-child {
  border-right: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  padding: 13px 15px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 760;
}

td {
  padding: 18px 15px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

th:nth-child(1) { width: 21%; }
th:nth-child(2) { width: 23%; }
th:nth-child(3) { width: 18%; }
th:nth-child(4) { width: 24%; }
th:nth-child(5) { width: 10%; }
th:nth-child(6) { width: 105px; }

.tool-name {
  display: grid;
  gap: 9px;
}

.tool-name strong {
  color: var(--text);
  font-size: 0.98rem;
}

.version-chip {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-strong);
  font-size: 0.73rem;
  font-weight: 700;
}

.line-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.line-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px;
}

.line-list li::before {
  color: var(--teal);
  content: "•";
}

.notes {
  margin: 0;
  white-space: pre-wrap;
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--blue);
  font-weight: 700;
}

.download-link:hover {
  text-decoration: underline;
}

.file-meta,
.muted-text {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
}

.date-cell {
  color: var(--muted);
  white-space: nowrap;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-action {
  border: 0;
  background: transparent;
  color: var(--teal-strong);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
}

.table-action:hover {
  text-decoration: underline;
}

.empty-state {
  display: grid;
  min-height: 330px;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin-bottom: 8px;
  border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line));
  border-radius: 18px;
  background: var(--teal-soft);
  color: var(--teal);
}

.empty-icon svg {
  width: 27px;
  height: 27px;
}

.empty-state h3 {
  margin: 0;
  font-size: 1.08rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.load-error {
  margin: 0;
  padding: 20px 26px;
  color: var(--red);
  background: var(--red-soft);
}

footer {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.modal {
  width: min(94vw, 540px);
  max-width: none;
  max-height: 90vh;
  padding: 0;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 110px rgba(0, 20, 30, 0.28);
}

.modal::backdrop {
  background: rgba(3, 18, 26, 0.62);
  backdrop-filter: blur(5px);
}

.modal-editor {
  width: min(94vw, 780px);
}

.modal-card {
  max-height: 90vh;
  padding: 27px;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
}

.modal-note {
  margin: 18px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
  margin-top: 23px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span {
  font-size: 0.84rem;
  font-weight: 700;
}

.field em {
  color: var(--red);
  font-style: normal;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
}

.field input {
  min-height: 44px;
  padding: 10px 12px;
}

.field textarea {
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.65;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--teal);
}

.file-field {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-soft);
}

.file-field input {
  padding: 8px;
  background: var(--surface);
}

.file-field small,
.file-field b {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.file-field b {
  color: var(--teal-strong);
}

.form-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.82rem;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 22px;
}

.modal-actions-split {
  justify-content: space-between;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 13px 17px;
  border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line));
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.86rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #071620;
  --surface: #0c1d28;
  --surface-soft: #10242f;
  --text: #edf7f7;
  --muted: #96aab3;
  --line: #1d3946;
  --line-strong: #31515f;
  --teal: #50dfc2;
  --teal-strong: #74efd5;
  --teal-soft: #0d332f;
  --blue: #85b4ff;
  --red: #ff7d89;
  --red-soft: #3a1b22;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
}

:root[data-theme="dark"] .button-primary,
:root[data-theme="dark"] .library-tab.is-active {
  color: #05211c;
}

@media (max-width: 820px) {
  .topbar,
  main,
  footer {
    width: min(100% - 28px, 680px);
  }

  .topbar {
    min-height: 74px;
  }

  .brand > strong {
    font-size: 1.7rem;
  }

  .brand > div,
  .public-badge,
  .admin-badge {
    display: none;
  }

  .brand > span {
    display: none;
  }

  main {
    padding: 32px 0 52px;
  }

  .intro-row,
  .workspace-head {
    align-items: stretch;
    flex-direction: column;
  }

  .library-heading-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .library-switch {
    width: 100%;
  }

  .library-tab {
    flex: 1;
  }

  .theme-button span {
    display: none;
  }

  .theme-button {
    width: 38px;
    padding: 7px;
  }

  .summary {
    width: 100%;
  }

  .summary > div {
    flex: 1;
  }

  .workspace-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .workspace-actions .button {
    width: 100%;
  }

  .workspace {
    border-radius: 19px;
  }

  .workspace-head {
    padding: 21px;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
  }

  .modal-card {
    padding: 22px;
  }

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

  .field-wide {
    grid-column: auto;
  }

  .modal-actions-split {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-actions-split > div,
  .modal-actions-split .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button,
  .theme-button,
  .library-tab,
  .workspace {
    transition: none;
  }
}
