:root {
  --red: #b42318;
  --ink: #241f1b;
  --muted: #766c62;
  --line: #e7ddd2;
  --paper: #fffdfa;
  --bg: #f6f4f1;
  --blue: #233d4d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 36px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.app-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.app-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.header-stat {
  min-width: 120px;
  text-align: right;
}

.header-stat strong {
  display: block;
  color: var(--red);
  font-size: 34px;
  line-height: 1;
}

.header-stat span {
  color: var(--muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - 105px);
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
}

.tab,
.secondary,
.load-more {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.tab {
  height: 42px;
}

.skill-tab { grid-column: 1 / -1; }
[hidden] { display: none !important; }
.assistant-form, .assistant-result { max-width: 1000px; }
.assistant-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
.assistant-form label, .assistant-result label, .skill-reference label {
  display: grid; gap: 8px; margin: 0 0 18px; font-weight: 600; font-size: 14px;
}
.assistant-form textarea, .assistant-result textarea, #skillPrompt {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font: inherit; line-height: 1.65; resize: vertical;
}
.assistant-form textarea:focus, .assistant-result textarea:focus, #skillPrompt:focus { border-color: var(--red); }
.assistant-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.assistant-actions > button:first-child {
  height: 42px; padding: 0 18px; border: 0; border-radius: 8px;
  background: var(--red); color: #fff; cursor: pointer;
}
.assistant-actions > span { flex-basis: 100%; color: var(--muted); font-size: 13px; line-height: 1.6; }
.assistant-actions a { color: var(--blue); }
.assistant-result { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); scroll-margin-top: 20px; }
.assistant-result .content-head { margin-bottom: 18px; }
.assistant-result h3 { margin: 0; font-size: 19px; }
.assistant-recommendation { margin-bottom: 22px; padding-left: 14px; border-left: 3px solid var(--red); line-height: 1.7; }
.assistant-checks { margin-top: 22px; border-top: 1px solid var(--line); color: var(--muted); line-height: 1.7; }
.assistant-checks h4 { margin: 18px 0 8px; color: var(--ink); font-size: 15px; }
.assistant-checks ul { margin: 0; padding-left: 22px; }
.skill-reference { max-width: 1000px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.skill-reference summary { cursor: pointer; font-weight: 600; }
.skill-reference p { color: var(--muted); line-height: 1.7; }
#skillPrompt { min-height: 120px; }
.link-row.skill-actions { flex-wrap: wrap; margin-top: 16px; }
.skill-actions a, .skill-actions button { min-height: 44px; }
.skill-status { min-height: 24px; font-size: 14px; color: var(--blue); }
button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--red); outline-offset: 3px;
}
.skill-actions a:hover, .skill-actions button:hover { filter: brightness(.92); }
@media (max-width: 580px) {
  .assistant-fields { grid-template-columns: 1fr; gap: 0; }
  .skill-actions { align-items: stretch; flex-direction: column; }
}

.tab.active {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.search,
.filters label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.search span,
.filters span {
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--red);
}

.hint {
  margin-top: 24px;
  padding: 14px;
  border-radius: 8px;
  background: #f7f1ea;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.content {
  display: none;
  padding: 24px 28px 48px;
}

.content.active {
  display: block;
}

.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.content-head h2 {
  margin: 0;
  font-size: 22px;
}

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

.secondary {
  height: 38px;
  padding: 0 14px;
}

.works-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.work-card,
.compare-card,
.compare-panel,
.cluster {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.work-card {
  padding: 18px;
  cursor: pointer;
}

.work-card:hover,
.cluster:hover {
  border-color: #d7b8a2;
  box-shadow: 0 8px 18px rgba(62, 43, 31, 0.08);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  background: #f0e7dc;
  color: #77502c;
  font-size: 12px;
}

.tag.red {
  background: #f8ded9;
  color: #9f2118;
}

.tag.blue {
  background: #dfeaf7;
  color: #245a8d;
}

.work-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
}

.meta,
.topic {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.load-more {
  display: block;
  width: 180px;
  height: 42px;
  margin: 24px auto 0;
}

.cluster-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.cluster {
  min-width: 150px;
  padding: 14px;
  cursor: pointer;
}

.cluster.active {
  border-color: var(--red);
  background: #fff5f3;
}

.cluster strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.compare-card {
  padding: 16px;
}

.analysis {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.55;
}

.analysis b {
  color: #9a5b24;
}

.detail-dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  padding: 0;
}

.detail-dialog::backdrop {
  background: rgba(18, 15, 13, 0.45);
}

.close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f1e8df;
  cursor: pointer;
}

.detail-body {
  padding: 28px;
}

.detail-body h2 {
  margin: 14px 0;
  padding-right: 40px;
  line-height: 1.4;
}

.detail-table {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px 18px;
  margin: 18px 0;
  font-size: 14px;
  line-height: 1.5;
}

.detail-table dt {
  color: var(--muted);
}

.detail-table dd {
  margin: 0;
}

.link-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.link-row a,
.link-row button {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.link-row button {
  background: var(--blue);
}

.link-row .ghost-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.extra-links {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: #f7f1ea;
  font-size: 13px;
  line-height: 1.45;
}

.extra-links a {
  color: #245a8d;
  overflow-wrap: anywhere;
}

.empty-note {
  min-width: 260px;
  padding: 14px;
  color: var(--muted);
}

.category-analysis { margin: 28px 0 36px; scroll-margin-top: 24px; }
.category-analysis-heading h3, .topic-compare-heading { margin: 0 0 8px; font-size: 18px; }
.category-analysis-heading p { margin: 0 0 16px; color: #61564d; font-size: 14px; line-height: 1.7; }
.report-entry {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); text-decoration: none;
  transition: border-color 160ms ease-out, background-color 160ms ease-out;
}
.report-entry:hover { border-color: var(--red); background: var(--paper); }
.report-entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: #61564d; font-size: 13px; }
.report-entry h4 { margin: 14px 0 10px; font-size: 22px; line-height: 1.5; text-wrap: balance; }
.report-entry p { max-width: 52ch; margin: 0 0 16px; font-size: 15px; line-height: 1.8; }
.report-entry-note { color: #61564d; font-size: 13px; }
.report-entry-action { flex-shrink: 0; font-size: 15px; color: var(--red); font-weight: 600; }
.topic-compare-heading { margin-bottom: 16px; }
@media (max-width: 580px) {
  .report-entry { align-items: flex-start; flex-direction: column; gap: 20px; padding: 20px; }
  .report-entry h4 { font-size: 20px; }
  .works-list { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .report-entry { transition: none; } }

@media (max-width: 820px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px;
  }

  .header-stat {
    text-align: left;
  }

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

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

  .content {
    padding: 20px;
  }
}

/* Category reports retain their own four-session scope. */
.report-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; margin: 18px 0 10px; }
.report-controls label { color: var(--ink); font-size: 14px; font-weight: 600; }
.report-controls select { width: auto; min-width: 230px; max-width: 100%; min-height: 44px; margin: 0; background-color: var(--paper); font-size: 15px; }
.report-controls a { color: var(--red); font-size: 14px; text-underline-offset: 4px; padding: 8px 0; }
.report-scope { margin: 0 0 18px; color: #61564d; font-size: 13px; line-height: 1.7; }
.report-controls :focus-visible, .report-entry:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }
@media (max-width: 580px) {
  .report-controls label { width: 100%; }
  .report-controls select { width: 100%; }
}
