/* ===== リセット・ベース ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-secondary: #6b7280;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.14);
}

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

/* ===== ヘッダー ===== */
header {
  background: var(--color-primary);
  color: #fff;
  padding: 1rem 2rem;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ===== メイン ===== */
main {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

section {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
}

/* ===== ドロップゾーン ===== */
.drop-zone {
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  color: var(--color-text-muted);
}

.drop-zone:hover,
.drop-zone.drag-over {
  background: #eef2ff;
  border-color: var(--color-primary-hover);
}

.drop-zone p {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.drop-zone .sub {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.file-label {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.file-label:hover {
  background: var(--color-primary-hover);
}

#file-input {
  display: none;
}

/* ===== プレビューリスト ===== */
.preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--color-border);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== ボタン ===== */
.btn-primary {
  margin-top: 1rem;
  padding: 0.65rem 2rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 0.5rem 1.25rem;
  background: var(--color-surface);
  color: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 1rem;
}

.btn-secondary:hover {
  background: var(--color-bg);
}

.btn-danger {
  padding: 0.5rem 1.25rem;
  background: var(--color-danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.75rem;
}

.btn-danger:hover {
  background: var(--color-danger-hover);
}

/* ===== ステータスメッセージ ===== */
.status-msg {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  min-height: 1.2em;
  color: var(--color-text-muted);
}

.status-msg.success { color: #16a34a; }
.status-msg.error   { color: var(--color-danger); }

/* ===== ギャラリー ===== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.gallery .placeholder {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  grid-column: 1 / -1;
}

.gallery-item {
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--color-bg);
  aspect-ratio: 1 / 1;
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item .item-name {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--color-surface);
}

/* ===== モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal-content {
  position: relative;
  z-index: 101;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  overflow: auto;
}

.modal-content img {
  max-width: 70vw;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 8px;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--color-bg);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-filename {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  header h1 { font-size: 1.1rem; }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .modal-content img {
    max-width: 90vw;
  }
}
