:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --border: #e3e8f0;
  --border-strong: #d2dae6;
  --text: #1a2433;
  --text-soft: #5b6b80;
  --text-faint: #8795a8;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eaf1fe;
  --accent-border: #c9dafb;
  --danger: #dc2626;
  --danger-soft: #fdf0f0;
  --star: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(20, 32, 54, 0.05);
  --shadow-md: 0 14px 34px -14px rgba(20, 32, 54, 0.22);
  --radius: 13px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
mark {
  background: #fde68a;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
::selection { background: rgba(37, 99, 235, 0.2); }
:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 11px 28px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  border-radius: 10px;
  padding: 2px 6px 2px 2px;
  outline: none;
}
.brand:hover .brand-mark { transform: rotate(-6deg); }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  box-shadow: 0 8px 18px -8px rgba(37, 99, 235, 0.8);
  transition: transform 0.25s ease;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: 0.3px; line-height: 1.3; }
.brand p { margin: 0; font-size: 11.5px; color: var(--text-faint); letter-spacing: 0.4px; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  height: 40px;
  width: min(340px, 30vw);
  margin-left: auto;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.searchbox .icon { color: var(--text-faint); width: 17px; height: 17px; }
.searchbox:focus-within {
  border-color: var(--accent-border);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.searchbox input {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  padding: 0;
}
.searchbox input::-webkit-search-cancel-button { cursor: pointer; }
.searchbox kbd {
  font-family: inherit;
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  background: #fff;
  line-height: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 16px -10px rgba(37, 99, 235, 0.9);
}
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn.ghost { border-color: var(--border); background: var(--surface); color: var(--text-soft); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-soft); color: var(--text); border-color: var(--border-strong); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b91c1c; }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover:not(:disabled) { background: var(--danger-soft); border-color: #f5caca; color: #b91c1c; }
.btn.dashed {
  width: 100%;
  height: 46px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  color: var(--text-soft);
  background: transparent;
}
.btn.dashed:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.btn .icon { width: 16px; height: 16px; }
.star-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.star-btn:hover { background: #f4f6fa; color: var(--star); transform: scale(1.08); }
.star-btn.active { color: var(--star); }
.star-btn.active svg { fill: currentColor; }
.star-btn svg { width: 18px; height: 18px; }
.icon-btn {
  width: 30px;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  color: var(--text-faint);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn:hover:not(:disabled) { background: #fff; border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); border-color: #f3c7c7; background: #fff5f5; }
.icon-btn .icon { width: 16px; height: 16px; }

/* ---------- Layout / sidebar ---------- */
.layout {
  max-width: 1340px;
  margin: 0 auto;
  padding: 24px 28px 70px;
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 82px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 2px;
}
.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-soft);
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  text-align: left;
  font-size: 13.5px;
  min-width: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-item:hover { background: #eceff6; color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
  font-weight: 600;
}
.nav-item > .icon { color: var(--text-faint); width: 16px; height: 16px; }
.nav-item.active > .icon { color: var(--accent); }
.nav-item .nav-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 500;
  background: #edf0f5;
  color: var(--text-soft);
  padding: 0 7px;
  border-radius: 20px;
  min-width: 23px;
  text-align: center;
  line-height: 19px;
}
.nav-item.active .nav-count { background: #fff; color: var(--accent); }
.sidebar-empty { padding: 8px 12px; font-size: 12.5px; color: var(--text-faint); }
.sidebar-footer {
  margin-top: 16px;
  padding: 14px 12px 0;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.9;
}
.sidebar-footer strong { color: var(--text-soft); }

/* ---------- List / cards ---------- */
.content { min-width: 0; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  min-height: 38px;
}
.result-info { font-size: 13px; color: var(--text-soft); }
.result-info strong { color: var(--text); font-weight: 600; }
.sort {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--text-soft);
  outline: none;
  cursor: pointer;
}
.sort:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08); }
.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 15px;
}
.record-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.record-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd6e7;
}
.card-top { display: flex; align-items: center; gap: 8px; }
.cat-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 1px 8px;
  border-radius: 20px;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.private-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #92400e;
  background: #fffaeb;
  border: 1px solid #f6dfa9;
  border-radius: 20px;
  padding: 0 7px;
  line-height: 19px;
  white-space: nowrap;
}
.private-chip .icon { width: 11px; height: 11px; }
.record-card h3 {
  margin: 1px 0 0;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0.1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.device-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-faint);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-line .icon { width: 14px; height: 14px; flex: none; }
.symptoms {
  font-size: 13px;
  color: var(--text-soft);
  margin: 1px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
}
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 1px; }
.tag {
  font-size: 11px;
  color: var(--text-soft);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 7px;
  line-height: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tag:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.card-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 11.5px;
  color: var(--text-faint);
  border-top: 1px dashed var(--border);
  padding-top: 9px;
  margin-top: auto;
}
.creator-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
}
.creator-link:hover { text-decoration: underline; }
.creator-link:focus-visible { outline: 2px solid var(--accent-border); outline-offset: 2px; }
.restricted-card { background: linear-gradient(180deg, #fffdf8, var(--surface)); }
.restricted-hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 2.9em;
  margin: 1px 0;
  padding: 8px 10px;
  border: 1px dashed #f6dfa9;
  border-radius: 8px;
  background: #fffaeb;
  color: #92400e;
  font-size: 12.5px;
  line-height: 1.6;
}
.restricted-hint .icon { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.restricted-foot { display: inline-flex; align-items: center; gap: 4px; color: #92400e; font-weight: 600; }
.restricted-foot .icon { width: 12px; height: 12px; }

/* ---------- Empty ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
}
.empty-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
}
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { margin: 0 0 6px; font-size: 16px; }
.empty p { margin: 0 0 18px; color: var(--text-faint); font-size: 13.5px; }
.empty .btn { height: 38px; }

/* ---------- Page / detail ---------- */
.page { max-width: 1000px; margin: 0 auto; padding: 26px 28px 90px; }
.page-head { margin-bottom: 16px; }
.page-title { font-size: 23px; margin: 4px 0 4px; letter-spacing: 0.2px; }
.page-sub { margin: 0; color: var(--text-faint); font-size: 13px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 10px;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--accent); }
.back-link .icon { width: 16px; height: 16px; }
.detail-paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 42px 44px;
  box-shadow: var(--shadow-sm);
}
.detail-title-row { display: flex; gap: 12px; align-items: flex-start; }
.detail-head h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.4;
  letter-spacing: 0.2px;
  flex: 1;
  overflow-wrap: anywhere;
}
.detail-title-row .star-btn { width: 36px; height: 36px; margin-top: 2px; }
.detail-title-row .star-btn svg { width: 21px; height: 21px; }
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 16px;
  color: var(--text-faint);
  font-size: 12.5px;
  margin-top: 12px;
}
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta-item .icon { width: 15px; height: 15px; }
.meta-item.clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 1px 5px;
  margin: -1px -5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.meta-item.clickable:hover { color: var(--accent); background: var(--accent-soft); }
.private-meta { color: #92400e; font-weight: 500; }
.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.detail-actions .btn { height: 36px; font-size: 13px; }
.detail-actions .btn.is-fav { color: #b45309; border-color: #f2d7a4; background: #fffaef; }
.detail-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.detail-section:first-of-type { border-top: 0; padding-top: 22px; margin-top: 0; }
.detail-section > h2 {
  font-size: 14px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.4px;
}
.detail-section > h2 .icon { width: 16px; height: 16px; color: var(--text-faint); }
.detail-section > p { margin: 0; white-space: pre-wrap; color: var(--text-soft); font-size: 14px; overflow-wrap: anywhere; }
.section-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.section-tags .tag { font-size: 12px; line-height: 22px; }
.muted-note { color: var(--text-faint); font-size: 13px; margin: 0; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { position: relative; display: flex; gap: 15px; padding-bottom: 24px; }
.steps li:last-child { padding-bottom: 0; }
.steps li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 38px;
  bottom: 2px;
  width: 2px;
  background: linear-gradient(#dbe5f8, #eef2f8);
  border-radius: 2px;
}
.step-num {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13.5px;
  display: grid;
  place-items: center;
  z-index: 1;
}
.step-body { flex: 1; min-width: 0; padding-top: 3px; }
.step-body h3 { margin: 0 0 5px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.step-body p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.75;
}
.step-images { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 11px; }
.thumb {
  position: relative;
  width: 128px;
  height: 96px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 0;
  cursor: zoom-in;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.step-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.file-item-wrap { display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: 100%; }
.file-item {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 340px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text-soft);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.file-item:hover { border-color: var(--accent-border); background: var(--accent-soft); }
.file-item-main {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.file-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex: none;
}
.file-item-icon .icon { width: 16px; height: 16px; }
.file-item-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.file-item-name {
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item-meta { font-size: 10.5px; color: var(--text-faint); }
.file-item-preview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  font-size: 10.5px;
  color: var(--accent);
  opacity: 0.85;
}
.file-item-wrap.preview-open { flex: 1 1 100%; }
.file-item-wrap.preview-open .file-item { max-width: 100%; }
.file-item-preview .icon { width: 14px; height: 14px; }
.file-item-wrap.preview-open .file-item-preview { color: var(--text-faint); }
.file-item-dl { margin-left: auto; color: var(--text-faint); flex: none; display: inline-flex; }
.file-item-dl:hover { color: var(--accent); }
.file-item-dl .icon { width: 15px; height: 15px; }

/* ---------- 附件预览 ---------- */
.file-preview {
  width: 100%;
  max-width: 780px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.file-preview-frame {
  display: block;
  width: 100%;
  height: 70vh;
  min-height: 420px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
}
.file-preview-text {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.file-preview-table-wrap {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.preview-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.preview-table th,
.preview-table td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  max-width: 280px;
}
.preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  font-weight: 600;
}
.preview-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.preview-tab {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text-soft);
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.preview-tab:hover { border-color: var(--accent-border); }
.preview-tab.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-strong); }
.file-preview-loading,
.file-preview-notice { padding: 20px 4px; text-align: center; color: var(--text-faint); font-size: 12.5px; }
.file-preview-doc { max-height: 60vh; overflow: auto; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.file-preview-doc h1,
.file-preview-doc h2,
.file-preview-doc h3,
.file-preview-doc h4 { margin: 14px 0 6px; font-size: 15px; }
.file-preview-doc p { margin: 0 0 8px; }
.file-preview-doc ul,
.file-preview-doc ol { margin: 0 0 8px; padding-left: 22px; }
.file-preview-doc table { border-collapse: collapse; width: 100%; font-size: 12px; margin: 0 0 10px; }
.file-preview-doc td,
.file-preview-doc th { border: 1px solid var(--border); padding: 4px 7px; }
.preview-modal-card { max-width: min(960px, 94vw); }
.file-preview-modal { max-width: 100%; }

/* ---------- Editor ---------- */
.editor { display: flex; flex-direction: column; gap: 15px; }
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 21px 23px;
  box-shadow: var(--shadow-sm);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-soft); font-weight: 500; }
.field-wide { grid-column: 1 / -1; }
.field em { color: var(--danger); font-style: normal; }
.field input, .field textarea {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfe;
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field textarea { resize: vertical; min-height: 42px; line-height: 1.65; }
.field input::placeholder, .field textarea::placeholder,
.step-editor input::placeholder, .step-editor textarea::placeholder { color: #a8b3c2; }
.field input:focus, .field textarea:focus {
  border-color: var(--accent-border);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09);
}
.field select {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfe;
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field select:focus {
  border-color: var(--accent-border);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09);
}
.field select:disabled { color: var(--text-faint); background: var(--surface-soft); cursor: not-allowed; }
.field-hint { font-size: 11.5px; color: var(--text-faint); font-weight: 400; line-height: 1.55; }
.tag-preview { display: flex; flex-wrap: wrap; gap: 5px; min-height: 0; }
.tag-hint { font-size: 11.5px; color: var(--text-faint); font-weight: 400; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.section-head h2 { font-size: 15.5px; margin: 0; }
.section-head .hint { font-size: 11.5px; color: var(--text-faint); }
.step-editor-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 13px; }
.step-editor {
  display: flex;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}
.step-editor .step-num { margin-top: 2px; width: 30px; height: 30px; font-size: 12.5px; }
.step-editor-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.step-editor-main input {
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  padding: 3px 2px;
  outline: none;
  width: 100%;
  border-radius: 0;
  color: var(--text);
}
.step-editor-main input:focus { border-bottom-color: var(--accent-border); }
.step-editor-main textarea {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  resize: none;
  min-height: 56px;
  outline: none;
  line-height: 1.65;
  width: 100%;
  color: var(--text);
  overflow-y: auto;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.step-editor-main textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.step-tools { display: flex; flex-direction: column; gap: 3px; }
.step-images-editor { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.thumb-edit { width: 88px; height: 66px; cursor: default; }
.thumb-edit img { cursor: zoom-in; }
.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background 0.15s ease;
}
.thumb-remove:hover { background: var(--danger); }
.thumb-add {
  width: 88px;
  height: 66px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 10.5px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.thumb-add:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.thumb-add .icon { width: 17px; height: 17px; }
.thumb-camera { display: none; border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.img-limit { font-size: 11px; color: var(--text-faint); }
.step-files-editor { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 4px 5px 4px 8px;
  max-width: 100%;
}
.file-chip-link {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 500;
}
.file-chip-link span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-link .icon { width: 14px; height: 14px; color: var(--accent); flex: none; }
button.file-chip-link {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
button.file-chip-link:hover { color: var(--accent-strong); }
.file-chip-meta { font-size: 10px; color: var(--text-faint); white-space: nowrap; }
.file-chip-remove {
  width: 19px;
  height: 19px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.file-chip-remove:hover { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.file-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text-faint);
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.file-add:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.file-add .icon { width: 15px; height: 15px; }
.file-limit { font-size: 11px; color: var(--text-faint); }
.steps-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 13px;
  background: var(--surface-soft);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 13px;
}
.steps-empty .icon { width: 18px; height: 18px; }
.steps-empty p { margin: 0; }
.editor-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 0 4px;
  background: linear-gradient(to bottom, rgba(243, 245, 248, 0), var(--bg) 38%);
}
.editor-actions .btn { height: 42px; min-width: 100px; }

/* ---------- Toast / modal / lightbox ---------- */
#toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #172033;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 14px 34px -12px rgba(15, 23, 42, 0.55);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: min(380px, 86vw);
  line-height: 1.55;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #b91c1c; }
#modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(2px);
  padding: 20px;
}
.modal-card {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  padding: 23px 24px 20px;
  box-shadow: 0 30px 70px -20px rgba(15, 23, 42, 0.5);
}
.modal-card h3 { margin: 0 0 8px; font-size: 16.5px; }
.modal-card p { margin: 0; color: var(--text-soft); font-size: 13.5px; line-height: 1.75; white-space: pre-line; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.modal-actions .btn { height: 37px; font-size: 13px; }
.creator-card { text-align: center; padding: 6px 0 2px; }
.creator-card .avatar-lg { margin: 0 auto 10px; }
.creator-card-name { display: flex; align-items: center; justify-content: center; gap: 7px; flex-wrap: wrap; font-size: 16px; font-weight: 700; }
.creator-card-sub { margin-top: 2px; color: var(--text-faint); font-size: 12.5px; }
.creator-actions { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.creator-status { color: var(--text-soft); font-size: 12.5px; }
.creator-status.subtle { color: var(--text-faint); }
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 115;
  background: rgba(8, 14, 26, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  cursor: zoom-out;
}
#lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
body.modal-open { overflow: hidden; }

/* ---------- User / account ---------- */
.user-area { position: relative; display: flex; align-items: center; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::marker { content: ''; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 10px 0 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.user-chip:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  flex: none;
}
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.user-name { font-size: 13px; font-weight: 500; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .chev { font-size: 10px; color: var(--text-faint); transition: transform 0.15s ease; }
.user-menu[open] .chev { transform: rotate(180deg); }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 228px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 22px 48px -18px rgba(20, 32, 54, 0.36);
  padding: 6px;
  z-index: 80;
}
.menu-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 11px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}
.menu-head strong { font-size: 13.5px; overflow-wrap: anywhere; }
.menu-head span { font-size: 11.5px; color: var(--text-faint); overflow-wrap: anywhere; }
.menu-panel button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-soft);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu-panel button:hover { background: var(--surface-soft); color: var(--text); }
.menu-panel button.danger-text { color: var(--danger); }
.menu-panel button.danger-text:hover { background: var(--danger-soft); }
.menu-panel .icon { width: 16px; height: 16px; }

/* ---------- Auth page ---------- */
.auth-page { display: flex; justify-content: center; padding: 34px 0 60px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 34px 26px;
  box-shadow: var(--shadow-md);
}
.auth-brand {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  box-shadow: 0 10px 22px -10px rgba(37, 99, 235, 0.9);
  margin-bottom: 16px;
}
.auth-brand svg { width: 25px; height: 25px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: 0.2px; }
.auth-sub { margin: 0 0 22px; color: var(--text-faint); font-size: 13px; line-height: 1.7; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-soft); }
.auth-field input {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfe;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.auth-field input:focus { border-color: var(--accent-border); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.auth-submit { height: 44px; margin-top: 4px; font-size: 14px; }
.auth-error { background: var(--danger-soft); border: 1px solid #f5caca; color: #b91c1c; border-radius: 8px; padding: 8px 11px; font-size: 12.5px; }
.auth-tip { margin: 18px 0 0; color: var(--text-faint); font-size: 12px; line-height: 1.7; text-align: center; }
.auth-tip a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-tip a:hover { text-decoration: underline; }

/* ---------- Tiny buttons / misc ---------- */
.btn.tiny { height: 29px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.tiny .icon { width: 14px; height: 14px; }
.count-pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 8px;
  line-height: 18px;
}
.loading-card {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  padding: 40px 22px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.modal-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--text-soft); }
.modal-field input, .modal-field select {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 0 11px;
  font-size: 13.5px;
  font-weight: 400;
  outline: none;
  width: 100%;
}
.modal-field input:focus, .modal-field select:focus { border-color: var(--accent-border); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.custom-modal { max-width: 440px; }
.share-row { margin-top: 14px; }
.share-input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 0 11px;
  font-size: 12.5px;
  color: var(--text-soft);
  outline: none;
}
.share-input:focus { border-color: var(--accent-border); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.share-tip { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; font-size: 12px; color: var(--text-faint); }
.share-tip .icon { width: 14px; height: 14px; flex: none; }
.share-label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--text-faint); }
.share-code-row { display: flex; align-items: center; gap: 8px; }
.share-code-row .share-input { flex: 1; min-width: 0; }
.share-code-row .btn { flex: none; height: 40px; }
.share-code-input {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}
.share-gate {
  max-width: 460px;
  margin: 44px auto 0;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 45px -32px rgba(23, 36, 56, 0.45);
  text-align: center;
}
.share-gate-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.share-gate-icon .icon { width: 25px; height: 25px; }
.share-gate h1 { margin: 0 0 8px; font-size: 20px; color: var(--text); }
.share-gate p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--text-soft); }
.share-gate-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 360px;
  margin: 0 auto 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  text-align: left;
}
.share-gate-summary strong { color: var(--text); font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.share-gate-summary span { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--text-faint); font-size: 12px; }
.share-gate-form { display: flex; gap: 10px; margin-top: 20px; }
.share-gate-form input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  padding: 0 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  outline: none;
}
.share-gate-form input:focus { border-color: var(--accent-border); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.share-gate-form .btn { flex: none; height: 42px; }
.share-gate p.share-gate-note { margin-top: 12px; font-size: 12px; color: var(--text-faint); }

/* ---------- History ---------- */
.history-section .section-head { margin-bottom: 12px; }
.history-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: var(--surface-soft);
}
.history-row + .history-row { border-top: 1px solid var(--border); }
.history-main { min-width: 0; }
.history-meta { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-soft); }
.history-time { color: var(--text-faint); font-size: 11.5px; }
.history-title {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-actions { display: flex; gap: 5px; flex: none; }
.version-banner {
  display: flex;
  align-items: center;
  gap: 13px;
  background: #fffaeb;
  border: 1px solid #f6dfa9;
  border-radius: 12px;
  padding: 13px 16px;
  margin-bottom: 14px;
}
.version-banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #f2d48e;
  color: #b45309;
  display: grid;
  place-items: center;
  flex: none;
}
.version-banner-text { flex: 1; min-width: 0; }
.version-banner-text strong { font-size: 13.5px; color: #92400e; }
.version-banner-text p { margin: 2px 0 0; font-size: 12px; color: #a16207; line-height: 1.6; }
.version-banner .btn { flex: none; height: 36px; font-size: 12.5px; }
.version-paper .detail-title-row h1 { font-size: 24px; }

/* ---------- Admin ---------- */
.admin-page { max-width: 1080px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.admin-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.25; }
.stat-label { font-size: 11.5px; color: var(--text-faint); }
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.admin-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 13px;
}
.admin-card-head h2 { margin: 0; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.admin-card-head h2 .icon { width: 17px; height: 17px; color: var(--text-faint); }
.admin-card-head .hint { font-size: 11.5px; color: var(--text-faint); }
.user-create-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
  align-items: end;
  padding: 13px;
  background: var(--surface-soft);
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  margin-bottom: 8px;
}
.user-create-form label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-soft); font-weight: 500; }
.user-create-form input, .user-create-form select {
  height: 37px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 400;
  outline: none;
  width: 100%;
}
.user-create-form input:focus, .user-create-form select:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08); }
.user-create-form .btn { height: 37px; width: 100%; }
.admin-list { display: flex; flex-direction: column; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px;
  border-top: 1px solid var(--border);
}
.admin-row:first-child { border-top: 0; padding-top: 6px; }
.admin-main { min-width: 0; }
.admin-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.admin-title strong { font-size: 13.5px; }
.admin-record-link { font-size: 13.5px; font-weight: 600; color: var(--text); }
.admin-record-link:hover { color: var(--accent); }
.admin-sub { font-size: 11.8px; color: var(--text-faint); margin-top: 2px; overflow-wrap: anywhere; }
.admin-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.role-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: #eef1f6;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 7px;
  line-height: 17px;
}
.role-badge.admin { color: var(--accent-strong); background: var(--accent-soft); border-color: var(--accent-border); }
.self-badge {
  font-size: 10.5px;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 20px;
  padding: 0 7px;
  line-height: 17px;
}

/* ---------- Responsive ---------- */
/* ---------- Profile / friends / messages ---------- */
.msg-btn { position: relative; }
.msg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  flex: none;
}
.msg-btn .msg-badge { position: absolute; top: -5px; right: -5px; box-shadow: 0 0 0 2px #fff; }
.menu-panel .menu-badge { margin-left: auto; }

.social-page { max-width: 1000px; }
.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.profile-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.avatar-lg { width: 60px; height: 60px; font-size: 24px; }
.profile-identity .page-title { margin: 0 0 2px; }
.profile-links { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-links .btn { height: 36px; font-size: 12.5px; }
.profile-stats { margin-bottom: 16px; }
.profile-fav {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: #b45309;
  background: #fffaef;
  border: 1px solid #f2d7a4;
  border-radius: 20px;
  padding: 0 7px;
  line-height: 18px;
}
.profile-fav .icon { width: 11px; height: 11px; fill: currentColor; }
.social-empty { text-align: center; padding: 24px 12px; color: var(--text-faint); }
.social-empty p { margin: 0 0 12px; font-size: 13px; }

.person-list { display: flex; flex-direction: column; }
.person-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 2px;
  border-top: 1px solid var(--border);
}
.person-row:first-child { border-top: 0; padding-top: 4px; }
.person-main { flex: 1; min-width: 0; }
.person-name { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13.5px; font-weight: 600; }
.person-sub { font-size: 11.8px; color: var(--text-faint); margin-top: 1px; overflow-wrap: anywhere; }
.person-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.friend-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 20px;
  padding: 0 7px;
  line-height: 18px;
  white-space: nowrap;
}
.friend-search-form { display: flex; gap: 8px; margin-bottom: 12px; }
.friend-search-form input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfe;
  padding: 0 12px;
  font-size: 13.5px;
  outline: none;
}
.friend-search-form input:focus { border-color: var(--accent-border); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.friend-search-form .btn { flex: none; }

.messages-page { max-width: 1080px; }
.messages-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}
.thread-panel, .chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  min-height: 540px;
  overflow: hidden;
}
.thread-panel { display: flex; flex-direction: column; }
.thread-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}
.thread-panel-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.thread-list { flex: 1; overflow-y: auto; padding: 5px; max-height: 620px; }
.thread-item {
  display: flex;
  gap: 9px;
  padding: 10px 9px;
  border-radius: 10px;
  color: inherit;
  transition: background 0.15s ease;
}
.thread-item:hover { background: var(--surface-soft); }
.thread-item.active { background: var(--accent-soft); }
.thread-avatar { position: relative; flex: none; }
.thread-avatar .msg-badge { position: absolute; top: -4px; right: -7px; box-shadow: 0 0 0 2px #fff; }
.thread-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thread-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.thread-top strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-top time { flex: none; font-size: 10.5px; color: var(--text-faint); }
.thread-preview { font-size: 11.8px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item.active .thread-preview { color: var(--text-soft); }
.thread-empty { padding: 26px 12px; text-align: center; color: var(--text-faint); font-size: 12.5px; }
.thread-empty p { margin: 0 0 10px; }
.chat-panel { display: flex; flex-direction: column; }
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.chat-back {
  display: none;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--text-soft);
  flex: none;
}
.chat-back:hover { background: var(--surface-soft); }
.chat-back .icon { width: 18px; height: 18px; }
.chat-head-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.chat-head-main strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-main > span { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-faint); flex-wrap: wrap; }
.chat-head-main .friend-badge, .chat-head-main .role-badge { line-height: 16px; }
.message-list {
  flex: 1;
  min-height: 360px;
  max-height: 560px;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fbfcfe;
}
.msg-row { display: flex; justify-content: flex-start; }
.msg-row.mine { justify-content: flex-end; }
.msg-bubble {
  max-width: 76%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 12px 6px;
  box-shadow: var(--shadow-sm);
}
.msg-row.mine .msg-bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
}
.msg-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.65; }
.msg-bubble time { display: block; margin-top: 3px; text-align: right; font-size: 10px; color: var(--text-faint); }
.msg-row.mine .msg-bubble time { color: rgba(255, 255, 255, 0.75); }
.message-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.message-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 140px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfe;
  padding: 9px 11px;
  font-size: 13.5px;
  line-height: 1.5;
  outline: none;
}
.message-form textarea:focus { border-color: var(--accent-border); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.message-form .btn { flex: none; height: 42px; }
.chat-notice {
  margin: 0;
  padding: 11px 15px;
  border-top: 1px solid var(--border);
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
}
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  color: var(--text-faint);
}
.chat-empty-icon {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 14px;
}
.chat-empty-icon .icon { width: 26px; height: 26px; }
.chat-empty h2 { margin: 0 0 5px; font-size: 17px; color: var(--text); }
.chat-empty p { margin: 0; font-size: 12.5px; line-height: 1.7; }
.chat-empty-actions { margin-top: 16px; display: flex; gap: 8px; }
.chat-empty-note { margin: auto; padding: 30px 12px; color: var(--text-faint); font-size: 12.5px; text-align: center; }

@media (max-width: 900px) {
  .messages-layout { grid-template-columns: 250px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .profile-head { align-items: flex-start; }
  .profile-links { width: 100%; }
  .profile-links .btn { flex: 1 1 auto; }
  .profile-identity .page-title { font-size: 20px; }
  .person-row { flex-wrap: wrap; align-items: flex-start; }
  .person-actions { width: 100%; justify-content: flex-start; padding-left: 41px; }
  .friend-search-form { flex-direction: column; }
  .friend-search-form .btn { width: 100%; }
  .messages-layout { grid-template-columns: 1fr; }
  .thread-panel, .chat-panel { min-height: 0; }
  .messages-layout:not(.has-active) .chat-panel { display: none; }
  .messages-layout.has-active .thread-panel { display: none; }
  .thread-list { max-height: 360px; }
  .chat-back { display: grid; }
  .message-list { min-height: 320px; max-height: 52vh; }
  .message-form { padding: 10px; }
  .message-form .btn { padding: 0 12px; }
  .msg-bubble { max-width: 84%; }
  .profile-record-row .admin-actions { padding-left: 0; }
}

@media (max-width: 1080px) {
  .topbar { padding: 11px 20px; }
  .layout { padding: 20px; gap: 22px; grid-template-columns: 205px minmax(0, 1fr); }
  .page { padding: 22px 20px 80px; }
  .detail-paper { padding: 32px 34px 40px; }
}
@media (hover: none), (pointer: coarse) {
  .thumb-camera { display: flex; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
  .sidebar {
    position: static;
    display: block;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--border);
  }
  #side-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
  .nav-label { display: none; }
  .nav-item { padding: 6px 10px; font-size: 12.5px; gap: 6px; }
  .nav-item > .icon { display: none; }
  .sidebar-footer, .sidebar-empty { display: none; }
  .page { padding: 18px 16px 80px; }
  .detail-paper { padding: 26px 24px 32px; border-radius: 14px; }
  .detail-head h1 { font-size: 23px; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .brand { padding: 0; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .brand h1 { font-size: 16px; }
  .brand p { display: none; }
  .topbar-actions { gap: 6px; margin-left: auto; }
  .topbar-actions .btn { padding: 0 10px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn.primary span { display: inline; }
  .topbar-actions .btn .icon { width: 17px; height: 17px; }
  .searchbox { order: 3; width: 100%; height: 38px; flex: 1 0 100%; margin-left: 0; }
  .searchbox kbd { display: none; }
  .toolbar { margin-bottom: 12px; }
  .record-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-card { padding: 17px 16px; }
  .detail-paper { padding: 22px 18px 28px; }
  .detail-head h1 { font-size: 21px; }
  .detail-actions .btn { flex: 1 1 auto; }
  .step-editor { padding: 12px; gap: 9px; }
  .step-editor .step-num { display: none; }
  .thumb { width: 100px; height: 76px; }
  .thumb-edit, .thumb-add { width: 76px; height: 58px; }
  .file-item { width: 100%; max-width: 100%; }
  .file-chip-link span { max-width: 120px; }
  .file-add { flex: 1 1 100%; justify-content: center; }
  .page-title { font-size: 20px; }
  .editor-actions { flex-direction: row; }
  .editor-actions .btn { width: auto; flex: 1 1 0; min-width: 0; }
  .page { padding-bottom: 60px; }
  .user-name { display: none; }
  .user-chip { padding: 0 8px 0 5px; gap: 5px; }
  .user-chip .chev { display: none; }
  .user-menu .menu-panel { right: 0; width: 210px; }
  .auth-page { padding: 14px 0 40px; }
  .auth-card { padding: 25px 20px 22px; border-radius: 14px; }
  .auth-card h1 { font-size: 20px; }
  .admin-page { padding-left: 0; padding-right: 0; }
  .admin-head { align-items: stretch; }
  .admin-head-actions .btn { flex: 1 1 auto; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat-card { padding: 11px 13px; }
  .stat-value { font-size: 21px; }
  .admin-card { padding: 15px 14px; border-radius: 12px; }
  .user-create-form { grid-template-columns: 1fr 1fr; }
  .user-create-form .btn { grid-column: 1 / -1; }
  .admin-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .admin-actions { justify-content: flex-start; }
  .history-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .history-actions { justify-content: flex-end; }
  .version-banner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .version-banner .btn { width: 100%; }
  .version-paper .detail-title-row h1 { font-size: 20px; }
  .detail-meta { gap: 6px 12px; }
  .share-input { font-size: 12px; }
  .share-code-row { flex-direction: column; align-items: stretch; }
  .share-code-row .btn { width: 100%; }
  .share-gate { margin-top: 24px; padding: 24px 18px; }
  .share-gate-form { flex-direction: column; }
  .share-gate-form .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 16mm 14mm; }
  body { background: #fff; font-size: 12pt; }
  .topbar, .sidebar, #toast-wrap, #modal, #lightbox, .detail-actions, .back-link, .editor-actions, .toolbar,
  .history-section, .version-banner, .admin-head-actions { display: none !important; }
  .page { max-width: none; padding: 0; margin: 0; }
  .detail-paper {
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }
  .detail-head h1 { font-size: 20pt; }
  .detail-title-row .star-btn { display: none; }
  .detail-meta { color: #555; }
  .detail-section { border-top-color: #ddd; page-break-inside: auto; }
  .detail-section > p, .step-body p { color: #333; }
  .steps li { page-break-inside: avoid; }
  .step-num { border: 1px solid #999; color: #111; background: #f2f2f2; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .steps li:not(:last-child)::before { background: #ddd; }
  .thumb { width: 46mm; height: 34mm; cursor: default; border: 1px solid #ddd; }
  .thumb img { object-fit: cover; }
  .file-item { border: 1px solid #ddd; background: #fff; color: #333; max-width: 70mm; }
  .file-item-dl, .file-item-preview, .file-item-wrap .file-preview { display: none !important; }
  .cat-chip, .tag { border: 1px solid #ccc; color: #333; background: #f7f7f7; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  mark { background: transparent; }
  .detail-section { break-inside: auto; }
}