* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f5f6f7;
  --bg-card: #fff;
  --text: #1e1e2f;
  --text-secondary: #555;
  --text-muted: #888;
  --border: #e8e8ed;
  --accent: #1e80ff;
  --accent-hover: #0d6efd;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.04);
  --shadow-hover: 0 4px 20px rgba(0,0,0,.08);
  --bg-input: #fff;
  --bg-code: #f0f2f5;
  --bg-tag: #e8f0fe;
  --bg-warning: #fffbeb;
  --bg-tip: #f0fdf4;
  --bg-note: #eff6ff;
  --border-warning: #f59e0b;
  --border-tip: #22c55e;
  --border-note: #3b82f6;
  --hero-bg: linear-gradient(135deg, #1e80ff 0%, #0d6efd 100%);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-card: #161b22;
  --text: #e6edf3;
  --text-secondary: #b0b8c4;
  --text-muted: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --shadow-hover: 0 4px 20px rgba(0,0,0,.5);
  --bg-input: #21262d;
  --bg-code: #21262d;
  --bg-tag: #1f2d45;
  --bg-warning: #2b1d0a;
  --bg-tip: #0a2b1a;
  --bg-note: #0a1a2b;
  --border-warning: #f59e0b;
  --border-tip: #22c55e;
  --border-note: #3b82f6;
  --hero-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; min-height: 100vh; display: flex; flex-direction: column; transition: background .3s, color .3s; }
a { color: var(--accent); transition: color .2s; }
a:hover { color: var(--accent-hover); }

/* Nav */
.nav { background: var(--bg-card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.nav-inner { max-width: 860px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.nav-brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-link { color: var(--text-secondary); text-decoration: none; font-size: 14px; cursor: pointer; background: none; border: none; font-family: inherit; padding: 8px 12px; border-radius: 6px; transition: all .2s; min-height: 36px; display: inline-flex; align-items: center; }
.nav-link:hover, .nav-link.active { color: var(--accent); background: var(--bg-tag); }
.nav-user-name { font-size: 12px; color: var(--text-muted); padding: 0 6px; }
.theme-btn { background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 15px; padding: 6px 10px; line-height: 1; transition: all .2s; margin-left: 4px; min-height: 36px; }
.theme-btn:hover { border-color: var(--accent); }

/* Hamburger */
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; font-size: 22px; color: var(--text); line-height: 1; min-height: 44px; min-width: 44px; }
.nav-overlay { display: none; }

/* Main */
.main { flex: 1; max-width: 860px; margin: 0 auto; padding: 32px 24px; width: 100%; }

/* Hero */
.hero { background: var(--hero-bg); border-radius: var(--radius); padding: 36px 40px; margin-bottom: 28px; color: #fff; position: relative; overflow: hidden; }
.hero h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.hero p { font-size: 14px; opacity: .85; line-height: 1.6; }
.hero .hero-stats { margin-top: 12px; font-size: 13px; opacity: .7; display: flex; gap: 16px; }

/* Search bar */
.search-bar { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; display: flex; align-items: center; margin-bottom: 24px; box-shadow: var(--shadow); }
.search-input { flex: 1; padding: 12px 16px; border: none; font-size: 14px; background: transparent; color: var(--text); outline: none; min-height: 44px; }
.search-btn { padding: 10px 22px; background: var(--accent); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 15px; margin: 2px; min-height: 44px; transition: background .2s; }
.search-btn:hover { background: var(--accent-hover); }

/* Tag bar */
.tag-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.tag { display: inline-block; padding: 4px 14px; border-radius: 20px; font-size: 13px; background: var(--bg-tag); color: var(--accent); border: 1px solid transparent; }
.tag-filter { cursor: pointer; transition: all .2s; }
.tag-filter:hover { border-color: var(--accent); }
.tag-filter.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Post cards */
.post-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; transition: all .25s; box-shadow: var(--shadow); display: flex; }
.post-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.post-card-cover { width: 80px; min-height: 100px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.post-card-body { padding: 20px 24px; flex: 1; min-width: 0; }
.post-card-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.post-card-title a { color: var(--text); text-decoration: none; }
.post-card-title a:hover { color: var(--accent); }
.post-card-excerpt { font-size: 14px; color: var(--text-secondary); line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 10px; }
.post-card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.post-card-meta .tag { font-size: 11px; padding: 2px 10px; }
.post-card-readtime { background: var(--bg-code); padding: 1px 8px; border-radius: 4px; font-size: 11px; color: var(--text-secondary); }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 32px; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; font-size: 14px; color: var(--text); transition: all .2s; }
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Footer */
.footer { text-align: center; padding: 28px 24px; color: var(--text-muted); font-size: 13px; border-top: 1px solid var(--border); margin-top: 40px; }
.footer-inner { max-width: 860px; margin: 0 auto; }
.footer-links { margin-bottom: 8px; display: flex; gap: 20px; justify-content: center; }
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 13px; }
.footer-links a:hover { color: var(--accent); }

/* Post detail */
.post-content-wrap { max-width: 760px; margin: 0 auto; }
.post-full { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 44px; box-shadow: var(--shadow); }
.post-title { font-size: 28px; font-weight: 700; line-height: 1.4; margin-bottom: 8px; }
.post-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 32px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.post-content { font-size: 15px; line-height: 1.9; }
.post-content h2 { font-size: 22px; margin: 40px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.post-content h3 { font-size: 18px; margin: 28px 0 8px; }
.post-content p { margin-bottom: 1.2em; }
.post-content ul, .post-content ol { margin-bottom: 1.2em; padding-left: 24px; }
.post-content li { margin-bottom: 4px; }
.post-content code { background: var(--bg-code); padding: 2px 6px; border-radius: 4px; font-size: 13px; border: 1px solid var(--border); }
.post-content pre { background: #161b22; color: #e6edf3; padding: 20px; border-radius: var(--radius); overflow-x: auto; margin: 1.2em 0; font-size: 13px; line-height: 1.6; border: 1px solid #30363d; }
.post-content pre code { background: none; padding: 0; border: none; }
.post-content blockquote { border-left: 4px solid var(--accent); padding: 8px 20px; margin: 1.2em 0; background: var(--bg-code); border-radius: 0 var(--radius) var(--radius) 0; }
.post-content img { max-width: 100%; border-radius: var(--radius); margin: 1.2em 0; }

/* Notice boxes */
.post-content .notice, .post-content .tip, .post-content .warning {
  padding: 14px 18px; border-radius: var(--radius); margin: 1.2em 0; border-left: 4px solid; font-size: 14px;
}
.post-content .notice { background: var(--bg-note); border-color: var(--border-note); }
.post-content .tip { background: var(--bg-tip); border-color: var(--border-tip); }
.post-content .warning { background: var(--bg-warning); border-color: var(--border-warning); }
.post-content .notice::before { content: "💡 "; }
.post-content .tip::before { content: "💪 "; }
.post-content .warning::before { content: "⚠️ "; }

/* Table of contents */
.post-content .toc { background: var(--bg-code); border-radius: var(--radius); padding: 16px 20px; margin: 1.2em 0; font-size: 14px; }
.post-content .toc ul { list-style: none; padding-left: 16px; margin: 8px 0 0; }
.post-content .toc li { margin: 4px 0; }
.post-content .toc a { text-decoration: none; }

.back-link { display: inline-block; margin-top: 32px; color: var(--accent); text-decoration: none; font-size: 14px; }
.back-link:hover { text-decoration: underline; }

/* Empty state */
.empty-state { text-align: center; padding: 80px 0; color: var(--text-muted); }

/* Auth boxes */
.auth-box { max-width: 400px; margin: 60px auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow); }
.auth-box h2 { font-size: 20px; margin-bottom: 4px; }
.auth-box .subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.auth-box input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: var(--bg-input); color: var(--text); outline: none; margin-bottom: 12px; min-height: 44px; }
.auth-box input:focus { border-color: var(--accent); }
.auth-box .error { color: #dc2626; font-size: 13px; min-height: 20px; }
.auth-box .auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.auth-box .auth-switch a { color: var(--accent); cursor: pointer; text-decoration: none; }
.btn-primary { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; transition: background .2s; min-height: 44px; }
.btn-primary:hover { background: var(--accent-hover); }

/* Admin */
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 8px; }
.admin-btn { padding: 10px 18px; background: var(--accent); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background .2s; min-height: 36px; }
.admin-btn:hover { background: var(--accent-hover); }
.admin-btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); cursor: pointer; padding: 10px 18px; border-radius: 6px; font-size: 13px; transition: all .2s; min-height: 36px; }
.admin-btn-outline:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.admin-btn-danger { background: #dc2626; }
.admin-btn-danger:hover { background: #b91c1c; }

/* Editor */
.editor-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }

/* Tools */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.tool-card, .tool-page { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: var(--shadow); }
.tool-card { cursor: pointer; transition: all .2s; text-decoration: none; color: var(--text); }
.tool-card:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.tool-icon { font-size: 30px; margin-bottom: 8px; }
.tool-name { font-size: 14px; font-weight: 500; }
.tool-desc { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }
.tool-page { padding: 32px; text-align: left; }
.tool-page button { padding: 10px 22px; background: var(--accent); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; transition: background .2s; margin-right: 8px; margin-bottom: 12px; }
.tool-page button:hover { background: var(--accent-hover); }
.tool-result { background: var(--bg-code); border-radius: var(--radius); padding: 16px; font-family: monospace; font-size: 13px; overflow-x: auto; word-break: break-all; }
.tool-page textarea, .tool-page input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; background: var(--bg-input); color: var(--text); margin-bottom: 12px; outline: none; }
.tool-page select { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; background: var(--bg-input); color: var(--text); outline: none; margin-bottom: 12px; cursor: pointer; }
.tool-page select:focus { border-color: var(--accent); }
.tool-page .form-group { display: flex; flex-direction: column; flex: 1; min-width: 120px; }
.tool-page .form-group label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.editor-wrap input, .editor-wrap textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; margin-bottom: 12px; background: var(--bg-input); color: var(--text); font-family: inherit; }
.editor-wrap textarea { min-height: 400px; resize: vertical; font-family: monospace; font-size: 14px; line-height: 1.6; }
.editor-wrap input:focus, .editor-wrap textarea:focus { border-color: var(--accent); }
.editor-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }

/* Archive */
.archive-group { margin-bottom: 28px; }
.archive-year { font-size: 18px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); color: var(--accent); }
.archive-list { list-style: none; }
.archive-list li { padding: 8px 0; font-size: 14px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); }
.archive-list li:last-child { border-bottom: none; }
.archive-list li a { color: var(--text); text-decoration: none; }
.archive-list li a:hover { color: var(--accent); }
.archive-date { color: var(--text-muted); font-size: 12px; }

/* About */
.about-content h2 { font-size: 22px; }
.about-content h3 { font-size: 17px; margin: 24px 0 10px; }
.about-content p { margin-bottom: 12px; color: var(--text-secondary); }
.about-content ul { padding-left: 20px; color: var(--text-secondary); }
.about-content li { margin-bottom: 6px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 10px; text-align: left; border-bottom: 2px solid var(--border); font-weight: 600; }
td { padding: 10px; border-bottom: 1px solid var(--border); }

/* Users */
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.user-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.user-card .username { font-weight: 600; }
.role-badge { font-size: 11px; background: var(--bg-tag); color: var(--accent); padding: 1px 6px; border-radius: 4px; }

/* Users / Profile */
.profile-header { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; box-shadow: var(--shadow); }
.profile-avatar { flex-shrink: 0; }
.profile-avatar img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.profile-avatar-placeholder { width: 80px; height: 80px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 700; }
.profile-info { flex: 1; min-width: 200px; }
.profile-info h2 { font-size: 22px; margin-bottom: 2px; }
.profile-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.profile-bio { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; line-height: 1.6; }
.profile-stats { display: flex; gap: 20px; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.profile-stats strong { color: var(--text); font-size: 15px; }
.profile-links { display: flex; gap: 12px; font-size: 13px; }
.profile-links a { color: var(--accent); text-decoration: none; }
.profile-links a:hover { text-decoration: underline; }
.profile-actions { flex-shrink: 0; }
.post-card-author { color: var(--accent); text-decoration: none; font-size: 12px; }
.post-card-author:hover { text-decoration: underline; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* Loading */
.loading { text-align: center; color: var(--text-muted); padding: 60px 0; }

/* Mobile */
@media (max-width: 640px) {
  .hamburger { display: block; }
  .nav-links { display: none; position: fixed; top: 60px; left: 0; right: 0; background: var(--bg-card); flex-direction: column; padding: 12px; border-bottom: 1px solid var(--border); z-index: 99; box-shadow: var(--shadow); }
  .nav-links.open { display: flex; }
  .nav-link { padding: 12px 16px; min-height: 44px; font-size: 15px; width: 100%; }
  .nav-user-name { padding: 12px 16px; display: block; }
  .nav-overlay.open { display: block; position: fixed; top: 60px; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.3); z-index: 98; }

  .nav-inner { padding: 0 12px; height: 60px; }
  .main { padding: 16px; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 22px; }
  .post-card { flex-direction: column; }
  .post-card-cover { width: 100%; min-height: 48px; padding: 8px 0; }
  .post-card-body { padding: 16px; }
  .post-full { padding: 24px 20px; }
  .post-title { font-size: 22px; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .search-btn { min-height: 44px; padding: 10px 18px; }
  .search-input { min-height: 44px; }
  .page-link { height: 44px; min-width: 44px; }
}

.settings-avatar{display:flex;align-items:center;gap:16px;margin-bottom:20px}
.settings-avatar-preview img,.settings-avatar-placeholder{width:80px;height:80px;border-radius:50%;object-fit:cover}
.settings-avatar-placeholder{background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;font-size:32px;font-weight:700}

@media(max-width:640px){.profile-header{padding:20px}.post-card-meta{gap:6px}}