/* けつあつログ */
:root {
  --bg: #f9f9f7;
  --card: #ffffff;
  --text: #2b2b28;
  --sub: #8a8a84;
  --line: #e8e6e0;
  --accent: #cf6a63;
  --accent-soft: #f9e7e5;
  --none: #edebe5;
  --c-sys: #d96c5f;
  --c-dia: #6f93c4;
  --c-check: #f2a45c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --card: #1c1c1e;
    --text: #f0f0ec;
    --sub: #9a9a94;
    --line: #33332f;
    --accent: #e08a83;
    --accent-soft: #3c2624;
    --none: #2c2c2e;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.55;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}

.app-header {
  padding: calc(14px + env(safe-area-inset-top)) 20px 6px;
}
.app-title { font-size: 1.25rem; margin: 0; }

main { padding: 0 16px 16px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-top: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}
.card-title { font-size: 1rem; margin: 0 0 10px; color: var(--sub); font-weight: 600; }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.chart-head .card-title { margin: 0; }

/* --- 日付ナビ --- */
.day-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.day-label-wrap { text-align: center; }
.day-label { font-size: 1.15rem; font-weight: 700; }
.icon-btn {
  background: none; border: none; font-size: 1.2rem; padding: 10px 14px;
  color: var(--text); cursor: pointer; border-radius: 12px;
}
.icon-btn:disabled { opacity: .25; }
.mini-btn {
  background: var(--accent-soft); color: var(--accent); border: none;
  border-radius: 999px; padding: 6px 14px; font-size: .85rem; font-weight: 700; cursor: pointer;
  font-family: inherit;
}

/* --- 大ボタン --- */
.big-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.big-btn {
  min-height: 84px; border-radius: 18px; border: none;
  font-size: 1.05rem; font-weight: 700; cursor: pointer; color: #2b2b28;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-family: inherit; padding: 8px;
}
.big-emoji { font-size: 1.7rem; }
.bp-btn { background: #fbe3df; }
.check-btn { background: #fbe8d4; }
.big-btn:active { transform: scale(.97); }

.grid-label { font-size: .8rem; color: var(--sub); font-weight: 600; margin: 14px 2px 6px; }
.act-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.sym-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act-btn, .sym-btn {
  min-height: 56px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  font-size: .9rem; font-weight: 700; cursor: pointer; font-family: inherit;
  padding: 4px 2px;
}
.act-btn:active, .sym-btn:active { transform: scale(.97); }

/* --- グラフ --- */
#dayChart svg { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--sub); font-size: .9rem; padding: 8px 0; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: .8rem; color: var(--sub); }
.lg-item { display: inline-flex; align-items: center; gap: 5px; }
.lg-chip { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* --- チェック結果 --- */
.check-row { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.check-row:last-child { border-bottom: none; }
.check-time { font-weight: 700; margin-right: 8px; font-variant-numeric: tabular-nums; }
.check-vals { font-variant-numeric: tabular-nums; }
.check-drop { font-weight: 700; }
.check-drop.warn { color: var(--accent); }
.check-note { font-size: .8rem; color: var(--sub); margin-top: 2px; }

/* --- 記録リスト --- */
.entry-list { display: flex; flex-direction: column; }
.entry-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.entry-row:last-child { border-bottom: none; }
.entry-time { font-weight: 700; min-width: 56px; font-variant-numeric: tabular-nums; }
.entry-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-bp { font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-pos { font-size: .8rem; color: var(--sub); margin-left: 6px; }
.entry-row .icon-btn { padding: 6px 8px; font-size: 1rem; }
.empty-msg { color: var(--sub); font-size: .9rem; padding: 8px 0; }

/* --- りれき --- */
.history-rows { display: flex; flex-direction: column; }
.hist-row {
  display: grid; grid-template-columns: 78px 1fr; gap: 8px; align-items: center;
  padding: 7px 0; background: none; border: none; text-align: left;
  font-size: .85rem; color: var(--text); cursor: pointer; width: 100%;
  font-family: inherit; border-bottom: 1px solid var(--line);
}
.hist-row:last-child { border-bottom: none; }
.hist-date { font-weight: 600; }
.hist-body { min-width: 0; }
.hist-bar-wrap { position: relative; height: 14px; border-radius: 5px; background: var(--none); }
.hist-bar { position: absolute; top: 0; height: 100%; border-radius: 5px; background: var(--c-sys); opacity: .75; min-width: 6px; }
.hist-info { font-size: .75rem; color: var(--sub); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.hist-syms { font-size: .8rem; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat-tile { border-radius: 14px; padding: 12px 8px; text-align: center; color: #2b2b28; }
.tile-sys { background: #fbe3df; }
.tile-dia { background: #e2eaf4; }
.tile-sym { background: #f2efe4; }
.stat-name { font-size: .8rem; font-weight: 600; }
.stat-hours { font-size: 1.5rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: .8rem; font-weight: 600; margin-left: 2px; }

/* --- ボタン類 --- */
.primary-btn {
  width: 100%; min-height: 56px; border: none; border-radius: 16px;
  background: var(--accent); color: #fff; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; margin-top: 14px; font-family: inherit;
}
.ghost-btn {
  width: 100%; min-height: 50px; border: 1px dashed var(--sub); border-radius: 14px;
  background: none; color: var(--text); font-size: 1rem; font-weight: 600;
  cursor: pointer; margin-top: 10px; font-family: inherit;
}
.danger-btn { border-color: #c25b4e; color: #c25b4e; border-style: solid; }
.data-note { font-size: .8rem; color: var(--sub); margin: 10px 0 0; }
.about-text { font-size: .95rem; margin: 0; }

/* --- かぞくと共有 --- */
.share-code {
  font-size: 1.7rem; font-weight: 800; text-align: center; letter-spacing: 3px;
  background: var(--bg); border: 2px dashed var(--accent); border-radius: 14px;
  padding: 12px; user-select: all; -webkit-user-select: all;
  font-variant-numeric: tabular-nums;
}
.share-status { font-size: .8rem; color: var(--sub); margin: 10px 0 0; text-align: center; }
.share-leave { color: #c25b4e; border-color: #c25b4e; }

/* --- タブバー --- */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 30;
}
.tab-btn {
  flex: 1; background: none; border: none; padding: 10px 0 8px;
  font-size: .8rem; font-weight: 700; color: var(--sub); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: inherit;
}
.tab-btn.active { color: var(--accent); }
.tab-emoji { font-size: 1.35rem; }

/* --- シート --- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 50;
  display: flex; align-items: flex-end;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px; margin: 0 auto;
  border-radius: 20px 20px 0 0; padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h3 { margin: 0; font-size: 1.1rem; }
.sheet-note { color: var(--sub); font-size: .9rem; margin: 8px 0; }
.field-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.field-label { font-size: .9rem; color: var(--sub); font-weight: 600; min-width: 48px; }
.time-input, .text-input {
  flex: 1; font-size: 1.2rem; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg); color: var(--text); font-family: inherit;
}

/* 体位えらび */
.pos-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.pos-chip {
  min-height: 54px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--bg); color: var(--text); font-size: .95rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.pos-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.standmin-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; margin-top: 8px; }
.standmin-row .pos-chip { min-height: 44px; font-size: .8rem; border-radius: 12px; }

/* 血圧の数字入力 */
.bp-inputs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 14px; }
.bp-field { text-align: center; }
.bp-field-label { font-size: .85rem; color: var(--sub); font-weight: 700; margin-bottom: 4px; }
.bp-num {
  width: 100%; text-align: center; font-size: 1.7rem; font-weight: 800;
  padding: 10px 4px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.memo-input {
  width: 100%; min-height: 90px; margin-top: 12px; font-size: 1.05rem;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font-family: inherit; resize: vertical;
}

/* たちくらみチェック */
.check-step-text { font-size: 1.05rem; margin: 14px 0 0; }
.check-timer {
  text-align: center; font-size: 3rem; font-weight: 800; margin: 18px 0 6px;
  font-variant-numeric: tabular-nums;
}
.check-timer.ready { color: var(--accent); }
.check-timer-label { text-align: center; color: var(--sub); font-size: .9rem; }
.check-result-box {
  background: var(--bg); border-radius: 14px; padding: 14px; margin-top: 14px;
  font-size: 1.05rem;
}
.check-result-main { font-size: 1.3rem; font-weight: 800; margin-top: 6px; }
.check-result-main.warn { color: var(--accent); }

/* --- トースト --- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom));
  background: #2b2b28; color: #fff; border-radius: 14px; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: .9rem; z-index: 40; max-width: 600px; margin: 0 auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.undo-btn {
  background: none; border: none; color: #ffd35c; font-weight: 700;
  font-size: .95rem; cursor: pointer; white-space: nowrap; font-family: inherit;
}

/* --- 印刷レポート --- */
#printView { display: none; }

@media print {
  body > *:not(#printView) { display: none !important; }
  body { padding: 0; background: #fff; color: #000; font-size: 12px; }
  #printView { display: block; padding: 10mm; }
  .p-title { font-size: 18px; margin: 0 0 4px; }
  .p-meta { color: #555; font-size: 11px; }
  .p-name { margin-top: 6px; font-size: 12px; border-bottom: 1px solid #999; width: 200px; padding-bottom: 2px; }
  .p-section { font-size: 13px; font-weight: 700; margin: 12px 0 4px; border-bottom: 1px solid #999; padding-bottom: 2px; }
  .p-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
  .p-table th, .p-table td { border: 1px solid #bbb; padding: 2px 5px; text-align: left; }
  .p-table th { background: #f0f0f0; font-weight: 700; }
  .p-warn { font-weight: 700; }
  .p-day { break-inside: avoid; margin-top: 8px; }
  .p-day-date { font-size: 11.5px; font-weight: 700; margin-bottom: 1px; }
  .p-line { font-size: 10.5px; padding-left: 8px; }
  .p-line .num { font-variant-numeric: tabular-nums; }
  .p-foot { margin-top: 12px; font-size: 9px; color: #999; text-align: right; }
  .p-table th, .p-table td, .p-warn {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
