/* ============================================================
   おうちカレンダー — 壁掛けディスプレイ用デザイン
   参考写真のトーンを再現：ダークチャコール背景・細身の時計・
   7日カラム＋タスクパネル
   ============================================================ */

:root {
  --bg: #24282a;
  --bg-column-line: #3b4144;
  --bg-today: rgba(255, 255, 255, 0.075);
  --fg: #e9e7e2;
  --fg-dim: #a9adaf;
  --fg-faint: #6f7578;
  --accent-warm: #e0a24b;   /* 最高気温のオレンジ */
  --sun-red: #e0795c;       /* 日曜 */
  --sat-blue: #8ab6d6;      /* 土曜 */

  /* カテゴリ色（凡例ドット / カード） */
  --cat-family: #7fb5d5;
  --cat-lesson: #a9cc8e;
  --cat-hoikuen: #d5c468;
  --cat-mama: #e6e4de;
  --cat-guest: #dd9a88;
  --cat-dinner: #d5c468;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 画面幅に合わせて全体を等倍スケール（1920px時に等倍）。
   TVでもiPadでも同じ比率でぴったり収まる */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
@media (min-width: 801px) {
  html { font-size: clamp(9px, calc(100vw / 120), 28px); }
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-weight: 400;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  /* iPadのノッチ/セーフエリアも考慮 */
  padding: max(1.125rem, env(safe-area-inset-top))
           max(1.625rem, env(safe-area-inset-right))
           max(1.375rem, env(safe-area-inset-bottom))
           max(1.625rem, env(safe-area-inset-left));
}

/* ===== ヘッダー ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  padding: 0.25rem 0.375rem 0.875rem;
}

.clock-area { display: flex; align-items: center; gap: 1.25rem; }

.clock {
  font-size: 5.5rem;
  font-weight: 300;
  letter-spacing: 2px;
  color: #efe9df;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.date-area { line-height: 1.25; }
.date-label { font-size: 2rem; font-weight: 700; }
.dow-label { font-size: 1.25rem; color: var(--fg-dim); }

/* 凡例 */
.legend {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--fg-dim);
}
.legend .item { display: flex; align-items: center; gap: 0.375rem; white-space: nowrap; }
.legend .dot { width: 0.5625rem; height: 0.5625rem; border-radius: 50%; }

/* 現在の天気 */
.now-weather { display: flex; align-items: center; gap: 0.875rem; }
.now-icon svg { width: 4.25rem; height: 4.25rem; display: block; }
.now-temps { font-size: 2.875rem; font-weight: 500; line-height: 1; }
.now-hi { color: var(--accent-warm); }
.now-slash { color: var(--fg-faint); margin: 0 0.1875rem; font-weight: 300; }
.now-lo { color: var(--fg); }
.now-desc { text-align: right; font-size: 1.125rem; line-height: 1.5; }
.now-precip { color: var(--fg-dim); font-size: 1rem; }

.gear-btn {
  background: none; border: none; color: var(--fg-faint);
  font-size: 1.25rem; cursor: pointer; padding: 0.375rem; margin-left: 2px;
}
.gear-btn:hover { color: var(--fg-dim); }

/* ===== メインボード ===== */
.board {
  flex: 1;
  display: flex;
  min-height: 0;
  border-top: 1px solid var(--bg-column-line);
}

.week-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  display: flex;
}

.week {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.week::-webkit-scrollbar { display: none; }

.day-col {
  flex: 0 0 20%;            /* 5日表示 */
  scroll-snap-align: start;
  border-right: 1px solid var(--bg-column-line);
  padding: 0.875rem 0.75rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
}

/* スライド用ナビ矢印 */
.week-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 10;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1px solid var(--bg-column-line);
  background: rgba(36, 40, 42, 0.85);
  color: var(--fg-dim);
  font-size: 1.5rem; line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.week-nav:hover { opacity: 1; color: var(--fg); }
.week-nav.prev { left: 0.375rem; }
.week-nav.next { right: 0.375rem; }
.week-nav[disabled] { opacity: 0; pointer-events: none; }
.day-col.today {
  background: var(--bg-today);
  border-radius: 0 0 0.625rem 0.625rem;
}

.day-head { text-align: center; line-height: 1.2; margin-bottom: 0.25rem; }
.day-dow { font-size: 1.25rem; color: var(--fg-dim); }
.day-dow.sun { color: var(--sun-red); }
.day-dow.sat { color: var(--sat-blue); }
.day-num { font-size: 2.5rem; font-weight: 700; }

.day-weather { text-align: center; margin-bottom: 0.625rem; }
.day-weather svg { width: 2.5rem; height: 2.5rem; }
.day-temps { font-size: 1.1875rem; }
.day-temps .hi { font-weight: 500; }
.day-temps .sep { color: var(--fg-faint); margin: 0 1px; }
.day-temps .lo { color: var(--fg-dim); }
.day-precip { font-size: 0.9375rem; color: var(--fg-dim); margin-top: 1px; }
.day-weather .nodata { color: var(--fg-faint); font-size: 0.875rem; padding: 0.875rem 0; }

/* ===== 予定カード（幅いっぱい・従来より広く） ===== */
.events { display: flex; flex-direction: column; gap: 0.4375rem; overflow-y: auto; }
.events::-webkit-scrollbar { display: none; }

.ev-card {
  border-radius: 0.5rem;
  padding: 0.75rem 0.75rem 0.8125rem;
  line-height: 1.45;
  cursor: pointer;
  border-left: 0.25rem solid transparent;
}
.ev-time { font-size: 0.9375rem; opacity: 0.85; font-variant-numeric: tabular-nums; }
.ev-title { font-size: 1.1875rem; font-weight: 700; word-break: break-all; margin-top: 0.125rem; }
.ev-sub { font-size: 0.9375rem; margin-top: 0.25rem; opacity: 0.9; }

/* カテゴリごとの配色（写真のチップに寄せた淡色ベタ＋濃色文字） */
.ev-card.family   { background: #37596d; color: #ddeef8; border-left-color: var(--cat-family); }
.ev-card.lesson   { background: #b9d3a2; color: #2c3d20; border-left-color: #7fa562; }
.ev-card.hoikuen  { background: #c4b45e; color: #332e10; border-left-color: #99893a; }
.ev-card.mama     { background: #d9d7d0; color: #33322e; border-left-color: #a6a49c; }
.ev-card.guest    { background: #b3695b; color: #ffe9e2; border-left-color: #e5a08e; }
.ev-card.dinner   { background: #c4b45e; color: #332e10; border-left-color: #99893a; }

/* ===== タスクパネル ===== */
.tasks {
  width: 14.375rem;
  padding: 1rem 0.375rem 0.625rem 1.375rem;
  display: flex;
  flex-direction: column;
}
.tasks-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.tasks h2 { font-size: 1.1875rem; font-weight: 700; }
.task-add-btn {
  width: 1.875rem; height: 1.875rem; border-radius: 50%;
  border: 1px solid var(--bg-column-line);
  background: none; color: var(--fg-dim);
  font-size: 1.0625rem; cursor: pointer;
}
.task-add-btn:hover { color: var(--fg); border-color: var(--fg-faint); }

.task-list { list-style: none; overflow-y: auto; }
.task-list li {
  display: flex; align-items: center; gap: 0.5625rem;
  padding: 0.4375rem 0.25rem; font-size: 0.9375rem; cursor: pointer;
  color: var(--fg);
}
.task-list li .box {
  width: 1rem; height: 1rem; flex: none;
  border: 1.5px solid var(--fg-faint); border-radius: 0.25rem;
}
.task-list li.done { color: var(--fg-faint); text-decoration: line-through; }
.task-list li.done .box { background: var(--fg-faint); }
.task-empty { color: var(--fg-dim); font-size: 0.9375rem; }

/* ===== モーダル ===== */
.modal-back[hidden] { display: none; }
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
}
.modal {
  background: #2e3336;
  border: 1px solid #454b4f;
  border-radius: 0.875rem;
  padding: 1.5rem 1.625rem;
  width: 28.75rem; max-width: 100%;
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 1.125rem 3.125rem rgba(0,0,0,0.5);
}
.modal.small { width: 23.75rem; }
.modal h3 { font-size: 1.1875rem; margin-bottom: 1.125rem; }

.form-row { margin-bottom: 0.875rem; }
.form-row.two { display: flex; gap: 0.75rem; }
.form-row.two > label { flex: 1; }
.form-row label { display: block; font-size: 0.8125rem; color: var(--fg-dim); }
.form-row input {
  display: block; width: 100%; margin-top: 0.3125rem;
  background: #23272a; color: var(--fg);
  border: 1px solid #454b4f; border-radius: 0.5rem;
  padding: 0.625rem 0.75rem; font-size: 1rem;
  font-family: inherit;
}
.form-row input:focus { outline: none; border-color: var(--cat-family); }

.cat-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4375rem; }
.cat-chip {
  border: 1px solid #454b4f; border-radius: 1.25rem;
  background: none; color: var(--fg-dim);
  padding: 0.4375rem 0.875rem; font-size: 0.875rem; cursor: pointer;
  display: flex; align-items: center; gap: 0.375rem;
  font-family: inherit;
}
.cat-chip .dot { width: 0.5625rem; height: 0.5625rem; border-radius: 50%; }
.cat-chip.sel { border-color: var(--fg); color: var(--fg); background: rgba(255,255,255,0.06); }

/* ===== 予定入力シート（Googleカレンダー風） ===== */
.modal.sheet { width: 30rem; padding: 1rem 0 0.75rem; border-radius: 1.375rem; }

.sheet-head {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0 1rem 0.25rem;
}
.sheet-head .spacer { flex: 1; }
.icon-btn {
  width: 2.625rem; height: 2.625rem; border-radius: 50%;
  border: none; background: none; color: var(--fg-dim);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 1.375rem; height: 1.375rem; }
.icon-btn:hover { background: rgba(255,255,255,0.07); color: var(--fg); }
.save-pill {
  border: none; border-radius: 1.375rem;
  background: #5b8aa8; color: #fff;
  padding: 0.625rem 1.375rem; font-size: 1rem; font-weight: 700;
  font-family: inherit; cursor: pointer;
}
.save-pill:hover { background: #6b9ab8; }

.title-input {
  display: block; width: 100%;
  background: none; border: none; outline: none;
  color: var(--fg);
  font-family: inherit; font-size: 1.75rem; font-weight: 500;
  padding: 0.625rem 1.5rem 0.75rem;
}
.title-input::placeholder { color: var(--fg-faint); font-weight: 400; }

.modal.sheet .cat-picker { padding: 0 1.5rem 1rem; margin-top: 0; }

.sheet-sec { border-top: 1px solid #3a4043; padding: 0.5rem 1rem; }
.srow {
  display: flex; align-items: center; gap: 0.75rem;
  min-height: 3rem; padding: 0.125rem 0.5rem;
}
.srow .spacer { flex: 1; }
.srow.indent { padding-left: 3.75rem; }
.row-ic {
  width: 2.5rem; flex: none; display: flex; justify-content: center;
  color: var(--fg-dim);
}
.row-ic svg { width: 1.5rem; height: 1.5rem; }
.row-label { font-size: 1.0625rem; color: var(--fg); }

.plain-input, .plain-select {
  background: none; border: none; outline: none;
  color: var(--fg); font-family: inherit; font-size: 1.0625rem;
  padding: 0.5rem 0.25rem;
}
.plain-input.grow { flex: 1; }
.plain-input::placeholder { color: var(--fg-faint); }
.plain-select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.plain-select option { background: #2e3336; color: var(--fg); }
input[type="date"].plain-input, input[type="time"].plain-input {
  color-scheme: dark;
}

/* 日付・時間のタップ設定（Googleカレンダー風の行） */
.dt-field {
  position: relative;
  display: inline-flex; align-items: center;
  padding: 0.625rem 0.375rem;
  font-size: 1.0625rem; color: var(--fg);
  border-radius: 0.5rem;
  cursor: pointer;
}
.dt-field:not(.is-static):hover { background: rgba(255,255,255,0.06); }
.dt-field input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; border: none; padding: 0;
  cursor: pointer;
  color-scheme: dark;
}
.dt-field.is-static { cursor: default; }
.dt-dim { color: var(--fg-dim); }
.dt-field .placeholder { color: var(--fg-faint); }

/* トグルスイッチ */
.switch { margin-left: auto; position: relative; display: inline-block; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.switch .knob {
  display: block; width: 3.25rem; height: 1.875rem;
  border-radius: 1rem; background: #4a5154;
  position: relative; transition: background 0.15s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 0.1875rem; left: 0.1875rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: #c9cdd0; transition: left 0.15s, background 0.15s;
}
.switch input:checked + .knob { background: #5b8aa8; }
.switch input:checked + .knob::after { left: 1.5625rem; background: #fff; }

.modal-actions { display: flex; align-items: center; gap: 0.625rem; margin-top: 1.25rem; }
.modal-actions .spacer { flex: 1; }
.btn {
  border: none; border-radius: 0.5625rem; padding: 0.625rem 1.25rem;
  font-size: 0.9375rem; cursor: pointer; font-family: inherit; font-weight: 500;
}
.btn.primary { background: #5b8aa8; color: #fff; }
.btn.primary:hover { background: #6b9ab8; }
.btn.ghost { background: none; color: var(--fg-dim); border: 1px solid #454b4f; }
.btn.danger { background: none; color: #dd8878; border: 1px solid #7a5048; }

.geo-results { margin-top: 0.5rem; }
.geo-item {
  padding: 0.5rem 0.625rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.875rem;
  color: var(--fg);
}
.geo-item:hover { background: rgba(255,255,255,0.07); }
.geo-current { margin-top: 0.625rem; font-size: 0.8125rem; color: var(--fg-dim); }

/* ===== スマホ ===== */
.mobile-list { display: none; }
.fab { display: none; }

@media (max-width: 800px) {
  html, body { overflow: auto; }
  body { padding: 0.875rem 0.875rem 5.625rem; }

  .topbar { flex-wrap: wrap; gap: 0.625rem; }
  .clock { font-size: 2.5rem; }
  .date-label { font-size: 1.25rem; }
  .dow-label { font-size: 0.875rem; }
  .legend { order: 3; width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 0.75rem; }
  .now-weather { margin-left: auto; gap: 0.5rem; }
  .now-icon svg { width: 2.375rem; height: 2.375rem; }
  .now-temps { font-size: 1.5rem; }
  .now-desc { font-size: 0.75rem; }

  .board { display: none; }

  .mobile-list { display: block; }
  .m-day { border-top: 1px solid var(--bg-column-line); padding: 0.75rem 2px; }
  .m-day-head { display: flex; align-items: baseline; gap: 0.625rem; margin-bottom: 0.5rem; }
  .m-day-head .d { font-size: 1.125rem; font-weight: 700; }
  .m-day-head .w { font-size: 0.875rem; color: var(--fg-dim); }
  .m-day-head .w.sun { color: var(--sun-red); }
  .m-day-head .w.sat { color: var(--sat-blue); }
  .m-day-head .wx { margin-left: auto; font-size: 0.8125rem; color: var(--fg-dim); display: flex; align-items: center; gap: 0.375rem; }
  .m-day-head .wx svg { width: 1.375rem; height: 1.375rem; }
  .m-day .events { gap: 0.5rem; }
  .m-day .none { color: var(--fg-faint); font-size: 0.875rem; }

  .m-tasks { border-top: 1px solid var(--bg-column-line); padding: 0.875rem 2px; }
  .m-tasks h2 { font-size: 1.0625rem; margin-bottom: 0.625rem; }

  .fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 1.25rem; bottom: 1.5rem; z-index: 40;
    width: 3.625rem; height: 3.625rem; border-radius: 50%;
    border: none; background: #5b8aa8; color: #fff;
    font-size: 1.75rem; box-shadow: 0 0.375rem 1.125rem rgba(0,0,0,0.45);
    cursor: pointer;
  }
}
