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

body {
  font-family: "Hiragino Sans", "Meiryo", "Yu Gothic", sans-serif;
  background: #F5F7F6;
  color: #333333;
  min-height: 100vh;
  padding-bottom: 48px;
  overflow-x: hidden; /* カルーセルの横はみ出し防止 */
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 16px;
}

/* ==========================================
   ヘッダー
   ========================================== */
header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 {
  font-size: 1.5rem;
  color: #333333;
  letter-spacing: 0.02em;
}

header .subtitle {
  color: #888;
  font-size: 0.85rem;
  margin-top: 6px;
}

/* ==========================================
   使い方カード
   ========================================== */
.howto-card {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 14px 20px;
  margin-bottom: 20px;
  border-left: 4px solid #3CBCA0;
}

.howto-title {
  font-size: 0.8rem;
  font-weight: bold;
  color: #3CBCA0;
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.howto-steps {
  padding-left: 1.4em;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.howto-steps li {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.5;
}

.howto-steps a {
  color: #3CBCA0;
  text-decoration: none;
  font-weight: bold;
}

.howto-steps a:hover {
  text-decoration: underline;
}

/* ==========================================
   アップロードエリア
   ========================================== */
.upload-area {
  background: #FFFFFF;
  border: 2px dashed #3CBCA0;
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 20px;
  transition: background 0.15s, border-color 0.15s;
}

/* A4: モバイルではアップロードエリアの余白を縮小する */
@media (max-width: 768px) {
  .upload-area {
    padding: 20px 16px;
  }
}

.upload-area:hover,
.upload-area.dragover {
  background: #eef9f6;
  border-color: #2a9d8a;
}

.upload-area .upload-icon {
  display: block;
  margin: 0 auto 12px;
  color: #3CBCA0;
}

.upload-area strong {
  font-size: 1rem;
  color: #333;
}

.upload-area p {
  color: #999;
  font-size: 0.85rem;
  margin-top: 8px;
}

#file-input { display: none; }

/* ==========================================
   エラーメッセージ
   ========================================== */
.error-msg {
  background: #fff0f0;
  border: 1px solid #e05c5c;
  border-radius: 8px;
  padding: 10px 16px;
  color: #c0392b;
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: none;
}
.error-msg.visible { display: block; }

/* ==========================================
   銘柄情報カード
   ========================================== */
.stock-info {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 20px;
  border-left: 4px solid #3CBCA0;
  display: none;
}
.stock-info.visible { display: block; }

.stock-info h2 {
  font-size: 1.3rem;
  color: #333;
}

.stock-info .code {
  font-size: 0.85rem;
  color: #3CBCA0;
  margin-top: 4px;
  font-weight: bold;
}

/* ==========================================
   凡例カード
   ========================================== */
.legend-card {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 10px 20px;
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 20px;
  font-size: 0.85rem;
  color: #555;
}
.legend-card.visible { display: flex; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* ==========================================
   概要カード
   ========================================== */
.summary-card {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: none;
}
.summary-card.visible { display: block; }
.summary-year { font-size: 0.8rem; color: #888; margin-bottom: 12px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 480px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-tile {
  text-align: center;
  padding: 10px 6px;
  background: #F5F7F6;
  border-radius: 8px;
}
.stat-label { font-size: 0.72rem; color: #888; margin-bottom: 4px; }
.stat-value { font-size: 1.15rem; font-weight: bold; color: #333; }
.stat-unit  { font-size: 0.7rem; color: #aaa; margin-top: 2px; }

/* ==========================================
   グラフカード（デスクトップ）
   ========================================== */
.chart-card {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  display: none;
  position: relative;
}
.chart-card.visible { display: block; }

/* グラフの高さを固定（maintainAspectRatio: false に対応） */
.chart-card canvas {
  height: 380px;
}

/* ==========================================
   PNG保存ボタン
   ========================================== */
.dl-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: #f2f2f2;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  color: #555;
  transition: background 0.15s;
  z-index: 1;
}
.dl-btn:hover { background: #e4e4e4; }

/* ==========================================
   スワイプヒント（モバイル/タブレットのみ表示）
   ========================================== */
.swipe-hint {
  display: none; /* デスクトップでは非表示 */
}

@media (max-width: 768px) {
  .swipe-hint {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 10px;
  }
}

/* ==========================================
   カルーセルナビゲーション（ドット）
   デスクトップでは非表示、モバイルで表示
   ========================================== */
.carousel-nav {
  display: none; /* デスクトップ：非表示 */
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 0 4px;
}

.carousel-nav .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}

.carousel-nav .dot.active {
  background: #3CBCA0;
  transform: scale(1.3);
}

/* ==========================================
   モバイル / タブレット（横幅 768px 以下）
   グラフをカルーセル表示に切り替える
   ========================================== */
/* ==========================================
   フッター
   ========================================== */
.site-footer {
  text-align: center;
  padding: 32px 16px 24px;
  border-top: 1px solid #e5e5e5;
  margin-top: 40px;
}

.site-footer .disclaimer {
  font-size: 0.75rem;
  color: #999;
  line-height: 1.7;
  max-width: 700px;
  margin: 0 auto 16px;
}

.site-footer .disclaimer a {
  color: #3CBCA0;
  text-decoration: none;
}

.site-footer .disclaimer a:hover {
  text-decoration: underline;
}

.site-footer .footer-nav {
  margin-bottom: 10px;
}

.site-footer .footer-nav a {
  font-size: 0.8rem;
  color: #888;
  text-decoration: none;
}

.site-footer .footer-nav a:hover {
  text-decoration: underline;
}

.site-footer .copyright {
  font-size: 0.72rem;
  color: #bbb;
}

@media (max-width: 768px) {

  /* カルーセルコンテナ */
  .chart-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;        /* Firefox */
    gap: 0;
    margin-bottom: 0;
  }
  .chart-carousel::-webkit-scrollbar { display: none; }

  /* 各グラフカードを1スライドとして扱う */
  .chart-carousel .chart-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    border-radius: 12px;
    margin-bottom: 0;
    /* A2: 左右・下パディングを縮小して表示領域を広げる */
    /* A3: 上部はPNG保存ボタンが重ならないようスペースを確保 */
    padding: 38px 10px 10px;
  }

  /* グラフの高さをモバイル向けに調整 */
  .chart-card canvas {
    height: 300px;
  }

  /* A3: PNG保存ボタンのサイズ・位置をモバイル向けに調整 */
  .dl-btn {
    top: 10px;
    right: 10px;
    font-size: 0.72rem;
    padding: 3px 8px;
  }

  /* ナビゲーションドットを表示 */
  .carousel-nav {
    display: flex;
    margin-bottom: 20px;
  }
}
