body {
  display: flex;
  flex-direction: column;
  min-width: 1000px;
  overflow: hidden;
}

/* ヘッダー */
.header {
  height: 60px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}
.date-title {
  margin: 0 8px 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .01em;
  min-width: 170px;
}
.date-title small {
  font-size: 20px;
  font-weight: 400;
  color: var(--sub);
  margin-left: 6px;
}
.spacer { flex: 1; }
/* 週表示・月表示のフィルター（表示するカレンダーの切り替えを開く） */
/* 正方形だと隣のボタンより背が高く見えるので、横長にしてそろえて見せる（高さはどれも34px） */
.btn.filter-btn { color: var(--sub); width: 44px; }
/* 今日を表示中の「今日」と、開いているフィルターは、「日・週・月」の選択中と同じ見た目：
   灰色の枠の内側に2pxの余白をあけて、ピンクの背景に白 */
#todayBtn.on, .btn.filter-btn.on, .btn.rec-toggle.on {
  border-color: var(--line);
  background: var(--pink);
  box-shadow: inset 0 0 0 2px var(--surface);
  color: #fff;
  font-weight: 700;
}
#todayBtn.on:hover, .btn.filter-btn.on:hover, .btn.rec-toggle.on:hover { background: #D93879; }
#todayBtn:focus, .btn.filter-btn:focus, .btn.rec-toggle:focus { outline: none; }
.segmented {
  display: inline-flex;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 4px;
  min-width: 36px;
  padding: 0 10px;
}
.segmented button.selected {
  background: var(--pink);
  color: #fff;
  font-weight: 700;
}
.sync-status {
  color: var(--sub);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}
.sync-status .mono { font-size: 12px; }
.sync-status.clickable { cursor: pointer; border-radius: 4px; padding: 4px 6px; }
.sync-status.clickable:hover { background: var(--surface); }
.sync-status.error { color: #C23B3F; }

/* メイン */
.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 560px;
  gap: 20px;
  padding: 13px 22px 16px;
}

/* タイムライン */
.timeline-card {
  background: var(--field);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tl-head {
  flex: none;
  height: 38px;
  display: grid;
  grid-template-columns: 64px 1fr 1fr;
  column-gap: 10px;
  padding-right: 22px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  color: var(--sub);
}
.tl-head > div:not(:first-child) { padding-left: 4px; }
/* スケジュール列の見出し：今日と過去の日は右端の「実績」で実績の列を開ける */
.sched-head { display: flex; align-items: center; gap: 10px; }
.sched-head .rec-toggle { margin-left: auto; }
.rec-toggle.btn { height: 26px; padding: 0 12px; font-size: 12px; font-weight: 500; color: var(--sub); }
/* 実績の見出しの右側：起きている時間のうち記録で埋まっている割合（ストックの見出しと同じ形の小さい版） */
.rec-sum { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-weight: 400; cursor: default; }
.rec-sum b { font-family: var(--mono); font-size: 15px; color: var(--text); font-weight: 700; }
.rec-sum i { display: block; width: 72px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.rec-sum u { display: block; height: 100%; background: var(--pink); }
/* 実績のブロック。計測中のものは点線の枠 */
.block.rec .block-title { font-weight: 500; }
.block.rec.live { border-style: dashed; cursor: default; opacity: .85; }
/* 1日の埋まり具合（ストックの見出し） */
.day-fill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--sub);
  white-space: nowrap;
  cursor: default;
}
.day-fill b { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--text); min-width: 44px; }
.day-fill i { display: block; width: 160px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.day-fill u { display: block; height: 100%; background: var(--pink); }
.day-fill span { font-family: var(--mono); font-size: 12px; }
.tl-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.tl-body {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr 1fr;
  column-gap: 10px;
  padding-right: 14px;
}
.tl-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hour-line {
  position: absolute;
  left: 72px;
  right: 8px;
  border-top: 1px solid var(--line);
}
.hour-line.half { border-top: 1px dashed #DCDDE0; }
.hour-label {
  position: absolute;
  left: 0;
  width: 60px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--sub);
  transform: translateY(-50%);
}
.tl-col {
  position: relative;
  grid-row: 1;
}
#colSchedule { grid-column: 2; cursor: crosshair; }
#colTask { grid-column: 3; cursor: crosshair; }
/* 実績の列：開いているあいだはストックをたたみ、タイムラインを3列（スケジュール・タスク・実績）にする */
#colRecords { grid-column: 3; cursor: crosshair; display: none; }
.rec-head { display: none; }
body.show-records .main { grid-template-columns: 1fr; }
body.show-records .stock { display: none; }
body.show-records .tl-head, body.show-records .tl-body { grid-template-columns: 64px 1fr 1fr 1fr; }
body.show-records #colRecords { display: block; }
/* 実績はスケジュールとタスクのあいだ（3列目）。タスクは4列目へ */
body.show-records #colTask { grid-column: 4; }
body.show-records .tl-head > .rec-head { grid-column: 3; grid-row: 1; }
body.show-records .tl-head > .task-head { grid-column: 4; grid-row: 1; }
body.show-records .rec-head { display: flex; align-items: center; gap: 10px; }

.now-line {
  position: absolute;
  left: 60px;
  right: 8px;
  border-top: 1.5px solid var(--pink);
  pointer-events: none;
  z-index: 5;
  display: none;
}
.now-line::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -4.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pink);
}
.now-line span {
  position: absolute;
  right: calc(100% + 4px);
  top: -8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--pink-text);
  background: var(--field);
  padding-left: 4px;
}

/* 睡眠 */
.sleep-band {
  position: absolute;
  left: 72px;
  right: 8px;
  background: repeating-linear-gradient(135deg, rgba(78, 81, 89, .07) 0 6px, transparent 6px 12px);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sleep-chip {
  position: relative;
  z-index: 3;
  pointer-events: auto;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--sub);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 6px;
  font-family: var(--mono);
}
.sleep-chip:hover, .sleep-btn:hover { color: var(--text); background: var(--surface); }
.sleep-chip svg, .sleep-btn svg { width: 12px; height: 12px; }
.sleep-btn {
  border: 0;
  background: none;
  color: var(--sub);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.sleep-btn.custom { color: var(--pink-text); }
.sleep-pop .pop-when select { font-family: var(--mono); }
.sleep-pop .pop-when span { width: 64px; font-size: 13px; color: var(--text); }

/* 予定・タスクのブロック */
.block {
  position: absolute;
  border: 1px solid;
  border-radius: 4px;
  padding: 7px 11px;
  overflow: hidden;
  cursor: grab;
  z-index: 2;
}
.block:hover { filter: brightness(.985); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.block.dragging { opacity: .35; }
.block.moving { z-index: 6; box-shadow: 0 4px 12px rgba(0, 0, 0, .15); cursor: grabbing; }
.block-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  min-width: 0;
}
/* 幅が狭いときはタイトルを優先し、時刻は次の行へ回す */
.block-title {
  flex: 1 1 64px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.block.tiny .block-row { flex-wrap: nowrap; }
.block-time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  flex: none;
}
.block-src { color: var(--sub); font-size: 11px; flex: none; margin-left: auto; }
.block-src + .block-time { margin-left: 0; }
/* 短い予定・タスク（30分前後）は、1行を上下のまん中に置く */
.block.compact { padding-top: 2px; padding-bottom: 2px; display: flex; align-items: center; }
.block.compact .block-row { flex: 1; }
.block.compact .block-title { font-size: 12px; }
.block.tiny { padding: 0 8px; display: flex; align-items: center; }
.block.tiny .block-row { flex: 1; }
.block.tiny .block-title, .block.tiny .block-time { font-size: 10px; line-height: 1; }
.block.tiny .check { width: 9px; height: 9px; }
.block.tiny .check::after { width: 6px; height: 6px; }
.block.tiny .repeat-icon { width: 10px; height: 10px; }
.block.narrow .block-time, .block.narrow .block-src { display: none; }
.block.readonly { cursor: default; }
.block.readonly .resize { display: none; }
.block .resize {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
  cursor: ns-resize;
}
/* 下の端（終了時刻）はつかみやすいよう広め。上の端（開始時刻）は細め */
.block .resize.top { top: 0; bottom: auto; height: 7px; }
/* 短い予定は、上下のつまみがタイトルをふさがないよう細くする */
.block.tiny .resize { height: 6px; }
.block.tiny .resize.top { height: 4px; }
.block.task .block-title { font-weight: 500; }
.block.task.done .block-title { text-decoration: line-through; color: var(--sub); }
.block.task.done { opacity: .7; }
.repeat-icon { width: 13px; height: 13px; color: var(--sub); flex: none; }

/* タスクの完了チェック（色の丸を兼ねる） */
.check {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  flex: none;
  display: grid;
  place-items: center;
  position: relative;
}
.check::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}
.check:hover::after, .done .check::after {
  width: 13px;
  height: 13px;
}
.done .check::before, .check:hover::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: 3px;
  height: 6px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-1px) rotate(45deg);
}

/* 空き時間 */
.gap {
  position: absolute;
  left: 0;
  right: 0;
  border: 1px dashed var(--line);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  font-size: 12px;
  pointer-events: none;
  z-index: 1;
}

/* ドラッグ中のプレビュー */
.preview {
  position: absolute;
  left: 0;
  right: 0;
  border: 1.5px dashed var(--pink);
  border-radius: 4px;
  background: rgba(227, 66, 131, .06);
  z-index: 7;
  pointer-events: none;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pink-text);
  font-weight: 500;
}
.ghost {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
  font-size: 13px;
  white-space: nowrap;
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
/* ドラッグ中の時刻（マウスのそば） */
.drag-time {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.drag-time small { font-size: 11px; font-weight: 400; opacity: .75; }

/* ストック */
.stock {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  border-radius: 10px;
  transition: background .15s;
}
.stock.drop-target { background: rgba(227, 66, 131, .06); outline: 1.5px dashed var(--pink); outline-offset: -1px; }
.stock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
}
/* ストックは「ルーティン」「タスク」の2列。それぞれ「やること」「候補」 */
/* 「やること」「候補」は同じ高さ（列の残りを半分ずつ）で、それぞれの中だけスクロールする */
.stock-cols { height: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stock-col { min-height: 0; display: flex; flex-direction: column; }
.stock-col h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; flex: none; }
.stock-group { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; border-radius: 8px; transition: background .15s; }
.stock-group.drop-target { background: rgba(227, 66, 131, .06); outline: 1.5px dashed var(--pink); outline-offset: 2px; }
.stock-group + .stock-group { margin-top: 12px; }
.stock-group .group-head { flex: none; margin: 4px 0 8px; }
.group-list { flex: 1; min-height: 0; overflow-y: auto; margin-right: -6px; padding-right: 6px; }
.link {
  border: 0;
  background: none;
  color: var(--pink-text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  padding: 0;
}
.link svg { width: 14px; height: 14px; }
.stock-hint { margin: 10px 0 14px; color: var(--sub); font-size: 12px; }
.stock-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--sub);
  margin: 14px 0 10px;
}
.group-head:first-child { margin-top: 4px; }
.group-head button {
  border: 0;
  background: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: var(--sub);
}
.group-head button:hover { background: var(--surface); }
.group-head svg { width: 14px; height: 14px; }
.group-empty { color: var(--sub); font-size: 12px; opacity: .7; padding: 4px 2px 8px; }

.stock-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 0 10px 0 0;
  margin-bottom: 7px;
  background: var(--surface);
  border: 1px solid #CDCFD3;
  border-radius: 6px;
}
.stock-item.placed { opacity: .5; }
/* ルーティンの並べ替え：落とす位置にピンクの線 */
.stock-item { position: relative; }
.stock-item.drop-before::before, .stock-item.drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--pink);
}
.stock-item.drop-before::before { top: -5px; }
.stock-item.drop-after::after { bottom: -5px; }
.stock-item .handle {
  width: 26px;
  height: 100%;
  flex: none;
  display: grid;
  place-items: center;
  cursor: grab;
  color: #8A8D94;
  touch-action: none;
}
.stock-item .handle svg { width: 8px; height: 14px; }
.stock-item .handle:hover { color: var(--text); }
.stock-item .title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
.stock-item .dur { font-family: var(--mono); font-size: 12px; color: var(--sub); cursor: pointer; }
.stock-item .freq { font-size: 11px; color: var(--sub); background: var(--field); border-radius: 8px; padding: 1px 7px; white-space: nowrap; cursor: pointer; }
.stock-edit .edit-freq {
  grid-column: 1 / -1;
  padding-left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sub);
  font-size: 12px;
}
.stock-edit .edit-freq select {
  flex: 1;
  min-width: 0;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  padding: 0 6px;
  font-size: 12px;
}
.stock-edit .edit-freq .link { font-size: 12px; white-space: nowrap; flex: none; }
/* 「繰り返し」「時間」の見出しは折り返さず、同じ幅でそろえる */
.stock-edit .edit-label { width: 4em; flex: none; white-space: nowrap; }
/* 狭い列でも「完了」まで収まるよう、時間の−／＋を詰める。それでも入らないときは「完了」を次の行の右へ */
.stock-edit .edit-foot { gap: 6px; flex-wrap: wrap; }
.stock-edit .stepper { flex: none; gap: 3px; }
.stock-edit .dur-input {
  width: 80px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 0 2px;
  outline: none;
}
.stock-edit .dur-input:focus { border-color: var(--sub); }
.stock-edit .edit-foot .edit-label { width: auto; }
.stock-edit .edit-foot .btn { flex: none; padding: 0 10px; }
.stock-item .dot { width: 9px; height: 9px; cursor: pointer; margin-left: -4px; }

.stock-edit {
  background: var(--surface);
  border: 1.5px solid var(--pink);
  border-radius: 6px;
  padding: 10px 14px 12px 0;
  margin-bottom: 7px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  row-gap: 12px;
}
.stock-edit .handle { grid-row: 1; display: grid; place-items: center; color: #8A8D94; }
.stock-edit .handle svg { width: 8px; height: 14px; }
.stock-edit input[type=text] {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  padding: 0 10px;
  outline: none;
}
.stock-edit input[type=text]:focus { border-color: var(--sub); }
/* 2列のストックは狭いので、9色が右の余白を残して収まるよう少し小さくする */
.stock-edit .swatches { grid-column: 1 / -1; padding-left: 10px; justify-content: space-between; gap: 2px; }
.stock-edit .swatch { width: 24px; height: 24px; }
.stock-edit .swatch span { width: 14px; height: 14px; }
.stock-edit .edit-foot {
  grid-column: 1 / -1;
  padding-left: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sub);
  font-size: 12px;
}
.stock-edit .edit-foot .btn { margin-left: auto; height: 30px; }

.trash {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70px;
  border: 1.5px dashed #B6B8BD;
  border-radius: 8px;
  background: var(--surface);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--sub);
  z-index: 3;
}
.trash svg { width: 18px; height: 18px; }
.is-dragging .trash { display: flex; }
.trash.hot { border-color: #D9474B; color: #D9474B; background: #F9E3E4; }

/* ポップオーバー（予定・タスクの編集） */
.popover {
  position: fixed;
  z-index: 40;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.popover .pop-time { font-family: var(--mono); font-size: 12px; color: var(--sub); }
.popover input[type=text] {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  padding: 0 10px;
  outline: none;
}
/* 9色が幅に収まるよう間隔を詰め、残りは均等に配る */
.popover .swatches { justify-content: space-between; gap: 2px; }
.popover .pop-cal { font-size: 12px; color: var(--sub); margin-top: -4px; }
.popover .pop-cal b { color: var(--text); font-weight: 500; }
.popover .pop-foot { display: flex; gap: 8px; justify-content: flex-end; }
.popover.wide { width: 340px; }
.pop-when { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--sub); }
.pop-when input, .pop-when select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 12px;
}
.pop-when input[type=date] { width: 128px; }
.pop-when span { font-size: 12px; }
.popover .pop-foot .btn { height: 30px; }
.popover .danger { margin-right: auto; color: #C23B3F; }

/* 設定メニュー */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 29, 33, .28);
  z-index: 30;
  display: none;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  background: var(--bg);
  z-index: 31;
  transform: translateX(100%);
  transition: transform .2s ease;
  display: flex;
  flex-direction: column;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-backdrop { display: block; }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 14px;
}
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-head button { border: 0; background: none; width: 30px; height: 30px; display: grid; place-items: center; }
.drawer-head svg { width: 16px; height: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 24px 24px; }
.drawer h3 { font-size: 13px; color: var(--sub); margin: 18px 0 10px; }
.card {
  background: var(--field);
  border: 1px solid #CDCFD3;
  border-radius: 8px;
}
.card-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
}
.card-row + .card-row { border-top: 1px solid #D3D5D9; }
.card-row .label { flex: 1; }
.card-row .note { display: block; font-size: 11px; color: var(--sub); margin-top: 2px; }
.card-row select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 8px;
  font-family: var(--mono);
}
.card-row input[type=range] { width: 130px; accent-color: var(--pink); }
.card-row .value { font-family: var(--mono); font-size: 12px; width: 40px; text-align: right; }
.card-row .later { color: var(--sub); font-size: 12px; }
.card-row .value-text { color: var(--sub); font-size: 12px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-row.stack { flex-direction: column; align-items: stretch; gap: 6px; }
.card-row.stack input {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
.card-row.stack input:focus { border-color: var(--sub); }
.card-row.check-row { cursor: pointer; min-height: 48px; }
.cal-color {
  width: 26px;
  height: 26px;
  margin: 0 -4px 0 -8px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.cal-color .dot { width: 12px; height: 12px; }
.cal-color:hover { background: var(--surface); }
.cal-color.open { border-color: var(--text); }
.cal-color.static { cursor: inherit; }
.cal-color.static:hover { background: transparent; }
.card-row.color-cal-row { min-height: 46px; padding-top: 6px; padding-bottom: 6px; }
.color-cal-row .dot { width: 10px; height: 10px; }
.color-cal-row.unassigned .label, .color-cal-row.unassigned select { color: var(--sub); }
.card-row.cal-swatches { padding-top: 0; padding-left: 26px; min-height: 0; }
.card-row select.font-body { font-family: var(--font); max-width: 200px; }
.check-box {
  width: 18px;
  height: 18px;
  accent-color: var(--pink);
  cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.segmented.small { height: 30px; }
.segmented.small button { font-size: 12px; }

.toggle {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  border: 0;
  background: #B6B8BD;
  position: relative;
  flex: none;
  padding: 0;
  transition: background .15s;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left .15s;
}
.toggle.on { background: var(--pink); }
.toggle.on::after { left: 21px; }

/* ───────── 週表示・月表示 ───────── */
.cal-view { display: none; min-height: 0; }
body.view-cal .main { grid-template-columns: 1fr; }
body.view-cal .timeline-card, body.view-cal .stock { display: none; }
body.view-cal .cal-view { display: flex; flex-direction: column; }

.wk {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--field);
  border-radius: 10px;
  padding: 6px 16px 14px 0;
}
.wk-head, .wk-allday, .wk-body { display: grid; grid-template-columns: 64px 1fr; }
.wk-head { grid-template-columns: 64px repeat(7, 1fr); height: 46px; border-bottom: 1px solid var(--line); }
.wk-day {
  border: 0;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--sub);
  font-size: 13px;
}
.wk-day b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 15px;
  color: var(--text);
  min-width: 28px;
  height: 28px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.wk-day:hover b { background: var(--surface); }
.wk-day.today b { background: var(--pink); color: #fff; font-weight: 700; }
.wk-allday { border-bottom: 1.5px solid var(--line); padding: 5px 0; }
.wk-allday-label { font-size: 11px; color: var(--sub); text-align: right; padding-right: 10px; align-self: center; }
.wk-allday-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px 0; }
.wk-allday-item {
  margin: 0 3px;
  border: 1px solid;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  min-width: 0;
  cursor: pointer;
}
.wk-allday-item .dot { width: 7px; height: 7px; }
.t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wk-body { flex: 1; min-height: 0; margin-top: 9px; }
.wk-gutter, .wk-cols { position: relative; }
.wk-label {
  position: absolute;
  right: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--sub);
  transform: translateY(-50%);
}
.wk-cols { display: grid; grid-template-columns: repeat(7, 1fr); }
.wk-hour { position: absolute; left: 0; right: 0; border-top: 1px solid #D3D5D9; pointer-events: none; }
.wk-col { position: relative; border-left: 1px solid #D3D5D9; }
.wk-block, .mo-chip { cursor: pointer; }
.wk-col.today { background: var(--today); }
.wk-sleep {
  position: absolute;
  left: 0;
  right: 0;
  background: repeating-linear-gradient(135deg, rgba(78, 81, 89, .07) 0 6px, transparent 6px 12px);
  pointer-events: none;
}
.wk-block {
  position: absolute;
  margin: 1px 3px 0;
  border: 1px solid;
  border-radius: 4px;
  padding: 4px 7px;
  overflow: hidden;
  font-size: 12px;
  z-index: 1;
  max-width: calc(100% - 6px);
}
.wk-block .t { font-weight: 700; }
/* 週表示の予定：本体をドラッグで移動、上下の端で長さ（下の端は広め） */
.wk-block:not(.readonly) { cursor: grab; }
.wk-block.moving { z-index: 6; box-shadow: 0 4px 12px rgba(0, 0, 0, .15); }
.wk-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; cursor: ns-resize; }
.wk-resize.top { top: 0; bottom: auto; height: 6px; }
.wk-block.tiny .wk-resize { height: 5px; }
.wk-block.tiny .wk-resize.top { height: 3px; }
body.wk-dragging, body.wk-dragging * { cursor: grabbing !important; user-select: none; }
body.wk-dragging.wk-resizing, body.wk-dragging.wk-resizing * { cursor: ns-resize !important; }
.wk-block .time { font-family: var(--mono); font-size: 10.5px; margin-top: 1px; white-space: nowrap; }
.wk-block.short .time, .wk-block.tiny .time { display: none; }
.wk-block.tiny { padding: 0 6px; display: flex; align-items: center; }
.wk-block.tiny .t { font-size: 10px; line-height: 1; }
.wk-block:hover, .wk-allday-item:hover { filter: brightness(.97); }
.wk-now { position: absolute; left: -4px; right: 0; border-top: 1.5px solid var(--pink); z-index: 3; pointer-events: none; }
.wk-now::before {
  content: "";
  position: absolute;
  left: 0;
  top: -4.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pink);
}

.mo { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* 月表示の「表示するカレンダー」の切り替え */
.mo-filter { flex: none; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mo-filter-chip {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 12px;
}
.mo-filter-chip .dot { width: 8px; height: 8px; }
.mo-filter-chip.off { background: transparent; color: var(--sub); text-decoration: line-through; opacity: .6; }
.mo-filter-chip.off .dot { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--line); }
.mo-head { display: grid; grid-template-columns: repeat(7, 1fr); padding: 2px 0 8px; color: var(--sub); }
.mo-head div { padding-left: 10px; }
.mo-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}
.mo-cell {
  border: 0;
  background: var(--field);
  text-align: left;
  padding: 8px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.mo-cell { cursor: pointer; }
.mo-chip:hover { filter: brightness(.96); }
.mo-date:hover { background: var(--surface); }
.mo-cell.today .mo-date:hover { background: #D93879; }
.mo-cell.other { background: #DCDDE0; }
.mo-cell.other .mo-date { color: var(--sub); }
.mo-cell.today { background: var(--today); }
.mo-date {
  font-family: var(--mono);
  font-size: 13px;
  align-self: flex-start;
  min-width: 24px;
  height: 24px;
  margin: -2px 0 2px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}
.mo-cell.today .mo-date { background: var(--pink); color: #fff; font-weight: 700; padding: 0 4px; }
/* 日付の行：日付の右隣に終日の予定を並べる（入りきらない分は省略） */
.mo-top { display: flex; align-items: flex-start; gap: 8px; min-width: 0; flex: none; }
.mo-top .mo-date { flex: none; }
.mo-allday { flex: 1; min-width: 0; display: flex; gap: 5px; overflow: hidden; margin-top: -2px; }
.mo-chip.mo-chip-allday { flex: 0 1 auto; min-width: 0; height: 24px; padding: 0 10px; border-radius: 5px; color: #fff; font-weight: 700; }
.mo-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  flex: none;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 12px;
}
.mo-chip .dot { width: 7px; height: 7px; }
.mo-more { font-size: 11px; color: var(--sub); padding-left: 7px; }

/* タイマーの記録（日表示のタスク列の右端） */
.rec-bar {
  position: absolute;
  right: -10px;
  width: 5px;
  border-radius: 3px;
  background: var(--pink);
  opacity: .55;
  z-index: 3;
}
.rec-bar:hover { opacity: 1; }
.rec-bar.live { opacity: .9; }

/* カテゴリの選択（ストックの編集・ポップオーバー） */
.cat-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.stock-edit .cat-chips { grid-column: 1 / -1; padding-left: 10px; }
.cat-chip {
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  font-size: 12px;
}
.cat-chip .dot { width: 7px; height: 7px; }
.cat-chip.selected { border-color: var(--text); background: var(--surface); font-weight: 700; }
span.cat-chip { cursor: default; }
.stock-item .repeat-icon { margin-left: -6px; }

/* 設定のサブページ（カテゴリ・繰り返し） */
.drawer.wide { width: 820px; }
.drawer-head .crumb { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 700; margin: 0; }
.drawer-head .crumb span { color: var(--sub); font-weight: 500; }
.drawer-head .crumb i { font-style: normal; color: var(--sub); font-size: 14px; }
.drawer-head button.back { margin-left: -8px; }
.card-row.clickable { cursor: pointer; }
.card-row.clickable:hover { background: var(--surface); }
.card-row .chev { color: var(--sub); }
.card .cat-chips { padding: 14px 16px; }
.card .cat-chips + .card-row { border-top: 1px solid #D3D5D9; }
.cat-row .cname { color: var(--sub); font-size: 12px; }
.icon-btn {
  border: 0;
  background: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--sub);
  flex: none;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.form-card { padding: 16px; display: grid; gap: 10px; }
.form-card h4 { margin: 0 0 2px; font-size: 14px; }
.field-label { font-size: 12px; color: var(--sub); }
.text-input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 12px;
  outline: none;
  width: 100%;
}
.text-input:focus { border-color: var(--sub); }
.form-card .swatches, .rp-form .swatches { justify-content: space-between; }
.btn.full { width: 100%; height: 38px; }

.rp { display: grid; grid-template-columns: 300px 1fr; flex: 1; min-height: 0; border-top: 1px solid var(--line); }
.rp-list { padding: 14px 16px; overflow-y: auto; border-right: 1px solid var(--line); }
.rp-list-head { display: flex; gap: 8px; margin-bottom: 10px; }
.rp-list-head { align-items: center; }
.rp-list-title { flex: 1; font-weight: 700; color: var(--sub); }
.rp-list-head .segmented button { flex: 1; min-width: 0; padding: 0 4px; font-size: 12px; white-space: nowrap; }
.rp-item {
  width: 100%;
  border: 1.5px solid transparent;
  background: none;
  border-radius: 8px;
  text-align: left;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  column-gap: 10px;
  padding: 9px 12px;
}
.rp-item:hover { background: var(--surface); }
.rp-item.selected { border-color: var(--pink); background: var(--field); }
.rp-item .dot { width: 9px; height: 9px; }
.rp-item b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-item small { color: var(--sub); font-family: var(--mono); font-size: 11px; }
.rp-item .kind { color: var(--sub); font-size: 11px; }
.rp-empty { color: var(--sub); font-size: 12px; padding: 12px 4px; line-height: 1.7; }
.rp-form { padding: 6px 22px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.rp-form .field-label { margin-top: 12px; font-weight: 700; }
.rp-form .note { font-size: 12px; color: var(--sub); }
.rp-form .note.warn { color: #C23B3F; }
.rp-form .segmented { align-self: flex-start; }
.rp-form .segmented button { min-width: 64px; }
.dow-picks { display: flex; gap: 8px; }
.dow-picks button {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--field);
}
.dow-picks button.selected { background: var(--pink); border-color: var(--pink); color: #fff; font-weight: 700; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline select, .inline input[type=date], .inline input[type=number] {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 8px;
  font-family: var(--mono);
}
.inline input[type=number] { width: 72px; }
.rp-foot { display: flex; gap: 10px; margin-top: auto; padding-top: 20px; }
.rp-foot .danger { margin-right: auto; color: #C23B3F; border-color: transparent; background: none; }
.rp-placeholder { display: grid; place-items: center; color: var(--sub); padding: 40px; text-align: center; line-height: 1.8; }
