/* =========================================================
   秘書アプリ：秘書の執務手帳
   紙の上に紺インクで書き、完了には朱の「済」印を押す。
   ========================================================= */

:root {
  /* 色 */
  --paper: #f7f8f4;      /* 紙（青みのある白） */
  --sheet: #ffffff;      /* 記入欄 */
  --ink: #1d2940;        /* 墨紺インク：本文・主要ボタン */
  --pencil: #677084;     /* 鉛筆：補足情報 */
  --rule: #c9d5de;       /* 罫線 */
  --rule-soft: #e2e8ec;
  --shu: #c8372d;        /* 朱肉：済印・期限切れ・削除 */
  --shu-soft: #f7e3e0;
  --marker: #f4e07a;     /* 蛍光ペン：進行中 */
  --tab-memo: #2e7f95;   /* 見出しタブ：メモ（浅葱） */
  --tab-task: #1d2940;   /* 見出しタブ：タスク（紺） */
  --tab-review: #5e8c3e; /* 見出しタブ：振り返り（若草） */

  /* 書体 */
  --font-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-body: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;

  /* 文字サイズ（本文15pxを基準にした段階） */
  --fs-xs: 0.8rem;   /* 12.8 */
  --fs-sm: 0.875rem; /* 14 */
  --fs-md: 0.9375rem;/* 15 */
  --fs-lg: 1.125rem; /* 18 */
  --fs-xl: 1.375rem; /* 22 */
  --fs-2xl: 1.75rem; /* 28 */

  --radius: 4px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

/* 固定ヘッダーの下に見出しやフォーカス先が隠れないようにする */
html { font-size: 16px; scroll-padding-top: 140px; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.7;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1.3; margin: 0; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------------------------------------------------------
   上部固定：アプリ名・日付・ダッシュボード
   合計欄の二重線で本文と区切る
   --------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 4px double var(--ink);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 12px var(--gutter) 10px; }

.masthead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.masthead h1 { font-size: var(--fs-xl); letter-spacing: 0.08em; }
.today { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); color: var(--pencil); }

.dashboard {
  display: flex;
  margin-top: 6px;
  border-top: 1px solid var(--rule);
}
.stat {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 16px 2px;
}
.stat:first-child { padding-left: 0; }
.stat + .stat { border-left: 1px solid var(--rule); }
.stat-label { font-size: var(--fs-sm); color: var(--pencil); }
.stat-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-2xl);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.stat-unit { font-size: var(--fs-sm); color: var(--pencil); }
/* 未完了が残っているときだけ朱で知らせる */
.stat-open.has-open .stat-value { color: var(--shu); }

.message {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: var(--shu-soft);
  color: var(--shu);
  border-left: 3px solid var(--shu);
  font-weight: 700;
  font-size: var(--fs-sm);
}

/* ---------------------------------------------------------
   本文レイアウト
   --------------------------------------------------------- */
main { max-width: 1120px; margin: 0 auto; padding: 28px var(--gutter) 64px; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
@media (max-width: 800px) { .columns { grid-template-columns: 1fr; gap: 32px; } }

/* 見出しタブ：手帳のインデックスシール。色で「どの帳面か」を示す */
.book { --tab-color: var(--ink); min-width: 0; border-top: 2px solid var(--tab-color); }
.book-memo { --tab-color: var(--tab-memo); }
.book-task { --tab-color: var(--tab-task); }
.book-review { --tab-color: var(--tab-review); margin-top: 48px; }

.tab {
  display: inline-block;
  margin: 0 0 18px;
  padding: 4px 18px 6px;
  background: var(--tab-color);
  color: #fff;
  font-size: var(--fs-lg);
  letter-spacing: 0.1em;
  border-radius: 0 0 var(--radius) var(--radius);
}

.list-heading {
  margin: 28px 0 4px;
  font-size: var(--fs-md);
  color: var(--pencil);
  font-weight: 600;
}
.list-heading-flush { margin-top: 0; }

/* ---------------------------------------------------------
   記入欄（フォーム）
   --------------------------------------------------------- */
form { display: flex; flex-direction: column; gap: 6px; }
.entry { max-width: 40em; }
.inline-form { display: flex; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.entry-actions { display: flex; justify-content: flex-end; margin-top: 6px; }

.field-label { font-size: var(--fs-sm); color: var(--pencil); }
.due-label { white-space: nowrap; }

input, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  min-width: 0;
}
textarea { resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: #9aa2b1; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }

/* ボタン：主要は紺インクの塗り、それ以外は線だけ */
button {
  font: inherit;
  font-weight: 700;
  padding: 8px 18px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: #2c3b58; }
button.small { padding: 3px 10px; font-size: var(--fs-sm); }
button.secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
button.secondary:hover { border-color: var(--ink); background: transparent; }
button.danger { background: transparent; color: var(--shu); border-color: #e4b7b2; }
button.danger:hover { border-color: var(--shu); background: transparent; }
button.danger[data-armed] { background: var(--shu); border-color: var(--shu); color: #fff; }

/* ---------------------------------------------------------
   一覧：ノートの罫線に沿って並べる
   --------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--rule); padding: 14px 0; }
.list li:first-child { border-top: 1px solid var(--rule); }

.empty { margin: 8px 0 0; color: var(--pencil); font-size: var(--fs-sm); }
.meta { font-size: var(--fs-xs); color: var(--pencil); }

.review-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.task-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* メモ */
.memo-title { font-weight: 700; font-size: var(--fs-md); min-width: 0; word-break: break-word; }
.memo-body { white-space: pre-wrap; margin: 4px 0 6px; max-width: 40em; }

/* ---------------------------------------------------------
   タスク
   未着手：そのまま / 進行中：蛍光ペン / 完了：朱の「済」印
   --------------------------------------------------------- */
.task-title { display: flex; align-items: center; gap: 12px; }
.task-text { word-break: break-word; font-weight: 700; min-width: 0; }
.task.status-doing .task-text {
  background: linear-gradient(transparent 55%, var(--marker) 55%);
  padding: 0 2px;
}
.task.status-done .task-text { color: var(--pencil); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--pencil); }

/* 済印 */
.stamp {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 2em;
  height: 2em;
  border: 2.5px solid var(--shu);
  border-radius: 50%;
  color: var(--shu);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-xl);
  line-height: 1;
  transform: rotate(-14deg);
  opacity: 0.88;
  margin-left: auto;
}
.stamp.stamp-in { animation: stamp 260ms cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stamp {
  0%   { transform: rotate(-14deg) scale(1.9); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: rotate(-14deg) scale(1); opacity: 0.88; }
}

.task .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 4px; }

.due { font-weight: 700; color: var(--ink); }
.due.soon { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 3px; }
.due.today, .due.overdue { color: var(--shu); }
.due.overdue { background: var(--shu-soft); padding: 0 6px; }

.task-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.task-controls .push-right { margin-left: auto; }

/* 未着手 / 進行中 / 完了 の切り替え */
.status-switch { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--sheet); }
.status-switch button {
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--pencil);
  font-weight: 400;
  padding: 3px 12px;
  font-size: var(--fs-sm);
}
.status-switch button + button { border-left: 1px solid var(--rule); }
.status-switch button:hover { background: var(--rule-soft); }
.status-switch button.active { color: var(--ink); font-weight: 700; }
.status-switch button.status-todo.active  { background: var(--rule-soft); }
.status-switch button.status-doing.active { background: var(--marker); }
.status-switch button.status-done.active  { background: var(--shu-soft); color: var(--shu); }

.due-input { padding: 3px 6px; font-size: var(--fs-sm); }

/* ---------------------------------------------------------
   週次の振り返り
   --------------------------------------------------------- */
#review-week-hint { margin: 0 0 6px; }
.review-week { font-family: var(--font-display); font-weight: 600; }
.review-comment { white-space: pre-wrap; margin: 6px 0; max-width: 40em; }

/* 最新の振り返り：振り返りの帳面と同じ若草色のしおり */
.latest-review {
  margin-bottom: 44px;
  padding: 4px 0 4px 20px;
  border-left: 4px solid var(--tab-review);
  max-width: 44em;
}
.latest-review-title { font-size: var(--fs-sm); font-weight: 600; color: var(--tab-review); letter-spacing: 0.08em; }
.latest-review .review-week { display: block; font-size: var(--fs-xl); margin: 2px 0 4px; }
.latest-review .review-comment { font-size: var(--fs-md); }

/* ---------------------------------------------------------
   スマホ幅
   --------------------------------------------------------- */
@media (max-width: 560px) {
  .masthead h1 { font-size: var(--fs-lg); }
  .today { font-size: var(--fs-sm); }
  .stat { flex-direction: column; align-items: flex-start; gap: 0; padding: 4px 10px 0; }
  .stat-value { margin-left: 0; font-size: var(--fs-xl); }
  .stat-unit { display: none; }
  .latest-review .review-week { font-size: var(--fs-lg); }
  .inline-form input[type="date"] { flex: 1; }
}

/* ---------------------------------------------------------
   ゴミ箱
   --------------------------------------------------------- */
.masthead-side { display: flex; align-items: center; gap: 12px; }

/* 3点リーダーのメニュー */
.menu { position: relative; }
.menu-button {
  width: 36px;
  height: 32px;
  padding: 0;
  font-size: var(--fs-xl);
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border-color: transparent;
}
.menu-button:hover, .menu-button[aria-expanded="true"] { background: var(--rule-soft); border-color: var(--rule); }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 180px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(29, 41, 64, 0.16);
}
.menu-list[hidden] { display: none; }
.menu-list button {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: none;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--rule-soft); }
.menu-count { font-weight: 400; color: var(--pencil); }

/* ゴミ箱のパネル：メイン画面の右から重ねて開く */
.side-panel {
  margin: 0 0 0 auto;
  padding: 0;
  width: min(480px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border: none;
  border-left: 4px double var(--ink);
  background: var(--paper);
  color: var(--ink);
}
.side-panel::backdrop { background: rgba(29, 41, 64, 0.35); }
.side-panel[open] { animation: panel-in 200ms ease-out; }
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } }
.side-panel-inner { padding: 0 20px 32px; }
/* 見出しと「閉じる」はパネル内でスクロールしても上に残す */
.side-panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.side-panel-head h2 { font-size: var(--fs-xl); letter-spacing: 0.06em; }
.trash-count { font-family: var(--font-body); font-weight: 400; font-size: var(--fs-sm); color: var(--pencil); letter-spacing: 0; margin-left: 6px; }
.side-panel .message { margin: 0 0 12px; }

/* 使い方：各欄と同じ色の見出し線で、どの機能の説明かを示す */
.help-section { --help-color: var(--rule); padding: 4px 0 4px 14px; margin: 0 0 22px; border-left: 3px solid var(--help-color); }
.help-memo { --help-color: var(--tab-memo); }
.help-task { --help-color: var(--tab-task); }
.help-review { --help-color: var(--tab-review); }
.help-section h3 { font-size: var(--fs-lg); margin-bottom: 4px; }
.help-section ul { margin: 0; padding-left: 1.2em; }
.help-section li { margin: 4px 0; }
.help-section li::marker { color: var(--pencil); }
.help-section mark { background: linear-gradient(transparent 55%, var(--marker) 55%); color: inherit; padding: 0 2px; }
.help-section code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.85em;
  padding: 1px 5px;
  background: var(--rule-soft);
  border-radius: 3px;
  white-space: nowrap;
}

.trash-bar { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.trash-note { margin: 0; max-width: 40em; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.trash-item { --kind-color: var(--pencil); }
.trash-memos { --kind-color: var(--tab-memo); }
.trash-tasks { --kind-color: var(--tab-task); }
.trash-reviews { --kind-color: var(--tab-review); }
.trash-name { min-width: 0; word-break: break-word; color: var(--pencil); }
.trash-kind {
  display: inline-block;
  margin-right: 8px;
  padding: 0 7px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #fff;
  background: var(--kind-color);
  border-radius: var(--radius);
}
.days-left.near { color: var(--shu); font-weight: 700; }

/* 削除直後の通知（画面下） */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 10px 12px 10px 18px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  box-shadow: 0 6px 20px rgba(29, 41, 64, 0.25);
}
.toast[hidden] { display: none; }
.toast-undo {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  padding: 3px 12px;
  font-size: var(--fs-sm);
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.12); }

@media (max-width: 560px) {
  .toast { bottom: 12px; width: calc(100% - 2 * var(--gutter)); justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  .side-panel[open] { animation: none; }
  .stamp.stamp-in { animation: none; }
}
