:root {
  --bg: #f6efe2;
  --card: #fffaf1;
  --ink: #26323f;
  --sub: #6b7480;
  --line: #e4d9c6;
  --navy: #2e4057;
  --accent: #d66e40;
  --accent-soft: #f6dccd;
  --ok: #3f7d5c;
  --danger: #b0473a;
  --tab-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1f24;
    --card: #252a31;
    --ink: #ece6da;
    --sub: #a3a9b1;
    --line: #363c45;
    --navy: #9fb6d3;
    --accent: #e8875c;
    --accent-soft: #4a3329;
    --ok: #7cc39c;
    --danger: #e17d6f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
}

h1 { font-size: 22px; margin: 4px 0 2px; letter-spacing: .02em; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.date { color: var(--sub); font-size: 14px; }
.note { color: var(--sub); font-size: 14px; margin: 6px 0; }
.empty { color: var(--sub); font-size: 14px; padding: 12px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
}

/* 家／外 切りかえ */
.seg {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-top: 14px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--sub);
  font: inherit;
  font-size: 15px;
  padding: 8px 4px;
  border-radius: 9px;
}
.seg button.on { background: var(--navy); color: var(--bg); font-weight: 600; }

.prompt {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.55;
  margin: 2px 0 12px;
}
.prompt.free { color: var(--accent); }
.prompt-label { font-size: 12px; color: var(--sub); letter-spacing: .08em; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

button.btn, label.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
}
button.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  width: 100%;
  padding: 13px;
  font-size: 16px;
}
button.btn:disabled { opacity: .4; }
button.link {
  border: 0; background: none; color: var(--navy); font: inherit; font-size: 14px;
  padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
button.del {
  border: 0; background: none; color: var(--sub); font-size: 13px; padding: 4px 6px; cursor: pointer;
}

textarea, input[type=text] {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
}
textarea { min-height: 72px; }
textarea:focus, input:focus { outline: 2px solid var(--navy); outline-offset: 1px; }

.photo-in { display: none; }
.preview { position: relative; margin: 10px 0; }
.preview img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; display: block; }
.preview button {
  position: absolute; top: 8px; right: 8px;
  border: 0; border-radius: 99px; background: rgba(0,0,0,.55); color: #fff;
  padding: 4px 10px; font-size: 13px;
}

/* メモの一覧 */
.entry {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.entry:first-child { border-top: 0; }
.entry img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.entry .body { flex: 1; min-width: 0; }
.entry .text { white-space: pre-wrap; word-break: break-word; }
.entry .meta { font-size: 12px; color: var(--sub); margin-top: 2px; }
.tag {
  display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); margin-right: 4px;
}
.entry.pick { cursor: pointer; border-radius: 10px; padding: 12px 8px; }
.entry.pick:active { background: var(--accent-soft); }

/* 週1 */
.step { margin: 22px 0 6px; }
.step-no {
  display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center;
  border-radius: 99px; background: var(--navy); color: var(--bg); font-size: 13px; font-weight: 700;
  margin-right: 6px;
}
.step h3 { display: inline; font-size: 16px; }
.q { font-size: 14px; color: var(--sub); margin: 10px 0 4px; }
.angle {
  font-size: 18px; font-weight: 700; color: var(--accent); margin: 6px 0 8px;
}
.dig { border-top: 1px solid var(--line); padding: 10px 0; font-size: 14px; }
.dig:first-child { border-top: 0; }
.dig dt { color: var(--sub); font-size: 12px; margin-top: 4px; }
.dig dd { margin: 0 0 2px; white-space: pre-wrap; word-break: break-word; }

/* 見比べ */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.col { min-width: 0; }
.col h3 { font-size: 14px; margin: 0 0 4px; }
.col .range { font-size: 11px; color: var(--sub); margin-bottom: 6px; }
.col .entry { flex-direction: column; gap: 6px; padding: 10px 0; }
.col .entry img { width: 100%; height: 90px; }
.col .entry .text { font-size: 14px; }
.check { list-style: none; padding: 0; margin: 0; }
.check li { padding: 8px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.check li:first-child { border-top: 0; }
.check b { white-space: nowrap; }

/* タブ */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabs button {
  flex: 1; height: var(--tab-h);
  border: 0; background: none; color: var(--sub);
  font: inherit; font-size: 14px;
}
.tabs button.on { color: var(--accent); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%) translateY(10px);
  background: var(--navy); color: var(--bg);
  padding: 8px 16px; border-radius: 99px; font-size: 14px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
