/* system-techo-v3 基本スタイル
 * - body固定＋コンテナスクロール方式（iOS弾性バウンス対策）
 * - Sprint 1: Task タブ・モーダル・トースト・スピナーを追加
 */

/* ---------- 背景色テーマ ----------
 * 既定（紺）は従来と同じ色。テーマは data-theme で切り替える */
:root {
  --bg: #1e3a5f;
  --bg-deep: #1a3556;
  --surface: #25436c;
  --surface2: #2f5481;
  --field: #18304d;
  --head: #1e3a5f;
  --tabbar: #18304d;
  --fg: #f5f5f5;
  --muted: #aab8cc;
  --ov: 255 255 255;
  --accent: #7fd1b0;
  --field-deep: #16304f;
}
:root[data-kind="dark"][data-theme]:not([data-theme="navy"]) {
  --bg-deep: color-mix(in srgb, var(--bg) 82%, #000);
  --surface: color-mix(in srgb, var(--bg) 88%, #fff);
  --surface2: color-mix(in srgb, var(--bg) 78%, #fff);
  --field: color-mix(in srgb, var(--bg) 72%, #000);
  --head: var(--bg);
  --tabbar: color-mix(in srgb, var(--bg) 72%, #000);
  --field-deep: color-mix(in srgb, var(--bg) 76%, #000);
  --muted: color-mix(in srgb, #fff 68%, var(--bg));
}
:root[data-kind="light"] {
  --fg: #22262e;
  --ov: 0 0 0;
  --accent: #1b6e4c;
  --field-deep: color-mix(in srgb, var(--bg) 88%, #000);
  --bg-deep: color-mix(in srgb, var(--bg) 92%, #000);
  --surface: color-mix(in srgb, var(--bg) 62%, #fff);
  --surface2: color-mix(in srgb, var(--bg) 82%, #000);
  --field: color-mix(in srgb, var(--bg) 35%, #fff);
  --head: #2b3a4f;
  --tabbar: #223044;
  --muted: #5d6677;
}
:root[data-theme="black"] { --bg: #1c1c1e; }
:root[data-theme="green"] { --bg: #1f3b30; }
:root[data-theme="purple"] { --bg: #3a2a5c; }
:root[data-theme="wine"] { --bg: #4a2530; }
:root[data-theme="brown"] { --bg: #3d2f26; }
:root[data-theme="white"] { --bg: #f3f3f0; }
:root[data-theme="cream"] { --bg: #f8efd6; }
:root[data-theme="sky"] { --bg: #d9eaf8; }
:root[data-theme="mint"] { --bg: #d8f0e2; }
:root[data-theme="pink"] { --bg: #fadde6; }
:root[data-theme="lavender"] { --bg: #e6e0f7; }
/* 明るい背景では、色付き文字を濃くして読めるようにする */
:root[data-kind="light"] .task-status-doing { color: #0b6b5c; }
:root[data-kind="light"] .task-status-adjusting { color: #6a35a8; }
:root[data-kind="light"] .task-status-done { color: #1f55b8; }
:root[data-kind="light"] .habit-value.filled { color: #1b6e4c; background: rgba(27, 110, 76, 0.14); }
:root[data-kind="light"] .task-today h2 { color: #a35f00; }
:root[data-kind="light"] .task-item.is-done .task-title { color: var(--muted); }
:root[data-kind="light"] .task-title,
:root[data-kind="light"] .habit-label,
:root[data-kind="light"] .meal-day { color: var(--fg); }

/* メモの紙も、選んだ背景色に合わせる（紺は従来のロディア色のまま） */
:root[data-theme]:not([data-theme="navy"]) {
  --paper: var(--bg);
  --paper-ink: var(--fg);
  --paper-sub: var(--muted);
  --paper-line: rgb(var(--ov) / 0.2);
  --paper-input: rgb(var(--ov) / 0.08);
  --paper-btn: rgb(var(--ov) / 0.12);
}

/* 背景色の選択画面 */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 8px;
  padding: 16px 16px 20px;
}
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 11px;
  min-width: 0;
  white-space: nowrap;
}
.theme-chip {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: 2px solid rgb(var(--ov) / 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}
.theme-swatch.on .theme-chip {
  border: 3px solid #4d90fe;
}
.header-btns {
  display: flex;
  align-items: center;
}
.btn-theme {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  margin-right: 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* 虹色の輪（背景色ボタンのアイコン） */
.theme-ring {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, #ff3b5c, #ffb020, #e8e82a, #3ddc6a, #20c8e8, #4a7bff, #b04aff, #ff3b5c);
  -webkit-mask: radial-gradient(circle, transparent 0 7px, #000 8px);
  mask: radial-gradient(circle, transparent 0 7px, #000 8px);
}

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

/* iOS Safari の弾性バウンス完全対策
 * position:fixed だけでは不十分な場合があるため、html/bodyとも固定し
 * overscroll-behavior で連鎖スクロールも遮断する */
html,
body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  /* 縦スクロールとピンチ拡大だけ許可。画面全体が横に引っ張られるのを防ぐ
     （横方向のスワイプ操作はJS側で受けるので影響しない） */
  touch-action: pan-y pinch-zoom;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

#app-shell {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
}

#app-header {
  flex: 0 0 auto;
  padding-top: calc(env(safe-area-inset-top) + 10px);
  padding-bottom: 10px;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--head);
  color: #f5f5f5;
  border-bottom: 1px solid rgb(var(--ov) / 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#app-header h1 {
  font-size: 17px;
  font-weight: 600;
}

.btn-refresh {
  width: 56px;
  height: 40px;
  border-radius: 20px;
  border: 1px solid rgb(var(--ov) / 0.3);
  background: #4d90fe;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-refresh:active {
  background: #3a7ae0;
}

.btn-refresh svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

#tab-bar {
  flex: 0 0 auto;
  display: flex;
  background: var(--tabbar);
  border-bottom: 1px solid rgb(var(--ov) / 0.08);
}

.tab-btn {
  flex: 1;
  min-height: 48px;
  background: transparent;
  border: none;
  color: #aab8cc;
  font-size: 15px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: #4d90fe;
  background: rgba(77, 144, 254, 0.1);
}

.tab-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#scroll-container {
  flex: 1 1 auto;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.empty-hint {
  padding: 32px 20px;
  color: #99a7b8;
  text-align: center;
  line-height: 1.6;
}

/* ---------- Task Tab ---------- */

.task-tab {
  padding-bottom: 96px;
}

.task-controls {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 10px 12px;
  z-index: 5;
  border-bottom: 1px solid rgb(var(--ov) / 0.06);
}

.task-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.task-filter-row label {
  flex: 1;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--muted);
}

.task-filter-row select {
  min-height: 44px;
  background: var(--surface);
  border: 1px solid rgb(var(--ov) / 0.1);
  border-radius: 8px;
  padding: 0 10px;
  margin-top: 2px;
  font-size: 14px;
}

.task-group {
  padding: 8px 0;
}

.task-group h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 16px 6px;
  letter-spacing: 0.5px;
}

.task-items {
  list-style: none;
}

/* 今日やること: 橙の枠で囲み、前後に余白をとる */
.task-today {
  margin: 14px 10px 22px;
  padding: 0 0 4px;
  border: 2px solid #f2a33a;
  border-radius: 14px;
  background: rgba(242, 163, 58, 0.08);
  overflow: hidden;
}
.task-today h2 {
  color: #f2a33a;
  font-size: 14px;
}

/* ステータス表示: 左の帯と小さな札 */
.task-item-wrap.st-doing .task-item {
  box-shadow: inset 4px 0 0 #2fb5a0;
}
.task-item-wrap.st-adjusting .task-item {
  box-shadow: inset 4px 0 0 #b78be6;
}
.task-item-wrap.st-todo .task-item {
  box-shadow: inset 4px 0 0 #566b89;
}
.task-item-wrap.st-done .task-item {
  box-shadow: inset 4px 0 0 #4d90fe;
}
.task-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  flex: 0 0 auto;
  white-space: nowrap;
}
.task-status-todo {
  background: rgb(var(--ov) / 0.1);
  color: var(--muted);
}
.task-status-doing {
  background: rgba(47, 181, 160, 0.25);
  color: #5fe0cb;
}
.task-status-adjusting {
  background: rgba(183, 139, 230, 0.25);
  color: #d8b8ff;
}
.task-status-done {
  background: rgba(77, 144, 254, 0.25);
  color: #8ab8ff;
}
.task-status-archived {
  background: rgb(var(--ov) / 0.08);
  color: var(--muted);
}

.task-item-wrap {
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
  border-bottom: 1px solid rgb(var(--ov) / 0.06);
  min-height: 56px;
}

.task-row-action {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.task-row-del {
  right: -1px;
  background: #d95252;
}

.task-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  min-height: 56px;
  transition: transform 0.2s ease;
}

.task-item.is-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task-check {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  border: 2px solid #667a96;
  background: transparent;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  margin-top: 2px;
}

.task-check.checked {
  background: #4d90fe;
  border-color: #4d90fe;
}

.task-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.task-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-priority {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  flex: 0 0 auto;
  background: #566b89;
}

.task-priority.pri-high {
  background: #d95252;
}
.task-priority.pri-mid {
  background: #c88a3a;
}
.task-priority.pri-low {
  background: #4e7a5f;
}

.task-title {
  font-size: 15px;
  word-break: break-word;
}

.task-due {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.task-memo {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: #4d90fe;
  color: #fff;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 20;
}

/* ---------- Daily Tab ---------- */

.daily-tab {
  padding-bottom: 96px;
}

.daily-datenav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid rgb(var(--ov) / 0.06);
}

.daily-datenav .nav-btn {
  min-width: 48px;
  min-height: 44px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid rgb(var(--ov) / 0.1);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.daily-datenav .nav-date {
  flex: 1;
  min-height: 44px;
  background: transparent;
  color: var(--fg);
  border: 1px solid rgb(var(--ov) / 0.12);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.daily-allday {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.allday-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  min-height: 32px;
}

.allday-chip .ev-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allday-chip .ev-cal {
  font-size: 10px;
  opacity: 0.85;
  flex: 0 0 auto;
}

.daily-timeline-wrap {
  height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-top: 1px solid rgb(var(--ov) / 0.06);
  border-bottom: 1px solid rgb(var(--ov) / 0.06);
  background: var(--field-deep);
}

.daily-timeline {
  position: relative;
  height: 1152px; /* 24 * 48 */
  margin-left: 52px;
}

.hour-row {
  position: absolute;
  left: -52px;
  right: 0;
  height: 48px;
}

.hour-label {
  position: absolute;
  left: 0;
  top: -8px;
  width: 48px;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}

.hour-line {
  position: absolute;
  left: 52px;
  right: 0;
  top: 0;
  height: 1px;
  background: rgb(var(--ov) / 0.08);
}

.events-layer {
  position: absolute;
  inset: 0;
}

.event-block {
  position: absolute;
  left: 4px;
  right: 6px;
  border-radius: 4px;
  padding: 3px 6px;
  color: #fff;
  font-size: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  border-left: 3px solid rgba(0, 0, 0, 0.25);
}

.event-block .event-title {
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.event-block .event-time {
  font-size: 10px;
  opacity: 0.85;
  margin-top: 2px;
}

.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #ff5252;
  z-index: 2;
  pointer-events: none;
}

.now-line::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background: #ff5252;
}

.daily-related,
.daily-journal {
  padding: 12px 12px 8px;
  border-top: 1px solid rgb(var(--ov) / 0.05);
}

.daily-related h3,
.daily-journal h3 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.daily-task-list,
.daily-journal-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.daily-task-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border-radius: 6px;
  min-height: 44px;
}

.daily-task-item.is-done .task-title {
  text-decoration: line-through;
  color: var(--muted);
}

.daily-task-item.is-overdue {
  background: rgba(217, 82, 82, 0.15);
  border-left: 3px solid #d95252;
}

.daily-task-item.is-overdue .task-title {
  color: #ff8a8a;
}

.task-overdue-date {
  margin-left: auto;
  font-size: 11px;
  color: #d95252;
  white-space: nowrap;
}

.journal-item {
  padding: 10px;
  background: var(--surface);
  border-radius: 6px;
  min-height: 44px;
  cursor: pointer;
}

.journal-item .journal-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.journal-item .journal-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.journal-item .journal-body {
  font-size: 13px;
  color: #d9e1ec;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-hint-sm {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Memo Tab (iPhoneメモ風リスト) ---------- */

.memo-tab {
  padding-bottom: 96px;
}

.memo-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid rgb(var(--ov) / 0.06);
  background: var(--bg);
}

.memo-search-row {
  display: flex;
  gap: 8px;
}

.memo-search-row input[type="search"] {
  flex: 1;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid rgb(var(--ov) / 0.1);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--fg);
}

.memo-search-row select {
  min-height: 44px;
  background: var(--surface);
  border: 1px solid rgb(var(--ov) / 0.1);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--fg);
}

.memo-action-row {
  display: flex;
  gap: 6px;
}

.memo-action-row button {
  min-height: 44px;
  padding: 0 14px;
  background: var(--surface2);
  color: var(--fg);
  border: 1px solid rgb(var(--ov) / 0.12);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.memo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 96px;
}

.memo-date-header {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 8px 4px;
  letter-spacing: 0.5px;
  background: transparent;
}

.memo-row-wrap {
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
  border-radius: 8px;
  min-height: 56px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.memo-row-action {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.memo-row-pin {
  left: 0;
  background: #c89a3a;
}

.memo-row-del {
  right: -1px;
  background: #d95252;
}

.memo-row {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--surface);
  min-height: 56px;
  z-index: 1;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.memo-type-bar {
  flex: 0 0 auto;
  width: 4px;
  background: #4d90fe;
}

.memo-row-inner {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memo-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.memo-pin-icon {
  font-size: 13px;
  flex: 0 0 auto;
}

.memo-claude-badge {
  font-size: 10px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 8px;
  background: #1f5e3a;
  color: #c8f5d0;
  flex: 0 0 auto;
  letter-spacing: 0.02em;
}

.memo-detail-claude-badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: #1f5e3a;
  color: #c8f5d0;
  margin-left: 8px;
}

.memo-row-time {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
  min-width: 38px;
}

.memo-row-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.memo-row-preview {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-type {
  min-height: 56px;
  border-radius: 10px;
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-sort {
  background: var(--surface2) !important;
}

/* ---------- Memo Detail (全画面) ---------- */

.memo-detail {
  padding: 0 0 96px;
  display: flex;
  flex-direction: column;
}

.memo-detail-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid rgb(var(--ov) / 0.08);
}

.btn-back {
  min-height: 44px;
  padding: 0 12px;
  background: transparent;
  color: var(--fg);
  border: 1px solid rgb(var(--ov) / 0.2);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  flex: 0 0 auto;
}

.memo-detail-label {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  color: var(--fg);
  flex: 0 0 auto;
}

.memo-detail-time {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-take-sm {
  min-height: 44px;
  min-width: 60px;
  padding: 0 12px;
  background: #4d90fe;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}

.memo-detail-title {
  padding: 16px 16px 4px;
  font-size: 19px;
  font-weight: 700;
  color: var(--fg);
  word-break: break-word;
}

.memo-detail-tags {
  padding: 4px 16px;
  font-size: 12px;
  color: #8fb8f0;
}

.memo-detail-body {
  padding: 12px 16px 24px;
  font-size: 15px;
  line-height: 1.7;
  color: #e0e8f4;
  white-space: pre-wrap;
  word-break: break-word;
}

.memo-detail-body a {
  color: #8fb8f0;
  word-break: break-all;
}

.memo-detail-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgb(var(--ov) / 0.08);
}

.memo-detail-footer button {
  flex: 1;
  min-height: 44px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.modal header {
  padding: 16px 20px 10px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid rgb(var(--ov) / 0.08);
}

.modal-body {
  padding: 14px 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  min-height: 44px;
  background: var(--field);
  border: 1px solid rgb(var(--ov) / 0.1);
  border-radius: 8px;
  padding: 10px;
  font-size: 15px;
  color: var(--fg);
}

.modal-body textarea {
  min-height: 80px;
  resize: vertical;
}

.modal footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgb(var(--ov) / 0.08);
}

.modal button {
  min-height: 44px;
  border-radius: 8px;
  border: none;
  padding: 0 14px;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary {
  background: #4d90fe;
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgb(var(--ov) / 0.15) !important;
}
.btn-danger {
  background: #d95252;
  color: #fff;
}

/* ---------- Toast ---------- */

/* トーストはタブバーをブロックしないよう最上部（safe-area直下）に配置 */
#toast-root {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 4px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 200;
}

.toast {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  max-width: 88vw;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s;
}

.toast-fadeout {
  opacity: 0;
}
.toast-success {
  background: rgba(46, 125, 72, 0.95);
}
.toast-error {
  background: rgba(180, 60, 60, 0.95);
}
.toast-warn {
  background: rgba(180, 130, 40, 0.95);
}

/* ---------- Spinner ---------- */

#spinner-root {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  border: 3px solid rgb(var(--ov) / 0.2);
  border-top-color: #4d90fe;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- タブ5つ対応 ---------- */
.tab-btn {
  font-size: 14px;
  padding: 0 2px;
}

/* ---------- 長押し並べ替え（共通） ---------- */
.reorder-placeholder {
  opacity: 0.25;
}
.reorder-ghost {
  background: #2d4f7c !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  opacity: 0.96;
  list-style: none;
}
.reorder-active,
.reorder-active *,
.habit-item,
.habit-item *,
.task-item-wrap,
.task-item-wrap *,
.memo-group,
.memo-group *,
.memo-row-wrap,
.memo-row-wrap *,
.tab-btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- Task: ピン留め ---------- */
.task-row-pinhint {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e08a3a;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

/* ---------- 習慣タブ ---------- */
.habit-tab,
.meal-tab {
  padding: 0 12px 40px;
}
.habit-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  background: var(--bg);
}
.habit-nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: 1px solid rgb(var(--ov) / 0.2);
  background: var(--surface);
  font-size: 22px;
  cursor: pointer;
}
.habit-nav-spacer {
  width: 44px;
}
.habit-date {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}
.habit-today {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 22px;
  border: 1px solid rgb(var(--ov) / 0.2);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}
.habit-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 14px 14px;
  margin-top: 12px;
}
.habit-card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin: 4px 0 6px;
}
.habit-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.habit-edit-btn {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 22px;
  border: 1px solid rgba(127, 209, 176, 0.5);
  background: rgba(127, 209, 176, 0.18);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}
.habit-nav {
  gap: 6px;
}
.habit-date {
  white-space: nowrap;
  font-size: 16px;
}
.habit-list {
  list-style: none;
}
.habit-item,
.habit-sleep {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 0;
  border-bottom: 1px solid rgb(var(--ov) / 0.07);
}
.habit-item:last-child {
  border-bottom: none;
}
.habit-icon {
  width: 28px;
  text-align: center;
  font-size: 22px;
}
.habit-label {
  flex: 1;
  font-size: 16px;
}
.habit-value {
  min-width: 110px;
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: rgb(var(--ov) / 0.06);
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  cursor: pointer;
}
input.habit-value {
  width: 112px;
  min-width: 0;
  padding: 0 8px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
input.habit-value::placeholder {
  color: var(--muted);
}
.habit-unit-out {
  flex: 0 0 34px;
  width: 34px;
  font-size: 12px;
  color: var(--muted);
  margin-left: 0;
  margin-right: -4px;
  white-space: nowrap;
  overflow: hidden;
}
.habit-clear {
  flex: 0 0 28px;
  width: 28px;
  height: 44px;
  border: none;
  background: transparent;
  padding: 0;
}
.habit-clear img {
  display: block;
  margin: 0 auto;
  width: 24px;
  height: 24px;
}
.habit-clear[hidden] {
  display: block;
  visibility: hidden;
}
input.habit-value {
  flex: 0 0 104px;
  width: 104px;
}
.habit-value.filled {
  background: rgba(127, 209, 176, 0.18);
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
}
.habit-unit {
  margin-left: 3px;
  font-size: 12px;
  font-weight: 400;
}
.habit-sleep-val {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(127, 209, 176, 0.18);
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
}
.habit-check-row {
  cursor: pointer;
}
.habit-check {
  width: 34px;
  height: 34px;
  border-radius: 17px;
  border: 2px solid rgba(127, 209, 176, 0.4);
  background: transparent;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.habit-check.on {
  background: #34c759;
  border-color: #34c759;
}
.habit-del {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  border: none;
  background: #d95252;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.habit-add {
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
}
.habit-hint {
  padding: 10px 4px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 食事タブ ---------- */
.meal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.meal-wd {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
}
.meal-cell {
  position: relative;
  min-height: 52px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.meal-cell.blank {
  background: transparent;
  cursor: default;
}
.meal-cell.today {
  outline: 2px solid #4d90fe;
}
.meal-day {
  font-size: 15px;
}
.meal-dot {
  position: absolute;
  bottom: 7px;
  left: 50%;
  width: 7px;
  height: 7px;
  margin-left: -3px;
  border-radius: 50%;
  background: #7fd1b0;
}
.meal-slot {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 14px 14px;
  margin-top: 12px;
}
.meal-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.meal-slot-head h2 {
  font-size: 16px;
  font-weight: 600;
}
.meal-time-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}
.meal-time {
  min-height: 44px;
  width: 130px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgb(var(--ov) / 0.12);
  background: var(--field);
  color: var(--fg);
  font-size: 17px;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}
.meal-time-clear {
  width: 32px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}
.meal-time-clear[hidden] {
  display: none;
}
.meal-text {
  width: 100%;
  min-height: 192px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgb(var(--ov) / 0.1);
  background: var(--field);
  color: var(--fg);
  font-size: 16px;
  resize: vertical;
}

/* ---------- Memo: ロディアのブロックメモ風 ----------
 * 生成り色の紙に、薄い青紫の罫線。上端にオレンジの帯。
 * 罫線は行の高さ(32px)に合わせ、文字が線の上に乗るようにしている */
:root {
  --paper: #fbfaf4;
  --paper-line: #c9cde4;
  --paper-ink: #2b2b3a;
  --paper-sub: #7c8199;
  --paper-orange: #f26b1d;
}
.memo-tab,
.memo-detail {
  background: var(--paper);
  min-height: 100%;
}
/* 紙の色を画面の下まで届かせる */
#scroll-container:has(.memo-tab),
#scroll-container:has(.memo-detail) {
  background: var(--paper);
}
.memo-controls {
  background: var(--paper);
  border-top: 5px solid var(--paper-orange);
  border-bottom: 1px solid var(--paper-line);
}
.memo-search-row input[type="search"] {
  background: var(--paper-input, #fff);
  border: 1px solid var(--paper-line);
  color: var(--paper-ink);
}
.memo-action-row button,
.btn-sort {
  background: var(--paper-btn, #efeadb) !important;
  color: var(--paper-ink) !important;
  border: 1px solid var(--paper-line) !important;
}
.memo-list {
  gap: 0;
  padding: 0 0 96px;
}
.memo-date-header {
  color: var(--paper-orange);
  background: var(--paper);
  padding: 14px 14px 4px;
  border-bottom: 1px solid var(--paper-line);
}
.memo-row-wrap {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border-bottom: 1px solid var(--paper-line);
}
.memo-row {
  background: var(--paper);
}
.memo-row-inner {
  padding: 10px 14px;
}
.memo-row-time {
  color: var(--paper-sub);
}
.memo-row-title {
  color: var(--paper-ink);
  font-weight: 500;
}
.memo-row-preview {
  color: var(--paper-sub);
}
.memo-detail-header {
  background: var(--paper);
  border-top: 5px solid var(--paper-orange);
  border-bottom: 1px solid var(--paper-line);
}
.memo-detail-header .btn-back {
  color: var(--paper-ink);
  border-color: var(--paper-line);
}
.memo-detail-time {
  color: var(--paper-sub);
}
.memo-detail-title {
  color: var(--paper-ink);
  padding-bottom: 8px;
}
.memo-detail-tags {
  color: var(--paper-sub);
}
.memo-detail-footer {
  background: var(--paper);
  border-top: 1px solid var(--paper-line);
}
.memo-detail-footer .btn-ghost {
  color: var(--paper-ink);
  border-color: var(--paper-line) !important;
}
.memo-paper {
  font-size: 16px;
  line-height: 32px;
  color: var(--paper-ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    var(--paper-line) 31px,
    var(--paper-line) 32px
  );
  background-attachment: local;
}
.memo-detail-body.memo-paper {
  padding: 0 16px 24px;
  min-height: 60vh;
}
.memo-detail-body.memo-paper a {
  color: #3b5bdb;
}
.memo-backdrop {
  align-items: flex-start;
  padding-top: env(safe-area-inset-top);
}
/* 画面いっぱいに表示する（キーボードが出たら残りの高さに合わせる） */
.memo-backdrop {
  padding-top: 0;
  background: var(--paper);
}
.memo-backdrop .memo-modal {
  max-width: none;
  width: 100%;
  height: var(--memo-h, 100dvh);
  max-height: none;
  border-radius: 0;
  border-top: 5px solid var(--paper-orange);
  padding-top: env(safe-area-inset-top);
  padding-bottom: 0;
}
.memo-backdrop .memo-modal-body {
  flex: 1 1 auto;
  min-height: 0;
}
.memo-backdrop .modal-body textarea.memo-paper-input {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
.memo-modal {
  background: var(--paper);
  border-top: 5px solid var(--paper-orange);
  color: var(--paper-ink);
}
.memo-modal header {
  border-bottom: 1px solid var(--paper-line);
}
.memo-modal .btn-ghost {
  color: var(--paper-ink);
  border-color: var(--paper-line) !important;
}
.modal-body textarea.memo-paper-input {
  min-height: 288px;
  padding: 0 12px;
  border: none;
  border-radius: 0;
  color: var(--paper-ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    var(--paper-line) 31px,
    var(--paper-line) 32px
  );
  background-attachment: local;
  resize: none;
}
.modal-body .memo-title-input {
  background: var(--paper-input, #fff);
  border: 1px solid var(--paper-line);
  color: var(--paper-ink);
}

/* 習慣：加算ボタン・項目編集 */
.habit-plus {
  flex: 0 0 28px;
  width: 28px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
}
.ed-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.icon-opt {
  height: 38px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--field);
  font-size: 20px;
  padding: 0;
}
.icon-opt.sel { border-color: var(--accent); }

/* 入力欄は16px以上にする（iPhoneは小さい文字の欄を押すと画面を拡大し、横にずれたままになる） */
input,
select,
textarea {
  font-size: 16px !important;
}

/* ---------- メモ：一覧（すべて左端をそろえる） ---------- */
.memo-row-inner {
  padding: 10px 14px;
  gap: 2px;
}
.memo-row-head {
  gap: 6px;
}
.memo-row-title {
  font-size: 16px;
  font-weight: 600;
}
.memo-row-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.memo-row-time {
  min-width: 0;
  font-size: 12px;
}
.memo-pin-icon {
  margin-left: auto;
  font-size: 12px;
}

/* ---------- メモ：詳細（開いてすぐ書ける） ---------- */
.memo-tools {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--paper-line);
  background: var(--paper);
  position: sticky;
  top: 61px;
  z-index: 4;
}
.memo-tool {
  flex: 1;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--paper-line);
  background: var(--paper-btn, #efeadb);
  color: var(--paper-ink);
  font-size: 13px;
  padding: 0 4px;
}
.memo-detail-title-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid var(--paper-line);
  background: var(--paper);
  color: var(--paper-ink);
  padding: 8px 16px;
  font-weight: 700;
  border-radius: 0;
}
textarea.memo-detail-text {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0 16px;
  border: none;
  border-radius: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  font: 16px/32px -apple-system, "Hiragino Sans", sans-serif;
  color: var(--paper-ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    var(--paper-line) 31px,
    var(--paper-line) 32px
  );
  background-origin: padding-box;
  background-position: 0 0;
  background-attachment: scroll;
  -webkit-appearance: none;
  appearance: none;
}
.memo-atts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
}
.memo-att {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.memo-att-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid var(--paper-line);
}
.memo-att-file {
  flex: 1;
  text-align: left;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--paper-line);
  background: var(--paper-btn, #efeadb);
  color: var(--paper-ink);
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.memo-att-rm {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
}
.memo-att-file + .memo-att-rm {
  position: static;
  flex: 0 0 auto;
}
.memo-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.memo-viewer img {
  max-width: 100%;
  max-height: 100%;
}

.habit-total {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}

/* 習慣：入力・グラフ・履歴の切り替え */
.habit-subtabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
}
.habit-sub {
  flex: 1;
  min-height: 38px;
  border-radius: 19px;
  border: 1px solid rgb(var(--ov) / 0.2);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
.habit-sub.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1b2a;
  font-weight: 600;
}
.habit-stats { padding: 12px; }
.chart-c {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.chart-t { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.chart-c canvas { display: block; width: 100%; height: 160px; }
.chart-s {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
.chart-s span { color: var(--fg); font-weight: 600; margin-left: 2px; }
.hist-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
}
.hist-d { flex: 0 0 84px; font-weight: 600; }
.hist-v { font-size: 12px; color: var(--muted); }

.habit-ranges {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
}
.habit-range {
  flex: 1;
  min-height: 32px;
  border-radius: 16px;
  border: 1px solid rgb(var(--ov) / 0.2);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.habit-range.on {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.habit-cum {
  display: block;
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
}
.habit-cum:empty {
  display: none;
}

.memo-wrap {
  position: relative;
}
.memo-strike {
  position: absolute;
  inset: 0;
  padding: 0 16px;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
  font: 16px/32px -apple-system, "Hiragino Sans", sans-serif;
  color: transparent;
}
.memo-strike .done {
  text-decoration: line-through;
  text-decoration-color: var(--paper-ink);
  text-decoration-thickness: 1.5px;
}

/* メモ詳細：入力欄を画面の残りいっぱいに。入力欄の中だけがスクロールする */
#scroll-container:has(.memo-detail) {
  overflow: hidden;
}
.memo-detail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.memo-detail > * {
  flex: 0 0 auto;
}
.memo-detail .memo-tools {
  position: static;
}
.memo-detail .memo-wrap {
  flex: 1 1 auto;
  min-height: 0;
}
.memo-detail textarea.memo-detail-text {
  position: absolute;
  inset: 0;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.memo-detail .memo-strike {
  overflow: hidden;
}
.memo-detail .memo-atts {
  max-height: 30%;
  overflow-y: auto;
}
/* キーボードが出ている間は、削除ボタンを隠す（誤タップ防止） */
#app-shell.kb-on .memo-detail-footer {
  display: none;
}

/* 罫線は入力欄の外側の枠に描き、文字のスクロールに合わせて動かす
   （入力欄の中の背景は、入力中にiPhoneが描き損ねるため） */
.memo-detail .memo-wrap {
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    var(--paper-line) 31px,
    var(--paper-line) 32px
  );
  background-position: 0 var(--paper-scroll, 0px);
}
.memo-detail textarea.memo-detail-text {
  background: transparent;
}

/* メモ詳細の上2段を詰めて、書く欄を広げる（キーボードが出ても7行ほど見える） */
.memo-detail .memo-detail-header {
  padding: 4px 12px;
}
.memo-detail .memo-detail-header .btn-back {
  min-height: 32px;
}
.memo-detail .memo-tools {
  padding: 4px 12px;
}
.memo-detail .memo-tool {
  min-height: 32px;
}
.memo-detail .memo-atts:empty {
  display: none;
}
/* キーボードが出ている間は、下の余白をなくして書く欄に回す */
#app-shell.kb-on .memo-detail {
  padding-bottom: 0;
}

/* ===== メモ詳細：画面いっぱいの書く画面 =====
   上の見出しとタブを隠し、メモだけを全面に出す。
   書く欄の高さは最初から「キーボードの上端まで」に決めてあり、キーボードが出ても動かない */
.memo-detail {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  overflow: hidden;
  /* 上の位置は、一覧のオレンジの線と同じ高さ（見出しとタブの下）。JSが測って入れる */
  top: 190px;
  box-sizing: border-box;
}
.memo-detail .memo-detail-header {
  padding: 6px 12px;
}
.memo-detail .memo-detail-header .btn-back {
  min-height: 40px;
  font-size: 16px;
}
.memo-detail .memo-tools {
  padding: 6px 12px;
  gap: 8px;
}
.memo-detail .memo-tool {
  min-height: 40px;
  font-size: 15px;
}
.memo-detail .memo-wrap {
  flex: 0 0 auto;
}
.memo-detail .memo-atts,
.memo-detail .memo-detail-footer {
  flex: 0 0 auto;
}
.memo-detail .memo-detail-footer {
  padding: 12px 16px;
}

/* チェック欄（☐ ☑）だけを大きく表示する。他の文字は変えない */
@font-face {
  font-family: "TechoCheck";
  src: local("Apple Symbols"), local("Hiragino Sans"), local("Arial Unicode MS");
  unicode-range: U+2610-2611;
  size-adjust: 165%;
}
textarea.memo-detail-text,
.memo-strike {
  font-family: "TechoCheck", -apple-system, "Hiragino Sans", sans-serif;
}
/* カーソル（青い棒）：iPhone標準は高さが罫線と合わないため隠し、罫線の幅（32px）ぴったりの棒を自前で描く */
textarea.memo-detail-text {
  caret-color: transparent;
}
.memo-strike .caret {
  display: inline-block;
  position: relative;
  width: 0;
  height: 32px;
  vertical-align: top;
}
.memo-strike .caret::after {
  content: "";
  position: absolute;
  left: -1px;
  top: 0;
  width: 2px;
  height: 32px;
  background: #1a7aff;
  animation: techo-caret 1.1s step-end infinite;
}
@keyframes techo-caret {
  50% {
    opacity: 0;
  }
}

/* ===== アーカイブ：左スワイプで「アーカイブ」と「削除」の2つ（削除は端に離して置く） ===== */
.memo-row-del {
  width: 88px;
}
.memo-row-arch {
  right: 99px;
  width: 88px;
  background: #6b7a90;
}
.memo-detail-footer {
  display: flex;
  gap: 12px;
}
.memo-detail-footer button {
  flex: 1 1 0;
}
