/* ===== CSS Variables ===== */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #6b7280;
  --warning-bg: #fffbeb;
  --warning-border: #f59e0b;
  --error-bg: #fef2f2;
  --error-border: #ef4444;
  --success: #10b981;
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

/* ===== Base ===== */
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  padding: 2rem 1rem 1.75rem;
  text-align: center;
}

header h1 {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

header p {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* ===== Main ===== */
main {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card-error {
  border-color: var(--error-border);
  background: var(--error-bg);
  text-align: center;
}

.card-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  text-align: center;
}

.card-warning h2 {
  color: #92400e;
  margin-bottom: 0.5rem;
}

.card-warning p {
  color: #78350f;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Usage Info ===== */
.usage-info {
  text-align: center;
  padding: 0.6rem 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: #1e40af;
}

.usage-info span {
  font-weight: 700;
  font-size: 1.1em;
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2.5rem 1rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.drop-zone:focus {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
}

.drop-text {
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.drop-or {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.6rem 0 0.75rem !important;
}

.upload-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1rem;
  text-align: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
}

.btn-icon {
  font-size: 1.1em;
}

/* ===== Loading ===== */
#loading-section {
  text-align: center;
  padding: 2.5rem 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.loading-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Results ===== */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.results-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.select-actions {
  display: flex;
  gap: 0.5rem;
}

.badge {
  display: inline-block;
  background: #eff6ff;
  color: var(--primary);
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* ===== Events List ===== */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem;
}

.event-item {
  border-radius: 6px;
  transition: background 0.1s;
}

.event-item:hover {
  background: #f9fafb;
}

.event-label {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  width: 100%;
}

.event-check {
  margin-top: 0.2rem;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.event-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.event-title {
  font-weight: 600;
  font-size: 0.9rem;
  word-break: break-word;
}

.event-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.event-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== Download Area ===== */
.download-area {
  text-align: center;
  padding-top: 0.5rem;
}

.download-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

/* ===== Error ===== */
.error-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.error-text {
  color: #991b1b;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ===== How-to ===== */
.how-to h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

.how-to ol {
  padding-left: 1.4rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* ===== Ad Container ===== */
.ad-container {
  margin-bottom: 1.25rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.ad-container:empty::after {
  content: "広告";
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: auto;
}

.footer-note {
  font-size: 0.72rem;
  margin-top: 0.3rem;
  opacity: 0.75;
}

footer a {
  color: inherit;
  text-decoration: underline;
  opacity: 0.8;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  header {
    padding: 1.5rem 1rem;
  }

  .drop-zone {
    padding: 2rem 0.75rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-lg {
    width: 100%;
    justify-content: center;
  }
}
