* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  background: #f5f6fa;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  background: #1f2a44;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.topbar .brand a { color: #fff; font-weight: 700; font-size: 17px; }
.topbar nav { margin-left: 32px; flex: 1; }
.topbar nav a {
  color: #cbd5e1;
  margin-right: 20px;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.topbar nav a.active, .topbar nav a:hover { color: #fff; border-color: #60a5fa; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 14px; }
.userbox .user { color: #e2e8f0; font-size: 13px; }
.userbox .link { color: #cbd5e1; font-size: 13px; }

.container { max-width: 1200px; margin: 24px auto; padding: 0 24px 64px; }

h1 { font-size: 22px; margin: 12px 0 18px; }
h3 { margin-top: 0; }

.muted { color: #6b7280; }
.small { font-size: 12px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace; font-size: 12px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.page-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.search input { padding: 8px 11px; border: 1px solid #d1d5db; border-radius: 6px; width: 280px; font-size: 13px; }
.search { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid #d1d5db;
  background: #fff; color: #1f2937; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost-danger { background: #fff; border-color: #fecaca; color: #b91c1c; }
.btn-ghost-danger:hover { background: #fef2f2; }
.btn-link { background: transparent; border: none; color: #2563eb; padding: 4px 8px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { display: block; width: 100%; text-align: center; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
.table th { background: #f9fafb; font-weight: 600; font-size: 12px; text-transform: uppercase; color: #6b7280; white-space: nowrap; }
.table tbody tr:hover { background: #fafbff; }
.table td.actions { white-space: nowrap; }
.table td.actions .btn { margin-right: 4px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; background: #e0e7ff; color: #3730a3; font-size: 11px; font-weight: 600; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-pin { background: #fee2e2; color: #b91c1c; }
.article-card-pinned { border-left: 4px solid #ef4444; background: #fff7f7; }
.article-detail-pinned { border-left: 4px solid #ef4444; padding-left: 14px; }
.btn-pin { padding: 0; font-size: 12px; }

.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; text-align: left; vertical-align: top; }
.kv th { width: 180px; color: #6b7280; font-weight: 500; }

.card { background: #fff; border-radius: 8px; padding: 18px; margin-top: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

.pagination { margin-top: 20px; display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a { padding: 6px 11px; border: 1px solid #d1d5db; border-radius: 5px; background: #fff; color: #2563eb; font-size: 13px; }
.pagination a.active { background: #2563eb; color: #fff; border-color: #2563eb; }

.login-card {
  max-width: 380px; margin: 80px auto; background: #fff; border-radius: 10px; padding: 32px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.login-card h1 { text-align: center; margin: 0 0 6px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.login-card label { font-size: 12px; color: #6b7280; margin-top: 8px; }
.login-card input { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.login-card .btn { margin-top: 18px; padding: 11px; }

.form-card { background: #fff; padding: 24px 26px; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); max-width: 1000px; }
.form-card .field { margin-top: 14px; }
.form-card label { display: block; margin: 0 0 6px; font-weight: 600; font-size: 13px; color: #374151; }
.form-card label .req { color: #dc2626; }
.form-card label .counter { float: right; font-weight: 400; color: #9ca3af; font-size: 11px; }
.form-card label .counter.warn { color: #b45309; }
.form-card label .counter.over { color: #b91c1c; font-weight: 600; }
.form-card .hint { font-size: 12px; color: #6b7280; margin: 4px 0 0; }
.form-card input[type=text], .form-card input[type=password], .form-card textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-card input:focus, .form-card textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-card textarea { resize: vertical; min-height: 100px; }
.form-card .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-card .checkbox { display: flex; align-items: center; gap: 8px; margin-top: 18px; cursor: pointer; }
.form-card .checkbox input { width: 18px; height: 18px; }
.form-card .actions {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid #f3f4f6;
  display: flex; gap: 10px; align-items: center;
}
.form-card .actions .spacer { flex: 1; }

.article-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.article-card {
  background: #fff; padding: 16px 18px; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex; gap: 14px; align-items: flex-start;
}
.article-card .article-body { flex: 1; min-width: 0; }
.article-card .article-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.article-card h3 { margin: 0 0 6px; word-break: break-word; }
.article-card .meta { margin-bottom: 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { background: #eef2ff; color: #3730a3; padding: 2px 8px; border-radius: 4px; font-size: 12px; }

.article-detail { background: #fff; padding: 28px; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); max-width: 900px; }
.article-detail h1 { margin-top: 0; word-break: break-word; }
.article-detail .meta { font-size: 13px; margin: 4px 0 12px; }
.article-detail .summary { padding: 12px 14px; background: #f9fafb; border-left: 3px solid #2563eb; border-radius: 4px; margin: 14px 0; }
.article-detail .content {
  white-space: pre-wrap;
  font-family: 'Cambria','Times New Roman',serif;
  font-size: 16px;
  line-height: 1.75;
  color: #111827;
  word-break: break-word;
}

.footer { text-align: center; padding: 18px; color: #9ca3af; font-size: 12px; }

/* Confirm modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  animation: fadeIn .15s ease;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; max-width: 440px; width: 100%;
  padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: pop .18s ease;
}
.modal h3 { margin: 0 0 8px; color: #b91c1c; font-size: 17px; }
.modal p { margin: 0 0 6px; color: #374151; }
.modal .modal-target { display: block; background: #f9fafb; padding: 8px 10px; border-radius: 6px; margin: 10px 0 16px; font-weight: 600; color: #111827; word-break: break-word; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.95); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* Mobile */
@media (max-width: 768px) {
  body { font-size: 14px; }
  .container { padding: 0 12px 56px; margin: 14px auto; }

  .topbar { padding: 8px 12px; height: auto; flex-wrap: wrap; gap: 8px; }
  .topbar .brand a { font-size: 15px; }
  .topbar nav { margin-left: 0; order: 3; width: 100%; padding-top: 4px; border-top: 1px solid #2d3a55; }
  .topbar nav a { margin-right: 14px; font-size: 13px; padding: 4px 0; }
  .userbox { margin-left: auto; gap: 8px; }
  .userbox .user { display: none; }
  .userbox .link { font-size: 12px; }

  h1 { font-size: 18px; }

  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .search { width: 100%; }
  .search input { width: 100%; flex: 1; }
  .page-actions .btn-primary { text-align: center; }

  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 10px; }

  .form-card { padding: 16px; border-radius: 8px; }
  .form-card .row { grid-template-columns: 1fr; gap: 0; }
  .form-card textarea { font-size: 15px !important; }
  .form-card .actions {
    position: sticky; bottom: 0; background: #fff;
    margin: 22px -16px 0; padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 12px rgba(0,0,0,.04);
    flex-direction: row-reverse;
  }
  .form-card .actions .btn-primary { flex: 1; padding: 11px; }
  .form-card .actions .btn-link { padding: 11px 14px; }

  .article-detail { padding: 18px; }
  .article-detail .content { font-size: 15px; line-height: 1.75; }

  .article-card { flex-direction: column; gap: 10px; padding: 14px; }
  .article-card .article-actions { flex-direction: row; width: 100%; }
  .article-card .article-actions .btn { flex: 1; }

  .login-card { margin: 30px 12px; padding: 24px 22px; }

  .kv th { width: 110px; font-size: 12px; }
  .kv td { font-size: 12px; }

  .btn { padding: 9px 14px; }
  .btn-sm { padding: 6px 11px; }

  .modal { padding: 18px 18px; }
  .modal .modal-actions { flex-direction: column-reverse; }
  .modal .modal-actions .btn { width: 100%; text-align: center; }
}

@media (max-width: 420px) {
  .topbar .brand a { font-size: 14px; }
  .userbox .link { display: none; }
}
