/* hifermin-admin white theme */
:root {
  --hw-bg: #ffffff;
  --hw-surface: #f7f7f8;
  --hw-text: #1f2328;
  --hw-muted: #6b7280;
  --hw-accent: #ad6a3e;
  --hw-accent-hover: #95592f;
  --hw-border: #e5e7eb;
  --hw-border-strong: #d1d5db;
  --hw-error-bg: #fef2f2;
  --hw-error-fg: #b91c1c;
  --hw-error-border: #fecaca;
  --hw-warn-bg: #fffbeb;
  --hw-warn-fg: #92400e;
  --hw-warn-border: #fde68a;
  --hw-success-bg: #ecfdf5;
  --hw-success-fg: #047857;
  --hw-success-border: #a7f3d0;
  --hw-danger-bg: #fee2e2;
  --hw-danger-fg: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif;
  background: var(--hw-bg);
  color: var(--hw-text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--hw-accent); text-decoration: none; }
a:hover { color: var(--hw-accent-hover); text-decoration: underline; }
.muted { color: var(--hw-muted); }
.small { font-size: 0.85em; }
code { background: var(--hw-surface); padding: 1px 6px; border-radius: 3px; font-size: 0.9em; }

/* Auth page */
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--hw-surface);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: #fff;
  border: 1px solid var(--hw-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.auth-card h1 { margin: 0 0 8px; font-size: 1.4em; color: var(--hw-text); }
.auth-card label {
  display: block;
  margin: 14px 0 4px;
  font-size: 0.9em;
  color: var(--hw-text);
}
.auth-card input {
  width: 100%;
  padding: 9px 11px;
  background: #fff;
  color: var(--hw-text);
  border: 1px solid var(--hw-border-strong);
  border-radius: 4px;
  font: inherit;
}
.auth-card input:focus { outline: 2px solid var(--hw-accent); outline-offset: -2px; border-color: var(--hw-accent); }
.auth-card button {
  margin-top: 18px;
  width: 100%;
  padding: 10px;
  background: var(--hw-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1em;
}
.auth-card button:hover { background: var(--hw-accent-hover); }

/* Admin header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--hw-border);
  background: #fff;
}
.admin-header h1 { margin: 0; font-size: 1.15em; }
.admin-header h1 a { color: var(--hw-text); }
.admin-header nav { display: flex; align-items: center; gap: 18px; }
.admin-header nav a, .admin-header nav span { color: var(--hw-text); }

/* Admin main */
.admin-main { padding: 28px; max-width: 1280px; margin: 0 auto; }
.admin-main h2 { margin: 28px 0 12px; font-size: 1.05em; color: var(--hw-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.published-collapsible { margin: 0; }
.published-collapsible summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.published-collapsible summary::-webkit-details-marker { display: none; }
.published-collapsible summary::before {
  content: "▶";
  font-size: 0.7em;
  color: var(--hw-muted);
  transition: transform 0.15s ease;
}
.published-collapsible[open] summary::before { transform: rotate(90deg); }
.published-collapsible summary:hover { color: var(--hw-text); }

/* Tables */
.article-table { width: 100%; border-collapse: collapse; margin: 12px 0 32px; background: #fff; border: 1px solid var(--hw-border); border-radius: 6px; overflow: hidden; }
.article-table th, .article-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--hw-border); }
.article-table th { background: var(--hw-surface); color: var(--hw-muted); font-weight: 600; font-size: 0.85em; }
.article-table tr:last-child td { border-bottom: 0; }
.article-table tr:hover td { background: var(--hw-surface); }
.article-table form { display: inline; }
.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--hw-accent);
  font: inherit;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.danger-link { color: #b42318; }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 16px 0 32px;
  padding: 12px;
  font-size: 0.9em;
}
.pagination a, .pagination span {
  padding: 6px 14px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--hw-text);
}
.pagination a {
  background: #fff;
  border: 1px solid var(--hw-border-strong);
}
.pagination a:hover {
  background: var(--hw-surface);
  border-color: var(--hw-accent);
  color: var(--hw-accent);
}
.pagination .current {
  background: var(--hw-accent);
  color: #fff;
  font-weight: 600;
}
.pagination .disabled {
  color: var(--hw-muted);
  border: 1px dashed var(--hw-border-strong);
}
.article-form { max-width: none; }
.article-form > label { display: block; margin: 14px 0; }
.article-form > label > span.lbl { display: block; color: var(--hw-muted); font-size: 0.85em; margin-bottom: 5px; }
.article-form input, .article-form select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px;
  background: #fff;
  color: var(--hw-text);
  border: 1px solid var(--hw-border-strong);
  border-radius: 4px;
  font: inherit;
}
.article-form input:focus, .article-form select:focus { outline: 2px solid var(--hw-accent); outline-offset: -2px; border-color: var(--hw-accent); }
.article-form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px;
  background: #fff;
  color: var(--hw-text);
  border: 1px solid var(--hw-border-strong);
  border-radius: 4px;
  font: inherit;
  resize: vertical;
}
.form-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.form-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-grid label { margin: 0; }

.score-grid {
  border: 1px solid var(--hw-border-strong);
  border-radius: 6px;
  padding: 16px;
  margin: 14px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.score-grid legend {
  padding: 0 8px;
  color: var(--hw-muted);
  font-size: 0.85em;
}
.score-grid label { margin: 0; }
.score-grid .score-name {
  display: block;
  color: var(--hw-muted);
  font-size: 0.85em;
  margin-bottom: 4px;
}
.score-grid input { width: 100%; }
@media (max-width: 768px) {
  .score-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .score-grid { grid-template-columns: 1fr; }
}

/* Form actions */
.form-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.form-actions button { padding: 10px 18px; border: 0; border-radius: 4px; background: var(--hw-accent); color: #fff; cursor: pointer; font: inherit; font-weight: 600; }
.form-actions button:hover { background: var(--hw-accent-hover); }
.form-actions .secondary { background: #fff; color: var(--hw-text); border: 1px solid var(--hw-border-strong); }
.form-actions .secondary:hover { background: var(--hw-surface); }
.form-actions .publish { background: #047857; color: #fff; }
.form-actions .publish:hover { background: #065f46; }
.form-actions .danger { background: #fff; color: var(--hw-danger-fg); border: 1px solid var(--hw-error-border); }
.form-actions .danger:hover { background: var(--hw-error-bg); }
.form-actions button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Alerts */
.alert { padding: 12px 14px; margin: 14px 0; border-radius: 4px; font-size: 0.92em; border: 1px solid; }
.alert-error { background: var(--hw-error-bg); color: var(--hw-error-fg); border-color: var(--hw-error-border); }
.alert-warn  { background: var(--hw-warn-bg); color: var(--hw-warn-fg); border-color: var(--hw-warn-border); }
.alert-success { background: var(--hw-success-bg); color: var(--hw-success-fg); border-color: var(--hw-success-border); }
.alert ul { margin: 8px 0 0; padding-left: 22px; }

/* Preview */
.preview-content { max-width: 900px; }
.preview-content article { line-height: 1.8; }
.preview-content article img { max-width: 100%; height: auto; }
.preview-content article video { max-width: 100%; }

/* Editor override (TOAST UI) */
.toastui-editor-default-container, .toastui-editor { background: #fff !important; color: var(--hw-text) !important; }
.toastui-editor-md-container, .toastui-editor-ww-container { background: #fff !important; }

/* Mobile */
@media (max-width: 768px) {
  .auth-page { background: var(--hw-bg); }
  .auth-card { max-width: 92vw; padding: 24px 18px; }
  .admin-header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 18px; }
  .admin-header h1 { font-size: 1.05em; }
  .admin-header nav { display: flex; flex-wrap: wrap; gap: 10px 14px; width: 100%; }
  .admin-header nav a, .admin-header nav span { margin-left: 0; font-size: 0.95em; }
  .admin-main { padding: 16px; }
  /* 表格改为卡片：每行一个 tr，div.playing card display */
  .article-table, .article-table thead, .article-table tbody, .article-table tr, .article-table td, .article-table th { display: block; }
  .article-table { border: 0; }
  .article-table form { display: inline; }
  .link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--hw-accent);
    font: inherit;
    cursor: pointer;
  }
  .link-button:hover { text-decoration: underline; }
  .danger-link { color: #b42318; }
  .article-table tr {
    background: #fff;
    border: 1px solid var(--hw-border);
    border-radius: 6px;
    margin-bottom: 12px;
    padding: 10px 12px;
  }
  .article-table td {
    border: 0;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .article-table td:last-child { padding-top: 8px; justify-content: flex-end; }
  .article-table td code { font-size: 0.82em; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .article-table form { width: 100%; display: flex; }
  .article-table form button { width: 100%; }
  .article-form { max-width: none; }
  .article-form label { margin: 12px 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions button { width: 100%; flex: 1 1 100%; }
  .pagination { flex-wrap: wrap; gap: 8px; }
  .pagination a, .pagination span { padding: 6px 10px; font-size: 0.85em; }
}
