:root {
  --bg-color: #fafafa;
  --text-main: #1a1a1a;
  --text-muted: #666666;
  --card-bg: #ffffff;
  --border-color: #e5e5e5;
  --accent: #000000;
  --accent-hover: #333333;
  --success: #2e7d32;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Noto Sans JP", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  /* スマホでのスクロールを滑らかに */
  -webkit-overflow-scrolling: touch;
}

.app-container {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* ヘッダー */
header {
  padding: 24px 20px 16px;
  background-color: var(--bg-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
  text-align: center;
}

/* タブナビゲーション */
.tabs {
  display: flex;
  background-color: #eeeeee;
  border-radius: 12px;
  padding: 4px;
  margin: 0 20px 24px;
  overflow-x: auto;
  /* スマホでスクロール可能に */
  white-space: nowrap;

  /* 折り返し防止 */
  /* スクロールバーを非表示にする (Webkit) */
  &::-webkit-scrollbar {
    display: none;
  }

  -ms-overflow-style: none;
  /* IE, Edge */
  scrollbar-width: none;
  /* Firefox */
}

.tab-btn {
  flex: 0 0 auto;
  /* 幅を自動調整し縮小させない */
  padding: 10px 16px;
  /* 横の余白を追加 */
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn.active {
  background-color: var(--card-bg);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

/* コンテンツエリア */
main {
  flex: 1;
  padding: 0 20px 40px;
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 内部タブ（3日間用） */
.sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.sub-tab-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.sub-tab-btn.active {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
}

.sub-tab-content {
  display: none;
}

.sub-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease forwards;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* カード（質問・チェックリストの枠） */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  transition: box-shadow 0.3s ease;
}

.card:focus-within {
  border-color: #ccc;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

/* フォーム要素 */
label.question-label {
  display: block;
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 15px;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  background-color: #fafafa;
  transition: all 0.3s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--card-bg);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
  /* 影を少し強めに */
}

/* テキストエリアの右下に「広げられます」のヒントを表示するラッパー */
.textarea-wrapper {
  position: relative;
  width: 100%;
}

.textarea-wrapper::after {
  content: "右下を引っ張ると広げられます ↘";
  position: absolute;
  bottom: -20px;
  right: 4px;
  font-size: 11px;
  color: #999;
  pointer-events: none;
}

/* 印刷時は非表示にする */
@media print {
  .textarea-wrapper::after {
    display: none !important;
  }
}

.range-slider {
  width: 100%;
  margin: 16px 0 8px;
  accent-color: var(--accent);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

select.text-input {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

/* テキスト入力（1行） */
.text-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  background-color: #fafafa;
  transition: all 0.3s ease;
  margin-top: 8px;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--card-bg);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
  /* 影を少し強めに */
}

/* ワークの説明文 */
.work-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.7;
}

.work-instruction {
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--accent);
  background: #f0f0f0;
  padding: 16px;
  /* パディングを増やして読みやすく */
  border-radius: 12px;
  /* 丸みを追加 */
  font-size: 15px;
  text-align: center;
}

/* ステップボックス */
.step-container {
  position: relative;
  margin-top: 24px;
}

.step-box {
  position: relative;
  padding-bottom: 32px;
  padding-left: 36px;
}

.step-box::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 32px;
  bottom: -4px;
  width: 2px;
  background-color: #e0e0e0;
}

.step-box:last-child::before {
  display: none;
}

.step-number {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  background-color: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  z-index: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.step-box.break-loop .step-number {
  background-color: #e53935;
  font-size: 16px;
}

.hint {
  font-size: 13.5px;
  /* 少し大きく */
  color: #555;
  /* 少し濃くして視認性アップ */
  margin-bottom: 12px;
  margin-top: 4px;
  background: #f8f9fa;
  padding: 12px 14px;
  /* パディング調整 */
  border-radius: 8px;
  /* 丸み調整 */
  border-left: 4px solid #ccc;
  /* 左の線を少し太く */
  line-height: 1.6;
}

/* ラジオボタン */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.radio-item {
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
  background-color: #fff;
}

.radio-item:hover,
.radio-item:focus-within {
  background-color: #f8f9fa;
  border-color: #ccc;
}

.radio-item input[type="radio"] {
  margin-top: 3px;
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.radio-item span {
  font-size: 14px;
  line-height: 1.5;
}

.mt-2 {
  margin-top: 16px;
}

/* チェックボックス */
.date-display {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 500;
}

.checkbox-item {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  cursor: pointer;
}

.checkbox-item:last-child {
  margin-bottom: 0;
}

.checkbox-item input[type="checkbox"] {
  display: none;
}

.custom-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.checkbox-item input:checked+.custom-checkbox {
  background-color: var(--accent);
  border-color: var(--accent);
}

.checkbox-item input:checked+.custom-checkbox::after {
  content: "";
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.checkbox-text {
  font-size: 15px;
  color: var(--text-main);
  transition: color 0.2s ease;
}

.checkbox-item input:checked~.checkbox-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.save-btn {
  width: 100%;
  padding: 18px;
  /* 少し大きくして押しやすく */
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 14px;
  /* 丸みを強く */
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  /* 影を追加 */
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  background-color: var(--accent-hover);
}

.save-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.next-chapter-btn {
  width: 100%;
  padding: 16px;
  margin-top: 24px;
  background-color: #f0f0f0;
  color: var(--text-main);
  border: 2px solid transparent;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.next-chapter-btn:hover {
  background-color: #e4e4e4;
}

.values-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  background: var(--bg-color);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.save-msg {
  text-align: center;
  color: var(--success);
  font-size: 15px;
  /* 少し大きく */
  font-weight: 700;
  /* 強調 */
  margin-top: 16px;
  padding: 12px;
  background-color: #e8f5e9;
  /* 背景色で目立たせる */
  border-radius: 8px;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.save-msg.show {
  opacity: 1;
  transform: translateY(0);
}

.print-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.2s;
  width: fit-content;
}

.print-btn:hover {
  border-color: var(--text-main);
  color: var(--text-main);
  background: #f0f0f0;
}

@media print {
  body {
    background-color: white !important;
    margin: 0;
    padding: 0;
  }

  header,
  .tabs,
  .save-btn,
  .next-chapter-btn,
  .print-btn,
  .save-msg,
  .date-display {
    display: none !important;
  }

  .app-container {
    padding: 0 !important;
    max-width: 100% !important;
    box-shadow: none !important;
  }

  .tab-content {
    display: none;
  }

  .tab-content.active {
    display: block !important;
  }

  .card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin-bottom: 20px !important;
  }

  .text-input,
  textarea,
  select {
    border: 1px solid #666 !important;
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }

  /* 印刷時は入力内容が見えないように透明にして、枠線だけ生かす（手書き用） */
  .text-input,
  textarea,
  select,
  .range-val {
    color: transparent !important;
  }

  /* プレースホルダー（入力してください等）を非表示にする */
  ::-webkit-input-placeholder {
    color: transparent !important;
  }

  ::-moz-placeholder {
    color: transparent !important;
  }

  :-ms-input-placeholder {
    color: transparent !important;
  }

  ::-ms-input-placeholder {
    color: transparent !important;
  }

  ::placeholder {
    color: transparent !important;
  }

  /* 初期値の「0」などを非表示にする（数値入力や特定の値がある場合） */
  input[type="number"],
  input[value="0"] {
    color: transparent !important;
  }

  /* スライダー本体と目盛りを印刷時に消す */
  .range-slider,
  input[type="range"],
  .range-labels {
    display: none !important;
    visibility: hidden !important;
  }

  /* 「強さ ( /10)」 のテキストは残す（手書きできるようにする） */
  div:has(> .range-slider) {
    display: block !important;
  }

  /* 現在の数値「5」などの部分だけ透明にする（手書き用の空白にする） */
  label span[id$="-range-val"] {
    color: transparent !important;
    /* ある程度の空白を確保 */
    display: inline-block;
    width: 15px;
  }

  textarea {
    min-height: 120px !important;
  }

  .step-box {
    border: 1px solid #ddd !important;
    background: white !important;
    page-break-inside: avoid;
  }

  select {
    -webkit-appearance: none;
    appearance: none;
  }
}

.usage-accordion {
  background-color: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 12px;
  margin: 0 20px 24px;
  padding: 16px;
}

.usage-accordion summary {
  font-weight: bold;
  font-size: 15px;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
  /* デフォルトの矢印を非表示 */
  display: flex;
  align-items: center;
  outline: none;
}

.usage-accordion summary::-webkit-details-marker {
  display: none;
}

.usage-accordion summary::after {
  content: "▼";
  font-size: 12px;
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.usage-accordion[open] summary::after {
  transform: rotate(-180deg);
}

.accordion-content {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed #ddd;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.accordion-content h4 {
  font-size: 14px;
  color: var(--text-main);
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.accordion-content p {
  margin: 0 0 16px 0;
}

.accordion-content p:last-child {
  margin-bottom: 0;
}

@media print {
  .usage-accordion {
    display: none !important;
  }
}

/* 閉じるボタン追加 */
.close-accordion-btn {
  display: block;
  width: fit-content;
  margin: 20px auto 0;
  padding: 8px 16px;
  background-color: #f0f0f0;
  color: var(--text-main);
  border: 1px solid #ccc;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.close-accordion-btn:hover {
  background-color: #e4e4e4;
}
