:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: #e6e8eb;
  --text: #1f2328;
  --text-2: #5b626b;
  --text-3: #9aa0a6;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 12px 40px rgba(79,70,229,.18);
  --radius: 12px;
  --sidebar-w: 260px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); -webkit-font-smoothing: antialiased; line-height: 1.7; display: flex; flex-direction: column; min-height: 100vh; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; background: linear-gradient(135deg,#6366f1,#ec4899); flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* LOGIN */
.login-bg { flex: 1; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #ec4899 100%); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; padding: 40px 34px; box-shadow: var(--shadow-lg); }
.login-card .logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 18px; background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; }
.login-card h1 { text-align: center; font-size: 22px; }
.login-card .sub { text-align: center; color: var(--text-3); font-size: 13px; margin: 6px 0 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; transition: border-color .15s; }
.field input:focus { border-color: var(--primary); }
.login-btn { width: 100%; padding: 13px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 700; font-size: 15px; margin-top: 6px; transition: filter .15s; }
.login-btn:hover { filter: brightness(1.07); }
.login-tip { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 16px; }
.login-err { text-align: center; font-size: 13px; color: #ef4444; margin-top: 12px; }

/* APP SHELL */
.site-header { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 28px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.site-nav { display: flex; gap: 6px; margin-left: 12px; }
.site-nav a { padding: 8px 14px; border-radius: 8px; font-size: 14px; color: var(--text-2); }
.site-nav a:hover, .site-nav a.active { background: var(--surface-2); color: var(--text); }
.spacer { flex: 1; }
.write-btn { background: var(--primary); color: #fff; padding: 9px 18px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.write-btn:hover { filter: brightness(1.07); }
.avatar-btn { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px; border-radius: 30px; }
.avatar-btn:hover { background: var(--surface-2); }
.menu-drop { position: absolute; top: 56px; right: 24px; z-index: 40; width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 8px; }
.menu-drop .mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 9px; font-size: 14px; color: var(--text); text-align: left; }
.menu-drop .mi:hover { background: var(--surface-2); }
.menu-drop .mi.danger { color: #ef4444; }
.menu-drop .sep { height: 1px; background: var(--border); margin: 6px 4px; }

.layout { display: flex; align-items: flex-start; max-width: 1200px; width: 100%; margin: 0 auto; padding: 0 28px; flex: 1; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); flex-shrink: 0; padding: 22px 14px 40px 0; position: sticky; top: 62px; align-self: flex-start; max-height: calc(100vh - 62px); overflow-y: auto; }
.user-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: linear-gradient(135deg, #eef0ff, #fce7f3); margin-bottom: 20px; }
.user-card .avatar { width: 44px; height: 44px; font-size: 17px; }
.user-card .uname { font-weight: 700; font-size: 15px; }
.side-title { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 0 12px 10px; }
.cat { margin-bottom: 4px; }
.cat-head { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px 12px; border-radius: 9px; color: var(--text); font-size: 14px; font-weight: 600; }
.cat-head:hover { background: var(--surface-2); }
.cat-head .arrow { margin-left: auto; font-size: 11px; color: var(--text-3); transition: transform .18s; }
.cat.open .cat-head .arrow { transform: rotate(90deg); }
.cat-head .dot { width: 9px; height: 9px; border-radius: 50%; }

.main { flex: 1; min-width: 0; padding: 22px 0 60px 30px; border-left: 1px solid var(--border); }

/* HOME */
.blog-home { display: grid; grid-template-columns: 1fr 300px; gap: 30px; align-items: start; }
.posts h2.sec { font-size: 17px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--primary); display: inline-block; }
.post-card { border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.post-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.08); }
.pc-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.pc-meta .tag { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.post-card h3 { font-size: 18px; margin-bottom: 6px; }
.post-card p { font-size: 14px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.widgets { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 18px; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.widget h3 { font-size: 14px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.widget h3::before { content: ""; width: 4px; height: 14px; background: var(--primary); border-radius: 2px; display: inline-block; }
.about-card { background: linear-gradient(135deg, #eef0ff, #e0f2fe); }
.about-card .a-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.about-card .avatar { width: 48px; height: 48px; font-size: 18px; }
.about-card .a-name { font-weight: 700; }
.about-card .a-bio { font-size: 13px; color: var(--text-2); }
.stats { display: flex; justify-content: space-around; text-align: center; }
.stats .num { font-size: 22px; font-weight: 800; color: var(--primary); }
.stats .lbl { font-size: 12px; color: var(--text-3); }
.cat-list-w { display: flex; flex-direction: column; gap: 2px; }
.cat-list-w button { display: flex; justify-content: space-between; padding: 7px 8px; border-radius: 8px; font-size: 13.5px; color: var(--text-2); text-align: left; }
.cat-list-w button:hover { background: var(--surface-2); color: var(--text); }
.cat-list-w .cnt { color: var(--text-3); font-size: 12px; }

/* Note detail */
.reading { max-width: 720px; margin: 0 auto; }
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 14px; }
.breadcrumb a:hover { color: var(--primary); }
.post-meta { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; margin: 14px 0 24px; }
.tag { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.post-body { font-size: 16px; color: #2b3138; }
.post-body p { margin-bottom: 16px; }
.post-body h1 { font-size: 26px; margin: 14px 0 10px; }
.post-body h2 { font-size: 21px; margin: 14px 0 8px; }
.post-body h3 { font-size: 18px; margin: 12px 0 6px; }
.post-body code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.post-body pre { position: relative; background: #1e293b; color: #e2e8f0; padding: 14px 16px; border-radius: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.6; overflow: auto; margin: 14px 0; }
.post-body pre code { font-family: inherit; background: none; padding: 0; color: inherit; }
.copy-btn { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.12); color: #e2e8f0; border: 1px solid rgba(255,255,255,.22); border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.copy-btn:hover { background: rgba(255,255,255,.24); }
.post-actions { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.btn-ghost { border: 1px solid var(--border); color: var(--text-2); padding: 8px 16px; border-radius: 9px; font-size: 14px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); color: #fff; padding: 10px 22px; border-radius: 9px; font-weight: 600; }

/* Profile */
.profile-wrap { max-width: 560px; margin: 0 auto; }
.profile-head { display: flex; align-items: center; gap: 22px; padding: 24px; border-radius: 16px; background: linear-gradient(135deg,#eef0ff,#e0f2fe); margin-bottom: 24px; }
.avatar-lg { width: 76px; height: 76px; font-size: 28px; }
.avatar-upload { position: relative; cursor: pointer; }
.avatar-upload .upload-btn { position: absolute; bottom: -6px; right: -6px; background: var(--primary); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 20px; border: 2px solid #fff; }
.avatar-upload input { display: none; }
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.form-row input, .form-row textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; font-family: inherit; }
.form-row input:focus, .form-row textarea:focus { border-color: var(--primary); }
.bg-upload { display: flex; gap: 14px; align-items: center; }
.bg-preview { width: 104px; height: 64px; border-radius: 10px; border: 1px solid var(--border); background-size: cover; background-position: center; color: var(--text-3); font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bg-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bg-btn { border: 1px solid var(--border); border-radius: 9px; padding: 8px 14px; font-size: 13px; color: var(--text-2); cursor: pointer; position: relative; overflow: hidden; }
.bg-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Favorites */
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 14px; }
.fav-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: var(--surface); box-shadow: var(--shadow); transition: transform .12s; }
.fav-card:hover { transform: translateY(-2px); }
.fav-card .fav-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.fav-icon { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg,#6366f1,#8b5cf6); color:#fff; display:flex; align-items:center; justify-content:center; font-size:16px; }
.fav-card h3 { font-size: 15px; }
.fav-card .url { font-size: 12px; color: var(--text-3); word-break: break-all; margin-bottom: 10px; }
.fav-card .fav-actions { display: flex; gap: 8px; }
.fav-card .visit { background: var(--primary-soft); color: var(--primary); padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.fav-card .del { color: var(--text-3); padding: 6px 10px; font-size: 13px; }
.fav-add { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.fav-add input { flex: 1; min-width: 180px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; }
.fav-add input:focus { border-color: var(--primary); }

/* Editor */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-bottom: none; border-radius: 12px 12px 0 0; background: var(--surface-2); }
.editor-toolbar select { border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; font-size: 13px; background: var(--surface); color: var(--text); }
.editor-toolbar button { min-width: 34px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); font-size: 14px; color: var(--text); }
.editor-toolbar button:hover { background: var(--primary-soft); color: var(--primary); }
.editor-toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.editor-area { border: 1px solid var(--border); border-radius: 0 0 12px 12px; padding: 18px 20px; min-height: 420px; outline: none; font-size: 15px; line-height: 1.8; background: var(--surface); }
.editor-area:empty:before { content: attr(data-placeholder); color: var(--text-3); }
.editor-area h1 { font-size: 26px; margin: 12px 0 8px; }
.editor-area h2 { font-size: 21px; margin: 14px 0 8px; }
.editor-area h3 { font-size: 18px; margin: 12px 0 6px; }
.editor-area code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.editor-area pre.code-block { position: relative; background: #1e293b; color: #e2e8f0; padding: 14px 16px; border-radius: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.6; overflow: auto; margin: 14px 0; }
.editor-area pre.code-block code { font-family: inherit; background: none; padding: 0; color: inherit; }

/* Plans */
.plans-wrap { max-width: 860px; margin: 0 auto; }
.plan-new { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.plan-new input { flex: 1; min-width: 220px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; }
.plan-new input:focus { border-color: var(--primary); }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.plan-card { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--surface); box-shadow: var(--shadow); }
.plan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.plan-head h3 { font-size: 16px; }
.plan-del { color: var(--text-3); font-size: 13px; }
.plan-del:hover { color: #ef4444; }
.progress { height: 8px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 20px; transition: width .3s; }
.progress-meta { font-size: 12px; color: var(--text-3); margin: 6px 0 12px; }
.plan-parts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.plan-part { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.plan-part input { width: 16px; height: 16px; accent-color: var(--primary); }
.plan-part .done { color: var(--text-3); text-decoration: line-through; }
.plan-empty { font-size: 13px; color: var(--text-3); }
.plan-addpart { display: flex; gap: 8px; }
.plan-addpart input { flex: 1; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; }
.plan-addpart button { width: 38px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 18px; color: var(--primary); }
.empty-hint { color: var(--text-3); font-size: 14px; padding: 30px 0; text-align: center; }

/* Markdown import modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(31,35,40,.45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px; padding: 26px 28px; box-shadow: var(--shadow-lg); }
.modal h3 { font-size: 18px; margin-bottom: 6px; }
.modal .modal-sub { font-size: 13px; color: var(--text-3); margin-bottom: 16px; line-height: 1.6; }
.modal textarea { width: 100%; min-height: 240px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.7; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; outline: none; resize: vertical; color: var(--text); }
.modal textarea:focus { border-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #1f2328; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; opacity: 0; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }

@media (max-width: 980px) {
  .blog-home { grid-template-columns: 1fr; }
  .widgets { position: static; flex-direction: row; flex-wrap: wrap; }
  .widgets .widget { flex: 1 1 240px; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; max-height: none; border-bottom: 1px solid var(--border); padding: 18px 0; }
  .main { border-left: none; padding: 22px 0 50px; }
}
