:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --subtle: #f1f1ee;
  --border: #e5e5e0;
  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius-card: 10px;
  --radius-control: 6px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.num, .nav-count, .meta-time {
  font-variant-numeric: tabular-nums;
}

/* 按钮与输入控件 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background-color 0.12s ease, border-color 0.12s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--subtle);
  color: var(--text);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.textarea {
  height: auto;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.6;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
}

/* 登录页 */
.login-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px 26px;
}

.brand-mark {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-control);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
}

.login-desc {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.site-footer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.site-footer a {
  color: var(--text-muted);
}

/* 主三栏工作台 */
.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(340px, 1fr) minmax(380px, 480px);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  overflow-y: auto;
}

.sidebar-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--border);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover {
  background: var(--subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-count {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-item.active .nav-count {
  color: var(--accent);
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.sidebar-tags {
  flex: 1;
  min-height: 80px;
  border-top: 1px solid var(--border);
  padding: 12px 4px;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.tag-chip:hover {
  background: var(--subtle);
  color: var(--text);
}

.tag-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sidebar-beian {
  margin-top: 4px;
  font-size: 11px;
}

/* 中栏列表 */
.list-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
}

.list-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.digest-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pane-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.pane-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.filter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 20px;
}

.list-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.flash-card:hover {
  border-color: #d4d4ce;
}

.flash-card.selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.pill-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-control);
  font-size: 11px;
  font-weight: 500;
  background: var(--subtle);
  color: var(--text-secondary);
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-pin {
  background: #fef3c7;
  color: #92400e;
}

.meta-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-summary {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mini-tag {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 6px;
}

/* 右栏详情 */
.detail-pane {
  background: var(--surface);
  overflow-y: auto;
  padding: 20px 24px 32px;
}

.empty-state {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-desc {
  margin: 0;
  font-size: 12px;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.detail-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-title {
  margin: 8px 0 8px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
}

.detail-summary {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: var(--radius-control);
  background: var(--bg);
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
  font-size: 13px;
}

.detail-source {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}

.md-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  margin-bottom: 18px;
}

.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 16px 0 8px;
  line-height: 1.4;
}

.md-body h1 { font-size: 18px; }
.md-body h2 { font-size: 16px; }
.md-body h3 { font-size: 14px; }

.md-body p {
  margin: 0 0 10px;
}

.md-body ul, .md-body ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.md-body blockquote {
  margin: 0 0 10px;
  padding: 6px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg);
}

.md-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--subtle);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.md-body pre {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--subtle);
  overflow-x: auto;
}

.md-body pre code {
  padding: 0;
  background: transparent;
}

.meta-block {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.meta-block-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.concept-chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

.related-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.related-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* 演进时间线 */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.timeline-item {
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--bg);
  border: 1px solid var(--border);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.timeline-body {
  font-size: 13px;
}

.timeline-body .md-body {
  margin-bottom: 0;
  font-size: 13px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  flex-direction: column;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 弹窗与提示 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 22px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 9px 14px;
  border-radius: var(--radius-control);
  background: var(--text);
  color: #ffffff;
  font-size: 13px;
  z-index: 60;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .detail-pane {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}
