/* === CSS変数 === */
:root {
  --color-primary: #2d8a4e;
  --color-primary-dark: #1e6b38;
  --color-primary-light: #e8f5e9;
  --color-accent: #4caf50;
  --color-bg: #f5f9f6;
  --color-bg-white: #ffffff;
  --color-text: #333333;
  --color-text-light: #666666;
  --color-border: #e0e0e0;
  --color-error: #d32f2f;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 720px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* === ヘッダー === */
.header {
  background: var(--color-bg-white);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-logo a {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
}

/* ハンバーガーメニュー */
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 110;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  transition: transform 0.3s, opacity 0.3s;
}

.hamburger.active .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger.active .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ナビゲーション */
.nav {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--color-bg-white);
}

.nav.open {
  max-height: 300px;
}

.nav-list {
  list-style: none;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.nav-link::after {
  content: '›';
  font-size: 1.3rem;
  color: #ccc;
  margin-left: 8px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-primary);
  text-decoration: none;
}

.nav-link:hover::after,
.nav-link.active::after {
  color: var(--color-primary);
}

/* === メインコンテンツ === */
.main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* ヒーロー */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}

.hero-logo {
  width: 100%;
  height: auto;
  margin: 0 auto 16px;
  display: block;
}

.hero h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.hero p {
  color: var(--color-text-light);
  font-size: 0.95rem;
}

/* === 画像アップロード === */
.upload-section {
  margin-bottom: 24px;
}

.upload-section h3,
.form-section h3,
.result-section h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  padding-left: 4px;
  border-left: 3px solid var(--color-primary);
  padding-left: 10px;
}

.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s, background 0.3s;
  background: var(--color-bg-white);
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.upload-area.has-image {
  padding: 12px;
  border-style: solid;
  cursor: default;
}

.upload-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

.upload-placeholder p {
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.upload-note {
  font-size: 0.8rem !important;
  margin-top: 4px;
  color: #999 !important;
}

.preview-image {
  max-height: 300px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

/* === フォーム === */
.form-section {
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-bg-white);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45, 138, 78, 0.15);
}

.form-group textarea {
  resize: vertical;
}

/* === ボタン === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
}

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

.btn-primary:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.btn-secondary {
  background: #eee;
  color: var(--color-text);
  margin-top: 8px;
  font-size: 0.85rem;
  padding: 8px 16px;
}

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

/* === ローディング === */
.loading {
  text-align: center;
  padding: 40px 0;
}

.loading p {
  color: var(--color-text-light);
  margin-top: 16px;
  font-size: 0.95rem;
}

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

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

/* === 診断結果 === */
.result-section {
  margin-bottom: 24px;
  background: var(--color-bg-white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.result-content {
  line-height: 1.7;
  font-size: 0.95rem;
}

.result-content h4 {
  color: var(--color-primary);
  margin: 20px 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}

.result-content h4:first-child {
  margin-top: 0;
}

.result-content h5 {
  margin: 12px 0 2px;
  font-size: 0.95rem;
  font-weight: 600;
}

.result-content p {
  margin: 0 0 6px;
}

.result-content ul,
.result-content ol {
  padding-left: 20px;
  margin: 2px 0 6px;
}

.result-content li {
  margin-bottom: 2px;
}

/* === シェア・保存機能 === */
.share-section {
  margin: 24px 0;
  padding: 20px;
  background: var(--color-primary-light);
  border-radius: var(--radius);
}

.share-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
  border-left: none;
  padding-left: 0;
}

.share-buttons,
.save-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.save-buttons {
  margin-top: 10px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.share-btn:hover {
  filter: brightness(1.15);
  text-decoration: none;
}

/* ネイティブ共有ボタン */
.share-btn--native {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45, 138, 78, 0.3);
}

/* X(Twitter)ボタン */
.share-btn--x {
  background: #000;
  color: #fff;
}

/* LINEボタン */
.share-btn--line {
  background: #06C755;
  color: #fff;
  box-shadow: 0 2px 8px rgba(6, 199, 85, 0.2);
}

/* URLコピーボタン */
.share-btn--copy {
  background: #6C757D;
  color: #fff;
}

/* PDF保存ボタン */
.share-btn--pdf {
  background: #d32f2f;
  color: #fff;
}

/* PNG保存ボタン */
.share-btn--png {
  background: #1565c0;
  color: #fff;
}

.copy-feedback {
  font-size: 0.8rem;
  color: var(--color-primary-dark);
  margin-left: 8px;
  font-weight: 500;
}

/* === フッター === */
.footer {
  background: var(--color-bg-white);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px;
  text-align: center;
}

.footer-inner p {
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-bottom: 8px;
}

.footer-nav {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-nav a {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.footer-nav a:hover {
  color: var(--color-primary);
}

/* === 読み物ページ === */
.articles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.article-card {
  background: var(--color-bg-white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.article-card:hover {
  box-shadow: var(--shadow-md);
}

.article-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
  border-left: none;
  padding-left: 0;
}

.article-card h3 a {
  color: var(--color-text);
}

.article-card h3 a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.article-card p {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

/* 記事詳細ページ */
.article-detail {
  background: var(--color-bg-white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.article-detail h2 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.article-detail h3 {
  font-size: 1.1rem;
  margin: 24px 0 12px;
  color: var(--color-text);
}

.article-detail p {
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.article-detail ul,
.article-detail ol {
  padding-left: 24px;
  margin-bottom: 12px;
}

.article-detail li {
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* === 法的ページ === */
.legal-page {
  background: var(--color-bg-white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.legal-page h2 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin-bottom: 20px;
}

.legal-page h3 {
  font-size: 1.05rem;
  margin: 20px 0 10px;
  border-left: none;
  padding-left: 0;
}

.legal-page p {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.legal-page ul {
  padding-left: 24px;
  margin-bottom: 12px;
}

.legal-page li {
  margin-bottom: 4px;
  font-size: 0.9rem;
}

/* === 広告枠 === */
.ad-section {
  margin: 24px 0;
  padding: 20px;
  background: var(--color-bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.ad-label {
  font-size: 0.7rem;
  color: #999;
  margin-bottom: 8px;
}

.ad-placeholder {
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 20px;
}

/* === エラー表示 === */
.error-message {
  background: #ffebee;
  color: var(--color-error);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* === レスポンシブ === */
@media (min-width: 600px) {
  .articles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .hero h2 {
    font-size: 1.25rem;
  }

  .share-buttons,
  .save-buttons {
    flex-direction: column;
  }

  .share-btn {
    justify-content: center;
  }

  .article-detail,
  .legal-page {
    padding: 20px;
  }
}
