/* ====== Design Tokens ====== */
:root {
  --primary: #8B7355;
  --primary-light: #F5F0EB;
  --primary-dark: #5C4A3A;
  --success: #6B8E6B;
  --warning: #C4A35A;
  --error: #B55A5A;
  --text: #2C2416;
  --text-secondary: #8B7E6A;
  --border: #E0D5C7;
  --bg: #FAF7F2;
  --bg-secondary: #F0EBE3;
  --overlay: rgba(0,0,0,0.4);
  --white: #FFFFFF;

  --radius-btn: 8px;
  --radius-card: 12px;
  --radius-input: 8px;
  --radius-modal: 16px;
  --radius-tag: 4px;

  --shadow-card: 0 1px 3px rgba(44,36,22,0.08);
  --shadow-card-hover: 0 4px 12px rgba(44,36,22,0.12);
  --shadow-modal: 0 20px 60px rgba(44,36,22,0.18);
  --transition: 150ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg);
  line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column;
}

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

.hidden { display: none !important; }

/* ====== Nav Bar ====== */
.nav-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px; background: var(--white);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 12px; }
.nav-brand { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.nav-brand:hover { text-decoration: none; }
.nav-sep { width: 1px; height: 20px; background: var(--border); }
.nav-title { font-size: 14px; color: var(--text-secondary); }
.nav-title-link { font-size: 14px; color: var(--text-secondary); text-decoration: none; }
.nav-title-link:hover { color: var(--primary); text-decoration: none; }
.nav-link { font-size: 14px; color: var(--text-secondary); padding: 4px 12px; border-radius: var(--radius-btn); }
.nav-link:hover { background: var(--primary-light); text-decoration: none; }
.nav-user-menu { position: relative; cursor: pointer; }
/* 点击展开模式：兼容桌面和移动端 */
.nav-user-menu.open .nav-dropdown { display: block; }
.nav-username { font-size: 14px; color: var(--primary-dark); font-weight: 500; padding: 4px 8px; border-radius: var(--radius-btn); }
.nav-username:hover { background: var(--primary-light); }
.nav-dropdown { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: var(--shadow-modal); min-width: 120px; overflow: hidden; }
.dropdown-item { display: block; width: 100%; padding: 10px 16px; border: none; background: none;
  font-size: 14px; color: var(--text); cursor: pointer; text-align: left; }
.dropdown-item:hover { background: var(--primary-light); }

/* ====== Footer ====== */
.app-footer {
  text-align: center; padding: 24px; color: var(--text-secondary); font-size: 13px;
  margin-top: auto; border-top: 1px solid var(--border);
}
.footer-link { margin-left: 16px; }

/* ====== Layout ====== */
#app-main { flex: 1; padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

.page-title { font-size: 28px; font-weight: 600; color: var(--text); margin-bottom: 24px; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 32px; margin-top: -16px; }

/* ====== Cards ====== */
.card {
  background: var(--white); border-radius: var(--radius-card);
  border: 1px solid var(--border); padding: 24px; box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-card-hover); }

.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card-grid .card { cursor: pointer; text-align: center; padding: 32px 24px; }
.card-grid .card-icon { font-size: 36px; margin-bottom: 12px; }
.card-grid .card-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; color: var(--primary-dark); }
.card-grid .card-desc { font-size: 14px; color: var(--text-secondary); }

/* ====== Buttons ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 24px; border-radius: var(--radius-btn); font-size: 15px; font-weight: 500;
  border: none; cursor: pointer; transition: all var(--transition); gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover:not(:disabled) { opacity: 0.9; }

.btn-error { background: var(--error); color: var(--white); }
.btn-error:hover:not(:disabled) { opacity: 0.9; }

.btn-ghost {
  background: transparent; color: var(--primary); border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-light); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 36px; font-size: 17px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 8px; margin-top: 24px; }

/* ====== Forms ====== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--error); margin-left: 2px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-input);
  font-size: 15px; font-family: inherit; color: var(--text); background: var(--white);
  transition: border-color var(--transition); outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139,115,85,0.1);
}
.form-input.error, .form-textarea.error { border-color: var(--error); }
.form-error { font-size: 13px; color: var(--error); margin-top: 4px; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-help { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section { margin-bottom: 24px; }
.form-section-title { font-size: 16px; font-weight: 600; color: var(--primary-dark); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ====== Tags ====== */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; background: var(--primary-light); border-radius: var(--radius-tag);
  font-size: 13px; color: var(--primary-dark);
}
.tag-remove { cursor: pointer; font-size: 14px; color: var(--text-secondary); }
.tag-remove:hover { color: var(--error); }
.tag-add { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px;
  background: none; border: 1px dashed var(--border); border-radius: var(--radius-tag);
  font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.tag-add:hover { border-color: var(--primary); color: var(--primary); }

/* ====== Avatar ====== */
.avatar-area { text-align: center; }
.avatar-preview {
  width: 120px; height: 120px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--primary-light); margin-bottom: 12px;
}
.avatar-placeholder {
  width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 12px;
  background: var(--primary-light); display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: var(--text-secondary); cursor: pointer;
  border: 2px dashed var(--border); transition: border-color var(--transition);
}
.avatar-placeholder:hover { border-color: var(--primary); }
.avatar-upload-hint { font-size: 13px; color: var(--text-secondary); }

/* ====== Style Picker ====== */
.style-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.style-option {
  padding: 16px 12px; border: 2px solid var(--border); border-radius: var(--radius-card);
  text-align: center; cursor: pointer; transition: all var(--transition); font-size: 14px;
}
.style-option:hover { border-color: var(--primary); }
.style-option.selected { border-color: var(--primary); background: var(--primary-light); }
.style-option .style-icon { font-size: 24px; margin-bottom: 6px; }
.style-option .style-name { font-weight: 500; }

/* ====== Toggle / Switch ====== */
.toggle-group { display: flex; width: 100%; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-btn); overflow: hidden; }
.toggle-option { flex: 1; padding: 8px 20px; font-size: 14px; border: none; background: var(--white); color: var(--text-secondary); cursor: pointer; transition: all var(--transition); text-align: center; }
.toggle-option.active { background: var(--primary); color: var(--white); }
.toggle-option:hover:not(.active) { background: var(--primary-light); }

/* ====== Search Bar ====== */
.search-bar { position: relative; margin-bottom: 20px; }
.search-bar .form-input { padding-left: 40px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 18px; }

/* ====== Member Grid ====== */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.member-card {
  text-align: center; padding: 20px 16px; cursor: pointer;
  transition: box-shadow var(--transition);
}
.member-card:hover { box-shadow: var(--shadow-card-hover); }
.member-card .member-avatar {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--primary-light); margin-bottom: 10px;
}
.member-card .member-avatar-placeholder {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 10px;
  background: var(--primary-light); display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--text-secondary);
}
.member-card .member-name { font-size: 16px; font-weight: 600; color: var(--text); }
.member-card .member-role { font-size: 13px; color: var(--text-secondary); }
.member-card .member-motto { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ====== Badges ====== */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 500;
}
.badge-admin { background: #F5F0EB; color: var(--primary-dark); }
.badge-pending { background: #FFF3E0; color: #E65100; }

/* ====== Login Page ====== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 120px); padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px;
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .logo { font-size: 32px; margin-bottom: 8px; }
.login-header h1 { font-size: 24px; color: var(--primary-dark); margin-bottom: 4px; }
.login-header .slogan { font-size: 14px; color: var(--text-secondary); }
.login-tabs { display: flex; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.login-tab {
  flex: 1; padding: 10px; border: none; background: none; font-size: 16px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.login-tab.active { color: var(--primary); border-bottom: 2px solid var(--primary); margin-bottom: -2px; }
.login-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-secondary); }
.login-switch a { cursor: pointer; color: var(--primary); font-weight: 500; }

/* ====== Modal ====== */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 200ms ease;
}
.modal-box {
  background: var(--white); border-radius: var(--radius-modal); padding: 32px;
  max-width: 480px; width: 90%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.modal-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }
.modal-body { margin-bottom: 24px; font-size: 15px; color: var(--text-secondary); line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ====== Lightbox ====== */
.lightbox-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 1100;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.lightbox-img { max-width: 80vw; max-height: 80vh; border-radius: 8px; cursor: default; }
.lightbox-close { position: absolute; top: 24px; right: 24px; font-size: 32px;
  color: var(--white); cursor: pointer; opacity: 0.8; }
.lightbox-close:hover { opacity: 1; }

/* ====== Toast ====== */
#toast-container { position: fixed; top: 72px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-card); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-modal); animation: slideIn 300ms ease;
  display: flex; align-items: center; gap: 8px; max-width: 360px;
}
.toast-success { background: var(--success); color: var(--white); }
.toast-error { background: var(--error); color: var(--white); }
.toast-info { background: var(--primary-dark); color: var(--white); }

/* ====== Loading ====== */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 600ms linear infinite;
}
.loading-center { display: flex; align-items: center; justify-content: center; padding: 48px; }

/* ====== Empty State ====== */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; color: var(--border); }
.empty-state .empty-text { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state .empty-hint { font-size: 14px; color: var(--text-secondary); }

/* ====== Org List Items ====== */
.org-item {
  display: flex; align-items: center; gap: 16px; padding: 16px;
  border-bottom: 1px solid var(--border);
}
.org-item:last-child { border-bottom: none; }
.org-item-icon { font-size: 28px; }
.org-item-info { flex: 1; }
.org-item-name { font-size: 16px; font-weight: 500; }
.org-item-meta { font-size: 13px; color: var(--text-secondary); }
.org-item-status { font-size: 13px; color: var(--warning); }

/* ====== Tabs ====== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-item {
  padding: 10px 20px; border: none; background: none; font-size: 15px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-item:hover:not(.active) { color: var(--text); }
.tab-badge { background: var(--error); color: var(--white); font-size: 11px; padding: 1px 6px;
  border-radius: 10px; margin-left: 6px; }

/* ====== Manage Member List ====== */
.manage-member {
  display: flex; align-items: center; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.manage-member:last-child { border-bottom: none; }
.manage-member-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  background: var(--primary-light); display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-secondary); flex-shrink: 0;
}
.manage-member-info { flex: 1; min-width: 0; }
.manage-member-name { font-size: 15px; font-weight: 500; }
.manage-member-meta { font-size: 13px; color: var(--text-secondary); }
.manage-member-actions { display: flex; gap: 8px; }

/* ====== Dashboard ====== */
.dashboard-welcome { margin-bottom: 32px; }
.dashboard-welcome h2 { font-size: 24px; font-weight: 600; color: var(--text); }
.dashboard-welcome p { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* ====== Responsive ====== */
@media (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .style-picker { grid-template-columns: 1fr; }
  .member-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  #app-main { padding: 16px; }
  .nav-bar { padding: 0 12px; }
}

/* ====== Animations ====== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Profile Edit Layout ====== */
.profile-edit-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.profile-edit-main { min-width: 0; }
.profile-edit-sidebar { position: sticky; top: 80px; }
@media (max-width: 900px) {
  .profile-edit-layout { grid-template-columns: 1fr; }
  .profile-edit-sidebar { position: static; }
}

/* ====== Style Preview Cards ====== */
.style-preview-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* ====== Organization States (shared by all themes) ====== */
.org-login-card {
  border-radius: 12px;
  padding: 20px 24px;
  text-align: center;
  margin: 16px 0;
  background: rgba(139, 115, 85, 0.06);
  border: 1px dashed rgba(139, 115, 85, 0.2);
}
.org-login-icon { font-size: 28px; margin-bottom: 8px; }
.org-login-text { font-size: 14px; color: var(--text-secondary); }

.org-common-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ---- Contact Line (shared) ---- */
.poster-contact-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  font-size: 13px;
  opacity: 0.85;
}
.poster-contact-line .contact-item {
  white-space: nowrap;
}

/* ---- Keywords Panel (shared) ---- */
.keywords-panel {
  display: flex;
  gap: 32px;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  max-width: 780px;
  flex-wrap: wrap;
}
.keywords-panel-title {
  flex-basis: 100%;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.keywords-panel-left {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  justify-content: center;
}
.keywords-cloud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  line-height: 1.4;
}
.kw-word {
  display: inline-block;
  font-weight: 600;
  transition: transform 0.15s;
  cursor: default;
}
.kw-word:hover { transform: scale(1.1); }
.keywords-panel-right {
  flex: 0 0 auto;
  text-align: center;
}
.qr-code-wrap {
  display: inline-block;
  background: white;
  padding: 8px;
  border-radius: 8px;
}
.qr-code-img { display: block; }
.qr-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ---- Share Modal ---- */
.share-modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
}
.share-modal {
  background: var(--card-bg, #fff);
  border-radius: 16px;
  padding: 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.share-modal h3 {
  margin: 0 0 20px 0;
  font-size: 18px;
}
.share-modal .btn {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 12px;
}
.share-modal .qr-code-wrap { margin: 16px auto; }
.share-modal .btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  margin-top: 8px;
}

/* Canvas word cloud */
.kw-cloud-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* SVG word cloud */
.keywords-cloud-svg { width: 260px; margin: 0 auto; }
.keywords-cloud-svg img { display: block; width: 100%; height: auto; }
