/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-main: #fafafa;
  --bg-card: #ffffff;
  --text-primary: #2c3e50;
  --text-secondary: #6c757d;
  --accent: #5c7cfa;
  --accent-hover: #4c6ef5;
  --border: #e1e4e8;
  --success: #51cf66;
  --shadow: rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.7;
  padding: 20px;
  min-height: 100vh;
}

/* Container */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 40px;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Card */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px var(--shadow);
}

.card h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.card p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 16px;
}

/* Link Cards (for index) */
.link-cards {
  display: grid;
  gap: 20px;
  margin-top: 32px;
}

.link-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
  display: block;
}

.link-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-2px);
}

.link-card h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.link-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Checkbox List */
.checkbox-list {
  margin: 24px 0;
}

.checkbox-item {
  display: flex;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.checkbox-item:last-child {
  border-bottom: none;
}

.checkbox-item input[type="checkbox"] {
  margin-right: 12px;
  margin-top: 4px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-item label {
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.6;
  user-select: none;
  flex: 1;
}

/* Category Section */
.category-section {
  margin-bottom: 32px;
}

.category-section h3 {
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 12px;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
}

/* Question Item */
.question-item {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.question-item:last-child {
  border-bottom: none;
}

.question-item label {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.question-item textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s ease;
}

.question-item textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.char-counter {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Summary Section */
.summary {
  background: #f8f9fa;
  border-left: 4px solid var(--success);
  padding: 24px;
  border-radius: 8px;
  margin-top: 32px;
  display: none;
}

.summary.active {
  display: block;
}

.summary h2 {
  font-size: 1.3rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.summary ul {
  list-style: none;
  margin-bottom: 16px;
}

.summary li {
  padding: 8px 0 8px 20px;
  position: relative;
  font-size: 0.92rem;
}

.summary li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: bold;
}

.summary .category-group {
  margin-bottom: 20px;
}

.summary .category-group h4 {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 8px;
}

.summary-note {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  line-height: 1.7;
}

/* Closing Message */
.closing-message {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 24px;
  margin-top: 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.7;
}

/* Button */
.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 8px 4px;
}

.button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.button:disabled {
  background: #adb5bd;
  cursor: not-allowed;
  transform: none;
}

.button-group {
  text-align: center;
  margin-top: 32px;
  display: none;
}

.button-group.active {
  display: block;
}

/* Back Link */
.back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 60px;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Print Styles */
@media print {
  body {
    background: white;
    padding: 0;
  }

  .button,
  .button-group,
  .back-link,
  footer,
  header nav {
    display: none !important;
  }

  .card,
  .summary {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .checkbox-item input[type="checkbox"]:checked + label {
    font-weight: bold;
  }
}

/* Responsive */
@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 20px;
  }

  .link-card {
    padding: 20px;
  }

  .checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  .question-item textarea {
    min-height: 70px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .button {
    width: 100%;
    display: block;
    margin: 8px 0;
  }
}

/* Loading indicator for image generation */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-overlay.active {
  display: flex;
}

.loading-content {
  background: white;
  padding: 32px;
  border-radius: 12px;
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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