/* =========================================================
   iouu.cc · 管理后台样式
   复用首页的设计令牌（style.css 已先加载）
   ========================================================= */

body.admin {
  display: block;
  min-height: 100vh;
}

.admin-theme-toggle {
  position: fixed;
  top: 14px;
  right: 28px;
  z-index: 25;
}

/* ---------- 登录门 ---------- */
.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 66px 24px 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 36px 32px 30px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -.02em;
}

.login-card p {
  margin: 0 0 26px;
  font-size: 13.5px;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}

.field > label,
.field-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 14px;
  outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.field textarea { height: auto; padding: 10px 14px; resize: vertical; min-height: 64px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
    background-color .18s var(--ease), border-color .18s var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--danger { color: #d33b3b; border-color: color-mix(in srgb, #d33b3b 32%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, #d33b3b 8%, transparent); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12.5px; }

.form-error {
  display: none;
  margin: -4px 0 14px;
  font-size: 13px;
  color: #d33b3b;
}
.form-error.is-visible { display: block; }

/* ---------- 后台框架 ---------- */
.admin-shell { display: none; }
.admin-shell.is-visible { display: block; }

.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 69px;
  padding: 14px 82px 14px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.admin-brand .badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent);
  background: var(--accent-soft);
}

.admin-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.admin-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px 28px 60px;
  align-items: start;
}

@media (max-width: 980px) {
  .admin-body { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 面板 ---------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel + .panel { margin-top: 20px; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.panel-head .count {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg-sub);
  padding: 2px 8px;
  border-radius: 999px;
}

.panel-head .panel-actions { margin-left: auto; display: flex; gap: 8px; }

.panel-body { padding: 18px 20px 22px; }

.hint {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}
.hint code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-sub);
}

/* ---------- 卡片编辑器列表 ---------- */
.card-list { display: flex; flex-direction: column; gap: 12px; }

.card-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
  overflow: hidden;
}

.card-editor.is-dragging { opacity: .45; }

.card-editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg-elev) 70%, transparent);
  border-bottom: 1px solid var(--line);
}

.drag-handle {
  cursor: grab;
  color: var(--faint);
  font-size: 15px;
  line-height: 1;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }

.card-editor-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-editor-title .status {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .06em;
}
.status--live { color: #0f9d6e; background: color-mix(in srgb, #0f9d6e 12%, transparent); }
.status--pending { color: var(--muted); background: var(--bg-sub); }

.card-editor-head .spacer { flex: 1; }

.card-editor-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  padding: 14px;
}
.card-editor-body .field { margin: 0; }
.card-editor-body .field--wide { grid-column: 1 / -1; }
.card-editor-body input[type="color"] { padding: 3px; cursor: pointer; }

.sub-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.sub-row input { min-width: 0; height: 36px; font-size: 13px; }
.sub-row .btn { height: 36px; }

.thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  font-size: 17px;
  background: var(--bg-sub);
}

/* ---------- 右侧预览 ---------- */
.preview-wrap { position: sticky; top: 82px; }

.preview-frame {
  width: 100%;
  height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.preview-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 对话框 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 14, 24, .45);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }

.modal-card {
  width: min(560px, 100%);
  max-height: 80vh;
  overflow: auto;
  padding: 22px;
  background: var(--bg-elev);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.modal-card h3 { margin: 0 0 12px; font-size: 16px; }

.code-box {
  width: 100%;
  min-height: 200px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.admin-editor { min-width: 0; }
.admin-editor > .panel { margin-top: 0; }

.editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}
.editor-tab {
  flex: 1 1 90px;
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.editor-tab:hover,
.editor-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }

.info-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
#infoIconFile { height: auto; min-height: 44px; padding: 8px; }
.icon-feedback { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 14px; }
#iconStatus { overflow-wrap: anywhere; }

.editor-section-title { margin: 0 0 8px; font-size: 15px; }
.article-library { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.article-picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.article-picker select {
  flex: 1 1 170px;
  min-width: 0;
  padding: 6px 10px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.article-list { margin: 12px 0; padding: 0; list-style: none; }
.article-list li { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.article-label { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.article-label small { display: block; color: var(--muted); }
#articleForm { margin-top: 16px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }

@media (max-width: 650px) {
  .admin-theme-toggle { right: 16px; }
  .admin-header { position: static; flex-wrap: wrap; padding-inline: 16px 70px; }
  .admin-actions { margin-left: 0; }
  .admin-body { padding-inline: 12px; }
  .preview-wrap { position: static; }
  .panel-head, .card-editor-head { flex-wrap: wrap; }
  .sub-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .info-fields { grid-template-columns: minmax(0, 1fr); }
}
