:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --surface: #ffffff;
  --surface-soft: #f4f7f6;
  --line: #dfe5e2;
  --line-strong: #c7d2ce;
  --text: #17201f;
  --muted: #6b7774;
  --teal: #086466;
  --teal-dark: #05484a;
  --teal-soft: #e4f1ef;
  --green: #2f7d32;
  --amber: #c77700;
  --orange: #e87924;
  --danger: #c2410c;
  --blue: #2563eb;
  --shadow: 0 16px 38px rgba(17, 24, 39, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 92px;
  padding: 0 28px;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #ffffff;
  background: #0c1716;
  font-size: 13px;
  font-weight: 900;
  border-radius: 4px;
}

.nav-list,
.sidebar-bottom {
  display: grid;
  gap: 8px;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 48px;
  padding: 0 15px;
  color: #263230;
  background: transparent;
  border-radius: var(--radius);
  text-align: left;
  position: relative;
}

.nav-item svg {
  width: 21px;
  height: 21px;
}

.nav-item.active {
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-weight: 700;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: var(--teal);
  border-radius: 0 4px 4px 0;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  border-radius: 10px;
  color: var(--orange);
  background: #fff1e6;
  font-size: 12px;
}

.sidebar-bottom {
  margin-top: auto;
  padding-bottom: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.account-chip {
  display: grid;
  grid-template-columns: 42px 1fr 18px;
  align-items: center;
  gap: 10px;
  margin: 10px 4px 0;
  padding: 10px;
  border-radius: var(--radius);
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e7b49a, #f5ddca);
  color: #693c2c;
  font-weight: 800;
}

.account-chip strong,
.account-chip span {
  display: block;
}

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

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  height: 92px;
  padding: 0 24px 0 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
}

.account-select {
  display: grid;
  gap: 6px;
  padding-top: 14px;
}

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

.account-select select {
  width: clamp(280px, 31vw, 430px);
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
}

.status-dot {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-top: 32px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.topbar-spacer {
  flex: 1;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: clamp(230px, 26vw, 350px);
  height: 40px;
  margin-top: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  font-size: 14px;
  font-weight: 500;
}

.search kbd {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
  background: #fafafa;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: 32px;
  color: var(--text);
  background: transparent;
  border-radius: var(--radius);
  position: relative;
}

.icon-button.framed {
  border: 1px solid var(--line-strong);
  background: #fff;
}

.icon-button.framed [data-icon="filter"] {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--text);
}

.icon-button i {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 40px;
  margin-top: 32px;
  padding: 0 18px;
  color: #fff;
  background: var(--teal-dark);
  border-radius: var(--radius);
  font-weight: 750;
  white-space: nowrap;
  box-shadow: 0 12px 22px rgba(5, 72, 74, 0.2);
}

.data-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.secondary-button.compact {
  height: 32px;
  padding: 0 8px;
  color: #34423f;
  background: #fff;
  font-size: 12px;
  white-space: nowrap;
}

.secondary-button.danger {
  color: var(--danger);
  border-color: #fed7aa;
  background: #fff8f3;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  grid-template-rows: minmax(620px, auto) auto;
  gap: 0;
}

.panel {
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.topic-panel {
  padding: 24px;
}

.detail-panel {
  padding: 22px;
}

.learning-panel {
  grid-column: 1 / 2;
  padding: 20px 24px 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header > div:first-child {
  flex: 1 1 260px;
  min-width: 220px;
}

.panel-header.compact {
  justify-content: space-between;
}

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

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h1 span {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 24px;
  margin-left: 8px;
  border-radius: 12px;
  color: var(--muted);
  background: #eef2f0;
  font-size: 13px;
  font-weight: 650;
}

h2 {
  font-size: 16px;
}

.panel-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: inline-flex;
  margin-left: auto;
  flex: 0 0 auto;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  overflow-x: auto;
  overflow-y: hidden;
}

.segmented button {
  flex: 0 0 auto;
  min-width: 86px;
  height: 40px;
  padding: 0 14px;
  color: #33403e;
  background: #fff;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: #fff;
  background: var(--teal);
}

.table-wrap {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: #3f4c49;
  background: #fbfcfb;
  font-weight: 750;
}

th:first-child,
td:first-child {
  width: 46px;
  text-align: center;
}

th:nth-child(2),
td:nth-child(2) {
  width: 260px;
}

th:nth-child(9),
td:nth-child(9) {
  width: 78px;
  text-align: center;
}

th:nth-child(10),
td:nth-child(10) {
  width: 72px;
  text-align: center;
}

th small {
  color: var(--muted);
  font-weight: 500;
}

tr {
  transition: background 160ms ease, box-shadow 160ms ease;
}

tbody tr:hover {
  background: #fbfdfc;
}

tbody tr.selected {
  background: #f3fbfa;
  box-shadow: inset 4px 0 0 var(--teal), inset 0 0 0 1px rgba(8, 100, 102, 0.5);
}

.topic-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
}

.topic-tags {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: #fafafa;
  font-size: 11px;
}

.tag.new {
  color: var(--teal);
  border-color: #cde7e4;
  background: var(--teal-soft);
}

.score {
  font-size: 18px;
  font-weight: 800;
}

.metric.green {
  color: var(--green);
}

.metric.amber {
  color: var(--amber);
}

.metric.risk {
  color: var(--danger);
}

.sparkline {
  width: 42px;
  height: 22px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
}

.pagination button.active {
  color: var(--teal);
  background: var(--teal-soft);
  border: 1px solid #cde7e4;
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.detail-title h2 {
  font-size: 23px;
  line-height: 1.25;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.stat {
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

.stat strong {
  display: block;
  margin-top: 3px;
  color: var(--teal);
  font-size: 14px;
}

.detail-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.detail-section:first-of-type {
  border-top: 0;
}

.detail-section h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}

.detail-section p {
  color: #33403e;
  font-size: 13px;
  line-height: 1.65;
}

.signal-list,
.title-list,
.draft-card,
.flag-list {
  display: grid;
  gap: 8px;
}

.signal,
.title-option,
.draft-card {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.signal strong,
.title-option strong {
  display: block;
  font-weight: 650;
}

.signal small,
.title-option small,
.draft-card small {
  color: var(--muted);
}

.signal .up {
  color: var(--teal);
  font-weight: 750;
}

.title-option input {
  accent-color: var(--teal);
}

.draft-card {
  grid-template-columns: 34px 1fr auto;
}

.draft-card .doc-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 6px;
}

.secondary-button {
  height: 32px;
  padding: 0 12px;
  color: var(--teal-dark);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-weight: 650;
}

.flag-list {
  display: flex;
  flex-wrap: wrap;
}

.flag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
}

.flag.warn {
  color: var(--danger);
  background: #fff4ed;
  border: 1px solid #fed7aa;
}

.flag.info {
  color: var(--teal);
  background: var(--teal-soft);
  border: 1px solid #cde7e4;
}

.link-button {
  color: var(--teal);
  background: transparent;
  font-weight: 700;
}

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

.learning-card {
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.learning-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.learning-card .learn-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--teal);
}

.learning-card h3 {
  font-size: 15px;
}

.learning-card p {
  color: #42504d;
  font-size: 13px;
  line-height: 1.55;
}

.learning-card footer {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.module-page {
  padding: 28px;
}

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

.module-header h1 {
  margin-bottom: 6px;
}

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

.module-grid {
  display: grid;
  gap: 16px;
}

.module-grid.two-col {
  grid-template-columns: minmax(520px, 0.92fr) minmax(420px, 1fr);
}

.form-panel,
.list-panel,
.insight-panel,
.editor-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-panel {
  display: grid;
  gap: 16px;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #46534f;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 92px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.55;
}

.search input {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
}

.insight-panel {
  align-self: start;
}

.summary-list {
  display: grid;
  gap: 12px;
}

.summary-item,
.source-item,
.rank-item,
.review-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.summary-item span,
.source-item span,
.rank-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.summary-item strong,
.source-item strong,
.rank-item strong {
  display: block;
  font-size: 14px;
}

.source-list,
.rank-list,
.review-grid {
  display: grid;
  gap: 10px;
}

.source-item p,
.review-card p {
  margin-top: 8px;
  color: #42504d;
  font-size: 13px;
  line-height: 1.55;
}

.source-meta {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.weight-panel {
  gap: 12px;
}

.weight-row {
  display: grid;
  grid-template-columns: 120px 1fr 52px;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.weight-row:last-child {
  border-bottom: 0;
}

.weight-row input {
  accent-color: var(--teal);
}

.weight-row output {
  text-align: right;
  color: var(--teal);
  font-weight: 750;
}

.rank-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--teal);
  background: var(--teal-soft);
  font-weight: 800;
}

.draft-layout {
  display: grid;
  grid-template-columns: 360px minmax(640px, 1fr);
  gap: 16px;
}

.editor-panel {
  display: grid;
  gap: 16px;
}

.editor-panel textarea#draftBody {
  min-height: 260px;
}

.editor-panel textarea#imagePrompts {
  min-height: 120px;
}

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

.review-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.review-card h2 {
  font-size: 15px;
}

.review-card.ok {
  border-color: #bfdfca;
}

.review-card.warn {
  border-color: #fed7aa;
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 10;
  padding: 12px 16px;
  color: #fff;
  background: var(--teal-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

svg {
  display: block;
}

@media (max-width: 1250px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .learning-panel {
    grid-column: 1;
  }

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

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 208px minmax(0, 1fr);
  }

  .brand {
    padding: 0 18px;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 92px;
    padding-bottom: 14px;
  }

  .topbar-spacer {
    display: none;
  }

  .account-select select,
  .search {
    width: min(100%, 380px);
  }

  .primary-action {
    margin-left: auto;
  }

  .module-grid.two-col,
  .draft-layout,
  .review-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 14px;
  }

  .account-select,
  .status-dot,
  .search,
  .icon-button,
  .primary-action {
    margin-top: 0;
  }

  .account-select {
    padding-top: 0;
  }

  .account-select,
  .account-select select,
  .search,
  .primary-action {
    width: 100%;
  }

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

  .module-page {
    padding: 16px;
  }

  .module-header,
  .form-row,
  .module-grid.two-col,
  .draft-layout,
  .review-grid,
  .metrics-row {
    grid-template-columns: 1fr;
  }

  .module-header {
    display: grid;
  }

  .detail-panel,
  .learning-panel {
    grid-column: 1;
  }

  .topic-panel,
  .detail-panel,
  .learning-panel {
    padding: 16px;
  }

  .panel-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .segmented {
    width: 100%;
    overflow-x: auto;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 840px;
  }

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