/* === Unified Article Styles — yche.me DataSystem === */
:root {
  --bg: #f0f2f5; --card: #fff; --text: #1a1a2e; --text2: #57606a;
  --border: #e0e4e8; --accent: #4a90d9;
  --d: #b45309; --d-bg: #fffbeb; --d-tag: #fef3c7;
  --p: #1d4ed8; --p-bg: #eff6ff; --p-tag: #dbeafe;
  --r: #be185d; --r-bg: #fdf2f8; --r-tag: #fce7f3;
  --s: #15803d; --s-bg: #f0fdf4; --s-tag: #dcfce7;
  --o: #7e22ce; --o-bg: #faf5ff; --o-tag: #f3e8ff;
  --code-bg: #0f172e; --code-fg: #e2e8f0;
  --red: #dc2626; --orange: #ea580c; --green: #16a34a;
}

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

body {
  font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.8;
  padding-top: 50px;  /* space for injected navbar */
  padding-bottom: 40px;
}

/* ===== INJECTED NAVBAR ===== */
.site-nav {
  position: fixed; top:0; left:0; right:0; z-index:1000;
  background: #fff; border-bottom: 1px solid var(--border);
  height: 50px; display: flex; align-items: center; padding: 0 24px; gap: 12px;
}
.site-nav .nav-home { font-size: 14px; font-weight: 700; color: var(--text); text-decoration: none; }
.site-nav .nav-home span { color: var(--accent); }
.site-nav .nav-spacer { flex: 1; }
.site-nav .nav-user { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 8px; }
.site-nav .nav-btn {
  font-size: 12px; padding: 4px 14px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--text2);
  font-family: inherit; transition: all .15s;
}
.site-nav .nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.site-nav .nav-btn.admin-link { border-color: var(--o); color: var(--o); }
.site-nav .nav-btn.admin-link:hover { background: var(--o-bg); }

/* ===== CONTENT CONTAINER ===== */
.content-area {
  max-width: 900px; margin: 0 auto; padding: 24px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; margin-top: 20px; margin-bottom: 20px;
}

/* ===== TYPOGRAPHY ===== */
.content-area h1 { font-size: 26px; font-weight: 700; color: var(--text); margin: 0 0 16px; line-height: 1.3; }
.content-area h2 { font-size: 20px; font-weight: 600; color: var(--text); margin: 32px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.content-area h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 24px 0 8px; }
.content-area h4 { font-size: 14px; font-weight: 600; color: #444; margin: 20px 0 6px; }
.content-area h5, .content-area h6 { font-size: 13px; font-weight: 600; color: #555; margin: 16px 0 4px; }
.content-area p { margin: 0 0 12px; font-size: 14px; }
.content-area a { color: var(--accent); text-decoration: none; }
.content-area a:hover { text-decoration: underline; }
.content-area strong { font-weight: 600; color: var(--text); }
.content-area ul, .content-area ol { margin: 0 0 16px 24px; font-size: 14px; }
.content-area li { margin-bottom: 4px; }
.content-area blockquote {
  border-left: 3px solid var(--accent); background: #f8fafc;
  padding: 10px 16px; margin: 16px 0; font-size: 13px; color: var(--text2);
  border-radius: 0 6px 6px 0;
}
.content-area hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ===== CODE ===== */
.content-area code {
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 13px; background: #f1f5f9; color: #b45309;
  padding: 1px 5px; border-radius: 3px;
}
.content-area pre {
  background: var(--code-bg); color: var(--code-fg);
  padding: 16px 20px; border-radius: 8px; overflow-x: auto;
  margin: 16px 0; font-size: 13px; line-height: 1.6;
}
.content-area pre code {
  background: transparent; color: inherit; padding: 0; border-radius: 0;
  font-size: inherit;
}

/* ===== TABLES ===== */
.content-area table {
  width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px;
}
.content-area th {
  background: #f8fafc; font-weight: 600; text-align: left;
  padding: 10px 14px; border-bottom: 2px solid var(--border); color: var(--text);
}
.content-area td {
  padding: 8px 14px; border-bottom: 1px solid var(--border); color: var(--text2);
}
.content-area tr:hover td { background: #fafbfc; }

/* ===== IMAGES & DIAGRAMS ===== */
.content-area img, .content-area svg {
  max-width: 100%; height: auto; display: block; margin: 16px auto;
  border-radius: 6px;
}

/* ===== Mermaid diagrams ===== */
.content-area .mermaid {
  text-align: center; margin: 16px 0; padding: 16px;
  background: #fafbfc; border-radius: 8px; border: 1px solid var(--border);
}

/* ===== STATUS / SEVERITY BADGES ===== */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* ===== RESTRICTED CONTENT GATE ===== */
.restricted-gate {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center;
}
.restricted-gate .gate-icon { font-size: 40px; margin-bottom: 16px; }
.restricted-gate .gate-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.restricted-gate .gate-desc { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
.restricted-gate .gate-form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.restricted-gate .gate-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; outline: none; min-width: 160px;
}
.restricted-gate .gate-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,144,217,.1); }
.restricted-gate .gate-submit {
  padding: 8px 20px; background: var(--accent); color: #fff;
  border: none; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.restricted-gate .gate-submit:hover { opacity: 0.9; }
.restricted-gate .gate-error { color: var(--red); font-size: 12px; margin-top: 8px; }

/* ===== COMMENT SECTION ===== */
.comments-section {
  max-width: 900px; margin: 0 auto; padding: 24px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; margin-top: 20px;
}
.comments-section .cm-title {
  font-size: 16px; font-weight: 600; color: var(--text);
  margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.comment-item {
  padding: 12px 0; border-bottom: 1px solid #f0f0f0;
}
.comment-item:last-child { border-bottom: none; }
.comment-item .cm-author {
  font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px;
}
.comment-item .cm-time {
  font-size: 11px; color: #bbb; margin-left: 8px; font-weight: 400;
}
.comment-item .cm-body {
  font-size: 13px; color: var(--text2); line-height: 1.6; white-space: pre-wrap;
  word-break: break-word;
}
.comment-item .cm-delete {
  font-size: 11px; color: #ccc; cursor: pointer; float: right; background: none; border: none;
  font-family: inherit; padding: 2px 6px; display: none;
}
.comment-item:hover .cm-delete { display: inline-block; }
.comment-item .cm-delete:hover { color: var(--red); }
.comments-section .cm-empty { text-align: center; color: #ccc; font-size: 13px; padding: 20px; }
.comments-section .cm-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.comments-section .cm-form-row { display: flex; gap: 10px; }
.comments-section .cm-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; outline: none; flex: 1;
}
.comments-section .cm-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,144,217,.1); }
.comments-section .cm-textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; outline: none; resize: vertical;
  min-height: 80px;
}
.comments-section .cm-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,144,217,.1); }
.comments-section .cm-submit {
  align-self: flex-end; padding: 8px 20px; background: var(--accent); color: #fff;
  border: none; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.comments-section .cm-submit:hover { opacity: 0.9; }
.comments-section .cm-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.comments-section .cm-error { color: var(--red); font-size: 12px; }

/* ===== LOGIN MODAL ===== */
.login-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center;
}
.login-modal {
  background: #fff; border-radius: 12px; padding: 32px; width: 360px; max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
}
.login-modal .lm-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.login-modal .lm-field { margin-bottom: 14px; }
.login-modal .lm-field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.login-modal .lm-field input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; outline: none;
}
.login-modal .lm-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,144,217,.1); }
.login-modal .lm-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.login-modal .lm-error { color: var(--red); font-size: 12px; margin-top: 8px; }

/* ===== RESPONSIVE ===== */
@media(max-width:800px) {
  .content-area { margin: 10px; padding: 16px; border-radius: 6px; }
  .content-area h1 { font-size: 20px; }
  .content-area h2 { font-size: 17px; }
  .content-area pre { padding: 12px; font-size: 12px; }
  .comments-section { margin: 10px; padding: 16px; }
  .comments-section .cm-form-row { flex-direction: column; }
  .site-nav { padding: 0 12px; }
}

@media print {
  .site-nav, .comments-section, .restricted-gate { display: none !important; }
  body { padding-top: 0; }
  .content-area { box-shadow: none; border: none; max-width: 100%; }
}
