:root {
  --bg: #0f1419;
  --panel: #171e26;
  --ink: #e8eef5;
  --muted: #8b9aab;
  --line: #2a3542;
  --accent: #3d9cf0;
  --accent-ink: #041018;
  --ok: #3ecf8e;
  --warn: #e0a35a;
  --font: "IBM Plex Sans", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2a3d 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #152018 0%, transparent 45%),
    var(--bg);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.header-auth {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.header-auth-btn {
  appearance: none;
  white-space: nowrap;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  border: 1px solid transparent;
  color: var(--accent-ink);
}
.header-auth-btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 500;
}
.header-auth-btn[hidden] { display: none !important; }
.brand { display: flex; gap: 0.85rem; align-items: center; }
.brand-mark {
  width: 2.5rem; height: 2.5rem; border-radius: 0.7rem;
  display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  background: linear-gradient(145deg, #4aa3f5, #1e6fb8);
  color: #fff;
}
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 650; }
.tagline { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; }

.layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  display: grid;
  gap: 1rem;
}
.panel {
  background: color-mix(in srgb, var(--panel) 92%, #000);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem 1rem 1.15rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #c5d2e0;
}

.preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: min(62vh, 520px);
  border-radius: 0.75rem;
  overflow: hidden;
  background: #05070a;
  border: 1px solid var(--line);
  touch-action: none;
}
.preview-wrap.cropping {
  border-color: var(--accent);
}
.preview-stage {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  will-change: transform;
}
.preview-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #05070a;
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
}
.preview-stage img[hidden] { display: none !important; }

.placeholder {
  position: absolute; inset: 0;
  z-index: 2;
  display: grid; place-items: center;
  color: var(--muted);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.92rem;
  pointer-events: none;
}
.placeholder.small {
  position: static;
  padding: 1.25rem 0.75rem;
  font-size: 0.85rem;
}
.placeholder[hidden] { display: none !important; }

.crop-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  cursor: grab;
}
.crop-layer.panning { cursor: grabbing; }
.crop-layer[hidden] { display: none !important; }
.crop-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.crop-dim {
  fill: rgba(0, 0, 0, 0.55);
  fill-rule: evenodd;
}
.crop-poly {
  fill: rgba(255, 255, 255, 0.06);
  stroke: #f5f8f6;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.crop-handle {
  position: absolute;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  cursor: grab;
  z-index: 6;
  touch-action: none;
}
.crop-handle:active { cursor: grabbing; background: #2a7fbf; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #222b35;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
}
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.status {
  min-height: 1.25rem;
  margin: 0.55rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.status.ok { color: var(--ok); }
.status.warn, .status.error { color: var(--warn); }
.hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #6f7f90;
  line-height: 1.45;
}

.result-wrap {
  min-height: 88px;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: #0a0d11;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 0.5rem;
}
.result-stack {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #111;
  border-radius: 0.35rem;
  overflow: hidden;
}
.result-stack[hidden] { display: none !important; }
#result {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: #111;
  vertical-align: top;
}
.result-note-bar {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.4rem;
  padding: 0.55rem 0.75rem;
  background: #ffffff;
  color: #111111;
  border-top: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
}
.result-note-text {
  font-size: 0.92rem;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
}
.result-note-text:empty::before {
  content: "（未填写备注）";
  color: #999;
}

.note-field {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.note-field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #10161d;
  color: var(--ink);
  border-radius: 0.55rem;
  padding: 0.6rem 0.75rem;
  font: inherit;
}
.check-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check-field input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.list-count {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.list-hint {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  color: #6f7f90;
  line-height: 1.45;
}
.profile-card {
  max-width: min(560px, 100%);
}
.profile-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #10161d;
}
.profile-account__info { min-width: 0; }
.profile-user {
  margin: 0 0 0.2rem;
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
}
.profile-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.profile-section-title {
  margin: 0.25rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #c5d2e0;
}
.profile-password {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}
.profile-password > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  padding: 0.35rem 0;
}
.profile-password > summary::-webkit-details-marker { display: none; }
.profile-password > summary::after {
  content: ' ▾';
  color: var(--muted);
  font-weight: 400;
}
.profile-password[open] > summary::after { content: ' ▴'; }
.profile-password__form { margin-top: 0.65rem; }
.profile-password__actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.records {
  display: grid;
  gap: 0.75rem;
}
.records .meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.record {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0.75rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #10161d;
}
.record img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 0.5rem;
  background: #05070a;
}
.record-body {
  min-width: 0;
  display: grid;
  gap: 0.35rem;
  align-content: start;
}
.record-body .fname {
  font-size: 0.82rem;
  font-weight: 600;
  color: #c5d2e0;
  word-break: break-all;
}
.record-body .note {
  font-size: 0.88rem;
  color: var(--ink);
  word-break: break-word;
}
.record-body .meta {
  font-size: 0.75rem;
}
.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.record-actions .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}
.record-actions .danger {
  color: #f0a0a0;
  border-color: #5a3030;
  background: #2a1616;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: end center;
  padding: 0;
  background: rgba(5, 10, 16, 0.55);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-modal[hidden] { display: none !important; }
.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: min(92dvh, 100%);
  overflow: auto;
  background: var(--panel);
  border-radius: 1rem 1rem 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.35);
  padding: 1.15rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
}
.auth-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.1rem;
}
.auth-lead {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.auth-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  border-radius: 0.5rem;
  padding: 0;
  cursor: pointer;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}
.auth-tab {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: #10161d;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.5rem 0.35rem;
  cursor: pointer;
}
.auth-tab.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}
.auth-form {
  display: grid;
  gap: 0.65rem;
}
.auth-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.auth-form label[hidden] { display: none !important; }
.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: #10161d;
  color: var(--ink);
  border-radius: 0.55rem;
  padding: 0.6rem 0.75rem;
  font: inherit;
}
.field-hint {
  font-size: 0.75rem;
  color: #6f7f90;
}
.auth-captcha-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}
.auth-captcha-field .auth-captcha-row {
  grid-template-columns: 1fr auto auto;
}
.auth-captcha-image {
  width: 128px;
  min-height: 44px;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: #eef3ef;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 0.75rem;
  color: #556;
}
.auth-captcha-image img,
.auth-captcha-image svg {
  display: block;
  width: 128px;
  height: 42px;
}
.auth-captcha-refresh {
  appearance: none;
  border: 1px solid var(--line);
  background: #222b35;
  color: var(--ink);
  border-radius: 0.55rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  white-space: nowrap;
  min-height: 44px;
  cursor: pointer;
}
.auth-submit { width: 100%; margin-top: 0.15rem; min-height: 48px; }
.limit-actions {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.35rem;
}
.limit-actions .btn { width: 100%; }

@media (max-width: 520px) {
  .brand h1 { font-size: 1.05rem; }
  .tagline { display: none; }
  .actions .btn, .actions .btn.primary, .actions label.btn {
    flex: 1 1 calc(50% - 0.55rem);
  }
  .record {
    grid-template-columns: 72px 1fr;
  }
  .record img {
    width: 72px;
    height: 72px;
  }
  .auth-captcha-field .auth-captcha-row {
    grid-template-columns: 1fr auto;
  }
  .auth-captcha-field .auth-captcha-refresh {
    grid-column: 2;
  }
  .auth-captcha-field .auth-captcha-image {
    grid-column: 1 / -1;
    width: 100%;
  }
}
