:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #202331;
  background: #f6f7fa;
  --paper: #fff;
  --line: #e2e5ed;
  --muted: #5a6376;
  --accent: #4338bc;
  --accent-hover: #352b9e;
  --accent-tint: #eeedff;
  --danger: #9d302f;
  --radius: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .drop-area:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button:disabled { cursor: default; opacity: .5; }
[hidden] { display: none !important; }

.topbar { border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-inner {
  max-width: 1328px;
  margin-inline: auto;
  min-height: 62px;
  padding-inline: clamp(18px, 4vw, 48px);
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { display: flex; gap: 10px; align-items: center; font-weight: 740; }
.brand-mark { position: relative; width: 30px; height: 30px; background: var(--accent); border-radius: 8px; }
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 13px;
  border: 1px solid white;
  border-radius: 2px;
}
.brand-mark::before { top: 7px; left: 8px; transform: rotate(-14deg); opacity: .7; }
.brand-mark::after { top: 10px; left: 12px; background: var(--accent); }
.topbar-section { border-left: 1px solid var(--line); padding-left: 20px; color: var(--muted); font-size: .875rem; }
.topbar-inner form { margin-left: auto; }

main { max-width: 1328px; margin-inline: auto; padding: 40px clamp(18px, 4vw, 48px) 64px; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 26px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.2rem); line-height: 1.25; letter-spacing: -.035em; }
.page-header p { margin-top: 8px; color: var(--muted); line-height: 1.5; }
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #25293a;
  background: var(--paper);
  font-size: .875rem;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover:not(:disabled) { background: #f0f1f7; }
.button.primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.page-header .button { min-height: 42px; padding-inline: 16px; }
.notice { margin-bottom: 14px; padding: 10px 14px; border: 1px solid #dcd9ff; border-radius: 8px; background: #f0eeff; color: #383077; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.listing { min-width: 0; overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 3px; }
.filters button {
  min-height: 36px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding-inline: 8px;
  font-size: .875rem;
  font-weight: 620;
  cursor: pointer;
}
.filters button:hover { background: #f3f4f8; }
.filters button[aria-pressed="true"] { background: var(--accent-tint); color: #3b329b; }
.filters span { margin-inline-start: 2px; font-variant-numeric: tabular-nums; }
.search { position: relative; flex: 0 1 220px; }
.search-icon {
  pointer-events: none;
  position: absolute;
  top: 11px;
  left: 11px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
}
.search-icon::after { content: ""; position: absolute; top: 9px; left: 8px; width: 5px; border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); }
.search input, .metadata input, .metadata select { width: 100%; border: 1px solid var(--line); border-radius: 8px; background-color: #fff; color: #202331; }
.search input { min-height: 36px; padding: 6px 9px 6px 30px; font-size: .875rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: #f5f6fa; color: var(--muted); }
th { padding-block: 11px; font-size: .875rem; font-weight: 620; }
td, th { padding-inline: 9px; }
td:first-child, th:first-child { padding-left: 17px; }
td:last-child, th:last-child { padding-right: 17px; }
td { padding-block: 11px; border-top: 1px solid var(--line); font-size: .875rem; }
td:not(:first-child), th:not(:first-child) { white-space: nowrap; }
tr.selected { background: #f4f2ff; }
tr:hover:has(.row-name) { background: #f7f6ff; }
.row-name {
  border: 0;
  padding: 0;
  text-align: left;
  color: #22263a;
  background: transparent;
  font-size: .925rem;
  font-weight: 680;
  cursor: pointer;
}
.row-name:hover { text-decoration: underline; }
.row-id { display: block; margin-top: 4px; color: var(--muted); font-family: ui-monospace, monospace; font-size: .78rem; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; color: #454d62; background: #eef0f5; font-size: .8125rem; font-weight: 620; }
.badge.draft { color: #4433a1; background: #eeebff; }
.list-message, .empty-details { color: var(--muted); padding: 28px 20px; }
.retry { margin: 0 20px 20px; }

.detail-header, .facts, .preview-section, .metadata, .detail-footer { padding-inline: clamp(16px, 2vw, 23px); }
.detail-header { padding-top: 21px; }
.detail-title { margin-top: 10px; line-height: 1.35; font-size: 1.25rem; overflow-wrap: anywhere; }
.pack-id, .description, .updated { color: var(--muted); }
.pack-id { margin-top: 4px; font-size: .8125rem; font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.description { margin-top: 10px; font-size: .925rem; line-height: 1.55; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); margin: 16px 0 0; padding-block: 14px; border-block: 1px solid var(--line); }
.facts div + div { border-left: 1px solid var(--line); padding-inline-start: 12px; }
dt { color: var(--muted); font-size: .875rem; }
dd { margin: 4px 0 0; font-weight: 720; font-variant-numeric: tabular-nums; }
.preview-section, .metadata { padding-block: 18px; }
h3 { font-size: .95rem; }
.preview-heading, .preview-actions, .metadata-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preview-position { color: var(--muted); font-size: .875rem; }
.preview-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
  min-height: 127px;
  margin-block: 10px;
  padding: 12px 14px;
  border: 1px solid #dfddf3;
  border-radius: 10px;
  background: #f8f7ff;
}
.face-name { color: #4e419b; font-size: .875rem; font-weight: 640; }
.preview-text { line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.flip { min-height: 31px; padding-block: 4px; }
.preview-actions .button { min-height: 33px; padding-block: 5px; }
.metadata { border-top: 1px solid var(--line); }
.metadata label { display: grid; gap: 5px; margin-top: 9px; font-size: .875rem; font-weight: 620; }
.metadata input, .metadata select { min-height: 37px; padding: 7px 9px; font-size: .875rem; font-weight: 400; }
.metadata select { appearance: none; padding-right: 30px; background: linear-gradient(45deg, transparent 50%, #5a6376 50%) right 15px center/5px 5px no-repeat, linear-gradient(135deg, #5a6376 50%, transparent 50%) right 10px center/5px 5px no-repeat; }
.metadata :disabled { color: var(--muted); opacity: 1; background-color: #f5f6fa; }
.metadata-actions { flex-wrap: wrap; }
.metadata-actions .save { margin-left: auto; }
.detail-footer { display: grid; gap: 5px; padding-block: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8125rem; }
.sha256 { overflow-wrap: anywhere; }
.feedback { color: var(--muted); font-size: .875rem; line-height: 1.5; margin-block: 8px; }
.feedback:empty { display: none; }
.feedback.error { color: var(--danger); }

.login { max-width: 500px; padding-top: clamp(34px, 13vh, 112px); }
.login-panel { padding: clamp(20px, 5vw, 32px); }
.login-panel h1 { margin-top: 24px; font-size: 1.65rem; }
.login-panel form { display: grid; gap: 8px; margin-top: 20px; }
.login-panel label { font-weight: 620; }
.login-panel input { min-width: 0; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login-panel button { margin-top: 8px; }
#invalid-key:not(:target) { display: none; }

dialog { padding: 0; width: min(440px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; box-shadow: 0 22px 75px #19163338; }
dialog::backdrop { background: #22264073; }
dialog form { padding: 21px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.dialog-heading h2 { font-size: 1.25rem; }
.close { font-size: 1.25rem; min-width: 36px; padding: 4px; }
.drop-area { display: grid; justify-items: center; gap: 8px; padding: 22px 12px; border: 1px dashed #a39ad8; border-radius: 10px; background: #f8f7ff; text-align: center; cursor: pointer; }
.drop-area:hover, .drop-area.dragging, .drop-area:has(+ input:focus-visible) { border-color: var(--accent); background: var(--accent-tint); }
.drop-area > span:last-child { color: var(--muted); font-size: .875rem; }
.file-icon { width: 21px; height: 25px; border: 1.5px solid var(--accent); border-radius: 4px; background: linear-gradient(var(--accent), var(--accent)) center 9px / 9px 1px no-repeat, linear-gradient(var(--accent), var(--accent)) center 14px / 9px 1px no-repeat; }
.selected-file { margin-top: 10px; font-weight: 620; font-size: .875rem; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
  main { padding-top: 25px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-header p { font-size: .925rem; }
  td, th { padding-inline: 6px; }
  td:first-child, th:first-child { padding-left: 11px; }
  td:last-child, th:last-child { padding-right: 11px; }
  .search { flex: 1 1 100%; }
}
