:root {
  --bg:          #ffffff;
  --card:        #F8F8F8;
  --navy:        #36363a;   /* チャコールグレー（文字色） */
  --navy-mid:    #6e6e74;
  --navy-light:  #a3a3a8;
  --accent:      #36363a;   /* アクセント色は使わず、文字色と同じにする */
  --accent-light:#efeff0;
  --accent-light-hover: #e3e3e5;
  --border:      #e8e8e8;
  --radius-lg:   20px;
  --radius-md:   14px;
  --radius-sm:   10px;
  --sun:         #c0392b;
  --sat:         #2f5fa8;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--navy);
  font-family: 'Noto Sans JP', 'Noto Sans', -apple-system, 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  font-size: 15px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

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

.lucide {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

/* ヘッダー */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.month-title {
  margin: 0;
  display: flex; align-items: baseline; gap: 8px;
  font-size: 28px; font-weight: 700; letter-spacing: .01em;
}
/* Sacramento は太さが1種類（400）だけなので、擬似的な太字にしない。細い筆記体のため大きめにする */
#month-name { font-family: 'Sacramento', cursive; font-weight: 400; font-size: 44px; line-height: 1; }
.month-year { font-size: 15px; font-weight: 700; color: var(--navy-light); }
/* 年とカレンダーの日付の数字 */
.month-year, .day-num { font-family: 'Lato', 'Noto Sans JP', sans-serif; }
.header-actions { display: flex; align-items: center; }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: var(--radius-md);
  cursor: pointer;
}
.icon-btn:hover { background: var(--accent-light); }

/* カレンダー */
.main { max-width: 720px; margin: 0 auto; padding: 12px 12px 0; touch-action: pan-y; }


.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--navy-mid);
  padding-bottom: 6px;
}
.weekdays .sun { color: var(--sun); }
.weekdays .sat { color: var(--sat); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar.slide-next { animation: slide-next .22s ease-out; }
.calendar.slide-prev { animation: slide-prev .22s ease-out; }
@keyframes slide-next { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes slide-prev { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .calendar.slide-next, .calendar.slide-prev { animation: none; }
}

.day {
  position: relative;
  aspect-ratio: 9 / 16;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  display: block; width: 100%;
  text-align: left;
}
.day:hover { border-color: var(--navy-light); }
.day.empty { background: none; cursor: default; }
.day.empty:hover { border-color: transparent; }

.day-num {
  position: absolute; top: 4px; left: 5px; z-index: 2;
  font-size: 12px; font-weight: 700; line-height: 20px;
  min-width: 20px; height: 20px; text-align: center; border-radius: 10px;
}
.day.sun .day-num { color: var(--sun); }
.day.sat .day-num { color: var(--sat); }
.day.today .day-num { background: var(--navy); color: #fff; padding: 0 4px; }

.day img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.day .count {
  position: absolute; right: 4px; bottom: 4px; z-index: 2;
  background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px;
  padding: 0 6px; border-radius: 9px;
}
.day .busy {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

/* アップロードボタン */
.upload-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; justify-content: center;
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 480px; height: 52px;
  background: var(--navy); color: #fff;
  border: none; border-radius: var(--radius-md);
  font-size: 16px; font-weight: 700; letter-spacing: .08em;
  cursor: pointer;
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: none; }
.btn-primary.full { max-width: none; margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-light); color: var(--accent);
  font-size: 14px; font-weight: 700;
  border: none; border-radius: var(--radius-sm);
  padding: 9px 14px;
  cursor: pointer;
}
.btn:hover { background: var(--accent-light-hover); }
.btn .lucide { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn[hidden] { display: none; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.danger { color: var(--sun); }

/* シート（モーダル） */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 30, 32, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: var(--bg);
  width: 100%; max-width: 720px;
  max-height: 92vh; max-height: 92dvh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 8px 20px;
  border-bottom: 1px solid var(--border);
}
.sheet-title { margin: 0; font-size: 20px; font-weight: 700; }
.sheet-body {
  overflow-y: auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.section-title { font-size: 14px; font-weight: 700; color: var(--navy-mid); margin: 20px 4px 8px; }
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 2px solid transparent;
}

.field { display: block; padding: 12px 0; border-top: 2px solid #ffffff; }
.field:first-child { border-top: none; padding-top: 0; }
.field:last-child { padding-bottom: 0; }
.field-label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.hint, .note { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy-mid); margin-top: 8px; line-height: 1.6; }
.note { margin: 0; }

input[type=password], input[type=text], select, textarea {
  width: 100%;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 16px; font-weight: 600;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy-light); }
textarea { font-size: 14px; line-height: 1.6; resize: vertical; margin-bottom: 12px; }

/* 日付ごとの記録 */
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.entry { background: var(--card); border-radius: var(--radius-lg); padding: 12px; }
.entry-img {
  display: block; width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: contain;
}
.entry-state {
  aspect-ratio: 9 / 16;
  background: #fff;
  border-radius: 15px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 20px; text-align: center;
  font-size: 14px; color: var(--navy-mid);
}
.entry-state.error { color: var(--sun); font-size: 13px; line-height: 1.6; word-break: break-word; }
.entry-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.entry-meta { font-size: 12px; font-weight: 700; color: var(--navy-mid); margin-top: 10px; }

.empty-msg { color: var(--navy-mid); text-align: center; padding: 40px 0; }

.viewer .sheet-body img { display: block; max-width: 100%; margin: 0 auto; border-radius: var(--radius-md); }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.day .spinner { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--navy); color: #fff;
  font-size: 14px; font-weight: 700; line-height: 1.5;
  padding: 12px 18px; border-radius: var(--radius-md);
}
