:root {
  --text: #1d1d1f;
  --text-muted: #86868b;
  --line: rgba(0, 0, 0, 0.09);
  --blue: #0a84ff;
  --blue-hover: #0071e3;
  --red: #ff453a;
  --window-bg: rgba(255, 255, 255, 0.78);
  --field-bg: rgba(255, 255, 255, 0.9);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% 0%, #b7c8ff 0%, transparent 60%),
    radial-gradient(1000px 700px at 90% 20%, #f3b6e6 0%, transparent 60%),
    radial-gradient(900px 700px at 50% 100%, #9fe0ff 0%, transparent 60%),
    #dfe4f5;
  background-attachment: fixed;
}

/* ---- メニューバー ---- */
.menubar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--line);
}

.menubar strong,
.menubar-sub {
  white-space: nowrap;
}

.menubar-sub {
  color: var(--text-muted);
  margin-left: 8px;
}

/* ---- アプリアイコン(角丸スクワークル) ---- */
.app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 23%;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.app-icon svg {
  width: 62%;
  height: 62%;
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.app-icon.small {
  width: 20px;
  height: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.app-icon.blue   { background: linear-gradient(180deg, #6fb4ff, #2f6bff); }
.app-icon.yellow { background: linear-gradient(180deg, #ffe066, #ffb400); }
.app-icon.green  { background: linear-gradient(180deg, #7be495, #24b04b); }
.app-icon.orange { background: linear-gradient(180deg, #ffb066, #ff6a2b); }

/* ---- 全体レイアウト: 日記 / ダッシュボード / タスク | メモ ---- */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 16px;
  height: max(calc(100vh - 34px), 760px);
  display: grid;
  grid-template-columns: 1.9fr 1fr;
  grid-template-rows: minmax(300px, 1.15fr) auto minmax(230px, 1fr);
  gap: 12px;
}

.diary-win,
.dashboard-win {
  grid-column: 1 / -1;
}

/* ---- ウィンドウ ---- */
.window {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--window-bg);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  box-shadow:
    0 22px 50px rgba(30, 40, 90, 0.22),
    0 2px 6px rgba(30, 40, 90, 0.12);
  overflow: hidden;
}

.titlebar {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(240, 240, 245, 0.5));
  border-bottom: 1px solid var(--line);
}

.titlebar .title {
  font-size: 13px;
  font-weight: 600;
  color: #3a3a3c;
}

.lights {
  position: absolute;
  left: 14px;
  display: flex;
  gap: 8px;
}

.lights i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.22);
}

.lights .red    { background: #ff5f57; }
.lights .yellow { background: #febc2e; }
.lights .green  { background: #28c840; }

.window-body {
  flex: 1;
  min-height: 0;
  padding: 12px 16px;
}

/* ---- フォーム部品 ---- */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 7px 10px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

textarea {
  resize: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px rgba(10, 132, 255, 0.28);
}

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  color: #fff;
  background: linear-gradient(180deg, #4aa3ff, var(--blue));
  border: none;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: linear-gradient(180deg, #3a96f5, var(--blue-hover));
}

button:active {
  filter: brightness(0.92);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

button.secondary {
  color: var(--text);
  background: rgba(120, 120, 128, 0.18);
  box-shadow: none;
}

button.secondary:hover {
  background: rgba(120, 120, 128, 0.3);
}

.icon-btn {
  padding: 3px 10px;
  font-size: 12px;
  color: var(--red);
  background: rgba(255, 69, 58, 0.1);
  box-shadow: none;
}

.icon-btn:hover {
  background: var(--red);
  color: #fff;
}

.icon-btn.neutral {
  color: var(--text-muted);
  background: rgba(120, 120, 128, 0.14);
}

.icon-btn.neutral:hover {
  background: rgba(120, 120, 128, 0.3);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

.toast {
  font-size: 13px;
  font-weight: 600;
  color: #1f8a3a;
  background: rgba(52, 199, 89, 0.16);
  border-radius: 8px;
  padding: 3px 10px;
  text-align: center;
}

.toast.error {
  color: var(--red);
  background: rgba(255, 69, 58, 0.12);
}

.list-heading {
  margin: 8px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

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

.item-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  color: #b25a00;
  background: rgba(255, 149, 0, 0.16);
}

.badge.done {
  color: #1f8a3a;
  background: rgba(52, 199, 89, 0.18);
}

/* ---- 1段目: 日記 ---- */
.diary-body {
  flex: none;
  height: 262px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
}

.diary-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
}

.diary-form input[type="date"] {
  width: auto;
  justify-self: start;
  padding: 4px 10px;
  font-size: 13px;
}

.diary-form .toast {
  align-self: center;
  justify-self: end;
}

.diary-form textarea,
.diary-form button {
  grid-column: 1 / -1;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 14px;
}

.cal-nav {
  padding: 0 12px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: rgba(120, 120, 128, 0.16);
  box-shadow: none;
}

.cal-nav:hover {
  background: rgba(120, 120, 128, 0.3);
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) 46px;
  grid-auto-rows: 30px;
  gap: 3px;
}

.cal-dow {
  height: 15px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

.calendar .cal-dow {
  grid-row: 1;
}

.cal-day,
.cal-week {
  position: relative;
  padding: 0;
  color: var(--text);
  background: rgba(120, 120, 128, 0.1);
  border: 1.5px solid transparent;
  border-radius: 8px;
  box-shadow: none;
  font-weight: 500;
  overflow: hidden;
}

.cal-day:hover,
.cal-week:hover {
  background: rgba(120, 120, 128, 0.22);
}

.cal-day.other {
  opacity: 0.4;
}

.cal-day.today {
  border-color: var(--blue);
}

.cal-day.selected {
  background: rgba(10, 132, 255, 0.22);
}

.cal-num {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 9px;
  line-height: 1;
  color: var(--text-muted);
  z-index: 1;
}

.cal-day img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 23%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.cal-week {
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
}

.cal-week.has-days {
  background: rgba(255, 149, 0, 0.14);
  color: #b25a00;
  font-weight: 600;
}

.cal-week.complete {
  background: rgba(255, 204, 0, 0.3);
}

.diary-c .list-heading:first-child {
  margin-top: 0;
}

.week-card {
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 149, 0, 0.12);
  border: 1px dashed rgba(255, 149, 0, 0.5);
}

.week-card.complete {
  background: rgba(255, 204, 0, 0.2);
  border-style: solid;
}

.week-card-head {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.week-card-note {
  font-size: 12px;
  color: var(--text-muted);
}

.special-badge {
  margin-left: 8px;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, #ffb400, #ff6a2b);
}

.week-card .shima-box {
  margin: 4px 0 0;
}

.week-card .shima-avatar {
  width: 48px;
  height: 48px;
}

.review-item {
  margin-bottom: 8px;
  padding: 10px 12px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-left: 4px solid #34c759;
  border-radius: 10px;
}

.review-head {
  margin-bottom: 4px;
}

.review-comment {
  white-space: pre-wrap;
  font-size: 14px;
  margin-bottom: 8px;
}

/* ---- しまちゃん ---- */
.shima-avatar {
  flex: none;
  width: 60px;
  height: 60px;
  border-radius: 23%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  background: #fdfbf9;
}

.shima-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 4px;
}

.shima-reply {
  position: relative;
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 12px;
  background: rgba(52, 199, 89, 0.14);
  border-radius: 12px;
  color: var(--text);
}

.shima-box .shima-reply::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  margin-top: -6px;
  border: 6px solid transparent;
  border-left: 0;
  border-right-color: rgba(52, 199, 89, 0.14);
}

/* ---- 2段目: ダッシュボード ---- */
.dashboard-win .window-body {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.points-stat {
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.points-left {
  flex: none;
  width: 34%;
  min-width: 130px;
}

.points-total {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.points-total small {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.points-level {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #b25a00;
  background: rgba(255, 149, 0, 0.18);
  padding: 1px 8px;
  border-radius: 999px;
}

.level-bar {
  height: 6px;
  margin: 6px 0 3px;
  background: rgba(120, 120, 128, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.level-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffb400, #ff6a2b);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.play-btn {
  margin-top: 6px;
  width: 100%;
  padding: 5px 10px;
  font-size: 12px;
  background: linear-gradient(180deg, #ffb066, #ff6a2b);
}

.play-btn:hover {
  background: linear-gradient(180deg, #ffa24d, #f25c1d);
}

.points-chart {
  flex: 1;
  min-width: 0;
  height: 96px;
}

.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-bar { fill: rgba(52, 199, 89, 0.55); }
.chart-bar.now { fill: #34c759; }
.chart-line { fill: none; stroke: #ff9f0a; stroke-width: 2; stroke-linejoin: round; }
.chart-dot { fill: #ff9f0a; }
.chart-val, .chart-label, .chart-cum { text-anchor: middle; font-size: 8px; fill: var(--text-muted); }
.chart-val { font-weight: 600; }
.chart-cum { fill: #d97706; font-weight: 700; font-size: 9px; }

/* ---- 3段目: タスク(左) / メモ(右) ---- */
.split-body {
  display: flex;
  gap: 16px;
}

.split-form {
  flex: 0 0 240px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.split-list {
  flex: 1;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 2px 4px 4px 2px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.split-list > li {
  flex: none;
}

.task-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.unit-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.unit-input em {
  flex: none;
  font-style: normal;
  font-size: 12px;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 8px;
}

.form-actions button:first-child {
  flex: 1;
}

.task-item {
  padding: 8px 10px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

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

.task-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

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

.task-actions {
  display: flex;
  gap: 6px;
}

.task-meta {
  margin: 2px 0 4px 30px;
  justify-content: flex-start;
  font-size: 11px;
}

.task-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 1.5px solid #c7c7cc;
  border-radius: 50%;
  background: #fff;
  box-shadow: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.task-item input[type="checkbox"]:checked {
  background: var(--blue);
  border-color: var(--blue);
}

.task-item input[type="checkbox"]:checked::after {
  content: "";
  width: 6px;
  height: 11px;
  margin-top: -2px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.task-progress {
  margin-left: 30px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prog-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.prog-bar {
  height: 6px;
  background: rgba(120, 120, 128, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.prog-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4aa3ff, var(--blue));
  border-radius: 999px;
}

.prog-bar.hours i {
  background: linear-gradient(90deg, #7be495, #24b04b);
}

.pace-line {
  font-size: 11px;
  color: #b25a00;
}

.pace-line.warn {
  color: var(--red);
  font-weight: 600;
}

.log-form {
  margin: 6px 0 0 30px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.log-form input {
  width: 58px;
  padding: 3px 6px;
  font-size: 12px;
}

.log-form button {
  padding: 3px 12px;
  font-size: 12px;
}

/* ---- しまちゃんとあそぶ(じゃんけん) ---- */
.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.game-window {
  width: min(420px, calc(100vw - 32px));
  background: var(--window-bg);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.game-window .lights i {
  cursor: default;
}

.game-window .lights .red {
  cursor: pointer;
}

.game-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.game-shima {
  width: 150px;
  height: 150px;
  border-radius: 23%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  background: #fdfbf9;
}

.game-message {
  min-height: 3em;
  font-size: 15px;
  line-height: 1.5;
}

.game-status {
  font-size: 12px;
  color: var(--text-muted);
}

.game-hands {
  display: flex;
  gap: 10px;
}

.game-hands button {
  width: 96px;
  padding: 14px 0;
  font-size: 18px;
  font-weight: 700;
  background: rgba(120, 120, 128, 0.16);
  color: var(--text);
  box-shadow: none;
}

.game-hands button:hover:not(:disabled) {
  background: rgba(10, 132, 255, 0.25);
}

.game-result {
  font-size: 13px;
  font-weight: 600;
}

.game-record {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- ダークモード ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #f5f5f7;
    --line: rgba(255, 255, 255, 0.12);
    --window-bg: rgba(44, 44, 48, 0.75);
    --field-bg: rgba(60, 60, 66, 0.8);
  }
  body {
    background:
      radial-gradient(1200px 700px at 15% 0%, #3b3f8f 0%, transparent 60%),
      radial-gradient(1000px 700px at 90% 20%, #7a2f6b 0%, transparent 60%),
      radial-gradient(900px 700px at 50% 100%, #1d5f80 0%, transparent 60%),
      #14141c;
    background-attachment: fixed;
  }
  .menubar { background: rgba(30, 30, 34, 0.55); }
  .titlebar { background: linear-gradient(180deg, rgba(70, 70, 76, 0.7), rgba(50, 50, 56, 0.5)); }
  .titlebar .title { color: #e5e5ea; }
  .window,
  .game-window { border-color: rgba(255, 255, 255, 0.12); }
  .task-item input[type="checkbox"] { background: #2c2c30; border-color: #636366; }
  .pace-line { color: #ffb066; }
}

/* ---- 狭い画面 ---- */
@media (max-width: 800px) {
  main {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .menubar-sub { display: none; }
  .diary-body {
    height: auto;
    grid-template-columns: 1fr;
  }
  .diary-a, .diary-b, .diary-c { overflow: visible; }
  .dashboard-win .window-body { grid-template-columns: 1fr; }
  .split-body { flex-direction: column; }
  .split-form { flex: none; }
  .split-list { max-height: 60vh; }
}

.task-form { gap: 5px; }
.task-form label { gap: 2px; }
.task-form input,
.task-form select { padding: 5px 8px; font-size: 13px; }
.task-form .form-actions button { padding: 6px 16px; }

/* ---- 1段目: 日記を左右2分割(左: カレンダー / 右: 週コメント・直近1週間・入力欄) ---- */
.diary-body {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: 270px;
}

.diary-left {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.calendar {
  grid-auto-rows: 34px;
}

.diary-right {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#week-card-slot {
  flex: none;
}

.diary-right .diary-c {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.diary-right .diary-form {
  flex: none;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
}

.diary-right .diary-form input[type="date"] { grid-column: 1; grid-row: 1; }
.diary-right .diary-form .toast            { grid-column: 2; grid-row: 1; }
.diary-right .diary-form textarea          { grid-column: 1; grid-row: 2; height: 52px; }
.diary-right .diary-form button            { grid-column: 2; grid-row: 2; align-self: stretch; }

.list-heading.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.week-card {
  padding: 4px 10px;
}

.week-card .shima-avatar {
  width: 40px;
  height: 40px;
}

.week-card .shima-reply {
  padding: 4px 10px;
  font-size: 13px;
}

.diary-right .review-item {
  padding: 8px 10px;
}

.diary-right .review-comment {
  margin-bottom: 4px;
}

@media (max-width: 800px) {
  .diary-body { grid-template-columns: 1fr; height: auto; }
  .diary-right .diary-c { max-height: 50vh; }
}

/* ---- 日記欄の高さ配分(画面の高さに合わせて伸びる) ---- */
.diary-body {
  flex: 1;
  height: auto;
  min-height: 0;
}

.diary-left {
  display: flex;
  flex-direction: column;
}

.diary-left .calendar {
  flex: 1;
  min-height: 0;
  grid-template-rows: 15px repeat(6, minmax(0, 1fr));
  grid-auto-rows: auto;
}

/* スマホ幅では .diary-left がもう背が高いフレックス項目ではなくなるため、
   1fr の行指定だと各行がつぶれてしまう。固定の高さに戻す */
@media (max-width: 800px) {
  .diary-left .calendar {
    flex: none;
    grid-template-rows: none;
    grid-auto-rows: 32px;
  }
}

.diary-right .diary-form textarea { height: 46px; }

.week-card { padding: 3px 10px; }
.week-card .shima-avatar { width: 34px; height: 34px; }
.week-card .shima-reply { padding: 3px 10px; font-size: 12.5px; }
.week-card-head { margin-bottom: 2px; }

.diary-right .shima-avatar { width: 38px; height: 38px; border-width: 1.5px; }
.diary-right .shima-reply { padding: 4px 10px; font-size: 13px; }
.diary-right .review-item { padding: 6px 10px; margin-bottom: 6px; }
.diary-right .review-comment { font-size: 13px; margin-bottom: 3px; }

@media (max-width: 800px) {
  .diary-body { flex: none; }
}

/* ---- 日記入力欄を1行に(左: 本文 / 右: 日付とボタン)。獲得ptの通知は入力欄の上に重ねる ---- */
.diary-right .diary-form {
  position: relative;
  grid-template-columns: 1fr 132px;
  grid-template-rows: auto auto;
  gap: 6px 8px;
}

.diary-right .diary-form textarea          { grid-column: 1; grid-row: 1 / span 2; height: auto; min-height: 56px; }
.diary-right .diary-form input[type="date"] { grid-column: 2; grid-row: 1; width: 100%; }
.diary-right .diary-form button            { grid-column: 2; grid-row: 2; }
.diary-right .diary-form .toast {
  position: absolute;
  right: 0;
  bottom: 100%;
  margin-bottom: 4px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  background: #e3f6e8;
}

.diary-body { padding-top: 8px; padding-bottom: 8px; }
.dashboard-win .window-body { padding-top: 8px; padding-bottom: 8px; }

/* ================= ダッシュボード: ポイント + 歩くしまちゃん ================= */
.dashboard-win .window-body {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
}

.points-stat {
  justify-content: flex-start;
  gap: 24px;
}

.points-chart {
  height: 104px;
}






@media (prefers-reduced-motion: reduce) {
}

/* ================= 下段: タスク(広く・2列) ================= */
.task-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
}

.task-list > .empty {
  grid-column: 1 / -1;
}

.task-win .split-form {
  flex-basis: 222px;
}

.task-item {
  padding: 6px 8px;
}

.task-meta {
  margin-left: 30px;
}

.task-progress,
.log-form {
  margin-left: 0;
}

.log-form {
  margin-top: 4px;
}

/* ================= 下段: メモ(付箋) ================= */
.titlebar-actions {
  position: absolute;
  right: 10px;
  display: flex;
  gap: 6px;
}

.titlebar-btn {
  padding: 2px 10px;
  font-size: 12px;
  color: var(--text);
  background: rgba(120, 120, 128, 0.16);
  box-shadow: none;
}

.titlebar-btn:hover {
  background: rgba(120, 120, 128, 0.3);
}

.note-scroll {
  overflow-y: auto;
  padding: 16px 16px 14px;
}

.sticky-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start;
  gap: 20px 16px;
  padding: 4px;
}

.sticky-board > .empty {
  grid-column: 1 / -1;
}

.sticky-note {
  --paper: #fff59d;
  --tilt: 0deg;
  position: relative;
  min-height: 132px;
  padding: 18px 12px 24px;
  color: #4a3f10;
  background: linear-gradient(180deg, var(--paper), color-mix(in srgb, var(--paper) 88%, #000 12%));
  border-radius: 2px 2px 16px 2px;
  box-shadow: 0 10px 12px -8px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.15);
  transform: rotate(var(--tilt));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", -apple-system, sans-serif;
}

.sticky-note::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 56px;
  height: 16px;
  margin-left: -28px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transform: rotate(-3deg);
}

.sticky-note:hover {
  transform: rotate(0deg) scale(1.03);
  z-index: 2;
  box-shadow: 0 14px 16px -8px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.15);
}

.paper-0 { --paper: #fff59d; }
.paper-1 { --paper: #ffc9de; }
.paper-2 { --paper: #c9e7ff; }
.paper-3 { --paper: #d5f5c2; }
.paper-4 { --paper: #ffd8a8; }

.sticky-title {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 700;
  word-break: break-word;
}

.sticky-text {
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.sticky-date {
  position: absolute;
  left: 12px;
  bottom: 7px;
  font-size: 10px;
  opacity: 0.6;
}

.sticky-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  color: #4a3f10;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  box-shadow: none;
  opacity: 0;
}

.sticky-note:hover .sticky-del,
.sticky-del:focus-visible {
  opacity: 1;
}

.sticky-del:hover {
  background: var(--red);
  color: #fff;
}

.sticky-new {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.28);
  border: 2px dashed rgba(120, 120, 128, 0.55);
  border-radius: 8px;
  box-shadow: none;
  transform: none;
}

.sticky-new::before {
  display: none;
}

.sticky-new:hover {
  transform: none;
  box-shadow: none;
}

.sticky-new textarea {
  flex: 1;
  min-height: 56px;
}

/* ================= しまちゃんとあそぶ(ゲーム選択) ================= */
.game-window {
  width: min(460px, calc(100vw - 32px));
}

.game-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.game-tabs button {
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text);
  background: rgba(120, 120, 128, 0.16);
  box-shadow: none;
}

.game-tabs button.active {
  color: #fff;
  background: linear-gradient(180deg, #4aa3ff, var(--blue));
}

.game-panel {
  width: 100%;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.number-form {
  display: flex;
  gap: 8px;
}

.number-form input {
  width: 110px;
  text-align: center;
}

.number-history {
  font-size: 12px;
  color: var(--text-muted);
}

.game-hands.cups button.ball {
  background: rgba(52, 199, 89, 0.3);
}

@media (max-width: 800px) {
  .dashboard-win .window-body { grid-template-columns: 1fr; }
  .task-list { grid-template-columns: 1fr; }
}

/* ---- 微調整: ポイント欄の幅 / タスクカードを低く ---- */
.points-left { width: 250px; flex: none; }
.points-chart { max-width: 520px; }
.task-item { padding: 5px 8px; }
.task-meta { margin: 0 0 3px 30px; }
.pace-line { line-height: 1.3; }
.log-form { flex-wrap: nowrap; gap: 4px; margin-top: 3px; }
.log-form input { width: 46px; padding: 2px 4px; }
.log-form button { padding: 2px 10px; }

/* ---- ダッシュボード右端: 天気・気分でかわる今日のしまちゃん ---- */
.today-shima {
  flex: none;
  width: 136px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: inherit;
  background: none;
  box-shadow: none;
  cursor: pointer;
}

.today-shima:hover {
  background: none;
}

.today-shima img {
  width: 104px;
  height: 104px;
  border-radius: 23%;
  object-fit: cover;
  border: 3px solid #fff;
  background: #fdfbf9;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.today-shima img.fading {
  opacity: 0;
  transform: scale(0.92);
}

.today-caption {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
  text-align: center;
  min-height: 2.7em;
  white-space: pre-line;
}

/* ================= タスク: 一覧を広く、入力欄は最下部(スクロールで表示) ================= */
.task-scroll {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 12px 16px 14px;
}

.task-scroll .task-list {
  flex: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  margin: 0;
  padding: 2px;
  list-style: none;
  overflow: visible;
}

.task-form-bottom {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 1.2fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 12px;
  border: 2px dashed rgba(120, 120, 128, 0.5);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  overflow: visible;
}

.task-form-bottom .field-row {
  display: contents;
}

.task-form-bottom .f-pace {
  grid-column: 5;
}

.task-form-bottom .form-actions {
  grid-column: 6;
}

.task-form-bottom .toast {
  grid-column: 1 / -1;
}

@media (max-width: 800px) {
  .task-form-bottom { grid-template-columns: 1fr 1fr; }
  .task-form-bottom .f-title,
  .task-form-bottom .f-pace,
  .task-form-bottom .form-actions { grid-column: 1 / -1; }
}

/* ---- 下段(タスク一覧)の高さを確保 ---- */
main { grid-template-rows: minmax(285px, 1fr) auto minmax(230px, 1fr); }
.today-shima img { width: 80px; height: 80px; }
.today-shima { gap: 4px; }
.task-scroll { padding-top: 10px; gap: 12px; }
.task-scroll .task-list { gap: 6px; }
.task-meta { margin-bottom: 2px; }

/* ================= ダッシュボード再編: メモと同じ幅・左に画像・右にポイント/グラフの切替 ================= */
main {
  grid-template-columns: 1.9fr 1fr;
  grid-template-rows: minmax(285px, 1fr) auto minmax(230px, 1fr);
}

.diary-win { grid-column: 1 / -1; grid-row: 1; }
.task-win { grid-column: 1; grid-row: 2 / span 2; }
.dashboard-win { grid-column: 2; grid-row: 2; }
.note-win { grid-column: 2; grid-row: 3; }

.dash-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
}

.dash-body .today-shima {
  width: auto;
}

.dash-body .today-shima img {
  width: 152px;
  height: 152px;
}

.dash-flip {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 172px;
}

.flip-pane {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.flip-pane.active {
  opacity: 1;
  pointer-events: auto;
}

.flip-chart {
  justify-content: center;
}

.flip-chart .points-chart {
  width: 100%;
  max-width: none;
  height: 150px;
}

.flip-dots {
  position: absolute;
  right: 2px;
  bottom: -2px;
  display: flex;
  gap: 5px;
}

.flip-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(120, 120, 128, 0.35);
  cursor: pointer;
}

.flip-dots .dot.active {
  background: var(--blue);
}

.task-win .task-scroll {
  padding-top: 12px;
}

/* ================= メモの付箋に編集ボタン ================= */
.sticky-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.sticky-note:hover .sticky-actions,
.sticky-actions:focus-within {
  opacity: 1;
}

.sticky-edit,
.sticky-del {
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  color: #4a3f10;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  box-shadow: none;
}

.sticky-edit:hover {
  background: var(--blue);
  color: #fff;
}

.sticky-del:hover {
  background: var(--red);
  color: #fff;
}

.sticky-edit-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
}

.sticky-edit-form .edit-title {
  font-weight: 700;
  font-size: 14px;
  padding: 3px 6px;
}

.sticky-edit-form .edit-body {
  flex: 1;
  min-height: 60px;
  resize: none;
  font-size: 13px;
  padding: 4px 6px;
}

.sticky-edit-actions {
  display: flex;
  gap: 6px;
}

.sticky-edit-actions button {
  flex: 1;
  padding: 4px 0;
  font-size: 12px;
}

.sticky-note.editing {
  cursor: default;
}

.sticky-note.editing:hover {
  transform: rotate(var(--tilt));
}

/* ================= 直近1週間の日記も自動で切り替え ================= */
.diary-c.auto-rotate .review-item {
  display: none;
}

.diary-c.auto-rotate .review-item.active {
  display: block;
}

.diary-rotate-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 4px;
}

.diary-rotate-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(120, 120, 128, 0.35);
  cursor: pointer;
}

.diary-rotate-dots .dot.active {
  background: #34c759;
}

@media (max-width: 800px) {
  .task-win { grid-column: 1; grid-row: auto; }
  .dashboard-win { grid-column: 1; grid-row: auto; }
  .note-win { grid-column: 1; grid-row: auto; }
}

/* ================= タスクを全体の半分幅に(残り半分がダッシュボード/メモの列) ================= */
main {
  grid-template-columns: 1fr 1fr;
}

.dash-body {
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
}

/* ================= メモの付箋: 横並びで少し小さめに ================= */
.sticky-board {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px 10px;
}

.sticky-note {
  min-height: 100px;
  padding: 14px 9px 18px;
}

.sticky-title {
  font-size: 12.5px;
}

.sticky-text {
  font-size: 11.5px;
  line-height: 1.4;
}

.sticky-date {
  font-size: 9px;
  left: 9px;
  bottom: 5px;
}

.sticky-actions {
  top: 4px;
  right: 4px;
}

.sticky-edit,
.sticky-del {
  width: 17px;
  height: 17px;
  font-size: 10px;
}

/* ================= ダッシュボード本体: 旧レイアウト(display:grid)を確実に上書き ================= */
.dashboard-win .window-body.dash-body {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
}

.dashboard-win .dash-body .today-shima {
  flex: none;
  width: auto;
}

.dashboard-win .dash-body .dash-flip {
  flex: 1;
  min-width: 0;
}

.diary-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diary-edit-form textarea {
  font-size: 14px;
}

/* ================= ポモドーロタイマー ================= */
.pomo-window {
  width: min(380px, calc(100vw - 32px));
}

#pomodoro-setup {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.pomo-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.pomo-field select {
  font-size: 14px;
}

.pomo-duration {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pomo-dur-btn {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
  background: rgba(120, 120, 128, 0.16);
  box-shadow: none;
}

.pomo-dur-btn.active {
  color: #fff;
  background: linear-gradient(180deg, #4aa3ff, var(--blue));
}

.pomo-duration .unit-input {
  flex: 1;
}

.pomo-duration input {
  width: 100%;
}

.pomo-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pomo-ring {
  position: relative;
  width: 140px;
  height: 140px;
}

.pomo-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pomo-ring-bg {
  fill: none;
  stroke: rgba(120, 120, 128, 0.18);
  stroke-width: 8;
}

.pomo-ring-fg {
  fill: none;
  stroke: var(--blue);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s linear, stroke 0.3s ease;
}

.pomo-ring-fg.pomo-done {
  stroke: var(--green);
}

.pomo-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pomo-task-label {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 1.3em;
}

.pomo-controls {
  display: flex;
  gap: 8px;
}

.gstat-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.pomo-schedule {
  width: 100%;
  max-height: 160px;
  overflow-y: auto;
  text-align: left;
}

.pomo-schedule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pomo-schedule-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  font-size: 12px;
}

.pomo-schedule-list .pomo-range {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.pomo-schedule-list .pomo-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pomo-schedule-list .icon-btn {
  flex: none;
}

/* ---- 日記の日別ビュー: その日のポモドーロ記録 ---- */
.day-pomo-box {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(10, 132, 255, 0.08);
  border: 1px solid rgba(10, 132, 255, 0.25);
  border-radius: 10px;
}

.day-pomo-box .list-heading {
  margin: 0 0 6px;
}

.day-pomo-box .pomo-schedule-list {
  max-height: none;
}

/* ---- タスクごとのポモドーロ記録 ---- */
.task-pomo-toggle {
  color: var(--blue);
  background: rgba(10, 132, 255, 0.12);
}

.task-pomo-box {
  margin: 6px 0 0 30px;
  padding: 6px 8px;
  background: rgba(10, 132, 255, 0.06);
  border: 1px solid rgba(10, 132, 255, 0.2);
  border-radius: 8px;
}

.task-pomo-box .pomo-schedule-list {
  max-height: 160px;
  overflow-y: auto;
}

/* ---- ポモドーロ完了の通知トースト ---- */
.pomo-alert {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--window-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  max-width: min(420px, calc(100vw - 32px));
  animation: pomo-alert-in 0.25s ease;
}

.pomo-alert img {
  width: 36px;
  height: 36px;
  border-radius: 23%;
  object-fit: cover;
  flex: none;
}

.pomo-alert .pomo-alert-text {
  flex: 1;
  min-width: 0;
}

.pomo-alert .pomo-alert-close {
  flex: none;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(120, 120, 128, 0.14);
  box-shadow: none;
}

@keyframes pomo-alert-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
