:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #192124;
  --muted: #65717a;
  --line: #dce3e7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d8f3ee;
  --warn: #b45309;
  --warn-soft: #fff3d7;
  --bad: #b42318;
  --bad-soft: #ffe4df;
  --blue: #2563eb;
  --blue-soft: #e4edff;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 21px;
}

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

h1 {
  font-size: 18px;
  line-height: 1.25;
}

.brand p,
.toolbar p,
.section-heading p,
.metrics p {
  color: var(--muted);
}

.brand p {
  margin-top: 4px;
  font-size: 13px;
}

.control-form {
  display: grid;
  gap: 14px;
}

.history-panel {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.history-head h2 {
  font-size: 15px;
}

.history-head span,
.history-empty {
  color: var(--muted);
  font-size: 12px;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  padding-right: 2px;
}

.history-item {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 9px 10px;
  text-align: left;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-title {
  overflow: hidden;
  color: #24333a;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta,
.history-stats {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.history-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

label {
  display: grid;
  gap: 7px;
  color: #354149;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd8dd;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 78px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.title-parts-panel {
  display: grid;
  gap: 8px;
}

.field-title {
  color: #354149;
  font-size: 13px;
  font-weight: 800;
}

.title-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.title-part {
  display: inline-flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
}

.title-part input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.title-part span {
  min-width: 64px;
  border: 1px solid #cfd8dd;
  border-radius: 6px;
  background: #fff;
  color: #46545c;
  padding: 8px 10px;
  text-align: center;
}

.title-part input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 850;
}

.title-part input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-action,
.secondary-action,
.toolbar-actions button {
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--accent);
  color: white;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.primary-action:disabled,
.secondary-action:disabled,
.toolbar-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary-action {
  padding: 11px 14px;
  background: #fff;
  border-color: var(--line);
  color: #263238;
}

.secondary-action:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.ai-panel {
  display: grid;
  gap: 8px;
}

.ai-config {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.ai-config .secondary-action {
  padding: 10px 8px;
}

.ai-config-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.image-ai-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.image-upload-action {
  display: grid;
}

.image-upload-action input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.image-upload-action span {
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #263238;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.image-upload-action:hover span {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.product-image-preview {
  width: 100%;
  max-height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.ai-result {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.ai-result-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.ai-keywords {
  display: grid;
  gap: 7px;
}

.ai-keyword {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid #d6e0e5;
  border-radius: 7px;
  background: #fcfefe;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 9px;
  text-align: left;
}

.ai-keyword:hover {
  border-color: var(--accent);
}

.ai-keyword strong {
  font-size: 13px;
}

.ai-keyword span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ai-avoid {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 16px;
  padding: 22px 24px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.toolbar h2 {
  font-size: 24px;
}

.toolbar p {
  margin-top: 5px;
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.toolbar-actions button {
  padding: 10px 13px;
  background: #fff;
  border-color: var(--line);
  color: #263238;
}

.toolbar-actions button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.plugin-progress-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 16px;
}

.plugin-progress-panel.is-running {
  border-color: #b6d9d3;
  background: #fbfffe;
}

.plugin-progress-panel.is-failed {
  border-color: #f2b8b0;
  background: #fffafa;
}

.plugin-progress-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.plugin-progress-head h3 {
  font-size: 16px;
}

.plugin-progress-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.plugin-progress-status {
  display: grid;
  gap: 4px;
  min-width: 240px;
  color: var(--muted);
  text-align: right;
}

.plugin-progress-status strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.plugin-progress-status span {
  font-size: 13px;
}

.plugin-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ecef;
}

.plugin-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.plugin-progress-panel.is-failed .plugin-progress-fill {
  background: var(--bad);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metrics > div {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 16px;
}

.metrics span {
  display: block;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.metrics p {
  margin-top: 8px;
  font-size: 13px;
}

.title-panel,
.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading h3 {
  font-size: 17px;
}

.section-heading p {
  font-size: 13px;
}

.title-list {
  display: grid;
  gap: 10px;
  padding: 14px 18px 18px;
}

.title-item {
  display: grid;
  gap: 8px;
  border: 1px solid #d6e0e5;
  border-radius: 8px;
  padding: 12px;
  background: #fcfefe;
}

.title-line {
  font-size: 15px;
  line-height: 1.45;
  font-weight: 750;
}

.title-meta {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.first80 {
  color: var(--accent-dark);
}

.empty-state,
.table-empty {
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 384px);
}

table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f4;
  color: #314047;
  text-align: left;
  font-weight: 850;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
}

tbody tr:hover {
  background: #f7fafb;
}

.keyword-cell {
  min-width: 240px;
  font-weight: 750;
}

.keyword-zh-cell {
  min-width: 190px;
  color: #314047;
}

.title-zh {
  color: #4a5961;
  font-size: 13px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-ok {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.badge-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.risk-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
  max-width: 260px;
}

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

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

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

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