*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0f;
  --surface: #1a1a20;
  --accent: #7b5ea7;
  --accent-light: #a07dc8;
  --selected-bg: rgba(123,94,167,0.35);
  --selected-border: #a07dc8;
  --text: #f0eef6;
  --muted: #888;
  --header-h: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== Login ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #1a1230 0%, #0d0d0f 70%);
}
.login-box {
  background: var(--surface);
  border: 1px solid #2e2a40;
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  text-align: center;
  width: 90%;
  max-width: 340px;
  box-shadow: 0 8px 40px rgba(123,94,167,0.15);
}
.login-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-box h1 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.login-sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.login-box input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #12111a;
  border: 1px solid #3a3550;
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.login-box input[type="password"]:focus { border-color: var(--accent); }
.login-box button {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.login-box button:hover { background: var(--accent-light); }
#login-error { color: #e07070; font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; }

/* ===== Header ===== */
#top-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(13,13,15,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2e2a40;
  padding: 0 1rem;
}
.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.header-title { font-size: 0.95rem; font-weight: 600; white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 0.5rem; }

#counter-badge {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent-light);
  border-radius: 99px;
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s;
}
#counter-badge.full {
  background: var(--accent);
  color: white;
  border-color: var(--accent-light);
  box-shadow: 0 0 12px rgba(123,94,167,0.5);
}

#confirm-btn {
  padding: 0.4rem 1rem;
  background: #333;
  color: #888;
  border: 1px solid #444;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  cursor: not-allowed;
  transition: all 0.2s;
  white-space: nowrap;
}
#confirm-btn:not(:disabled) {
  background: var(--accent);
  color: white;
  border-color: var(--accent-light);
  cursor: pointer;
  animation: pulse 1.5s infinite;
}
#confirm-btn:not(:disabled):hover { background: var(--accent-light); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123,94,167,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(123,94,167,0); }
}

.btn-ghost {
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid #444;
  border-radius: 0.4rem;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-ghost:hover { border-color: #888; color: var(--text); }

#session-info {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.25rem 0.35rem;
}

/* ===== Image Grid ===== */
#image-grid {
  margin-top: var(--header-h);
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);   /* mobile: 4列 */
  gap: 4px;
}
@media (min-width: 640px) {
  #image-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (min-width: 1024px) {
  #image-grid { grid-template-columns: repeat(8, 1fr); }
}

.img-cell {
  position: relative;
  aspect-ratio: 3/4;
  overflow: hidden;
  border-radius: 4px;
  background: #1a1a20;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s;
}
.img-cell:active { transform: scale(0.94); }

.img-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s;
}
.img-cell img.lazy { opacity: 0; }
.img-cell img.loaded { opacity: 1; }

.img-cell .overlay {
  position: absolute;
  inset: 0;
  background: var(--selected-bg);
  border: 2.5px solid var(--selected-border);
  border-radius: 4px;
  display: none;
  align-items: center;
  justify-content: center;
}
.img-cell.selected .overlay { display: flex; }
.img-cell .check-icon {
  background: var(--accent);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.img-cell .img-num {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ===== Center messages ===== */
.center-msg {
  margin-top: calc(var(--header-h) + 4rem);
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

/* ===== Done ===== */
#done-msg {
  position: fixed;
  inset: 0;
  background: rgba(13,13,15,0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.done-inner { text-align: center; }
.done-inner h2 { margin: 0.5rem 0; font-size: 1.5rem; }
.done-inner p { color: var(--muted); margin: 0.25rem 0; }
#done-detail { color: var(--accent-light) !important; font-size: 0.95rem !important; }

/* ===== Zoom dialog ===== */
#zoom-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 95vw;
  max-height: 95vh;
}
#zoom-dialog::backdrop { background: rgba(0,0,0,0.92); }
#zoom-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 0.5rem;
  display: block;
}
#zoom-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
