/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: #f0f3f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif;
  color: #333;
  line-height: 1.6;
}

/* ── SEO Header ───────────────────────────────────────────────────── */
.seo-header {
  max-width: 960px;
  margin: 24px auto 16px;
  padding: 0 16px;
}

.seo-header h1 {
  font-size: 1.65rem;
  line-height: 1.4;
  margin-bottom: 10px;
}

.seo-lead {
  color: #444;
  margin-bottom: 10px;
  line-height: 1.75;
}

.tool-note {
  background: #f5faf5;
  border-left: 4px solid #7bae7f;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 0.9rem;
  border-radius: 0 4px 4px 0;
}

.tool-note a{
  text-decoration: underline;
  color:#224499;
  font-weight: bold;
}

/* ── Main Container ───────────────────────────────────────────────── */
.main-container {
  max-width: 1100px;
  margin: 0 auto 48px;
  padding: 0 16px;
}

/* ── Two-column Grid ──────────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

@media (min-width: 900px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
  .col-full {
    grid-column: 1 / -1;
  }
}

/* ── Section Cards ────────────────────────────────────────────────── */
.section-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e4ece4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e5026;
  border-bottom: 2px solid #d0e8d0;
  padding-bottom: 8px;
  margin-bottom: 16px;
}

/* ── Title Input ──────────────────────────────────────────────────── */
.title-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #c8d8c8;
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.title-input:focus {
  outline: none;
  border-color: #7bae7f;
  box-shadow: 0 0 0 2px rgba(123, 174, 127, 0.25);
}

/* ── Sample Buttons ───────────────────────────────────────────────── */
.sample-section {
  margin-bottom: 14px;
}

.sample-note {
  font-size: 0.82rem;
  color: #999;
  margin-bottom: 8px;
}

.sample-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sample-btn {
  font-size: 0.85rem;
  padding: 6px 12px;
  background: #f0f5f0;
  border-color: #b8d4b8;
  color: #2a6632;
}
.sample-btn:hover { background: #e0eee0; }

/* ── Schedule Table ───────────────────────────────────────────────── */
.table-hint {
  font-size: 0.76rem;
  color: #aaa;
  text-align: right;
  margin-bottom: 4px;
}
@media (min-width: 560px) { .table-hint { display: none; } }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
  font-size: 0.87rem;
}

@media (max-width: 599px) {
  .schedule-table { min-width: 380px; }
  .td-name { width: 110px; }
}

.schedule-table th {
  background: #f2f7f2;
  padding: 8px 8px;
  text-align: left;
  font-weight: 600;
  color: #3a5a3a;
  border-bottom: 2px solid #d0e8d0;
  white-space: nowrap;
}

.schedule-table td {
  padding: 6px 6px;
  border-bottom: 1px solid #eef2ee;
  vertical-align: middle;
}

.item-name {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #d0ddd0;
  border-radius: 5px;
  font-size: 0.87rem;
}
.item-name:focus { outline: none; border-color: #7bae7f; }

.time-sel {
  padding: 5px 5px;
  border: 1px solid #d0ddd0;
  border-radius: 5px;
  font-size: 0.84rem;
  cursor: pointer;
  background: #fff;
}
.time-sel:focus { outline: none; border-color: #7bae7f; }

.td-color { width: 44px; text-align: center; }
.color-pick {
  width: 38px;
  height: 30px;
  border: 1px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
  padding: 1px;
  display: block;
}

.td-del { width: 42px; text-align: center; }
.del-btn {
  background: #fff5f5;
  border: 1px solid #ffcccc;
  border-radius: 5px;
  color: #cc3333;
  font-size: 0.82rem;
  padding: 4px 8px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s;
}
.del-btn:hover { background: #ffe8e8; }

.empty-row {
  color: #bbb;
  padding: 14px 8px !important;
  font-size: 0.85rem;
  text-align: center;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f8f9f8;
  color: #333;
  font-size: 0.87rem;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.12s;
  white-space: nowrap;
}
.btn:hover     { background: #edeeee; }
.btn:disabled  { opacity: 0.6; cursor: not-allowed; }

.btn-primary   { background: #2a6632; color: #fff; border-color: #2a6632; }
.btn-primary:hover { background: #1e5026; }

.btn-success   { background: #e8f5e8; border-color: #a8d8a8; color: #1e5026; }
.btn-success:hover { background: #d4ecd4; }

.btn-info      { background: #e8f0ff; border-color: #b0c4f0; color: #224499; }
.btn-info:hover { background: #d8e8ff; }

.btn-warn      { background: #fff8e8; border-color: #f0d890; color: #886600; }
.btn-warn:hover { background: #fff0cc; }

.btn-danger    { background: #fff0f0; border-color: #f0b0b0; color: #cc2222; }
.btn-danger:hover { background: #ffe4e4; }

/* ── Validation ───────────────────────────────────────────────────── */
#validation-area { margin-top: 10px; }

.v-alert {
  padding: 7px 12px;
  border-radius: 5px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.v-error   { background: #fff0f0; border: 1px solid #f0b0b0; color: #cc2222; }
.v-warning { background: #fffbf0; border: 1px solid #f0d890; color: #886600; }

/* ── Canvas ───────────────────────────────────────────────────────── */
.canvas-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

#chart-canvas {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
}

/* ── Legend ───────────────────────────────────────────────────────── */
#chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding-top: 12px;
  border-top: 1px solid #eee;
  min-height: 24px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.83rem;
}

.leg-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.leg-sub { color: #888; font-size: 0.78rem; }

/* ── Display Settings ─────────────────────────────────────────────── */
.display-settings {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 10px;
}

.settings-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.87rem;
  cursor: pointer;
}

.settings-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #2a6632;
}

.start-pos-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.start-pos-row label { font-size: 0.87rem; color: #555; }

.start-pos-sel {
  padding: 5px 8px;
  border: 1px solid #d0ddd0;
  border-radius: 5px;
  font-size: 0.87rem;
  cursor: pointer;
  background: #fff;
}
.start-pos-sel:focus { outline: none; border-color: #7bae7f; }

/* ── Summary Table ────────────────────────────────────────────────── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  min-width: 360px;
}

.summary-table th {
  background: #f2f7f2;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid #d0e8d0;
  font-weight: 600;
  color: #3a5a3a;
  white-space: nowrap;
}

.summary-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #eef2ee;
  vertical-align: middle;
}

.summary-table td:first-child {
  display: flex;
  align-items: center;
}

.tbl-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 7px;
  flex-shrink: 0;
}

.summary-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-size: 0.87rem;
}

.summary-total { font-weight: 600; color: #333; }
.summary-rem   { font-size: 0.87rem; }
.rem-under { color: #886600; }
.rem-over  { color: #cc2222; font-weight: 600; }
.rem-exact { color: #226622; font-weight: 600; }

/* ── Save / Export Button Rows ────────────────────────────────────── */
.save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.export-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.save-indicator {
  font-size: 0.78rem;
  color: #aaa;
  flex: 1;
}

/* ── Toast ────────────────────────────────────────────────────────── */
#toast {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  transition: opacity 0.3s;
  max-width: 300px;
  pointer-events: none;
}
.toast-success { background: #e8f8e8; border: 1px solid #a0d8a0; color: #226622; }
.toast-warning { background: #fffbe8; border: 1px solid #f0d890; color: #886600; }
.toast-info    { background: #e8f0ff; border: 1px solid #b0c4f0; color: #224499; }
.toast-error   { background: #fff0f0; border: 1px solid #f0b0b0; color: #cc2222; }

/* ── Privacy Note ─────────────────────────────────────────────────── */
.privacy-note {
  text-align: center;
  color: #999;
  font-size: 0.8rem;
  padding: 16px 16px 8px;
}

/* ── SEO Content ──────────────────────────────────────────────────── */
.seo-content {
  max-width: 960px;
  margin: 40px auto 60px;
  padding: 0 16px;
  line-height: 1.8;
  color: #444;
}
.seo-content h2 {
  font-size: 1.1rem;
  color: #2a6632;
  margin: 24px 0 8px;
  font-weight: bold;
}
.seo-content p { margin-bottom: 12px; }

/* ── Print ────────────────────────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }
  #toast { display: none !important; }

  body { background: white; }

  .seo-header,
  .seo-content,
  .privacy-note { display: none; }

  .main-container { padding: 0; max-width: 100%; margin-bottom: 0; }

  .main-grid { grid-template-columns: 1fr !important; gap: 12px; }

  .section-card {
    box-shadow: none;
    border: none;
    padding: 0;
    border-radius: 0;
  }

  #chart-canvas { max-width: 360px; }
}

  /* 関連ページ */
.related-pages {
  max-width: 1100px;
  margin: 32px auto;
  padding: 20px 22px;
  background: #f8faf8;
  border: 1px solid #dbe6db;
  border-left: 4px solid #6fa36f;
  border-radius: 8px;
  box-sizing: border-box;
}

.related-pages h2 {
  margin: 0 0 14px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1.4;
  color: #2f4f2f;
}

.related-pages ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-pages li {
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid #e5eee5;
  line-height: 1.7;
}

.related-pages li:first-child {
  border-top: none;
  padding-top: 0;
}

.related-pages li:last-child {
  padding-bottom: 0;
}

.related-pages a {
  color: #1f6f3f;
  text-decoration: none;
  font-weight: 600;
}

.related-pages a:hover {
  text-decoration: underline;
}

.related-pages a::before {
  content: "▶";
  display: inline-block;
  margin-right: 0.45em;
  font-size: 0.8em;
  color: #6fa36f;
}

/* スマホ */
@media (max-width: 600px) {
  .related-pages {
    margin: 24px 12px;
    padding: 16px 15px;
    border-radius: 6px;
  }

  .related-pages h2 {
    font-size: 1.1rem;
  }

  .related-pages li {
    padding: 9px 0;
    font-size: 0.95rem;
  }
}

/* 印刷時は非表示 */
@media print {
  .related-pages.no-print {
    display: none !important;
  }
}