:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-muted: #f7f8f7;
  --ink: #17201c;
  --muted: #66716c;
  --line: #dce2df;
  --line-strong: #c9d1cd;
  --green: #1f6650;
  --green-soft: #e4f0eb;
  --red: #a44343;
  --red-soft: #f8e9e7;
  --gold: #946f2a;
  --gold-soft: #f6efd9;
  --shadow: 0 16px 40px rgba(28, 45, 37, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(31, 102, 80, 0.2);
  outline-offset: 1px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 10px 28px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 6px;
  font-family: STKaiti, KaiTi, serif;
  font-size: 20px;
}
.brand h1 { margin: 0; font-size: 17px; line-height: 1.35; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.primary-tabs {
  display: flex;
  align-self: stretch;
  align-items: stretch;
  gap: 26px;
}
.tab {
  position: relative;
  min-width: 72px;
  padding: 0 4px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
}
.tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -10px;
  left: 0;
  height: 3px;
  background: transparent;
}
.tab.is-active { color: var(--green); }
.tab.is-active::after { background: var(--green); }

.data-meta {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3e8b6d; }

.essay-area { min-height: calc(100vh - 72px); }
.essay-subnav {
  height: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: 0 28px;
  background: #fafbfa;
  border-bottom: 1px solid var(--line);
}
.subtab {
  height: 40px;
  min-width: 104px;
  padding: 0 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
}
.subtab.is-active { color: var(--green); border-bottom-color: var(--green); }

.workspace {
  max-width: 1500px;
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.filter-panel {
  position: sticky;
  top: 72px;
  align-self: start;
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 28px 24px 40px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.filter-heading, .content-toolbar, .result-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}
.filter-heading h2, .content-toolbar h2, .materials-inner h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}
.text-button {
  padding: 6px 0;
  border: 0;
  color: var(--green);
  background: transparent;
}

.field { display: block; margin-top: 21px; }
.field > span:first-child, .sort-control > span {
  display: block;
  margin-bottom: 8px;
  color: #48534e;
  font-size: 12px;
  font-weight: 600;
}
input, select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
}
select { padding-right: 30px; }
.input-wrap { position: relative; display: block; }
.search-symbol {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 13px;
  height: 13px;
  border: 2px solid #7c8882;
  border-radius: 50%;
}
.search-symbol::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 2px;
  right: -5px;
  bottom: -3px;
  background: #7c8882;
  transform: rotate(45deg);
}
.search-field input { padding-left: 36px; }

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 22px; }
.filter-chip {
  max-width: 100%;
  overflow: hidden;
  padding: 5px 8px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 4px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-panel { min-width: 0; padding: 30px 34px 48px; }
.content-toolbar { align-items: flex-end; margin-bottom: 20px; }
.result-title { justify-content: flex-start; gap: 10px; }
.result-count { color: var(--muted); font-size: 13px; font-weight: 500; }
.sort-control { display: grid; grid-template-columns: auto 170px; align-items: center; gap: 10px; }
.sort-control > span { margin: 0; }
.sort-control select { height: 36px; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.summary-item { padding: 14px 17px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item span { display: block; color: var(--muted); font-size: 11px; }
.summary-item strong { display: block; margin-top: 4px; font-size: 17px; }

.essay-list {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.essay-row {
  width: 100%;
  min-height: 110px;
  display: grid;
  grid-template-columns: minmax(270px, 1.25fr) minmax(250px, 1fr) 118px 28px;
  align-items: center;
  gap: 22px;
  padding: 19px 22px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  background: var(--surface);
  text-align: left;
}
.essay-row:last-child { border-bottom: 0; }
.essay-row:hover { background: #f9fbfa; }
.essay-id { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.essay-title { margin: 0; font-size: 17px; line-height: 1.4; }
.essay-context { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.image-badge { display: inline-block; margin-left: 5px; padding: 2px 5px; color: var(--green); background: var(--green-soft); border-radius: 3px; font-size: 10px; vertical-align: 1px; }
.tag-line { display: flex; flex-wrap: wrap; gap: 6px; max-height: 52px; overflow: hidden; }
.tag {
  display: inline-block;
  max-width: 100%;
  padding: 4px 7px;
  overflow: hidden;
  border-radius: 4px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag.pro { color: var(--green); background: var(--green-soft); }
.tag.con { color: var(--red); background: var(--red-soft); }
.tag.neutral { color: #58625d; background: #edf0ee; }
.pending-tag { color: var(--gold); background: var(--gold-soft); }
.tag.invalid { color: #75551e; background: var(--gold-soft); border: 1px solid #e4d4a1; }
.score-block { text-align: right; }
.score-block strong { display: block; font-size: 17px; }
.score-block span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.row-arrow { color: #87918c; font-size: 20px; text-align: right; }

.empty-state { padding: 70px 20px; text-align: center; }
.empty-symbol {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}
.empty-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 22px; color: var(--muted); font-size: 12px; }
.page-jump { display: flex; align-items: center; gap: 6px; }
.page-jump input {
  width: 54px;
  height: 36px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  text-align: center;
}
.page-jump input:focus { border-color: #81948a; outline: 2px solid rgba(74, 108, 90, 0.14); outline-offset: 1px; }
.page-jump-button {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
}
.page-jump-button:hover { border-color: #81948a; background: #f6f8f7; }
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font-size: 18px;
}
.icon-button:disabled { opacity: 0.35; cursor: default; }

.materials-view {
  max-width: 1500px;
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}
.material-filters {
  position: sticky;
  top: 72px;
  align-self: start;
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 28px 24px 40px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.material-content { min-width: 0; padding: 30px 34px 48px; }
.material-data-status { max-width: 360px; color: var(--muted); font-size: 11px; text-align: right; line-height: 1.5; }
.sample-badge { display: inline-block; margin-right: 6px; padding: 3px 6px; color: var(--gold); background: var(--gold-soft); border-radius: 3px; font-weight: 600; }
.material-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.material-card {
  min-width: 0;
  min-height: 218px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 19px 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: inherit;
  background: var(--surface);
  text-align: left;
}
.material-card:hover { border-color: #b6c5be; background: #fbfcfb; }
.material-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.material-category { color: var(--green); font-size: 11px; font-weight: 700; }
.material-week { color: var(--muted); font-size: 10px; }
.material-card h3 { margin: 0; font-size: 16px; line-height: 1.55; }
.material-summary { margin: 0; overflow: hidden; color: #55615b; font-size: 12px; line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.material-card-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.material-keywords { display: flex; flex-wrap: wrap; gap: 5px; max-height: 50px; overflow: hidden; }
.material-card-arrow { flex: 0 0 auto; color: #87918c; font-size: 20px; }
.material-angle { margin: 0; padding: 13px 14px; color: #384841; background: var(--green-soft); border-left: 3px solid var(--green); line-height: 1.75; white-space: pre-wrap; }
.material-source { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 6px; }
.material-source .fact { background: var(--surface-muted); }
.link-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--green);
  background: var(--surface);
  font-weight: 600;
  text-decoration: none;
}
.link-button.is-disabled { color: var(--muted); pointer-events: none; opacity: 0.55; }

.analysis-view {
  max-width: 1500px;
  margin: 0 auto;
  padding: 30px 34px 56px;
}
.analysis-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
}
.analysis-header h2 { margin: 0; font-size: 22px; }
.analysis-header > div:first-child > p:last-child { margin: 7px 0 0; color: var(--muted); }
.analysis-filters { display: flex; align-items: flex-end; gap: 12px; }
.analysis-filters label { width: 176px; }
.analysis-filters label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.analysis-filters select { height: 36px; }

.analysis-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.analysis-kpi { min-width: 0; padding: 17px 18px; border-right: 1px solid var(--line); }
.analysis-kpi:last-child { border-right: 0; }
.analysis-kpi span { display: block; color: var(--muted); font-size: 11px; }
.analysis-kpi strong { display: block; margin-top: 5px; font-size: 20px; line-height: 1.25; }
.analysis-kpi small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }

.analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.analysis-panel {
  min-width: 0;
  padding: 20px 22px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.analysis-panel-wide, .analysis-panel-full { grid-column: 1 / -1; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-heading h3 { margin: 0; font-size: 15px; }
.panel-note { color: var(--muted); font-size: 11px; text-align: right; }
.cross-controls { display: flex; align-items: center; gap: 14px; }
.segment-control { display: inline-flex; padding: 2px; background: #edf0ee; border-radius: 5px; }
.segment-control button { height: 28px; padding: 0 10px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; font-size: 11px; }
.segment-control button.is-active { color: var(--green); background: var(--surface); box-shadow: 0 1px 3px rgba(28, 45, 37, 0.12); }

.bar-chart { display: grid; gap: 12px; }
.bar-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(80px, 118px) minmax(100px, 1fr) 54px;
  align-items: center;
  gap: 12px;
  padding: 3px 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}
.bar-row:hover .bar-fill, .rank-row:hover .rank-fill { filter: brightness(0.9); }
.bar-label { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; overflow: hidden; background: #e9eeeb; border-radius: 2px; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: var(--green); border-radius: 2px; }
.bar-value { color: #48534e; font-size: 11px; text-align: right; }
.bar-chart.compact { gap: 8px; }
.bar-chart.compact .bar-row { grid-template-columns: minmax(90px, 150px) 1fr 48px; }

.rank-chart { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 34px; row-gap: 13px; }
.rank-row {
  display: grid;
  grid-template-columns: 22px minmax(88px, 120px) minmax(80px, 1fr) 60px;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}
.rank-number { color: #89938e; font-size: 11px; }
.rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { height: 9px; background: var(--red-soft); border-radius: 2px; overflow: hidden; }
.rank-fill { display: block; height: 100%; min-width: 2px; background: var(--red); border-radius: 2px; }
.rank-value { color: var(--muted); font-size: 11px; text-align: right; }

.rating-chart { display: grid; gap: 18px; }
.rating-group h4 { margin: 0 0 9px; font-size: 12px; }
.rating-stack { display: flex; width: 100%; height: 30px; overflow: hidden; background: #edf0ee; border-radius: 4px; }
.rating-segment {
  min-width: 0;
  display: grid;
  place-items: center;
  border: 0;
  color: #fff;
  background: var(--green);
  font-size: 10px;
  white-space: nowrap;
}
.rating-segment:nth-child(2) { background: #4d846f; }
.rating-segment:nth-child(3) { background: #8d8a57; }
.rating-segment:nth-child(4) { background: #a95c50; }
.rating-legend { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.rating-legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 1px; background: var(--green); }
.rating-legend span:nth-child(2)::before { background: #4d846f; }
.rating-legend span:nth-child(3)::before { background: #8d8a57; }
.rating-legend span:nth-child(4)::before { background: #a95c50; }

.cross-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; }
.cross-table { width: 100%; min-width: 620px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.cross-table th, .cross-table td { padding: 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 11px; text-align: center; }
.cross-table th { height: 52px; color: var(--muted); background: var(--surface-muted); font-weight: 600; }
.cross-table th:first-child, .cross-table td:first-child { position: sticky; left: 0; z-index: 1; width: 28%; padding-left: 12px; text-align: left; background: var(--surface); }
.cross-table th:first-child { z-index: 2; background: var(--surface-muted); }
.cross-table th:last-child, .cross-table td:last-child { border-right: 0; }
.cross-table tbody tr:last-child td { border-bottom: 0; }
.cross-table th span, .cross-table th small { display: block; }
.cross-table th small { margin-top: 3px; color: #8a948f; font-size: 9px; font-weight: 400; }
.cross-value {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #813838;
  background: rgba(164, 67, 67, var(--heat));
  text-align: center;
}
.cross-value strong { font-size: 12px; line-height: 1.2; }
.cross-value small { color: #895a56; font-size: 9px; }
.cross-value.is-pro { color: #1f5c49; background: rgba(31, 102, 80, var(--heat)); }
.cross-value.is-pro small { color: #4d7466; }
.cross-value.is-row-max { border-color: currentColor; }
.cross-value:hover { filter: saturate(1.15); box-shadow: inset 0 0 0 1px currentColor; }
.cross-link { cursor: pointer; }

.quality-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  border: 1px solid #e4d4a1;
  background: var(--gold-soft);
  border-radius: 6px;
}
.quality-panel h3 { margin: 0 0 5px; font-size: 13px; }
.quality-panel p { margin: 0; color: #6c562b; font-size: 11px; line-height: 1.6; }
.quality-count { flex: 0 0 auto; color: var(--gold); font-size: 20px; font-weight: 700; }
.quality-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.quality-actions button { min-height: 30px; padding: 0 10px; border: 1px solid #d6bf7f; border-radius: 4px; color: #745719; background: rgba(255,255,255,0.6); font-size: 11px; }
.quality-actions button:hover { background: #fff; }
.word-chart { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.chart-empty { padding: 28px 12px; color: var(--muted); text-align: center; }
.analysis-error {
  grid-column: 1 / -1;
  padding: 24px;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #eccac6;
  border-radius: 6px;
}
.analysis-error strong { display: block; margin-bottom: 6px; }
.analysis-error p { margin: 0; color: #754444; line-height: 1.6; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 26, 22, 0.35);
}
.essay-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  width: min(760px, 92vw);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 180ms ease;
}
.essay-drawer.is-open { transform: translateX(0); }
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--line);
}
.drawer-header h2 { max-width: 600px; margin: 0; font-size: 23px; line-height: 1.4; }
.drawer-body { overflow: auto; padding: 24px 28px 48px; }
.detail-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 24px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.fact { min-width: 0; padding: 12px; background: var(--surface-muted); }
.fact span { display: block; color: var(--muted); font-size: 10px; }
.fact strong { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 13px; }
.detail-section { margin-top: 26px; }
.detail-section h3 { margin: 0 0 10px; font-size: 14px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.essay-text {
  margin: 0;
  color: #2b342f;
  font-family: STSong, SimSun, serif;
  font-size: 16px;
  line-break: strict;
  line-height: 1.95;
  overflow-wrap: break-word;
  word-break: normal;
}
.essay-paragraph { margin: 0; text-indent: 2em; white-space: pre-wrap; }
.kinsoku-unit { white-space: nowrap; }
.essay-paragraph.is-empty { height: 1.95em; text-indent: 0; }
.essay-paragraph.is-title { text-align: center; text-indent: 0; font-size: 1.15em; font-weight: 600; }
.essay-paragraph.is-note { text-align: right; text-indent: 0; }
.note-text { margin: 0; color: #4f5b55; line-height: 1.8; white-space: pre-wrap; }
.essay-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.essay-image-link {
  min-width: 0;
  display: block;
  overflow: hidden;
  color: var(--green);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  text-decoration: none;
}
.essay-image-link:hover { border-color: #aabdb4; }
.essay-image-link img { width: 100%; height: 280px; display: block; object-fit: contain; background: #eef1ef; }
.essay-image-link span { display: block; padding: 8px 10px; font-size: 10px; text-align: center; }
.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 28px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.primary-button, .secondary-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 5px;
  font-weight: 600;
}
.primary-button { border: 1px solid var(--green); color: #fff; background: var(--green); }
.secondary-button { border: 1px solid var(--line-strong); color: var(--ink); background: var(--surface); }

.card-editor {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: var(--ink);
  background: var(--bg);
}
.card-editor-header, .card-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  background: var(--surface);
}
.card-editor-header { border-bottom: 1px solid var(--line); }
.card-editor-header h2 { margin: 0; font-size: 18px; }
.card-editor-main { min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.card-settings { overflow-y: auto; padding: 6px 20px 32px; background: var(--surface); border-right: 1px solid var(--line); }
.card-setting-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.card-setting-section h3 { margin: 0 0 10px; font-size: 12px; }
.setting-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.setting-heading span { color: var(--muted); font-size: 9px; }
.card-toggle-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.card-toggle {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
}
.card-toggle input { width: 14px; height: 14px; accent-color: var(--green); }
.card-setting-section textarea {
  width: 100%;
  resize: vertical;
  padding: 10px;
  color: var(--ink);
  background: var(--surface-muted);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.7;
}
.card-text-input { min-height: 220px; font-family: STSong, SimSun, serif; }
.card-editor-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-edit-tag { display: inline-flex; align-items: center; gap: 4px; padding: 5px 5px 5px 8px; color: var(--green); background: var(--green-soft); border-radius: 3px; font-size: 10px; }
.card-edit-tag.is-con { color: var(--red); background: var(--red-soft); }
.card-edit-tag button { width: 18px; height: 18px; padding: 0; border: 0; color: currentColor; background: transparent; font-size: 14px; line-height: 1; }
.card-tag-reference { margin-top: 10px; padding: 10px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 4px; }
.card-reference-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.card-reference-heading small { font-size: 9px; }
.card-reference-list { display: flex; flex-wrap: wrap; gap: 5px; }
.card-reference-tag { min-height: 27px; padding: 0 7px; color: var(--green); background: #fff; border: 1px solid #c9dcd4; border-radius: 3px; font-size: 9px; }
.card-reference-tag.is-con { color: var(--red); border-color: #e7c9c6; }
.card-reference-tag:hover { background: var(--green-soft); }
.card-reference-tag.is-con:hover { background: var(--red-soft); }
.card-reference-toggle { margin-top: 8px; padding: 0; border: 0; color: var(--green); background: transparent; font-size: 9px; }
.card-tag-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-top: 8px; }
.card-tag-add input { min-width: 0; height: 34px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 4px; font-size: 11px; }
.card-tag-add button { min-width: 54px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--green); background: var(--surface); font-size: 11px; }
.card-size-control { display: grid; grid-template-columns: repeat(3, 1fr); padding: 2px; background: #edf0ee; border-radius: 5px; }
.card-size-control button { height: 30px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; font-size: 11px; }
.card-size-control button.is-active { color: var(--green); background: var(--surface); box-shadow: 0 1px 3px rgba(28, 45, 37, 0.12); }
.card-setting-section.is-disabled { opacity: 0.42; pointer-events: none; }
.card-preview-area { min-width: 0; overflow: auto; padding: 20px 28px 60px; }
.card-preview-toolbar { width: min(720px, 100%); display: flex; justify-content: space-between; margin: 0 auto 10px; color: var(--muted); font-size: 11px; }
.card-preview-toolbar small { font-size: 10px; }
.essay-card-preview {
  width: 720px;
  max-width: 100%;
  margin: 0 auto;
  padding: 42px 48px 52px;
  color: #1d2521;
  background: #fff;
  box-shadow: 0 8px 28px rgba(28, 45, 37, 0.12);
}
.card-preview-head { padding-bottom: 24px; border-bottom: 2px solid #1f6650; }
.card-preview-head p { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 600; }
.card-preview-head h1 { margin: 0; font-size: 25px; line-height: 1.4; }
.card-preview-section { margin-top: 27px; }
.card-preview-section h2 { margin: 0 0 12px; font-size: 14px; }
.card-preview-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 22px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.card-preview-fact { min-width: 0; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.card-preview-fact span { display: block; color: var(--muted); font-size: 9px; }
.card-preview-fact strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-size: 11px; }
.card-preview-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-preview-tag { padding: 5px 8px; color: var(--green); background: var(--green-soft); border-radius: 3px; font-size: 10px; }
.card-preview-tag.is-con { color: var(--red); background: var(--red-soft); }
.card-preview-note { margin: 0; color: #48534e; font-size: 12px; line-height: 1.8; white-space: pre-wrap; }
.card-preview-images { display: grid; gap: 10px; }
.card-preview-images.size-small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-preview-images.size-medium { padding-right: 13%; padding-left: 13%; }
.card-preview-images img { width: 100%; height: auto; display: block; object-fit: contain; background: #f3f5f4; border: 1px solid var(--line); }
.card-preview-images.size-small img { max-height: 260px; }
.card-preview-images.size-medium img { max-height: 480px; }
.card-preview-images.size-large img { max-height: 760px; }
.card-preview-text { margin: 0; font-family: STSong, SimSun, serif; font-size: 14px; line-break: strict; line-height: 1.95; overflow-wrap: break-word; word-break: normal; }
.card-preview-footer { margin-top: 36px; padding-top: 12px; color: #7b8580; border-top: 1px solid var(--line); font-size: 9px; text-align: right; }
.essay-card-preview.is-exporting { width: 720px; max-width: none; padding: 42px 48px 52px; box-shadow: none; }
.essay-card-preview.is-exporting .card-preview-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-editor-actions { border-top: 1px solid var(--line); }
.card-editor-actions > span { color: var(--muted); font-size: 10px; }
.card-editor-actions > div { display: flex; gap: 8px; }

.floating-actions {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 45;
  display: grid;
  justify-items: end;
  gap: 8px;
}
.feedback-launcher, .submission-launcher {
  min-width: 92px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  color: #fff;
  background: #26322c;
  border: 1px solid #26322c;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(28, 45, 37, 0.22);
  font-size: 13px;
  font-weight: 600;
}
.submission-launcher {
  min-width: 136px;
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}
.submission-launcher:hover { background: #184f3e; border-color: #184f3e; }
.submission-launcher-icon {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}
.feedback-launcher:hover { background: var(--green); border-color: var(--green); }
.feedback-launcher-icon {
  position: relative;
  width: 16px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.feedback-launcher-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: -4px;
  width: 5px;
  height: 5px;
  background: #26322c;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: skewY(-35deg);
}
.feedback-launcher:hover .feedback-launcher-icon::after { background: var(--green); }
.feedback-pending-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  color: #6e2d2d;
  background: #f3c9c4;
  border-radius: 9px;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}
.feedback-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(18, 26, 22, 0.48);
}
.feedback-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 120;
  width: min(520px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow-y: auto;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}
.feedback-dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px 17px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.feedback-dialog-header h2 { margin: 0; font-size: 18px; }
.feedback-form { display: grid; gap: 16px; padding: 20px 22px 22px; }
.submission-dialog { width: min(680px, calc(100vw - 32px)); }
.submission-form { gap: 18px; }
.submission-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.submission-grid-wide { grid-column: 1 / -1; }
.submission-optional-fields { padding-top: 2px; }
.submission-image-field {
  padding: 13px;
  background: #f7faf8;
  border: 1px solid #bdd5ca;
  border-radius: 5px;
}
.submission-image-field > span { color: var(--green); }
.submission-notes { min-height: 82px !important; }
.submission-extra { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.submission-extra summary {
  padding: 12px 2px;
  color: var(--green);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.submission-extra summary span { margin-left: 5px; color: var(--muted); font-size: 9px; font-weight: 400; }
.submission-extra[open] { padding-bottom: 14px; }
.submission-extra[open] summary { margin-bottom: 2px; }
.submission-tag-field { min-width: 0; }
.submission-tag-editor {
  min-width: 0;
  padding: 11px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.submission-tag-editor .card-tag-reference { background: var(--surface); }
.submission-tag-editor .card-edit-tag,
.submission-tag-editor .card-reference-tag { font-size: 10px; }
.submission-tag-editor .panel-note { font-size: 10px; }
.feedback-context {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  background: var(--green-soft);
  border-left: 3px solid var(--green);
  border-radius: 3px;
}
.feedback-context span { color: var(--muted); font-size: 10px; }
.feedback-context strong { overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; }
.feedback-field { display: grid; gap: 7px; }
.feedback-field > span { font-size: 12px; font-weight: 600; }
.feedback-field input, .feedback-field select, .feedback-field textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: var(--surface-muted);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 13px;
}
.feedback-field input, .feedback-field select { height: 40px; padding: 0 11px; }
.feedback-field textarea { min-height: 142px; padding: 10px 11px; resize: vertical; line-height: 1.65; }
.feedback-field small { color: var(--muted); font-size: 9px; text-align: right; }
.feedback-field > span em { margin-left: 5px; color: var(--muted); font-size: 9px; font-style: normal; font-weight: 400; }
.feedback-upload-button {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--green);
  background: var(--surface-muted);
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  font-size: 12px;
}
.feedback-upload-button:hover { background: var(--green-soft); border-color: var(--green); }
.feedback-upload-button:disabled { cursor: wait; opacity: 0.65; }
.feedback-upload-icon {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
}
.feedback-upload-help { text-align: left !important; }
.feedback-screenshot-preview {
  min-width: 0;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.feedback-screenshot-preview img { width: 68px; height: 48px; display: block; object-fit: cover; background: #e9eeeb; border: 1px solid var(--line); border-radius: 3px; }
.feedback-screenshot-preview > div { min-width: 0; }
.feedback-screenshot-preview strong, .feedback-screenshot-preview span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feedback-screenshot-preview strong { font-size: 11px; }
.feedback-screenshot-preview span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.feedback-screenshot-preview .icon-button { width: 30px; height: 30px; }
.submission-image-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.submission-image-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 9px;
  padding: 7px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.submission-image-item img {
  width: 62px;
  height: 58px;
  display: block;
  object-fit: cover;
  background: #e9eeeb;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.submission-image-item > div { min-width: 0; }
.submission-image-item strong, .submission-image-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.submission-image-item strong { font-size: 11px; }
.submission-image-item span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.submission-image-item .icon-button { width: 30px; height: 30px; }
.feedback-delivery {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
}
.feedback-delivery p { margin: 0; line-height: 1.5; }
.feedback-delivery.is-pending .status-dot { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.feedback-pending-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #745719;
  font-size: 11px;
}
.feedback-pending-row .text-button { flex: 0 0 auto; }
.feedback-error { margin: 0; padding: 9px 11px; color: #7a3636; background: var(--red-soft); border-radius: 4px; font-size: 11px; line-height: 1.5; }
.feedback-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }
.feedback-actions button { min-width: 92px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: calc(100vw - 40px);
  padding: 10px 15px;
  color: #fff;
  background: #26322c;
  border-radius: 5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .app-header { grid-template-columns: 1fr auto; gap: 12px; padding: 10px 18px; }
  .primary-tabs { grid-row: 2; grid-column: 1 / -1; height: 40px; justify-content: center; }
  .tab::after { bottom: -1px; }
  .data-meta { grid-column: 2; grid-row: 1; }
  .essay-area { min-height: calc(100vh - 122px); }
  .workspace { min-height: calc(100vh - 170px); grid-template-columns: 220px minmax(0, 1fr); }
  .filter-panel { top: 122px; height: calc(100vh - 122px); padding: 24px 18px; }
  .content-panel { padding: 26px 22px 42px; }
  .essay-row { grid-template-columns: minmax(220px, 1fr) 100px 24px; }
  .essay-row .tag-line { display: none; }
  .materials-view { grid-template-columns: 220px minmax(0, 1fr); }
  .material-filters { top: 122px; height: calc(100vh - 122px); padding: 24px 18px; }
  .material-content { padding: 26px 22px 42px; }
  .material-list { grid-template-columns: 1fr; }
  .analysis-view { padding: 26px 22px 48px; }
  .analysis-kpis { grid-template-columns: repeat(3, 1fr); }
  .analysis-kpi:nth-child(3) { border-right: 0; }
  .analysis-kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .rank-chart { grid-template-columns: 1fr; }
  .card-editor-main { grid-template-columns: 300px minmax(0, 1fr); }
  .card-preview-area { padding-right: 18px; padding-left: 18px; }
}

@media (max-width: 700px) {
  .app-header { position: relative; min-height: 118px; }
  .brand p, .data-meta { display: none; }
  .brand h1 { font-size: 15px; }
  .primary-tabs { grid-row: 2; }
  .essay-subnav { height: 46px; padding: 0 14px; }
  .workspace { display: block; min-height: 0; }
  .materials-view { display: block; min-height: 0; }
  .filter-panel { position: static; width: 100%; height: auto; padding: 20px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .material-filters { position: static; width: 100%; height: auto; padding: 20px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .material-filters .field { display: inline-block; width: calc(50% - 5px); margin-top: 12px; vertical-align: top; }
  .material-filters .field:nth-of-type(even) { margin-left: 6px; }
  .material-filters .search-field { width: 100%; margin-left: 0; }
  .filter-heading { margin-bottom: 4px; }
  .filter-panel .field { display: inline-block; width: calc(50% - 5px); margin-top: 12px; vertical-align: top; }
  .filter-panel .field:nth-of-type(even) { margin-left: 6px; }
  .search-field { width: 100% !important; margin-left: 0 !important; }
  .content-panel { padding: 20px 14px 36px; }
  .material-content { padding: 20px 14px 36px; }
  .material-data-status { max-width: 180px; }
  .material-card { min-height: 205px; padding: 17px 16px; }
  .content-toolbar { align-items: flex-start; }
  .sort-control { grid-template-columns: 1fr; gap: 4px; width: 142px; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .essay-row { min-height: 100px; grid-template-columns: minmax(0, 1fr) 76px 16px; gap: 10px; padding: 16px 14px; }
  .pagination { flex-wrap: wrap; gap: 10px; }
  .page-jump { order: 2; flex-basis: 100%; justify-content: center; }
  .essay-title { font-size: 15px; }
  .score-block strong { font-size: 15px; }
  .detail-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .essay-images { grid-template-columns: 1fr; }
  .essay-image-link img { height: auto; max-height: 520px; }
  .drawer-header, .drawer-body { padding-right: 18px; padding-left: 18px; }
  .drawer-actions { padding: 12px 18px; }
  .drawer-actions { flex-wrap: wrap; }
  .drawer-actions button { flex: 1 1 calc(50% - 5px); padding: 0 8px; }
  .drawer-actions #openCardEditor { flex-basis: 100%; }
  .material-drawer .drawer-actions { flex-wrap: wrap; }
  .material-drawer .link-button { width: 100%; justify-content: center; }
  .analysis-view { padding: 20px 14px 40px; }
  .analysis-header { display: block; }
  .analysis-filters { margin-top: 18px; }
  .analysis-filters label { flex: 1; width: auto; }
  .analysis-kpis { grid-template-columns: repeat(2, 1fr); }
  .analysis-kpi, .analysis-kpi:nth-child(3) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .analysis-kpi:nth-child(even) { border-right: 0; }
  .analysis-kpi:nth-last-child(-n+2) { border-bottom: 0; }
  .analysis-grid { grid-template-columns: 1fr; }
  .analysis-panel, .analysis-panel-wide, .analysis-panel-full { grid-column: 1; padding: 18px 16px; }
  .bar-row { grid-template-columns: 88px minmax(70px, 1fr) 46px; gap: 8px; }
  .bar-chart.compact .bar-row { grid-template-columns: 100px minmax(70px, 1fr) 42px; }
  .panel-heading { display: block; }
  .panel-note { display: block; margin-top: 5px; text-align: left; }
  .cross-controls { align-items: flex-start; justify-content: space-between; margin-top: 10px; }
  .cross-table { min-width: 540px; }
  .cross-table th:first-child, .cross-table td:first-child { width: 31%; }
  .quality-panel { align-items: flex-start; }
  .card-editor-main { display: block; overflow-y: auto; }
  .card-settings { overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .card-preview-area { overflow: visible; padding: 20px 10px 48px; }
  .essay-card-preview { padding: 28px 22px 36px; }
  .card-preview-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-editor-actions { align-items: stretch; flex-direction: column; }
  .card-editor-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
  .floating-actions { right: 14px; bottom: 14px; }
  .feedback-launcher { min-width: 82px; height: 42px; }
  .submission-launcher { min-width: 126px; height: 42px; }
  .feedback-dialog { top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-height: calc(100vh - 24px); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 7px 7px 0 0; transform: none; }
  .feedback-dialog-header { padding: 17px 18px 14px; }
  .feedback-form { gap: 14px; padding: 17px 18px calc(18px + env(safe-area-inset-bottom)); }
  .feedback-field textarea { min-height: 120px; }
  .feedback-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .feedback-actions button { width: 100%; }
  .submission-field-grid { grid-template-columns: 1fr; gap: 14px; }
  .submission-grid-wide { grid-column: auto; }
  .submission-image-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
