/* わが家ポータル 共通スタイル（スマホ最優先） */

:root {
  --bg: #faf6f1;
  --card: #ffffff;
  --ink: #3d3833;
  --muted: #9a8f84;
  --line: #eee4d9;
  --accent: #e08a6b;      /* テラコッタ */
  --accent-deep: #c96f4f;
  --sage: #a7beae;
  --gold: #e9c46a;
  --danger: #d05b5b;
  --radius: 16px;
  --tabbar-h: calc(58px + env(safe-area-inset-bottom, 0px));
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  padding-bottom: var(--tabbar-h);
  min-height: 100vh;
}

.app { max-width: 720px; margin: 0 auto; padding: 16px 16px 24px; }
body.full-bleed .app { max-width: none; padding: 0; }

a { color: var(--accent-deep); text-decoration: none; }

/* ---------- 見出し・ヘッダー ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.page-head h1 { font-size: 1.25rem; font-weight: 700; flex: 1; }
.page-head .sub { color: var(--muted); font-size: .8rem; }
.back-link { display: inline-flex; align-items: center; color: var(--muted); font-size: 1.4rem; padding: 4px 8px 4px 0; }

/* ---------- カード ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card h2 { font-size: 1.02rem; margin-bottom: 8px; }
.card .desc { color: var(--muted); font-size: .85rem; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 12px;
  padding: 13px 20px; font-size: 1rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--accent-deep); border: 1.5px solid var(--accent); }
.btn.subtle { background: #f3ece4; color: var(--ink); }
.btn.small { padding: 8px 14px; font-size: .87rem; border-radius: 10px; }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .45; }

/* ---------- フォーム ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field .label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.hint { font-size: .78rem; color: var(--muted); margin-top: 5px; }

/* ---------- ホーム ---------- */
.home-hero { text-align: center; padding: 26px 0 18px; }
.home-hero .logo { font-size: 2rem; }
.home-hero h1 { font-size: 1.35rem; margin-top: 6px; }
.home-hero p { color: var(--muted); font-size: .85rem; }
.home-hero .logo-img { max-width: 230px; width: 62%; height: auto; margin-bottom: 8px; }

.menu-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.menu-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; color: var(--ink);
}
.menu-item .emoji {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; flex-shrink: 0;
}
.menu-item .t { flex: 1; }
.menu-item .t b { display: block; font-size: 1.05rem; }
.menu-item .t span { color: var(--muted); font-size: .8rem; }
.menu-item .arrow { color: var(--muted); }

/* ---------- タブバー ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--muted); font-size: .66rem;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent-deep); font-weight: 700; }

/* ---------- 写真グリッド ---------- */
.month-head {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--bg) 75%, transparent);
  padding: 10px 4px 8px;
  font-weight: 700; font-size: .95rem;
}
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.grid a { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: #eee3d8; border-radius: 4px; }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .vid-badge {
  position: absolute; right: 5px; bottom: 5px;
  background: rgba(0,0,0,.55); color: #fff; font-size: .62rem;
  border-radius: 6px; padding: 1px 6px;
}
.grid .fav-badge { position: absolute; left: 5px; top: 4px; font-size: .8rem; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.grid .noimg {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--muted);
}
.grid .noimg.video { background: #4a443f; color: #fff; }

/* アルバム一覧 */
.album-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.album-cell { display: block; color: var(--ink); }
.album-cell .cover {
  aspect-ratio: 4/3; border-radius: 14px; overflow: hidden; background: #eee3d8;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: var(--muted);
}
.album-cell .cover img { width: 100%; height: 100%; object-fit: cover; }
.album-cell b { display: block; margin-top: 6px; font-size: .9rem; line-height: 1.35; }
.album-cell span { color: var(--muted); font-size: .75rem; }

/* フィルタチップ */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 999px;
  background: #f3ece4; color: var(--ink); font-size: .82rem; border: 1px solid transparent;
}
.chip.active { background: var(--accent); color: #fff; font-weight: 600; }

/* アップロードFAB */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 16px); z-index: 40;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 1.9rem; line-height: 1;
  box-shadow: 0 6px 18px rgba(201,111,79,.4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* アップロード進捗 */
.up-list { margin-top: 12px; }
.up-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .84rem; }
.up-item .pv {
  width: 44px; height: 44px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: #f0e7dc; display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.up-item .pv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.up-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .st { color: var(--muted); flex-shrink: 0; font-weight: 600; }
.up-item .st.ok { color: #4a9c6d; }
.up-item .st.ng { color: var(--danger); }
.progress { height: 8px; background: #f0e7dc; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- ビューア ---------- */
.viewer { background: #111; min-height: 100vh; padding-bottom: 0; }
.viewer .stage {
  min-height: 62vh; display: flex; align-items: center; justify-content: center;
}
.viewer .stage img, .viewer .stage video { max-width: 100vw; max-height: 74vh; display: block; }
.viewer .vtop {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px calc(10px);
  color: #eee; background: linear-gradient(rgba(0,0,0,.6), transparent);
}
.viewer .vtop a { color: #eee; font-size: 1.3rem; }
.viewer .panel {
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(var(--tabbar-h) + 8px);
  min-height: 30vh;
}
.viewer .meta { color: var(--muted); font-size: .8rem; margin-bottom: 10px; }
.action-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.comment { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.comment .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  color: #fff; font-size: .85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.comment .body { flex: 1; font-size: .9rem; }
.comment .who { font-size: .74rem; color: var(--muted); }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form input { flex: 1; }

/* ---------- カレンダー ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h1 { font-size: 1.15rem; }
.cal-head .nav-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-size: 1.05rem; color: var(--ink); cursor: pointer;
}
.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.cal-table th { font-size: .7rem; color: var(--muted); padding: 8px 0 6px; font-weight: 600; }
.cal-table th.sun, .cal-table td.sun .d { color: #d05b5b; }
.cal-table th.sat, .cal-table td.sat .d { color: #5b7fd0; }
.cal-table td.holiday .d { color: #d05b5b; } /* 祝日は日曜と同じ赤 */
.cal-table td .hol-name {
  font-size: .5rem; color: #d05b5b; text-align: center; line-height: 1.2;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-bottom: 1px;
}
.cal-table td {
  vertical-align: top; height: 84px; border-top: 1px solid var(--line);
  padding: 3px 2px; cursor: pointer;
}
.cal-table td.out { background: #faf7f3; opacity: .5; }
.cal-table td .d {
  font-size: .75rem; width: 24px; height: 24px; line-height: 24px;
  text-align: center; border-radius: 50%; margin: 0 auto 2px;
}
.cal-table td.today .d { background: var(--accent); color: #fff !important; font-weight: 700; }
.cal-ev {
  font-size: .58rem; line-height: 1.3; color: #fff; border-radius: 4px;
  padding: 1px 4px; margin-bottom: 2px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.cal-dot { display: flex; justify-content: center; gap: 2px; }
.cal-dot i { width: 5px; height: 5px; border-radius: 50%; background: var(--sage); }
.cam-mark { font-size: .55rem; text-align: center; display: block; }

/* 日別ビュー */
.day-sheet { margin-top: 14px; }
.ev-item { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ev-item .bar { width: 4px; border-radius: 4px; align-self: stretch; flex-shrink: 0; }
.ev-item .t { flex: 1; }
.ev-item .t b { font-size: .95rem; }
.ev-item .t .tm { color: var(--muted); font-size: .78rem; }
.ev-item .t .memo { font-size: .82rem; color: var(--muted); white-space: pre-wrap; }

/* ---------- 教育方針 ---------- */
.q-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.q-card .q-no {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem;
  margin-right: 8px;
}
.q-card h3 { display: inline; font-size: 1rem; vertical-align: middle; }
.q-card .q-body { margin: 10px 0 8px; font-size: .9rem; }
.q-card .q-hint { font-size: .76rem; color: var(--muted); background: #faf6f0; border-radius: 8px; padding: 7px 10px; margin-bottom: 8px; }
.q-card textarea { min-height: 84px; }
.q-card .saved-mark { font-size: .72rem; color: #4a9c6d; float: right; opacity: 0; transition: opacity .3s; }
.q-card .saved-mark.show { opacity: 1; }

.sec-head { margin: 22px 4px 10px; font-size: .95rem; font-weight: 700; color: var(--accent-deep); }
.progress-note {
  position: sticky; top: 0; z-index: 15;
  background: rgba(250,246,241,.95); backdrop-filter: blur(6px);
  padding: 10px 4px; font-size: .8rem; color: var(--muted);
}

/* 比較表示 */
.cmp-q { margin-bottom: 18px; }
.cmp-q .q-title { font-size: .92rem; font-weight: 700; margin-bottom: 6px; }
.cmp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmp-col { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: .85rem; white-space: pre-wrap; }
.cmp-col .who { font-size: .72rem; font-weight: 700; margin-bottom: 4px; }
.cmp-col.empty { color: var(--muted); font-style: italic; }

/* 最終方針の表示 */
.policy-view h2 { font-size: 1.05rem; color: var(--accent-deep); margin: 20px 0 8px; }
.policy-view ol { padding-left: 1.6em; }
.policy-view li { margin-bottom: 6px; }
.policy-oneline {
  background: #fff; border: 2px solid var(--accent); border-radius: 14px;
  padding: 18px; text-align: center; font-size: 1.05rem; font-weight: 700; margin-top: 20px;
}

/* 途中保存ボタン（フローティング）と保存トースト */
.float-save {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px); z-index: 40;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 999px; padding: 13px 20px;
  font-size: .95rem; font-weight: 700; font-family: inherit;
  box-shadow: 0 6px 18px rgba(201,111,79,.4);
  cursor: pointer;
}
.float-save:disabled { opacity: .7; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 78px);
  transform: translateX(-50%) translateY(10px);
  background: #3d3833; color: #fff;
  border-radius: 999px; padding: 12px 22px;
  font-size: .92rem; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 60; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- ログイン ---------- */
.login-wrap { max-width: 400px; margin: 0 auto; padding-top: 8vh; }
.user-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.user-pick button {
  border: 2px solid var(--line); background: #fff; border-radius: 14px;
  padding: 18px 10px; font-size: 1rem; font-weight: 700; color: var(--ink); cursor: pointer;
  font-family: inherit;
}
.user-pick button.sel { border-color: var(--accent); background: #fdf3ee; }

.notice { background: #fdf3ee; border: 1px solid #f3d9cc; color: var(--accent-deep); border-radius: 12px; padding: 12px 14px; font-size: .86rem; margin-bottom: 14px; }
.error-box { background: #fdeeee; border: 1px solid #f0cccc; color: var(--danger); border-radius: 12px; padding: 12px 14px; font-size: .86rem; margin-bottom: 14px; }

.empty-note { text-align: center; color: var(--muted); padding: 40px 20px; font-size: .9rem; }

/* ---------- 印刷（A4） ---------- */
@media print {
  :root { --bg: #fff; }
  body { background: #fff; padding: 0; font-size: 11pt; }
  .app { max-width: none; padding: 0; }
  .tabbar, .fab, .no-print, .page-head .back-link { display: none !important; }
  .cmp-cols { grid-template-columns: 1fr 1fr; }
  .cmp-q { break-inside: avoid; }
  .card, .q-card, .cmp-col { border-color: #ccc; }
  @page { size: A4 portrait; margin: 14mm; }
}
