/* =========================================================
   薛朗的资源仓库 - 样式表
   设计语言：浅灰背景、深灰文字、单一青色强调色，简约干净
   ========================================================= */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #F5F6F7;            /* 页面背景：浅灰 */
  --surface: #FFFFFF;       /* 卡片 / 面板 */
  --surface-2: #EDEFF2;     /* 次级底 */
  --border: #E4E7EB;        /* 分隔线 / 边框 */
  --text: #2B3038;          /* 主文字：深灰 */
  --text-2: #5B6472;        /* 次级文字 */
  --text-3: #8A93A2;        /* 弱化文字 */
  --accent: #0E7C66;        /* 强调色：深青 */
  --accent-dark: #0A6351;
  --accent-soft: #E3F1EC;   /* 强调色浅底 */
  --danger: #D6403A;
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --shadow: 0 1px 2px rgba(23, 27, 32, 0.05), 0 10px 28px rgba(23, 27, 32, 0.07);
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- 基础重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-stack);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
}

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- 通用容器 ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.container-narrow {
  max-width: 780px;
}

.section {
  padding: 76px 0;
  scroll-margin-top: calc(var(--nav-h) + 8px);
}

.section-head {
  position: relative;
  text-align: center;
  margin-bottom: 38px;
}

/* 「＋」新增按钮：位于区块标题右侧，仅站长登录后显示 */
.section-head .add-btn {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px dashed var(--text-3);
  color: var(--text-3);
}

.section-head .add-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  transform: translateY(-50%) scale(1.05);
}

.section-head .add-btn:active {
  transform: translateY(-50%) scale(0.96);
}

.section-head .add-btn svg {
  width: 22px;
  height: 22px;
}

.section-head h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-sub {
  margin-top: 8px;
  color: var(--text-3);
  font-size: 15px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
  min-height: 44px;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

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

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #B9332E;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.icon-btn svg,
.card-action svg {
  width: 18px;
  height: 18px;
}

/* ---------- 顶部导航 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--nav-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-logo {
  display: inline-flex;
  color: var(--accent);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.menu-btn svg {
  width: 22px;
  height: 22px;
}

/* ---------- 账号区域 ---------- */
.account-wrap {
  position: relative;
}

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 4px 12px 4px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.account-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

.account-caret {
  width: 15px;
  height: 15px;
  color: var(--text-3);
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 120;
}

.account-menu-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
}

.account-menu-item:hover {
  background: var(--surface-2);
}

/* ---------- Hero / 首页 ---------- */
.hero {
  position: relative;
  padding: 84px 0 72px;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#D9DEE4 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.5;
  -webkit-mask-image: radial-gradient(ellipse 75% 75% at 50% 35%, #000 25%, transparent 72%);
  mask-image: radial-gradient(ellipse 75% 75% at 50% 35%, #000 25%, transparent 72%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.avatar-wrap {
  position: relative;
  width: 124px;
  height: 124px;
  margin: 0 auto 22px;
}

.hero-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #FFFFFF;
  background: var(--surface-2);
  box-shadow: 0 0 0 6px var(--accent-soft), var(--shadow);
}

.avatar-edit-badge {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--bg);
}

.avatar-edit-badge svg {
  width: 17px;
  height: 17px;
}

body.owner-mode .avatar-wrap {
  cursor: pointer;
}

.nickname {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.intro {
  margin: 14px auto 0;
  max-width: 560px;
  color: var(--text-2);
  font-size: 17px;
}

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

/* ---------- 关于我 ---------- */
.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 32px;
  box-shadow: 0 1px 2px rgba(23, 27, 32, 0.03);
}

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

.about-head h2 {
  font-size: 20px;
  font-weight: 700;
}

.about-text {
  color: var(--text-2);
  font-size: 15.5px;
  white-space: pre-line;
}

/* ---------- 资源卡片 ---------- */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.resource-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.resource-card:hover {
  transform: translateY(-3px);
  border-color: #C6D6CF;
  box-shadow: var(--shadow);
}

.resource-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.resource-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-3);
  transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.card-action:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.card-action[data-action="delete"]:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #FDEBEA;
}

.resource-desc {
  flex: 1;
  color: var(--text-2);
  font-size: 14px;
}

.resource-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.resource-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.resource-link:hover {
  color: var(--accent-dark);
}

.resource-link svg {
  width: 15px;
  height: 15px;
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
}

.empty-sub {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 14px;
}

/* ---------- 编辑面板（站长可见） ---------- */
.editor-panel {
  margin-top: 30px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.editor-panel h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.add-form .input {
  flex: 1 1 200px;
  min-width: 0;
}

.editor-hint {
  margin-top: 12px;
  color: var(--text-3);
  font-size: 13px;
}

/* ---------- 加入资源仓库 ---------- */
.section-join {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.join-inner {
  text-align: center;
  max-width: 640px;
}

.join-inner h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.join-text {
  margin: 14px auto 0;
  color: var(--text-2);
  font-size: 16px;
}

.join-inner .btn {
  margin-top: 28px;
}

.join-hint {
  margin-top: 14px;
  color: var(--text-3);
  font-size: 13.5px;
}

/* ---------- 联系我 ---------- */
.contact-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 640px;
  display: grid;
  gap: 12px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 8px 6px 6px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.contact-item:hover {
  border-color: #C6D6CF;
  box-shadow: var(--shadow);
}

.contact-main {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  padding: 8px 8px 8px 8px;
  color: var(--text);
  text-decoration: none;
}

.contact-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.contact-icon svg {
  width: 20px;
  height: 20px;
}

.contact-info {
  min-width: 0;
}

.contact-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.contact-url {
  display: block;
  color: var(--text-3);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-arrow {
  margin-left: auto;
  color: var(--text-3);
  flex-shrink: 0;
}

.contact-arrow svg {
  width: 17px;
  height: 17px;
}

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 30px 0;
}

.footer-inner {
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ---------- 表单 ---------- */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.input {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(23, 27, 32, 0.45);
}

.modal {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(23, 27, 32, 0.18);
}

.modal-sm {
  max-width: 360px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  transition: background-color 0.18s ease, color 0.18s ease;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  padding-right: 28px;
}

.modal-sub {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 20px;
}

.modal-body p {
  color: var(--text-2);
  font-size: 14.5px;
  margin-bottom: 12px;
}

.modal-body p:last-child {
  margin-bottom: 20px;
}

.modal-body strong {
  color: var(--text);
}

.modal-hint {
  margin-top: 14px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 2px solid var(--border);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 300;
  max-width: min(90vw, 420px);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  background: #242A31;
  color: #FFFFFF;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(23, 27, 32, 0.25);
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------- 登录 / 注册 Tab ---------- */
.tab-switch {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}

.tab-btn {
  flex: 1;
  padding: 9px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 600;
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(23, 27, 32, 0.1);
}

.code-row {
  display: flex;
  gap: 10px;
}

.code-row .input {
  flex: 1;
  min-width: 0;
}

.code-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
  min-height: 44px;
}

.code-notice {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.5;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent-dark);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================================
   响应式：手机端
   ========================================================= */
@media (max-width: 1024px) {
  .resource-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .section {
    padding: 56px 0;
  }

  .hero {
    padding: 64px 0 56px;
  }

  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 16px 32px rgba(23, 27, 32, 0.08);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 12px 14px;
    font-size: 16px;
  }

  .menu-btn {
    display: inline-flex;
  }

  .account-name {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .about-card {
    padding: 24px 20px;
  }
}

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

  .container {
    padding: 0 16px;
  }

  .brand {
    font-size: 16px;
  }
}
