:root {
  color-scheme: light;
  --page: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --ink: #111318;
  --muted: #5c6470;
  --faint: #9aa3af;
  --line: rgba(17, 19, 24, 0.13);
  --line-soft: rgba(17, 19, 24, 0.08);
  --blue: #145cff;
  --cyan: #00b7ff;
  --rose: #fe2c55;
  --blue-soft: rgba(20, 92, 255, 0.09);
  --green: #009b72;
  --amber: #ad6a00;
  --red: #d7264f;
  --shadow-soft: 0 18px 48px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 28px 70px rgba(16, 24, 40, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.92) 168px, rgba(246, 247, 251, 0.94) 460px),
    var(--page);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 80px 0 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(17, 19, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 19, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 92, 255, 0.08), rgba(0, 183, 255, 0.04), rgba(254, 44, 85, 0.05));
  background-size: 56px 56px, 56px 56px, 100% 1px;
  background-position: -1px -1px, -1px -1px, 0 0;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.78), transparent 72%);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.topbar {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 15px 34px 16px;
  border-bottom: 1px solid rgba(17, 19, 24, 0.11);
  background: rgba(255, 255, 255, 0.9);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 18px 56px rgba(16, 24, 40, 0.05);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--cyan) 46%, var(--rose));
  opacity: 0.92;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 2px;
  color: #303744;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, var(--blue), var(--cyan) 55%, var(--rose));
}

h1 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 760;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status {
  color: #3f4754;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.button {
  border: 1px solid rgba(17, 19, 24, 0.12);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  min-height: 34px;
  padding: 7px 13px;
  cursor: pointer;
  text-decoration: none;
  font-size: 12px;
  font-weight: 760;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 8px 22px rgba(16, 24, 40, 0.06);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.button:hover {
  border-color: rgba(20, 92, 255, 0.38);
  background: #f8fbff;
  transform: translateY(-1px);
}

.button.primary {
  background: #111318;
  border-color: #111318;
  color: #ffffff;
  font-weight: 700;
}

.button.primary:hover {
  background: var(--blue);
  border-color: var(--blue);
}

.button:disabled,
.button.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.layout {
  width: min(100%, 1720px);
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 28px;
  margin: 0 auto;
  padding: 30px 34px 46px;
}

.sidebar {
  min-width: 0;
  position: sticky;
  top: 104px;
  align-self: start;
  max-height: calc(100vh - 126px);
  overflow: auto;
  padding-right: 2px;
}

.filters {
  display: grid;
  gap: 12px;
  padding: 18px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 92, 255, 0.18), transparent 28%),
    linear-gradient(315deg, rgba(254, 44, 85, 0.12), transparent 30%),
    #111318;
  box-shadow: 0 24px 64px rgba(17, 19, 24, 0.2);
}

.search-label,
.filter-row label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 700;
}

.search-input,
.filter-row select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  min-height: 42px;
  padding: 10px 12px;
}

.filter-row select {
  color-scheme: dark;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.46);
}

.search-input:focus,
.filter-row select:focus,
.button:focus-visible,
.reader-tab:focus-visible,
.file-link:focus-visible {
  outline: 3px solid rgba(0, 183, 255, 0.26);
  outline-offset: 2px;
}

.filter-row {
  display: grid;
  gap: 6px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 12px;
}

.metrics div {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(17, 19, 24, 0.08);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.055);
}

.metrics strong {
  color: var(--ink);
  font-size: 23px;
  line-height: 1;
}

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

.listing-grid {
  display: grid;
  gap: 10px;
}

.listing-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(17, 19, 24, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.05);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.listing-card:hover,
.listing-card.active {
  border-color: rgba(20, 92, 255, 0.42);
  box-shadow: 0 20px 48px rgba(20, 92, 255, 0.13);
  transform: translateY(-1px);
}

.listing-card.active {
  background:
    linear-gradient(90deg, rgba(20, 92, 255, 0.08), rgba(0, 183, 255, 0.035) 38%, rgba(255, 255, 255, 0.98) 66%),
    #ffffff;
}

.card-thumb {
  width: 88px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  overflow: hidden;
  background: #f0f0f2;
  border: 1px solid var(--line-soft);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 10px;
}

.card-body {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
}

.card-title {
  margin: 0;
  color: #4f5866;
  font-size: 13px;
  line-height: 1.28;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.card-headline {
  margin: 0;
  color: #111318;
  font-size: 14px;
  line-height: 1.32;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.card-meta {
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(17, 19, 24, 0.06);
  color: var(--muted);
}

.pill.ok {
  background: rgba(0, 155, 114, 0.11);
  color: var(--green);
}

.pill.warn {
  background: rgba(184, 110, 0, 0.12);
  color: var(--amber);
}

.pill.bad {
  background: rgba(199, 55, 47, 0.12);
  color: var(--red);
}

.detail {
  min-width: 0;
}

.mobile-detail-bar {
  display: none;
}

.empty-state {
  min-height: calc(100vh - 160px);
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin: 4px 0 18px;
  padding: 2px 0 14px;
  border-bottom: 1px solid rgba(17, 19, 24, 0.08);
}

.detail-title h2 {
  max-width: 920px;
  margin: 0 0 8px;
  font-size: clamp(21px, 1.72vw, 30px);
  line-height: 1.18;
  font-weight: 760;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.detail-kicker {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
}

.detail-subtitle {
  max-width: 920px;
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.quick-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-actions .button {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.finder-board {
  display: grid;
  grid-template-columns: minmax(460px, 1.42fr) minmax(300px, 0.76fr);
  gap: 20px;
  margin-bottom: 22px;
  align-items: stretch;
}

.finder-side {
  min-width: 0;
  display: grid;
  gap: 18px;
  grid-template-rows: auto minmax(0, 1fr);
}

.core-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(17, 19, 24, 0.1);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 26px 70px rgba(16, 24, 40, 0.1);
}

.core-plan-card {
  scroll-margin-top: 18px;
}

.core-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(17, 19, 24, 0.08);
  background:
    linear-gradient(90deg, rgba(20, 92, 255, 0.08), transparent 48%),
    #ffffff;
}

.core-label {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.core-path {
  color: var(--faint);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.core-media {
  position: relative;
  width: 100%;
  background:
    linear-gradient(135deg, rgba(17, 19, 24, 0.03), transparent 44%),
    #f4f6fa;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.core-cover-media,
.core-plan-media {
  aspect-ratio: 3 / 4;
}

.core-plan-card .core-plan-media {
  height: clamp(540px, 74vh, 780px);
  aspect-ratio: auto;
}

.core-cover-card .core-cover-media {
  max-height: 410px;
}

.core-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.core-cover-media img {
  object-fit: cover;
}

.core-file-open {
  min-height: 520px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--blue);
  text-decoration: none;
  font-size: 14px;
  font-weight: 760;
  background: #f4f6fa;
}

.core-empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.core-copy {
  display: grid;
  grid-template-rows: auto minmax(210px, 1fr) auto;
}

.core-copy-body {
  min-height: 210px;
  max-height: 330px;
  overflow: auto;
  padding: 17px;
  color: #1f2430;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.core-copy-body.loading {
  color: var(--muted);
}

.core-copy-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 15px;
  border-top: 1px solid var(--line-soft);
  background: #f9fafc;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.media-panel,
.reader-panel,
.file-panel {
  background: var(--surface);
  border: 1px solid rgba(17, 19, 24, 0.09);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.media-panel {
  padding: 14px;
}

.main-preview {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #f4f6fa;
  border: 1px solid rgba(17, 19, 24, 0.08);
  border-radius: 8px;
  overflow: hidden;
}

.main-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #f4f6fa;
}

.preview-caption {
  min-height: 26px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.image-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.image-choice {
  border: 1px solid rgba(17, 19, 24, 0.08);
  background: #f4f6fa;
  border-radius: 8px;
  padding: 0;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
}

.image-choice.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(20, 92, 255, 0.16);
}

.image-choice img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.reader-panel {
  min-width: 0;
  overflow: hidden;
}

.reader-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  border-bottom: 1px solid rgba(17, 19, 24, 0.08);
  background: #f9fafc;
}

.reader-tab {
  min-height: 32px;
  border: 1px solid rgba(17, 19, 24, 0.12);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  padding: 5px 11px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.reader-tab.active {
  background: #111318;
  color: #ffffff;
  border-color: #111318;
}

.reader-body {
  max-height: calc(100vh - 300px);
  overflow: auto;
  padding: 20px;
}

.markdown {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.72;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.25;
  margin: 24px 0 10px;
}

.markdown h1:first-child,
.markdown h2:first-child,
.markdown h3:first-child {
  margin-top: 0;
}

.markdown h1 {
  font-size: 21px;
}

.markdown h2 {
  font-size: 17px;
}

.markdown h3 {
  font-size: 15px;
}

.markdown p {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.markdown ul,
.markdown ol {
  margin: 0 0 14px 22px;
  padding: 0;
}

.markdown li {
  margin: 4px 0;
}

.markdown pre {
  overflow: auto;
  background: #111318;
  color: #f7f8fb;
  padding: 14px;
  border-radius: 8px;
  line-height: 1.5;
}

.markdown code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.table-wrap {
  overflow: auto;
  margin-bottom: 16px;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-size: 14px;
}

.markdown th,
.markdown td {
  border: 1px solid rgba(17, 19, 24, 0.08);
  padding: 8px 9px;
  vertical-align: top;
}

.markdown th {
  background: #f6f7fb;
  text-align: left;
}

.file-panel {
  margin-top: 20px;
  padding: 16px;
}

.file-panel h3 {
  margin: 0 0 12px;
}

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

.file-group h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.file-list {
  display: grid;
  gap: 6px;
}

.file-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid rgba(17, 19, 24, 0.08);
  border-radius: 8px;
  background: #f9fafc;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.file-link span:first-child {
  overflow-wrap: anywhere;
}

.file-link:hover {
  border-color: rgba(20, 92, 255, 0.32);
  background: var(--blue-soft);
}

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

.error {
  color: var(--red);
  background: rgba(199, 55, 47, 0.1);
  border: 1px solid rgba(199, 55, 47, 0.22);
  border-radius: 8px;
  padding: 12px;
}

@media (max-width: 1180px) {
  .layout,
  .detail-grid,
  .finder-board {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

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

  .reader-body {
    max-height: none;
  }

  .core-plan-card .core-plan-media {
    height: clamp(460px, 68vh, 650px);
  }
}

@media (max-width: 720px) {
  body.mobile-detail-open {
    overflow: hidden;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 15px 14px 16px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .layout {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .sidebar {
    order: 1;
  }

  .detail {
    order: 2;
    display: none;
    flex-direction: column;
  }

  body.mobile-detail-open .detail {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    min-width: 0;
    overflow: auto;
    padding: 12px;
    background:
      linear-gradient(180deg, #ffffff 0%, rgba(246, 247, 251, 0.96) 360px),
      var(--page);
  }

  .mobile-detail-bar {
    position: sticky;
    top: 0;
    z-index: 3;
    order: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin: -12px -12px 12px;
    padding: 11px 12px;
    border-bottom: 1px solid rgba(17, 19, 24, 0.1);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px) saturate(160%);
  }

  .mobile-back-button {
    min-height: 34px;
    border: 1px solid rgba(17, 19, 24, 0.14);
    border-radius: 6px;
    background: #111318;
    color: #ffffff;
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 760;
  }

  .mobile-detail-title {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .mobile-detail-title span {
    color: var(--blue);
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-detail-title strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
    margin-bottom: 10px;
  }

  .search-label,
  .search-input {
    grid-column: 1 / -1;
  }

  .filter-row {
    min-width: 0;
  }

  .search-input,
  .filter-row select {
    min-height: 38px;
    padding: 8px 9px;
    font-size: 12px;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 8px;
  }

  .metrics div {
    min-height: 50px;
    padding: 8px;
  }

  .metrics strong {
    font-size: 20px;
  }

  .listing-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    overflow: visible;
    padding: 0;
  }

  .listing-card {
    grid-template-columns: 82px minmax(0, 1fr);
    width: 100%;
  }

  .card-thumb {
    width: 82px;
  }

  .card-title {
    font-size: 12px;
  }

  .card-headline {
    font-size: 13px;
  }

  .file-groups {
    grid-template-columns: 1fr;
  }

  .detail-header {
    order: 2;
    flex-direction: column;
    gap: 12px;
    margin-top: 0;
  }

  .quick-actions {
    justify-content: flex-start;
  }

  .finder-board {
    order: 1;
    gap: 12px;
    margin-bottom: 14px;
  }

  .finder-side {
    gap: 12px;
  }

  .detail-grid {
    order: 3;
  }

  .file-panel {
    order: 4;
  }

  .core-copy-body {
    max-height: none;
  }

  .core-plan-card .core-plan-media {
    height: clamp(410px, 64vh, 560px);
  }

  .core-plan-card {
    scroll-margin-top: 64px;
  }
}

@media (max-width: 440px) {
  .listing-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .card-thumb {
    width: 76px;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .filter-row:last-child {
    grid-column: 1 / -1;
  }

  .image-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
