:root {
  --bg: #F5F5F5;
  --host-bg: #F5F5F5;
  --panel: #FFFFFF;
  --panel-strong: #FFFFFF;
  --ink: #1A1A1A;
  --muted: #6B7280;
  --line: #E0E0E0;
  --line-strong: rgba(26, 26, 26, 0.18);
  --brand: #4F46E5;
  --brand-soft: rgba(79, 70, 229, 0.10);
  --success: #059669;
  --review: #7d5e1f;
  --review-soft: rgba(125, 94, 31, 0.10);
  --danger: #b73b28;
  --danger-soft: rgba(183, 59, 40, 0.10);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.06);
  --plugin-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Source Han Sans SC", sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: #EBEBEB;
}

h3 { font-size: 14px; }
h4 { font-size: 13px; }

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

button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.16);
}

button:hover {
  transform: translateY(-1px);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(79, 70, 229, 0.45);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.06);
}

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

.browser-stage {
  min-height: 100vh;
  padding: 0 0 0 24px;
}

.browser-stage.plugin-only {
  display: flex;
  justify-content: flex-end;
}

.plugin-shell {
  width: 100%;
  max-width: 500px;
}

.plugin-window {
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-radius: 28px 0 0 28px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(224, 224, 224, 0.6);
  border-right: 0;
  box-shadow: var(--plugin-shadow);
  backdrop-filter: blur(16px);
}

.plugin-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.plugin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 18px 14px;
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.04), transparent);
  border-bottom: 1px solid rgba(26, 26, 26, 0.06);
}

.plugin-header h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.current-role-badge {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.current-role-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.plugin-header-side {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.admin-entry-link {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(79, 70, 229, 0.16);
  background: rgba(79, 70, 229, 0.08);
  color: var(--brand);
  text-decoration: none;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.2;
}

.admin-entry-link:hover {
  background: rgba(79, 70, 229, 0.12);
}

.role-switcher {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.role-switcher span {
  font-size: 11px;
  color: var(--muted);
}

.role-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.role-toggle {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  border: 1px solid rgba(26, 26, 26, 0.08);
  box-shadow: none;
}

.role-toggle.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: rgba(79, 70, 229, 0.22);
}

.plugin-kicker,
.eyebrow,
.panel-index {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.plugin-lights {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.light {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.light.green {
  background: #25a26b;
}

.light.amber {
  background: #f0a91a;
}

.plugin-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.plugin-page {
  display: none;
}

.plugin-page.active {
  display: grid;
  gap: 14px;
}

.audit-tabs {
  flex: none;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 6px;
  margin: 12px 16px 0;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(26, 26, 26, 0.08);
  overflow-x: auto;
}

.audit-tab-button {
  display: grid;
  justify-items: start;
  align-items: center;
  flex: 1 0 0;
  width: auto;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(26, 26, 26, 0.08);
  box-shadow: none;
  transition: all 160ms ease;
}

.audit-tab-button:hover {
  background: rgba(79, 70, 229, 0.05);
  border-color: rgba(79, 70, 229, 0.14);
}

.audit-tab-button.active {
  color: var(--brand);
  background:
    linear-gradient(180deg, rgba(79, 70, 229, 0.12), rgba(79, 70, 229, 0.06)),
    #fff;
  border-color: rgba(79, 70, 229, 0.26);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.1);
}

.audit-tab-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.audit-section {
  display: none;
}

.audit-section.active {
  display: block;
}

.plugin-panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: 22px;
  padding: 16px;
}

.panel-heading h3,
.result-column h3,
.mini-heading h4 {
  margin: 0;
}
.status-card,
.summary-card {
  background: var(--panel-strong);
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: 18px;
  padding: 14px;
}

.status-card.wide {
  grid-column: 1 / -1;
}

.status-card span,
.summary-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 11px;
}

.status-card strong {
  font-size: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.secondary-heading {
  margin-top: 16px;
}

.panel-note {
  color: var(--muted);
  font-size: 11px;
}

.import-card,
.result-column,
.detail-card,
.lookup-result,
.hit-list,
.highlight-card {
  background: var(--panel);
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: 18px;
}

.import-card {
  padding: 14px;
  transition: border-color 160ms ease, background 160ms ease;
}

.import-card.drag-over {
  border-color: var(--brand);
  background: rgba(79, 70, 229, 0.04);
}

.import-status {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--success);
  min-height: 0;
}

.import-status:empty {
  display: none;
}

.import-status.error {
  color: var(--danger);
}

.import-progress {
  margin-top: 8px;
}

.import-progress.hidden {
  display: none;
}

.progress-bar {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--brand);
  transition: width 300ms ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.progress-text {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-delete {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.import-card + .import-card {
  margin-top: 12px;
}

.locked-panel {
  padding: 16px;
  border-radius: 18px;
  background: rgba(183, 59, 40, 0.06);
  border: 1px dashed rgba(183, 59, 40, 0.24);
  line-height: 1.7;
}

.locked-panel strong {
  display: block;
  margin-bottom: 8px;
  color: var(--danger);
}

.mini-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.mini-heading span,
.field-label,
.field-block label {
  color: var(--muted);
  font-size: 11px;
}

.field-label,
.field-block label {
  display: block;
  margin: 12px 0 6px;
}

.lexicon-grid {
  display: grid;
  gap: 12px;
}

.lexicon-card textarea {
  min-height: 80px;
}

.lexicon-card input[type="file"] {
  display: none;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.action-row.split > * {
  flex: 0 1 auto;
}

.action-row.wide {
  margin-top: 14px;
}

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

.secondary-button,
.ghost-button {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
  font-size: 13px;
}

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

.field-block textarea {
  min-height: 56px;
}

#adBox {
  min-height: 40px;
}

#title {
  min-height: 40px;
}

#bullets {
  min-height: 100px;
}

#description {
  min-height: 80px;
}

.field-block.full-width textarea {
  min-height: 40px;
}

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

.summary-card strong {
  font-size: 20px;
}

.summary-card.danger strong {
  color: var(--danger);
}

.summary-card.review strong {
  color: var(--review);
}

.result-column.stack {
  padding: 14px;
}

.result-column.stack + .result-column.stack {
  margin-top: 12px;
}

.highlight-stack {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.highlight-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 0;
  color: var(--muted);
  font-size: 11px;
}

.highlight-body {
  padding: 12px 14px 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom: 1px solid rgba(26, 26, 26, 0.06);
}

.field-hit-list {
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
}

.field-hit-card {
  border-radius: 14px;
  border: 1px solid rgba(26, 26, 26, 0.08);
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
}

.field-hit-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.field-hit-tag {
  flex: none;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
}

.field-hit-line {
  margin: 0 0 8px;
  line-height: 1.7;
}

.field-hit-line span {
  display: inline-block;
  min-width: 64px;
  margin-right: 8px;
  color: var(--muted);
}

.field-hit-block {
  margin-top: 10px;
}

.field-hit-block strong {
  display: block;
  margin-bottom: 6px;
}

.field-hit-block ul {
  margin: 0;
  padding-left: 18px;
}

.risk-mark {
  padding: 0.08em 0.28em;
  border-radius: 7px;
  font-weight: 600;
}

.risk-delete {
  background: var(--danger-soft);
  color: var(--danger);
}

.risk-review {
  background: var(--review-soft);
  color: var(--review);
}

.detail-card,
.lookup-result {
  margin-top: 12px;
  padding: 14px;
  line-height: 1.7;
}

.permission-inline {
  margin: 8px 0 0;
  color: var(--muted);
}

.detail-card h4,
.lookup-result h3 {
  margin: 0 0 8px;
}

.detail-block {
  margin-top: 12px;
}

.detail-card ul,
.lookup-result ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.plugin-lookup {
  align-items: stretch;
}

.plugin-lookup input {
  flex: 1;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(26, 26, 26, 0.92);
  color: #fff;
  box-shadow: var(--plugin-shadow);
}

.toast.error {
  background: rgba(183, 59, 40, 0.95);
}

.hidden {
  display: none;
}

.hidden-utility {
  display: none;
}

.plugin-footer {
  padding: 8px 18px 14px;
  display: flex;
  justify-content: center;
  border-top: 1px solid rgba(26, 26, 26, 0.06);
  background: rgba(255, 255, 255, 0.38);
}

.footer-brand {
  margin: 0;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.28em;
  color: rgba(107, 114, 128, 0.20);
}

@media (max-width: 1180px) {
  .plugin-window {
    height: 100vh;
  }
}

@media (max-width: 560px) {
  .browser-stage {
    padding: 0;
  }

  .plugin-window {
    border-radius: 0;
    height: 100vh;
  }

  .quick-actions,
  .action-row,
  .plugin-lookup,
  .plugin-summary,
  .status-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex-direction: column;
  }

  .plugin-scroll {
    padding: 12px;
  }
}
