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

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Mochiy Pop One", "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic UI", sans-serif;
  background: #d9f0fa;
  color: #4A6572;
}

#app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: #EAF7FC;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.header {
  background: #7EC8E3; color: #fff;
  padding: calc(22px + env(safe-area-inset-top)) 18px 16px; font-size: 19px; font-weight: bold;
  border-radius: 0 0 22px 22px;
  text-shadow: 0 1px 2px rgba(0,0,0,.1);
  flex-shrink: 0;
}

.header-logo {
  background: #EAF7FC;
  display: flex; align-items: center; justify-content: center;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
}
.header-logo img { width: 84%; max-width: 340px; height: auto; display: block; }

.content {
  flex: 1; overflow-y: auto; padding: 16px;
  padding-bottom: calc(24px + 62px + env(safe-area-inset-bottom));
  background:
    linear-gradient(rgba(234,247,252,.65), rgba(234,247,252,.65)),
    url("../assets/pattern.jpg") center/240px repeat;
}

.screen { display: none; }
.screen.active { display: block; }

.tabs {
  display: flex; background: #fff; border-top: 2px solid #d5ecf5;
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; text-align: center; padding: 10px 2px 12px; font-size: 11px; color: #9db6c0;
  white-space: nowrap; background: none; min-height: 44px;
}
.tab .ico { font-size: 20px; display: block; margin-bottom: 2px; }
.tab.active { color: #4aa8cc; font-weight: bold; }

/* ---- ホーム ---- */

.countdown {
  background: #fff; border-radius: 20px; padding: 16px; text-align: center;
  box-shadow: 0 4px 12px rgba(126,200,227,.25); margin-bottom: 14px;
  font-size: 14px; line-height: 1.8;
}
.countdown b { font-size: 18px; color: #4aa8cc; }

.med-card {
  background: #fff; border-radius: 18px; padding: 12px 14px;
  box-shadow: 0 3px 10px rgba(126,200,227,.2);
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.med-card .emoji { font-size: 24px; flex-shrink: 0; }
.med-card .info { min-width: 0; flex: 1; }
.med-card .name { font-size: 14px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.med-card .time { font-size: 12px; color: #8aa5b0; white-space: nowrap; }
.med-card .status { margin-left: auto; font-size: 19px; flex-shrink: 0; background: none; }
.med-card.done { opacity: .55; }
.med-card.done .name { text-decoration: line-through; }

.empty-note {
  text-align: center; color: #8aa5b0; font-size: 13px; padding: 30px 10px;
}

.visit-card {
  background: #fff; border-left: 5px solid #7EC8E3; border-radius: 14px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 12px; color: #4A6572;
  box-shadow: 0 3px 10px rgba(126,200,227,.2);
}

.cheer {
  margin-top: 14px; text-align: center; background: #FFEFF3;
  border: 2px dashed #FFB7C5; border-radius: 18px; padding: 14px; font-size: 13px; line-height: 1.7;
}

/* ---- カレンダー ---- */

table.cal {
  width: 100%; table-layout: fixed; border-collapse: collapse; background: #fff;
  border-radius: 18px; overflow: hidden; box-shadow: 0 3px 10px rgba(126,200,227,.2);
}
.cal th { font-size: 11px; padding: 8px 0; color: #8aa5b0; background: #f2fafd; white-space: nowrap; }
.cal td {
  text-align: center; font-size: 12px; padding: 6px 0; position: relative;
  height: 44px; vertical-align: top; white-space: nowrap; cursor: pointer;
}
.cal td.empty { cursor: default; }
.cal .stamp { display: block; font-size: 15px; line-height: 1.3; }
.cal .visit-mark { position: absolute; top: 1px; right: 2px; font-size: 15px; line-height: 1; }
.cal td.today { background: #d9f0fa; border-radius: 12px; font-weight: bold; }
.cal td.selected { outline: 2px solid #7EC8E3; outline-offset: -2px; border-radius: 12px; }

.cal-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; font-weight: bold; font-size: 15px; white-space: nowrap;
}
.cal-nav .btn { background: #fff; border-radius: 12px; padding: 6px 14px; box-shadow: 0 2px 6px rgba(126,200,227,.3); }

.stats-card {
  margin-top: 12px; background: #fff; border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 3px 10px rgba(126,200,227,.2); font-size: 13px;
}
.stats-card b { color: #4aa8cc; font-size: 15px; }
.stats-sub { display: block; font-size: 11px; color: #8aa5b0; margin-top: 2px; }
.stats-bar { margin-top: 8px; background: #EAF7FC; border-radius: 999px; height: 10px; overflow: hidden; }
.stats-bar-fill { background: #7EC8E3; height: 100%; border-radius: 999px; transition: width .3s ease; }

.sheet {
  margin-top: 14px; background: #fff; border-radius: 18px; padding: 14px;
  box-shadow: 0 3px 10px rgba(126,200,227,.25); font-size: 13px; line-height: 1.9;
}
.sheet .sheet-title { font-weight: bold; margin-bottom: 6px; display: block; }
.sheet .sheet-item { display: block; }
.sheet .add-btn {
  margin-top: 12px; display: block; width: 100%; text-align: center; background: #7EC8E3; color: #fff;
  border-radius: 14px; padding: 11px 6px; font-weight: bold; font-size: 13px; line-height: 1.4;
}

/* ---- アラーム / お祝い ---- */

.alarm-overlay {
  position: fixed; inset: 0; z-index: 50; display: none;
}
.alarm-overlay.active { display: block; }

.alarm-body {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(191,230,245,.85), rgba(234,247,252,.85)),
    url("../assets/pattern.jpg") center/240px repeat;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}

.alarm-pill { animation: swing 1s infinite ease-in-out; }
.alarm-pill img { width: 220px; height: 220px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(126,200,227,.4)); }
@keyframes swing { 0%,100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }

.alarm-title { font-size: 22px; font-weight: bold; margin: 16px 0 8px; line-height: 1.5; }
.alarm-med {
  background: #fff; border-radius: 16px; padding: 10px 20px; font-size: 14px;
  margin: 10px 0 30px; box-shadow: 0 4px 12px rgba(126,200,227,.3);
}
.alarm-note { font-size: 11px; color: #6b8794; margin-top: -18px; margin-bottom: 20px; line-height: 1.6; }

.btn-big {
  width: 100%; max-width: 340px; padding: 15px 10px; border-radius: 22px; font-size: 16px; font-weight: bold;
  line-height: 1.5; text-align: center; margin-bottom: 12px; box-shadow: 0 5px 0 rgba(0,0,0,.08);
}
.btn-big small { display: block; font-size: 11px; font-weight: normal; }
.btn-take { background: #FFB7C5; color: #7c3f4e; }
.btn-snooze { background: #FFE9A8; color: #7a6a2f; }

/* ---- お薬設定 ---- */

.form-card {
  background: #fff; border-radius: 18px; padding: 16px; box-shadow: 0 3px 10px rgba(126,200,227,.2); font-size: 13px;
}
.form-card .form-title { font-weight: bold; font-size: 14px; }
.form-card label { display: block; font-weight: bold; margin: 12px 0 6px; font-size: 13px; }
.text-input, .date-input {
  width: 100%; background: #f2fafd; border: 2px solid #d5ecf5; border-radius: 12px;
  padding: 9px 10px; color: #4A6572; font-size: 16px; font-family: inherit;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: #d9f0fa; border-radius: 999px;
  padding: 6px 12px; font-size: 12px; white-space: nowrap;
}
.chip.on { background: #7EC8E3; color: #fff; font-weight: bold; }
.time-chip.remove::after { content: " ✕"; font-size: 10px; }
.save-btn {
  margin-top: 16px; width: 100%; background: #7EC8E3; color: #fff; text-align: center;
  border-radius: 16px; padding: 13px; font-weight: bold; font-size: 14px;
}
.cancel-link { display: block; text-align: center; margin-top: 10px; font-size: 12px; color: #8aa5b0; }

.med-list-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px;
  background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(126,200,227,.18); font-size: 14px;
}
.med-list-item .med-name { font-weight: bold; }
.med-list-item .med-detail { font-size: 11px; color: #8aa5b0; flex-basis: 100%; }
.med-list-item .edit { margin-left: auto; font-size: 12px; color: #4aa8cc; flex-shrink: 0; background: none; padding: 8px 4px; }
.med-list-item .del { font-size: 12px; color: #e08a9a; flex-shrink: 0; background: none; padding: 8px 4px; }

.section-title { font-size: 13px; font-weight: bold; color: #6b8794; margin: 4px 0 8px; }

/* ---- オンボーディング ---- */

.onboarding {
  position: fixed; inset: 0; z-index: 60; background: linear-gradient(180deg, #bfe6f5, #EAF7FC);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(30px + env(safe-area-inset-top)) 30px calc(30px + env(safe-area-inset-bottom));
  text-align: center;
}
.onboarding img { width: 200px; height: 200px; object-fit: contain; margin-bottom: 20px; }
.onboarding h2 { font-size: 20px; margin-bottom: 10px; line-height: 1.6; }
.onboarding p { font-size: 13px; color: #6b8794; margin-bottom: 26px; line-height: 1.7; }
.start-btn {
  background: #7EC8E3; color: #fff; border-radius: 22px; padding: 15px 40px; font-size: 16px; font-weight: bold;
  box-shadow: 0 5px 0 rgba(0,0,0,.08);
}

/* ---- ダイアログ ---- */

.confirm-overlay {
  position: fixed; inset: 0; z-index: 70; background: rgba(74,101,114,.4);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.confirm-overlay.active { display: flex; }
.confirm-box {
  background: #fff; border-radius: 20px; padding: 22px; max-width: 320px; width: 100%; text-align: center;
}
.confirm-box p { font-size: 14px; line-height: 1.7; margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button {
  flex: 1; padding: 11px; border-radius: 14px; font-size: 13px; font-weight: bold;
}
.confirm-cancel { background: #f2fafd; color: #4A6572; }
.confirm-ok { background: #FFB7C5; color: #7c3f4e; }
#notice-ok { background: #7EC8E3; color: #fff; }
