﻿/* 全体レイアウト */
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f7;
  color: #222;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #3949ab;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.title-wrap h1 {
  margin: 0;
  font-size: 20px;
}

.title-wrap h1[contenteditable="true"] {
  outline: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.4);
}

.top-controls {
  display: flex;
  gap: 8px;
}

.top-controls button {
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

#add-section {
  background: #ffca28;
}

#export-json {
  background: #26a69a;
  color: #fff;
}

#ifimport-json,
#import-json {
  background: #fff;
}

/* メインエリア */
.main-area {
  max-width: 960px;
  margin: 16px auto 40px;
  padding: 0 12px;
}

#sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* セクション */
.section {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 8px 12px 10px;
}

.section.dragging {
  opacity: 0.5;
  border-style: dashed;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.section-title {
  margin: 0;
  font-size: 18px;
}

.section-title[contenteditable="true"] {
  outline: none;
  padding: 2px 4px;
  border-radius: 4px;
}

.section-title[contenteditable="true"]:focus {
  background: #e3f2fd;
}

.section-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.section-tools button {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  cursor: pointer;
}

/* 折りたたみボタン */
.section-tools .toggle-fold {
  font-size: 14px;
  font-weight: bold;
  padding: 2px 6px;
}

/* セクション移動ボタン */
.section-tools .move-up,
.section-tools .move-down {
  padding: 2px 6px;
  font-size: 11px;
}

/* セクション本文 */
.section-body {
  margin-top: 6px;
}

/* 折りたたみ状態 */
.section.collapsed .section-body {
  display: none;
}

/* 進捗バー */
.progress-bar-wrap {
  width: 100%;
  background: #e0e0e0;
  height: 6px;
  border-radius: 999px;
  margin: 4px 0 8px;
  overflow: hidden;
}

.progress-bar {
  height: 6px;
  width: 0%;
  border-radius: 999px;
  background: #4caf50;
  transition: width 0.2s ease-out, background-color 0.2s ease-out;
}

/* 本文テキスト */
.section-text {
  padding: 4px 6px;
  border-radius: 4px;
  min-height: 20px;
  margin-bottom: 6px;
}

.section-text[contenteditable="true"] {
  outline: none;
}

.section-text[contenteditable="true"]:focus {
  background: #f0f4c3;
}

/* チェックリスト */
.checklist {
  list-style: none;
  padding-left: 0;
  margin: 4px 0 4px;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 4px;
}

.checklist li.dragging {
  opacity: 0.5;
  border: 1px dashed #9e9e9e;
}

.check-main {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 6px;
}

.check-main input[type="checkbox"] {
  transform: scale(1.1);
}

.item-text {
  flex: 1;
  min-height: 18px;
  padding: 2px 4px;
  border-radius: 3px;
}

.item-text[contenteditable="true"] {
  outline: none;
}

.item-text[contenteditable="true"]:focus {
  background: #fffde7;
}

.id-note {
  font-size: 10px;
  color: #999;
}

.delete-item {
  border: none;
  background: transparent;
  color: #e53935;
  cursor: pointer;
  font-size: 12px;
}

/* 小見出し */
.subsections {
  margin-top: 6px;
  border-top: 1px dashed #ddd;
  padding-top: 4px;
}

.subsection {
  border-radius: 6px;
  border: 1px solid #eee;
  padding: 4px 6px;
  margin-top: 4px;
  background: #fafafa;
}

.subsection.dragging {
  opacity: 0.5;
  border-style: dashed;
}

.subsection-title {
  margin: 0 0 2px;
  font-size: 15px;
}

.subsection-title[contenteditable="true"] {
  outline: none;
  border-radius: 4px;
  padding: 1px 3px;
}

.subsection-title[contenteditable="true"]:focus {
  background: #e3f2fd;
}

.subsection-tools {
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.subsection-tools button {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  cursor: pointer;
}
