/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tabs .btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 99px;
}

.tabs .btn.active {
  background: var(--text-main);
  color: white;
  border-color: var(--text-main);
}

/* Other */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--secondary);
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  color: var(--text-main);
  border: 1px solid var(--color-border);
  letter-spacing: 0.01em;
}

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

.mt-2 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-4 {
  margin-bottom: 16px;
}

.full-width {
  width: 100%;
  justify-content: center;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

.btn.is-busy,
button.is-busy,
[role="button"].is-busy {
  cursor: progress;
}

.btn.is-busy {
  opacity: 0.86;
}

.btn-busy-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn-busy-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: button-spin 0.72s linear infinite;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Review Dashboard */
.review-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
  min-height: 100%;
}

body.review-page .review-dashboard.context-panel-parent-collapsed {
  grid-template-columns: minmax(0, 1fr) 0;
}

.review-main-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.review-side-panel {
  min-width: 0;
}

.review-filterbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  position: sticky;
  top: 0;
  z-index: 5;
}

body.review-page .review-filterbar {
  grid-template-columns: 170px repeat(4, minmax(104px, 1fr)) auto;
  align-items: end;
  position: static;
}

.review-filterbar .field {
  min-width: 0;
}

.review-toolbar-actions,
.review-import-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.review-import-card {
  border-color: var(--color-border-strong);
  background: linear-gradient(180deg, #ffffff 0%, #faf9f5 100%);
}

.review-import-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.review-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.review-kpi-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

.review-kpi-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.review-kpi-card span,
.review-insight-list span,
.review-boundary-note {
  color: var(--text-muted);
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.review-kpi-card strong {
  display: block;
  margin: 10px 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: var(--weight-heavy);
  line-height: 1;
  letter-spacing: -0.03em;
}

.review-kpi-card p,
.review-insight-list p,
.review-empty-inline p,
.review-empty-table p {
  color: var(--text-muted);
  font-size: var(--text-caption);
  line-height: 1.45;
}

.review-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.85fr);
  gap: 16px;
}

.review-chart-card {
  min-width: 0;
}

.review-trend-chart {
  min-height: 178px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(42px, 1fr);
  gap: 8px;
  align-items: end;
  padding-top: 12px;
  overflow-x: auto;
}

.review-line-chart {
  min-height: 204px;
  display: grid;
  grid-template-rows: minmax(156px, 1fr) auto;
  gap: 8px;
}

.review-line-chart svg {
  width: 100%;
  height: 176px;
  display: block;
}

.review-grid-line {
  fill: none;
  stroke: #e8e6dc;
  stroke-width: 1;
}

.review-line-main {
  fill: none;
  stroke: var(--primary-accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.review-line-dot {
  fill: #ffffff;
  stroke: var(--primary-accent);
  stroke-width: 3;
}

.review-line-axis {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(52px, 1fr);
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
  overflow-x: auto;
}

.review-line-axis span {
  min-width: 52px;
  display: grid;
  gap: 2px;
  text-align: center;
}

.review-line-axis strong,
.review-line-axis em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.review-report-preview {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #faf9f5;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.review-trend-column {
  min-width: 42px;
  display: grid;
  grid-template-rows: 18px 132px 18px;
  gap: 5px;
  align-items: end;
  text-align: center;
}

.review-trend-column span,
.review-trend-column em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-style: normal;
}

.review-trend-column i {
  display: block;
  width: 100%;
  align-self: end;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
}

.review-platform-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-platform-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 54px;
  gap: 8px;
  align-items: center;
}

.review-platform-row span,
.review-platform-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.review-platform-row div {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8e6dc;
}

.review-platform-row i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: #f59e0b;
}

.review-table-card {
  min-width: 0;
}

.review-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.review-table {
  min-width: 760px;
  display: grid;
  grid-template-columns: minmax(160px, 1.35fr) 76px 100px 96px minmax(150px, 1.15fr) minmax(160px, 1.15fr);
  gap: 12px;
  align-items: center;
}

.review-table-head {
  padding: 10px 12px;
  background: var(--secondary);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.review-table-row {
  width: 100%;
  padding: 12px;
  border: 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-card);
  color: inherit;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.review-table-row:hover,
.review-table-row.active {
  background: var(--surface-muted);
  box-shadow: inset 3px 0 0 var(--primary);
}

.review-table-row strong,
.review-table-row span,
.review-table-row em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-table-row strong {
  display: block;
  font-size: 0.86rem;
}

.review-table-row em {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-style: normal;
}

.review-table-row mark {
  padding: 3px 8px;
  border-radius: 99px;
  background: #ecfeff;
  color: #155e75;
}

.review-summary-card {
  gap: 14px;
}

.review-insight-list {
  display: grid;
  gap: 10px;
}

.review-insight-list div {
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #faf9f5;
}

.review-insight-list strong {
  display: block;
  margin: 6px 0;
  line-height: 1.45;
}

.review-action-stack {
  display: grid;
  gap: 8px;
}

.review-action-stack .btn {
  width: 100%;
}

.review-empty-inline,
.review-empty-table {
  padding: 28px;
  text-align: center;
}

/* States */
.state-empty,
.state-loading,
.state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  border-radius: var(--radius-md);
  background: var(--color-card);
  border: 1px solid var(--color-border);
}

.state-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--text-main);
  color: white;
  padding: 10px 20px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  z-index: 1000;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Right Panel specific */
.right-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 10px;
}

.right-panel-header h3 {
  font-size: 1rem;
  line-height: 1.4;
  margin-bottom: 2px;
}

.right-panel-content {
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.5;
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-section-title);
  font-weight: var(--weight-semibold);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric-box {
  min-width: 0;
  background: var(--secondary);
  padding: 10px;
  border-radius: var(--radius-sm);
}

.metric-box label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-box span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 600;
}

.metric-note {
  margin-top: 10px;
}

/* Inspiration Preview Modal */
.preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(33, 32, 30, 0.72);
  backdrop-filter: blur(2px);
}

.preview-dialog {
  position: relative;
  z-index: 1060;
  width: min(1080px, var(--preview-max-width, 86vw));
  max-height: min(780px, calc(100vh - 80px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* overflow:hidden on a CSS-grid container can cause unexpected
     clipping of grid items (known Chromium behavior). The stage
     and title handle their own overflow independently. */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  box-shadow: 0 24px 80px rgba(33, 32, 30, 0.38);
  overflow: hidden;
}

.preview-window-actions {
  position: relative;
  z-index: 1070;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(239, 230, 227, 0.88);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 12px rgba(33, 32, 30, 0.10);
  flex-shrink: 0;
}

.preview-window-actions .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
}

.preview-window-actions .icon-btn svg {
  width: 14px;
  height: 14px;
}

.preview-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-card);
  flex-wrap: nowrap;
}

.preview-title {
  min-width: 0;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  overflow: hidden;
}

.preview-title strong {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Preview footer ───────────────────────────────────── */
.preview-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-card);
}

.preview-metrics-grid {
  min-width: 0;
}

.preview-footer .metrics-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
  margin-top: 0;
}

.preview-footer .metric-box {
  padding: 6px 8px;
}

.preview-footer .metric-box label {
  font-size: 0.7rem;
  margin-bottom: 2px;
}

.preview-footer .metric-box span {
  font-size: 0.88rem;
}

.preview-footer .metric-note {
  width: 100%;
  margin-top: 0;
}

.preview-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.preview-footer-actions .btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.preview-footer-actions .copy-link-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.preview-footer-actions .copy-link-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
  stroke: var(--text-secondary, #6e6b63);
  fill: none;
}

@media (max-width: 900px) {
  .preview-footer {
    grid-template-columns: 1fr;
  }

  .preview-footer-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .preview-footer .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-stage {
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  max-height: calc(min(780px, 88vh) - 90px);
  padding: 14px;
  background: var(--surface-muted);
}

.preview-media {
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-media img,
.preview-media video,
.preview-media iframe {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  object-fit: contain;
  background: var(--surface-muted);
}

.preview-media .embedded-video {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  margin-bottom: 0;
  border: 0;
  overflow: hidden;
}

.preview-media .embedded-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.preview-media .video-play-frame,
.preview-media .xiaohongshu-scroll {
  width: 100%;
  height: 100%;
  margin-bottom: 0;
}

.preview-media .xiaohongshu-scroll img {
  max-height: 64%;
  object-fit: contain;
  background: var(--surface-muted);
}

.preview-media .xiaohongshu-scroll-copy {
  max-height: 36%;
  overflow: auto;
  background: #fff;
}

/* ── Preview media fallback (cover + play overlay) ────── */
.preview-media-fallback {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  background: #f0eee6;
}

.preview-media-fallback.preview-media-empty {
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(135deg, #f0eee6 0%, #e8e6dc 100%);
}

.preview-fallback-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-fallback-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease;
}

.preview-fallback-overlay:hover {
  background: rgba(0, 0, 0, 0.35);
}

.preview-fallback-play-icon {
  opacity: 0.9;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.preview-fallback-overlay:hover .preview-fallback-play-icon,
.preview-media-empty .preview-fallback-play-icon {
  transform: scale(1.06);
  opacity: 1;
}

.preview-media-empty .preview-fallback-play-icon {
  opacity: 0.5;
}

.preview-fallback-hint {
  font-size: 0.85rem;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  text-align: center;
  padding: 0 16px;
}

.preview-media-empty .preview-fallback-hint {
  color: #6e6b63;
  text-shadow: none;
}

.preview-fallback-btn {
  margin-top: 4px;
  border-radius: 8px !important;
  font-size: 0.85rem !important;
  padding: 0 20px !important;
  height: 36px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Legacy styles for tests */
.legacy-backdrop {
  backdrop-filter: blur(10px);
}

.legacy-color {
  color: rgba(255, 255, 255, 0.6);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Material File Preview Modal ─────────────────────────────────── */
.material-preview-dialog {
  width: min(900px, 90vw);
  max-height: min(780px, 88vh);
}

.material-preview-header .preview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.material-preview-header .preview-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.material-preview-filesize {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.material-preview-header .preview-window-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.material-preview-stage {
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.material-preview-text {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--color-card);
}

.material-preview-text pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-main);
}

.material-preview-media {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-muted, #f0eee6);
  padding: 12px;
}

.material-preview-media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.material-preview-media video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}

.material-preview-media audio {
  width: 80%;
  max-width: 420px;
}

.material-preview-iframe {
  width: 100%;
  height: 100%;
}

.material-preview-iframe iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.material-preview-link-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  text-align: center;
}

.material-preview-link-view .material-preview-link-icon {
  font-size: 2rem;
  opacity: 0.4;
}

.material-preview-link-view strong {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.material-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.material-preview-file-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  text-align: center;
  width: 100%;
  min-height: 200px;
}

.material-preview-file-info .material-preview-file-info-icon {
  font-size: 2.5rem;
  opacity: 0.35;
  margin-bottom: 4px;
}

.material-preview-file-info strong {
  font-size: 1rem;
}

.material-preview-file-info p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

.material-preview-file-info .muted {
  font-size: 0.8rem;
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none;
    scroll-behavior: auto;
    transition: none;
  }
}

@media (max-width: 1180px) {
  .content-workflow-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .materials-grid,
  .materials-filter-row,
  .materials-toolbar,
  .copylibrary-layout,
  .copylibrary-toolbar,
  .copylibrary-filter-grid,
  .review-dashboard,
  .review-chart-grid,
  .review-filterbar,
  .assets-layout,
  .assets-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .material-detail-panel,
  .copylibrary-detail-panel,
  .review-summary-card,
  .assets-tree-panel,
  .asset-detail-panel {
    position: static;
    max-height: none;
  }

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

  .content-config-panel,
  .content-status-panel {
    position: static;
  }

  .assets-public-banner {
    grid-template-columns: minmax(0, 1fr);
  }

  .assets-public-roles {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-container {
    min-height: 100vh;
    height: auto;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .sidebar-header {
    padding: 16px;
  }

  .sidebar-nav {
    flex: none;
    padding: 0 12px 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar-nav ul {
    flex-direction: row;
    gap: 6px;
    min-width: max-content;
  }

  .nav-item {
    white-space: nowrap;
    padding: 8px 10px;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .topbar {
    align-items: flex-start;
    gap: 12px;
    padding: 16px 16px;
  }

  .topbar h1 {
    font-size: 1.15rem;
    line-height: 1.2;
  }

  .view-container {
    padding: 0 16px 24px;
    overflow: visible;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto;
  }

  .split-main,
  .split-side {
    overflow: visible;
    padding: 0;
  }

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

  .profile-workbench-grid,
  .profile-field-grid,
  .profile-check-grid {
    grid-template-columns: 1fr;
  }

  .profile-side-panel {
    position: static;
  }

  .profile-reference-head,
  .profile-reference-row {
    min-width: 780px;
    grid-template-columns: minmax(150px, 1.2fr) 64px minmax(120px, 1fr) 96px 72px 72px 48px;
  }

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

  .compact-import,
  .platform-import-form,
  .platform-import-strip,
  .analysis-grid,
  .ai-mode-grid,
  .content-aux-panels,
  .content-stepper,
  .content-workflow-grid,
  .draft-field-grid,
  .copylibrary-filter-grid,
  .copylibrary-composer-grid,
  .material-composer-grid,
  .asset-composer-grid,
  .material-meta-grid,
  .asset-meta-grid,
  .asset-scenario-list,
  .review-import-grid,
  .review-kpi-grid,
  .review-toolbar-actions,
  .assets-stat-row,
  .assets-toolbar,
  .assets-search,
  .materials-stat-row,
  .favorite-row {
    grid-template-columns: 1fr;
  }

  .content-config-panel,
  .content-status-panel {
    position: static;
  }

  .workflow-editor-card {
    min-height: 0;
  }

  .draft-body-field {
    min-height: 220px;
  }

  .module-heading,
  .filter-bar,
  .utility-strip,
  .content-subnav {
    align-items: stretch;
  }

  .import-side-tabs {
    justify-content: flex-start;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  body.assets-page .asset-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .assets-public-banner,
  .public-resource-detail {
    padding: 12px;
  }

  .assets-owner-toolbar,
  .assets-grid-heading-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .assets-grid-card .module-heading {
    grid-template-columns: minmax(0, 1fr);
  }

  .assets-grid-heading-actions .btn {
    max-width: 100%;
  }

  .asset-card-body p {
    min-height: 0;
  }

  .inspiration-workbench,
  .inspiration-topbar,
  .inspiration-import-actions,
  .inspiration-list-row,
  .detail-decompose-form {
    grid-template-columns: 1fr;
  }

  .inspiration-result-toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .toolbar-right-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .inspiration-detail-panel {
    position: static;
    max-height: none;
  }

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

  .inspiration-card-grid {
    grid-template-columns: 1fr;
  }

  .list-row-preview {
    width: 100%;
  }

  .list-row-metrics .inspiration-card-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .review-filterbar {
    position: static;
  }

  .review-toolbar-actions,
  .review-import-actions {
    justify-content: flex-start;
  }

  .preview-backdrop {
    padding: 12px;
  }

  .preview-dialog {
    width: 100%;
    max-height: 90vh;
  }

  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .preview-footer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .preview-footer-actions {
    justify-content: flex-end;
  }

  .preview-footer .metrics-row {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-history-backdrop {
    align-items: stretch;
    padding: 12px;
  }

  .profile-history-dialog {
    width: 100%;
    max-height: calc(100vh - 24px);
  }

  .profile-history-toolbar,
  .profile-history-header,
  .profile-history-row {
    grid-template-columns: 1fr;
  }

  .profile-history-row {
    gap: 8px;
  }

  .data-item {
    gap: 10px;
    flex-direction: column;
  }

  .data-item-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .btn {
    min-height: 36px;
    white-space: normal;
    word-break: keep-all;
  }

  .materials-table-head {
    display: none;
  }

  .materials-table-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
  }

  .materials-table-row .material-name-cell {
    order: 1;
  }

  .materials-table-row>span:nth-child(2),
  .materials-table-row>span:nth-child(3) {
    display: inline;
  }

  .materials-table-row>span {
    font-size: 0.78rem;
  }

  .materials-table-row .material-row-actions {
    order: 10;
    justify-content: flex-end;
    margin-top: 4px;
  }

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

  .material-action-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .materials-empty-actions {
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 1180px) {
  .profile-topbar {
    grid-template-columns: minmax(150px, 1fr) minmax(180px, 220px);
  }

  .profile-search,
  .profile-toolbar-actions {
    grid-column: 1 / -1;
  }

  .profile-toolbar-actions {
    justify-content: flex-start;
  }

  .profile-workbench-grid {
    grid-template-columns: 1fr;
  }

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

  .profile-context-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  body.profile-page {
    overflow: auto;
  }

  body.profile-page .app-container {
    min-height: 100vh;
    height: auto;
  }

  body.profile-page .sidebar {
    width: 100%;
  }

  body.profile-page .main-content {
    height: auto;
    overflow: visible;
  }

  body.profile-page .view-container {
    padding: 12px;
    overflow: visible;
  }

  .profile-topbar,
  .profile-context-selector,
  .profile-editor-meta,
  .profile-form-grid.two,
  .profile-ai-guide,
  .profile-row-field,
  .profile-summary-list div {
    grid-template-columns: 1fr;
  }

  .profile-toolbar-actions,
  .profile-meta-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .profile-reference-table {
    overflow-x: auto;
  }
}

@media (max-width: 1279px) {
  body.inspiration-page .inspiration-workbench {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  body.inspiration-page .inspiration-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.inspiration-page .inspiration-detail-panel {
    width: 300px;
  }
}

@media (max-width: 1180px) {
  body.inspiration-page .inspiration-workbench {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  body.inspiration-page .inspiration-detail-panel {
    width: 280px;
  }

  body.inspiration-page .inspiration-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.inspiration-page .inspiration-topbar {
    grid-template-columns: 1fr;
  }

  body.inspiration-page .inspiration-import-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 900px) {
  body.inspiration-page .inspiration-workbench {
    grid-template-columns: 1fr;
  }

  body.inspiration-page .inspiration-detail-panel {
    position: fixed;
    inset: auto 12px 12px 12px;
    z-index: 50;
    width: auto;
    max-height: min(76vh, 720px);
    border: 1px solid var(--inspiration-border);
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(33, 32, 30, 0.2);
  }
}

@media (max-width: 767px) {
  body.inspiration-page .app-container {
    display: block;
    overflow-x: hidden;
  }

  body.inspiration-page .sidebar {
    width: 100%;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--inspiration-border);
  }

  body.inspiration-page .sidebar-nav {
    overflow-x: auto;
  }

  body.inspiration-page #module-nav {
    display: flex;
    gap: 6px;
    padding: 8px;
  }

  body.inspiration-page .nav-item {
    min-width: 44px;
  }

  body.inspiration-page #app {
    padding: 12px;
  }

  body.inspiration-page .inspiration-title-block,
  body.inspiration-page .inspiration-list-row {
    grid-template-columns: 1fr;
  }

  body.inspiration-page .inspiration-result-toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  body.inspiration-page .filter-row,
  body.inspiration-page .chip-row,
  body.inspiration-page .inspiration-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  body.inspiration-page .inspiration-card-grid {
    grid-template-columns: 1fr;
  }

}

/* Typography pass: Apple-inspired PingFang hierarchy.
   Regular is the default for legibility; Medium/Semibold are reserved for controls, labels, navigation, and titles. */
body,
body .main-content,
body .sidebar,
body .workspace,
body .view-container,
body button,
body input,
body textarea,
body select,
body .btn,
body .nav-item,
body .filter-chip,
body .tab-btn,
body .status-pill,
body .inspiration-tag,
body .field,
body .checkbox-line,
body .data-item-meta,
body .detail-body,
body .creator-line,
body .list-row-meta,
body .source-link-row,
body .profile-summary-list,
body .profile-check-row,
body .copylibrary-table,
body .materials-table,
body .review-table {
  font-family: var(--font-sans);
  font-weight: var(--weight-regular);
  letter-spacing: 0;
}

body .main-content,
body .workspace,
body .view-container,
body .panel,
body .content-area,
body .right-panel-content,
body .profile-workbench,
body .inspiration-workbench {
  font-size: var(--text-body);
  line-height: 1.45;
}

body p,
body span,
body label,
body li,
body td,
body th,
body small,
body em,
body time,
body .muted,
body .section-subtitle,
body .data-item-meta,
body .detail-body,
body .creator-line,
body .list-row-meta,
body .source-link-row,
body .profile-summary-list,
body .profile-check-row,
body .copylibrary-table,
body .materials-table,
body .review-table {
  font-weight: var(--weight-regular);
  line-height: 1.45;
}

body button,
body input,
body textarea,
body select,
body .btn,
body .filter-chip,
body .tab-btn,
body .status-pill,
body .field,
body .checkbox-line {
  font-size: var(--text-control);
  font-weight: var(--weight-medium);
  line-height: 1.35;
}

body textarea,
body input,
body select {
  font-weight: var(--weight-regular);
}

body small,
body time,
body .muted,
body .section-subtitle,
body .data-item-meta,
body .creator-line,
body .list-row-meta,
body .metric-label,
body .user-role,
body .brand span,
body .inspiration-meta,
body .profile-muted {
  font-size: var(--text-caption);
  font-weight: var(--weight-regular);
}

body h1,
body h2,
body h3,
body h4,
body h5,
body h6,
body strong,
body b,
body .brand strong,
body .logo-mark,
body .section-title,
body .module-heading h2,
body .module-heading h3,
body .module-heading h4,
body .topbar h1,
body .info-title,
body .detail-title,
body .list-row-title,
body .data-item-title,
body .metric-box span,
body .profile-topbar h2,
body .profile-person strong,
body .profile-context-head strong,
body .profile-switch-row strong,
body .inspiration-title-block h2,
body .inspiration-card-v2 h3,
body .right-panel-header h3,
body .copylibrary-detail-card h3,
body .material-detail-card h3,
body .asset-detail-card h3,
body .review-detail-card h3 {
  font-weight: var(--weight-semibold);
  line-height: 1.25;
}

body .topbar h1,
body .module-heading h2,
body .profile-title-block h2,
body .inspiration-title-block h2 {
  font-size: var(--text-page-title);
  font-weight: var(--weight-semibold);
}

body .section-title,
body .right-panel-header h3,
body .module-heading h3,
body .module-heading h4,
body .profile-context-head strong,
body .copylibrary-detail-card h3,
body .material-detail-card h3,
body .asset-detail-card h3,
body .review-detail-card h3 {
  font-size: var(--text-section-title);
  font-weight: var(--weight-semibold);
}

body .data-item-title,
body .info-title,
body .detail-title,
body .list-row-title,
body .inspiration-card-v2 h3 {
  font-size: 15px;
  font-weight: var(--weight-semibold);
  line-height: 1.35;
}

body .sidebar,
body .sidebar .brand,
body .sidebar .brand strong,
body .sidebar .brand span,
body .sidebar .nav-item,
body .sidebar .nav-label,
body .sidebar .user-name,
body .sidebar .user-role {
  font-weight: var(--weight-semibold);
}

body .sidebar {
  font-size: var(--text-body);
  line-height: 1.35;
}

body .sidebar .nav-item {
  font-size: var(--text-body);
  line-height: 20px;
}

body .metric-box span,
body [class*="metric"] strong,
body [class*="count"] {
  font-family: var(--font-numeric);
  font-weight: var(--weight-semibold);
}

/* Settings */
body.settings-page {
  --workbench-max: 1180px;
}

body.access-review-page {
  --workbench-max: 980px;
}

.settings-workbench {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.settings-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.settings-hero h1,
.settings-card h2 {
  margin: 0;
  color: var(--text-main);
}

.settings-hero h1 {
  font-size: 24px;
}

.settings-hero p,
.settings-card-head p,
.settings-muted {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-pill {
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--secondary);
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
}

.access-review-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.access-review-meta>div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.access-review-meta span,
.access-review-meta strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-review-meta span {
  color: var(--text-muted);
  font-size: 12px;
}

.access-review-meta strong {
  margin-top: 3px;
  color: var(--text-main);
  font-size: 15px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(380px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.settings-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 16px;
}

.settings-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  box-shadow: var(--shadow-sm);
}

.settings-template-card {
  grid-column: auto;
}

.ai-status-note,
.settings-provider-summary,
.settings-config-readback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--color-warning) 40%, var(--color-border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-warning) 10%, var(--color-card));
  color: var(--color-warning);
}

.ai-status-note.ok,
.settings-provider-summary.ok,
.settings-config-readback.ok {
  border-color: color-mix(in srgb, var(--color-success) 40%, var(--color-border));
  background: color-mix(in srgb, var(--color-success) 10%, var(--color-card));
  color: var(--color-success);
}

.settings-config-readback.neutral {
  border-color: var(--color-border);
  background: var(--secondary);
  color: var(--primary-accent);
}

.ai-status-note.compact {
  margin-top: 0;
  margin-bottom: 10px;
}

body.profile-page .ai-status-note.subtle {
  width: max-content;
  max-width: 100%;
  min-height: 28px;
  justify-content: flex-start;
  margin: 0 0 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--color-card);
}

body.profile-page .ai-status-note.subtle div {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

body.profile-page .ai-status-note.subtle span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

body.profile-page .ai-status-note.subtle span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}

body.profile-page .ai-status-note.subtle strong,
body.profile-page .ai-status-note.subtle p {
  margin: 0;
  font-size: 12px;
}

body.profile-page .ai-status-note.subtle p {
  max-width: min(340px, 45vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-status-note div,
.settings-provider-summary,
.settings-config-readback {
  min-width: 0;
}

.ai-status-note span,
.settings-provider-summary span,
.settings-config-readback span {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.ai-status-note strong,
.settings-provider-summary strong,
.settings-config-readback strong {
  display: block;
  margin-top: 2px;
  color: var(--text-main);
  font-size: 14px;
}

.ai-status-note p,
.settings-provider-summary p,
.settings-config-readback p,
.settings-missing-line {
  margin: 4px 0 0;
  color: currentColor;
  font-size: 12px;
  line-height: 1.45;
}

.ai-status-note .btn {
  flex: 0 0 auto;
}

.settings-card-head,
.settings-template-actions,
.settings-test-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.theme-choice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.theme-choice {
  min-height: 86px;
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--secondary);
  color: var(--text-main);
  padding: 12px;
  cursor: pointer;
}

.theme-choice strong,
.theme-choice span {
  display: block;
}

.theme-choice span {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.theme-choice.active {
  border-color: var(--primary);
  background: var(--secondary);
  color: var(--primary);
}

.settings-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.settings-status-item {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--secondary);
}

.access-request-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.access-request-item>div:first-child {
  min-width: 0;
}

.access-request-item small {
  display: block;
  min-width: 0;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.access-request-source {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  margin: 0 6px 0 0;
  padding: 1px 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--primary-accent);
}

.settings-status-item span,
.settings-status-item strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-status-item span {
  color: var(--text-muted);
  font-size: 12px;
}

.settings-status-item strong {
  margin-top: 4px;
  font-size: 14px;
}

.settings-status-item strong.ok {
  color: #16a34a;
}

.settings-status-item strong.warn {
  color: #f97316;
}

.settings-inline-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.access-code-created {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  background: #fffbeb;
  color: #92400e;
}

.access-code-created span {
  color: currentColor;
  font-size: 12px;
  font-weight: 700;
}

.access-code-created strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-numeric);
  letter-spacing: 0.04em;
}

.access-code-created .btn {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.access-code-list,
.access-ledger-grid>div {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.access-code-list {
  margin-top: 14px;
}

.access-code-row,
.access-ledger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--secondary);
}

.access-code-row>div:first-child,
.access-ledger-row>div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.access-code-row strong,
.access-ledger-row strong,
.access-code-row small,
.access-ledger-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-code-row strong,
.access-ledger-row strong {
  color: var(--text-main);
  font-size: 14px;
}

.access-code-row small,
.access-ledger-row small {
  color: var(--text-muted);
  font-size: 12px;
}

.access-code-status,
.quota-mini {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--primary-accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.access-code-status.active,
.quota-mini.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.access-code-status.disabled,
.quota-mini.expired {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.quota-mini.exhausted,
.access-code-status.exhausted {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

/* HAZ-200 P1：派生态色板——已过期复用红、部分兑换走中性蓝灰。 */
.access-code-status.expired {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.access-code-status.partial {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

/* HAZ-200 P1：批次标记、展开兑换记录、检索工具条、批量数量预设、批量明文结果。 */
.access-code-batch {
  color: var(--primary-accent) !important;
  font-weight: 600;
}

.access-code-expand-toggle {
  justify-self: start;
  margin-top: 2px;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary-accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.access-code-expand-toggle:hover {
  text-decoration: underline;
}

.access-code-redemptions-wrap {
  margin-top: 6px;
}

.access-code-redemptions {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 8px 10px;
  list-style: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--background, #fff);
}

.access-code-redemptions li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-main);
  white-space: normal;
}

.access-code-redemptions li time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.access-code-redemptions-empty {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.access-code-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.access-code-search {
  flex: 1 1 200px;
  min-width: 160px;
}

.access-code-filter {
  flex: 0 0 auto;
  width: auto;
  min-width: 120px;
}

.access-code-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

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

.access-code-quantity-field .field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.access-code-quantity-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.access-code-qty-chip {
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.access-code-qty-chip:hover {
  border-color: var(--primary-accent);
  color: var(--primary-accent);
}

.access-code-qty-input {
  width: 110px;
}

.access-code-batch-result {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  background: #fffbeb;
  color: #92400e;
}

.access-code-batch-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.access-code-batch-result-head span {
  font-size: 12px;
  font-weight: 700;
}

.access-code-batch-codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  max-height: 220px;
  margin: 10px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.access-code-batch-codes code {
  display: block;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(146, 64, 14, 0.08);
  font-family: var(--font-numeric);
  font-size: 12px;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.btn.danger-ghost {
  border-color: #fecaca;
  color: #b91c1c;
}

.btn.danger-ghost:hover {
  background: #fef2f2;
}

.access-ledger-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.access-ledger-grid h3 {
  margin: 0 0 2px;
  color: var(--text-main);
  font-size: 14px;
}

.settings-env-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.settings-env-list div {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}

.settings-env-list code {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--secondary);
  color: var(--text-main);
}

.settings-env-list code {
  padding: 6px 8px;
  white-space: nowrap;
}

.settings-test-row {
  margin-top: 14px;
}

.settings-test-result {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-test-result.ok {
  color: #16a34a;
}

.settings-test-result.warn {
  color: #f97316;
}

.settings-template-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

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

.settings-template-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

.settings-note-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
  line-height: 1.8;
}

.settings-archive-card {
  overflow: hidden;
}

.settings-archive-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 14px;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--color-card) 94%, #ffffff), var(--color-card));
  cursor: pointer;
  list-style: none;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.settings-archive-summary:hover,
.settings-archive-summary:focus-visible,
.settings-archive-card[open] .settings-archive-summary {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--color-border));
  background: color-mix(in srgb, var(--primary) 7%, var(--color-card));
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.settings-archive-summary::after {
  content: "";
  width: 7px;
  height: 7px;
  justify-self: center;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.16s ease;
}

.settings-archive-card[open] .settings-archive-summary::after {
  transform: translateY(2px) rotate(225deg);
}

.settings-archive-summary::-webkit-details-marker {
  display: none;
}

.settings-archive-copy {
  display: block;
  min-width: 0;
}

.settings-archive-copy h2,
.settings-archive-copy p {
  overflow-wrap: anywhere;
}

.settings-archive-count {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--primary-accent);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.settings-archive-body {
  min-width: 0;
  margin-top: 12px;
}

body.settings-page .settings-archive-card .profile-archived-list {
  max-height: min(340px, 45vh);
  overflow: auto;
  padding-right: 2px;
}

body.settings-page .settings-archive-card .profile-archived-row {
  grid-template-columns: 32px minmax(0, 1fr) minmax(92px, auto);
  background: var(--secondary);
}

body.settings-page .settings-archive-card .profile-restore-btn {
  justify-self: end;
  min-width: 96px;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] body.reference-workbench-page,
html[data-theme="dark"] body.reference-workbench-page .main-content {
  background: var(--color-bg);
  color: var(--text-main);
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .module-card,
html[data-theme="dark"] .utility-strip,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .settings-hero,
html[data-theme="dark"] .material-detail-panel,
html[data-theme="dark"] .asset-detail-panel,
html[data-theme="dark"] .assets-tree-panel,
html[data-theme="dark"] .copylibrary-detail-panel,
html[data-theme="dark"] body.reference-workbench-page .materials-toolbar,
html[data-theme="dark"] body.reference-workbench-page .assets-toolbar,
html[data-theme="dark"] body.reference-workbench-page .copylibrary-toolbar,
html[data-theme="dark"] body.reference-workbench-page .review-filterbar {
  background: var(--color-card);
  border-color: var(--color-border);
}

html[data-theme="dark"] .material-detail-info div {
  background: var(--surface-muted);
  border-color: var(--color-border);
}

html[data-theme="dark"] .material-tag-more {
  background: var(--surface-muted);
}

html[data-theme="dark"] .material-row-action:hover {
  background: var(--ghost-hover-bg); /* §12 dark：复用中性浅白 token */
}

html[data-theme="dark"] .materials-empty-icon {
  background: var(--surface-muted);
}

html[data-theme="dark"] .input-field,
html[data-theme="dark"] .textarea-field,
html[data-theme="dark"] select,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea {
  background: var(--surface-muted);
  border-color: var(--color-border);
  color: var(--text-main);
}

html[data-theme="dark"] .secondary-btn,
html[data-theme="dark"] .page-btn,
html[data-theme="dark"] .theme-choice,
html[data-theme="dark"] .settings-status-item {
  background: var(--secondary);
  border-color: var(--color-border);
  color: var(--text-main);
}

html[data-theme="dark"] .nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-hover-text);
  border-color: var(--nav-hover-border);
}

html[data-theme="dark"] .nav-item:hover .nav-icon svg {
  stroke: var(--nav-hover-icon);
}

html[data-theme="dark"] .secondary-btn:hover {
  background: var(--secondary-hover);
}

html[data-theme="dark"] .nav-item.active {
  background: var(--nav-active-bg);
  border-color: var(--nav-active-border);
  color: var(--nav-active-text);
}

html[data-theme="dark"] .nav-item.active .nav-icon svg {
  stroke: var(--nav-active-icon);
}

html[data-theme="dark"] .secondary-btn.active,
html[data-theme="dark"] .theme-choice.active,
html[data-theme="dark"] .settings-pill,
html[data-theme="dark"] .settings-archive-count {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--text-main);
}

html[data-theme="dark"] .ai-status-note,
html[data-theme="dark"] .settings-provider-summary,
html[data-theme="dark"] .settings-config-readback {
  border-color: rgba(251, 146, 60, 0.35);
  background: rgba(154, 52, 18, 0.2);
  color: #fdba74;
}

html[data-theme="dark"] .ai-status-note.ok,
html[data-theme="dark"] .settings-provider-summary.ok,
html[data-theme="dark"] .settings-config-readback.ok {
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(22, 101, 52, 0.24);
  color: #86efac;
}

html[data-theme="dark"] .settings-config-readback.neutral {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--text-main);
}

body.profile-page .ai-status-note.subtle.ok {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--color-border));
  color: var(--accent);
}
body.profile-page .ai-status-note.subtle.warn {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--color-border));
  color: var(--danger);
}

@media (max-width: 1100px) {

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

  .theme-choice-row,
  .settings-status-grid,
  .access-review-meta {
    grid-template-columns: 1fr;
  }
}
