* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f2f3f5;
  color: #222;
}
header {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 12px 12px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: #1f6feb; color: #fff;
}
header h1 { font-size: 16px; margin: 0; flex: 1; white-space: nowrap; }
header button {
  background: #fff; color: #1f6feb; border: 0; border-radius: 6px;
  padding: 6px 9px; cursor: pointer; font-size: 12px;
  white-space: nowrap; flex: 0 0 auto;
}
header button[hidden] { display: none; }
#status { font-size: 12px; flex-basis: 100%; min-height: 16px; }
main { padding: 12px; max-width: 720px; margin: 0 auto; }
.card {
  background: #fff; border-radius: 10px; padding: 14px;
  margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
label { display: flex; flex-direction: column; font-size: 13px; gap: 4px; }
label.full { margin-top: 10px; }
select, textarea, input[type=file], input[type=search], input[type=password] {
  width: 100%; padding: 8px; border: 1px solid #ccc;
  border-radius: 6px; font-size: 14px; background: #fff;
}
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions button {
  flex: 1; padding: 10px; border: 0; border-radius: 6px;
  font-size: 15px; cursor: pointer;
}
#submit { background: #1f6feb; color: #fff; }
#cancelEdit { background: #eee; color: #333; }
#cancelEdit[hidden] { display: none; }
.filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1 1 100%; }
.filters select { flex: 1; }
.preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { position: relative; width: 72px; height: 72px; }
.thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; }
.thumb button {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border-radius: 50%; border: 0; background: #c00; color: #fff; cursor: pointer;
}
.record { border-top: 1px solid #eee; padding: 10px 0; }
.record:first-child { border-top: 0; }
.record.draft { background: #fffaf0; }
.record .meta { font-size: 14px; font-weight: 600; }
.record .time { font-size: 12px; color: #888; margin: 2px 0 6px; }
.record .note { font-size: 14px; white-space: pre-wrap; }
.record .imgs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.record .imgs img {
  width: 72px; height: 72px; object-fit: cover; border-radius: 6px; cursor: pointer;
}
.record .row { display: flex; gap: 8px; }
.record .row button {
  border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.record .edit { background: #fff; color: #1f6feb; border: 1px solid #1f6feb; }
.record .del { background: #fff; color: #c00; border: 1px solid #c00; }

#loginOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#loginOverlay[hidden] { display: none; }
.login-box {
  background: #fff; border-radius: 12px; padding: 24px;
  width: min(90vw, 340px); box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.login-box h2 { margin: 0 0 4px; font-size: 20px; }
.login-box p { margin: 0 0 16px; color: #666; font-size: 13px; }
.login-box button {
  width: 100%; margin-top: 12px; padding: 10px;
  background: #1f6feb; color: #fff; border: 0; border-radius: 6px;
  font-size: 15px; cursor: pointer;
}
#loginMsg { margin-top: 10px; font-size: 13px; color: #c00; min-height: 18px; }
.card[hidden] { display: none; }
.hint { font-size: 12px; color: #888; line-height: 1.5; margin: 10px 0 0; }

#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  z-index: 200; display: flex; flex-direction: column;
}
#lightbox[hidden] { display: none; }
.lb-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  color: #fff; font-size: 14px;
}
.lb-bar button {
  background: rgba(255,255,255,.15); color: #fff; border: 0;
  border-radius: 6px; padding: 6px 14px; font-size: 14px; cursor: pointer;
}
.lb-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; min-height: 0; padding: 0 8px 20px;
}
.lb-stage img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 4px;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  border: 0; font-size: 28px; line-height: 1; cursor: pointer;
}
.lb-nav[hidden] { display: none; }
#lbPrev { left: 8px; }
#lbNext { right: 8px; }
