:root {
  --primary: #0033ff;
  --primary-dark: #0029cc;
  --primary-soft: rgba(0, 51, 255, 0.12);
  --text: #1a1a2e;
  --muted: #5c6370;
  --border: #e8ecf4;
  --bg: #f4f6fb;
  --white: #fff;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(0, 51, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 56px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--white);
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.95;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  flex: 1;
}

.top-nav > a,
.nav-drop > summary {
  color: var(--white);
  font-size: 0.92rem;
  cursor: pointer;
  list-style: none;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
}

.top-nav > a:hover,
.nav-drop > summary:hover {
  background: rgba(255, 255, 255, 0.16);
  text-decoration: none;
}

.top-nav > a.is-active {
  background: rgba(255, 255, 255, 0.22);
  font-weight: 600;
}

.nav-drop {
  position: relative;
}

.nav-drop > summary::-webkit-details-marker {
  display: none;
}

.nav-drop[open] > summary {
  background: rgba(255, 255, 255, 0.22);
  font-weight: 600;
}

.nav-drop > summary.is-active {
  background: rgba(255, 255, 255, 0.22);
  font-weight: 600;
}

.nav-drop menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  margin: 0;
  padding: 8px 0;
  min-width: 180px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  z-index: 20;
}

.nav-drop menu a {
  display: block;
  padding: 8px 16px;
  color: var(--text);
}

.nav-drop menu a:hover {
  background: var(--primary-soft);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  font-family: inherit;
  line-height: inherit;
  text-decoration: none;
  box-sizing: border-box;
}

button.btn {
  appearance: none;
  -webkit-appearance: none;
}

.btn-primary {
  background: var(--white);
  color: var(--primary);
}

.btn-primary:hover {
  background: #f0f4ff;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #335dff 55%, #5c7cff 100%);
  color: var(--white);
  padding: 48px 20px 56px;
}

.hero-layout {
  max-width: 1200px;
  margin: 0 auto;
}

.hero-main {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

/* 登录层：固定遮罩 + 右侧卡片，避免被挤到首屏下方看不见 */
.portal-login-aside {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
}

.portal-login-aside.is-visible {
  display: block !important;
  pointer-events: auto;
}

.portal-login-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 60, 0.45);
  cursor: pointer;
}

.portal-login-aside .portal-login-card {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(100%, 380px);
  max-width: 100%;
  margin: 0;
  border-radius: 0;
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.2);
  animation: portal-login-slide-in 0.22s ease-out;
}

@media (max-width: 520px) {
  .portal-login-aside .portal-login-card {
    width: 100%;
  }
}

@keyframes portal-login-slide-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

body.portal-login-open {
  overflow: hidden;
}

.portal-login-card {
  position: relative;
  background: var(--white);
  color: var(--text);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  text-align: left;
}

.portal-login-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  color: var(--text);
}

.portal-login-lead {
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.portal-login-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}

.portal-login-close:hover {
  color: var(--text);
}

.portal-login-field {
  display: block;
  margin-bottom: 14px;
}

.portal-login-field span {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.portal-login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.portal-login-field input:focus {
  outline: 2px solid rgba(0, 51, 255, 0.25);
  border-color: var(--primary);
}

.portal-login-error {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: #c0392b;
}

.portal-login-submit {
  width: 100%;
  margin-top: 4px;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.portal-login-submit:hover {
  background: var(--primary-dark);
}

.portal-login-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.portal-login-foot {
  margin: 14px 0 0;
  font-size: 0.88rem;
  text-align: center;
}

.portal-login-success {
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: #0d6b3a;
  line-height: 1.5;
}

.portal-login-submit-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

.portal-login-foot--tight {
  margin-top: 12px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
}

.hero p {
  margin: 0 0 28px;
  opacity: 0.92;
  font-size: 1rem;
}

.search-form {
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  background: var(--white);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.search-form input {
  flex: 1;
  border: none;
  padding: 14px 20px;
  font-size: 1rem;
  outline: none;
}

.search-form button {
  border: none;
  background: var(--primary);
  color: var(--white);
  padding: 0 24px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
}

.search-form button:hover {
  background: var(--primary-dark);
}

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

.btn-hero-primary {
  display: inline-flex;
  align-items: center;
  padding: 12px 28px;
  border-radius: 999px;
  background: var(--white);
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.btn-hero-primary:hover {
  text-decoration: none;
  background: #f0f4ff;
}

.btn-hero-outline {
  display: inline-flex;
  align-items: center;
  padding: 12px 28px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  color: var(--white);
  font-weight: 500;
  text-decoration: none;
}

.btn-hero-outline:hover {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.12);
}

.header-actions .portal-register {
  border: 1px solid rgba(255, 255, 255, 0.45);
  margin-left: 4px;
}

.portal-user {
  color: var(--white);
  font-size: 0.9rem;
  margin-right: 4px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 首页顶栏：原「登录」位显示用户名 */
.portal-user-name {
  color: var(--white) !important;
  font-weight: 600;
  max-width: 10em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.portal-user-name:hover {
  color: var(--white) !important;
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
}

.portal-user-menu {
  position: relative;
}

.portal-user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 148px;
  margin: 0;
  padding: 6px 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  z-index: 40;
}

.portal-user-dropdown a,
.portal-user-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.portal-user-dropdown a:hover,
.portal-user-dropdown button:hover {
  background: #f4f6fb;
  text-decoration: none;
}

.portal-user-dropdown .portal-user-logout {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.section-title {
  font-size: 1.25rem;
  margin: 0 0 20px;
  font-weight: 600;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
  border-color: rgba(0, 51, 255, 0.35);
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.card h3 a.topic-card-title {
  color: inherit;
  text-decoration: none;
}

.card h3 a.topic-card-title:hover {
  color: var(--primary);
}

.topic-admin-note {
  margin: 0 0 14px;
  color: var(--primary);
  font-size: 0.88rem;
}

.card h3 .topic-edit {
  margin-left: 8px;
  padding: 0 8px;
  border: 1px solid rgba(0, 51, 255, 0.35);
  background: #fff;
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.8;
  cursor: pointer;
  font-weight: 600;
  vertical-align: middle;
}

.card h3 .topic-edit:hover {
  background: rgba(0, 51, 255, 0.08);
}

.topic-name-input {
  font: inherit;
  color: inherit;
  width: 10em;
  max-width: 100%;
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 2px 8px;
}

.card h3 .topic-delete {
  border-color: rgba(180, 40, 40, 0.35);
  color: #b42318;
}

.card h3 .topic-delete:hover {
  background: rgba(180, 35, 24, 0.08);
}

.intro-admin-bar {
  margin: 14px 0 0;
}

.intro-add-form[hidden] {
  display: none;
}

.intro-add-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-width: 440px;
}

.intro-add-form input,
.intro-add-form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.intro-href-label {
  font-size: 0.88rem;
  color: var(--muted);
}

.intro-href-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.intro-href-prefix {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: var(--surface, #f6f7f9);
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.intro-href-row input[name="slug"] {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 0 8px 8px 0;
}

.intro-href-preview {
  margin: 0;
  font-size: 0.82rem;
  color: var(--primary, #2563eb);
  word-break: break-all;
}

.intro-add-actions {
  display: flex;
  gap: 8px;
}

.intro-add-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.card .link {
  font-weight: 500;
  font-size: 0.9rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  margin-top: 40px;
}

@media (max-width: 900px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.side-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.side-box h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.side-box ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000;
  margin-top: 12px;
}

.video-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-placeholder {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.site-footer {
  text-align: center;
  padding: 24px 20px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--white);
}

.intro-page .breadcrumb {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.intro-page h1 {
  margin: 0 0 8px;
}

.intro-page .lead {
  color: var(--muted);
  margin-bottom: 28px;
}

.topic-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.topic-list li {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.topic-list li:last-child {
  border-bottom: none;
}

.topic-list a {
  font-weight: 500;
}

.topic-list span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.article-list {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.article-row {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
}

.article-row:hover {
  border-color: var(--primary);
}

.article-row h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.article-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.article-row span {
  display: inline-block;
  margin-top: 10px;
  color: var(--primary);
  font-weight: 600;
}

.article-body p {
  font-size: 1.05rem;
  line-height: 1.8;
  margin: 0 0 16px;
}

.article-body img,
.write-editor img {
  max-width: 100%;
  height: auto;
}

.article-body table,
.write-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
}

.article-body th,
.article-body td,
.write-editor th,
.write-editor td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  vertical-align: top;
}

.article-body th,
.write-editor th {
  background: #f7f8fc;
}

.write-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.write-tools button,
.write-tools select {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  cursor: pointer;
}

.write-tools label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.write-editor {
  min-height: 320px;
  padding: 16px 2px 8px;
  outline: none;
  font-size: 1.05rem;
  line-height: 1.8;
}

.write-editor:empty:before {
  content: "请输入正文，可插入图片和表格";
  color: #9aa1ad;
}

.article-empty {
  color: var(--muted);
}

.btn-solid {
  background: var(--primary);
  color: #fff;
}

.btn-solid:hover {
  background: var(--primary-dark);
  color: #fff;
  text-decoration: none;
}

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

.topic-toolbar h1 {
  margin: 0;
}

.article-row.has-cover {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 16px;
  align-items: center;
}

.article-cover-thumb {
  width: 128px;
  height: 84px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
}

.article-hero {
  display: block;
  width: min(100%, 720px);
  max-height: 360px;
  object-fit: cover;
  border-radius: 12px;
  margin: 8px 0 20px;
}

.article-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 28px;
}

/* .btn 的 display 会盖掉原生 [hidden]，无权限时仍会看到「修改文章」且没有 href */
#article-edit[hidden] {
  display: none !important;
}

.creator-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}

.creator-side,
.creator-panel,
.write-sheet {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.creator-side {
  padding: 24px 18px;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.creator-avatar {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 700;
}

.creator-side .btn-solid {
  width: 100%;
}

.creator-side a {
  font-weight: 600;
}

.creator-panel,
.write-sheet {
  padding: 22px 24px 18px;
}

.creator-compose h2 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.creator-prompt {
  display: block;
  color: var(--muted);
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.creator-prompt:hover {
  text-decoration: none;
  background: #eef2fb;
}

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

.creator-kind {
  display: block;
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  font-weight: 700;
  text-decoration: none;
}

.creator-kind:hover {
  text-decoration: none;
  filter: brightness(0.97);
}

.creator-kind-ask {
  background: #e7f8ef;
  color: #128a4b;
}

.creator-kind-write {
  background: #fff4df;
  color: #b86e00;
}

.creator-mine {
  margin-top: 22px;
}

.creator-mine h2 {
  font-size: 1.05rem;
  margin: 0 0 12px;
}

.mine-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.mine-row a {
  font-weight: 650;
}

.mine-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.write-title,
.write-body,
.write-topic {
  width: 100%;
  border: none;
  font-family: inherit;
  color: var(--text);
  background: transparent;
}

.write-title {
  font-size: 1.7rem;
  font-weight: 700;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--border);
}

.write-title:focus,
.write-body:focus,
.write-topic:focus {
  outline: none;
}

.write-body {
  min-height: 320px;
  resize: vertical;
  font-size: 1.05rem;
  line-height: 1.8;
  padding: 16px 0;
}

.write-topic {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.write-cover {
  margin-top: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  background: #fafbfe;
}

.write-cover img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
}

.write-cover input {
  display: none;
}

.write-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.write-bar-actions {
  display: flex;
  gap: 8px;
}

.write-preview {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.write-note {
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 800px) {
  .creator-shell {
    grid-template-columns: 1fr;
  }
}
