/* 尘箓 RuleHub — GitHub 风格样式（浅色主题） */
:root {
  /* GitHub 浅色色板 */
  --gh-canvas: #ffffff;
  --gh-canvas-subtle: #f6f8fa;
  --gh-border: #d0d7de;
  --gh-border-muted: #d8dee4;
  --gh-fg: #1f2328;
  --gh-fg-muted: #59636e;
  --gh-accent: #0969da;
  --gh-accent-subtle: #ddf4ff;
  --gh-success: #1f883d;
  --gh-success-hover: #1a7f37;
  --gh-success-subtle: #dafbe1;
  --gh-danger: #cf222e;
  --gh-danger-subtle: #ffebe9;
  --gh-attention: #9a6700;
  --gh-attention-subtle: #fff8c5;
  --gh-done: #8250df;
  --gh-done-subtle: #fbefff;
  --gh-neutral-subtle: rgba(175, 184, 193, 0.2);
  --gh-radius: 6px;
  --gh-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
    Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --gh-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--gh-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--gh-fg);
  background: var(--gh-canvas-subtle);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--gh-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ==================== 顶栏 ==================== */
.gh-header {
  background: var(--gh-canvas-subtle);
  border-bottom: 1px solid var(--gh-border);
}

.gh-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1012px;
  margin: 0 auto;
  padding: 12px 16px;
}

.gh-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gh-fg);
  font-weight: 600;
  font-size: 15px;
}

.gh-brand:hover {
  text-decoration: none;
}

.gh-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  border: 1px solid var(--gh-border);
  background: var(--gh-canvas);
  color: var(--gh-fg);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gh-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.gh-user-name {
  color: var(--gh-fg-muted);
  font-size: 13px;
}

.gh-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gh-neutral-subtle);
  border: 1px solid var(--gh-border);
  color: var(--gh-fg);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gh-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==================== 容器与页头 ==================== */
.gh-container {
  max-width: 1012px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.gh-container-narrow {
  max-width: 640px;
}

.gh-page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.gh-page-title {
  font-size: 20px;
  font-weight: 600;
}

.gh-page-sub {
  color: var(--gh-fg-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ==================== 卡片与列表 ==================== */
.gh-card {
  background: var(--gh-canvas);
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.gh-card-header {
  padding: 12px 16px;
  background: var(--gh-canvas-subtle);
  border-bottom: 1px solid var(--gh-border);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gh-card-header .gh-header-action {
  margin-left: auto;
}

.gh-list {
  display: block;
}

.gh-list-item {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-bottom: 1px solid var(--gh-border-muted);
  background: var(--gh-canvas);
  text-align: left;
  color: var(--gh-fg);
  font-size: 14px;
}

.gh-list-item:last-child {
  border-bottom: none;
}

a.gh-list-item {
  color: var(--gh-fg);
}

a.gh-list-item:hover,
button.gh-list-item:hover {
  background: var(--gh-canvas-subtle);
  text-decoration: none;
}

.gh-item-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gh-item-title {
  color: var(--gh-accent);
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.gh-item-desc {
  margin-top: 4px;
  color: var(--gh-fg-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.gh-item-meta {
  margin-top: 8px;
  color: var(--gh-fg-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.gh-item-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== 徽章 ==================== */
.gh-label-pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--gh-border);
  background: var(--gh-neutral-subtle);
  color: var(--gh-fg-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.gh-label-open {
  background: var(--gh-success-subtle);
  border-color: transparent;
  color: var(--gh-success);
}

.gh-label-closed {
  background: var(--gh-danger-subtle);
  border-color: transparent;
  color: var(--gh-danger);
}

.gh-label-warn {
  background: var(--gh-attention-subtle);
  border-color: transparent;
  color: var(--gh-attention);
}

.gh-label-done {
  background: var(--gh-done-subtle);
  border-color: transparent;
  color: var(--gh-done);
}

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 16px;
  border-radius: var(--gh-radius);
  border: 1px solid var(--gh-border);
  background: var(--gh-canvas);
  color: var(--gh-fg);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--gh-canvas-subtle);
  text-decoration: none;
}

.btn:disabled {
  opacity: .6;
  cursor: default;
}

.btn-primary {
  background: var(--gh-success);
  border-color: rgba(31, 136, 61, 0.4);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--gh-success-hover);
}

.btn-danger {
  color: var(--gh-danger);
}

.btn-danger:hover {
  background: var(--gh-danger-subtle);
  border-color: rgba(207, 34, 46, 0.4);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 3px 12px;
  font-size: 12px;
}

/* ==================== 表单 ==================== */
.gh-field {
  display: block;
  margin-bottom: 16px;
}

.gh-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.gh-label .gh-required {
  color: var(--gh-danger);
}

.gh-input,
.gh-textarea {
  display: block;
  width: 100%;
  padding: 5px 12px;
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  background: var(--gh-canvas);
  color: var(--gh-fg);
  font-size: 14px;
  font-family: inherit;
  line-height: 20px;
  outline: none;
}

.gh-input {
  height: 32px;
}

.gh-textarea {
  min-height: 96px;
  padding: 8px 12px;
  resize: vertical;
}

.gh-input:focus,
.gh-textarea:focus {
  border-color: var(--gh-accent);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.3);
}

input[type="file"].gh-input {
  height: auto;
  padding: 6px 10px;
  background: var(--gh-canvas-subtle);
  border-style: dashed;
}

.gh-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--gh-fg-muted);
}

.gh-error-text {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid rgba(207, 34, 46, 0.4);
  border-radius: var(--gh-radius);
  background: var(--gh-danger-subtle);
  color: var(--gh-danger);
  font-size: 13px;
}

/* ==================== 空白态 ==================== */
.gh-blank {
  padding: 40px 16px;
  text-align: center;
  color: var(--gh-fg-muted);
}

.gh-blank-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gh-fg);
  margin-bottom: 6px;
}

/* ==================== 认证页（登录/注册） ==================== */
.gh-auth-body {
  background: var(--gh-canvas-subtle);
}

.gh-auth-wrap {
  max-width: 340px;
  margin: 0 auto;
  padding: 48px 16px;
}

.gh-auth-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 1px solid var(--gh-border);
  background: var(--gh-canvas);
  color: var(--gh-fg);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Logo 图片（圆形边框容器内铺满显示） */
.gh-logo img,
.gh-auth-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gh-auth-title {
  text-align: center;
  font-size: 24px;
  font-weight: 300;
  margin-bottom: 20px;
}

.gh-auth-card {
  padding: 20px;
  margin-bottom: 16px;
}

.gh-auth-alt {
  padding: 16px;
  text-align: center;
  font-size: 14px;
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  background: var(--gh-canvas);
}

/* ==================== Toast ==================== */
.gh-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(8px);
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: var(--gh-radius);
  background: var(--gh-fg);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 99;
}

.gh-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.gh-toast-error {
  background: var(--gh-danger);
}

/* ==================== 工具 ==================== */
.gh-muted {
  color: var(--gh-fg-muted);
}

.gh-mono {
  font-family: var(--gh-font-mono);
  font-size: 12px;
}

.gh-body-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
  font-size: 14px;
}

.gh-divider {
  height: 1px;
  background: var(--gh-border-muted);
  margin: 16px 0;
}

/* ==================== 分类筛选（Phase 4） ==================== */
.gh-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.gh-filter {
  padding: 5px 12px;
  border: 1px solid var(--gh-border);
  border-radius: 999px;
  background: var(--gh-canvas);
  color: var(--gh-fg);
  font-size: 13px;
  line-height: 18px;
}

.gh-filter:hover {
  background: var(--gh-canvas-subtle);
}

.gh-filter.active {
  background: var(--gh-accent);
  border-color: var(--gh-accent);
  color: #fff;
}

/* 下拉选择（投稿栏目 / 分类） */
select.gh-input {
  height: 32px;
  padding: 0 8px;
}

/* ==================== 弹窗（审核拒绝等） ==================== */
.gh-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(31, 35, 40, 0.5);
}

.gh-modal {
  width: 100%;
  max-width: 420px;
  padding: 16px;
  background: var(--gh-canvas);
  border: 1px solid var(--gh-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
}

.gh-modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.gh-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ==================== 加载态 / 错误态（Phase 6） ==================== */
.gh-spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 10px;
  border: 2px solid var(--gh-border);
  border-top-color: var(--gh-accent);
  border-radius: 50%;
  animation: gh-spin .8s linear infinite;
}

@keyframes gh-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 列表项描述最多两行（保持列表整齐） */
.gh-list-item .gh-item-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 键盘可达性 */
.btn:focus-visible,
.gh-filter:focus-visible,
.gh-list-item:focus-visible {
  outline: 2px solid var(--gh-accent);
  outline-offset: 1px;
}

/* iOS 安全区 */
body {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.gh-toast {
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
}

/* ==================== 移动端适配（≤480px） ==================== */
@media (max-width: 480px) {
  .gh-header-inner {
    gap: 8px;
    padding: 10px 12px;
  }

  .gh-user-name {
    display: none;
  }

  .gh-header-right {
    gap: 6px;
  }

  .gh-header-right .btn {
    padding: 3px 8px;
    font-size: 12px;
  }

  .gh-brand span:last-child {
    font-size: 14px;
  }

  .gh-container {
    padding: 16px 12px 56px;
  }

  .gh-page-title {
    font-size: 18px;
  }

  .gh-page-head {
    gap: 8px;
  }

  .gh-filter {
    padding: 4px 10px;
    font-size: 12px;
  }

  .gh-modal {
    max-height: 80vh;
    overflow-y: auto;
  }
}
