/* ニアめざまし PWA — ダークで落ち着いた夜空トーン + 淡いピンク/紫のアクセント */
:root {
  --bg: #141628;
  --bg2: #1c1f38;
  --card: #22254299;
  --text: #eceef8;
  --text-dim: #9aa0c0;
  --accent: #e58fb1;
  --accent2: #8f9fe5;
  --grad: linear-gradient(90deg, #e58fb1, #a08fe5);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --tabbar-h: 62px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
[hidden] { display: none !important; }

/* ---------- 解錠オーバーレイ ---------- */
#unlock-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(120% 100% at 50% 0%, #2a2d52 0%, var(--bg) 70%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .45s ease;
}
#unlock-overlay.fade { opacity: 0; pointer-events: none; }
.unlock-inner { text-align: center; }
.unlock-icon { width: 96px; height: 96px; border-radius: 24px; box-shadow: 0 8px 32px #0008; }
.unlock-title { margin-top: 16px; font-size: 22px; font-weight: 700; letter-spacing: .06em; }
.unlock-hint { margin-top: 10px; color: var(--text-dim); font-size: 14px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .5 } 50% { opacity: 1 } }

/* ---------- ビュー/タブ ---------- */
#views { position: fixed; inset: 0 0 calc(var(--tabbar-h) + var(--safe-bottom)) 0; overflow: hidden; }
.view { display: none; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view.active { display: flex; flex-direction: column; }
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 6px 8px calc(6px + var(--safe-bottom));
  display: flex; justify-content: space-around; align-items: center;
  background: #10122488; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: .5px solid #ffffff14;
}
#tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: var(--text-dim); border-radius: 14px; padding: 4px 0;
}
#tabbar .tab.active { color: var(--accent); background: #ffffff0e; }
.tab-icon { font-size: 20px; line-height: 1.2; }

/* ---------- ホーム ---------- */
#view-home { background: radial-gradient(130% 90% at 50% -10%, #262a52 0%, var(--bg) 60%); }
#home-clock { text-align: center; padding-top: calc(var(--safe-top) + 18px); z-index: 2; }
#clock-time { font-size: 56px; font-weight: 200; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
#clock-date { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
#home-chips { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.chip {
  font-size: 12px; color: var(--text); background: #ffffff14;
  padding: 6px 12px; border-radius: 999px; border: .5px solid #ffffff1c;
}
#chara-stage { flex: 1; min-height: 0; position: relative; }
#chara-stage canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

/* ---------- 字幕 ---------- */
#subtitle {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  max-width: min(86vw, 480px); z-index: 70; /* 起床オーバーレイ(60)より上 */
  background: #000000a8; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: #fff; font-size: 14px; line-height: 1.5; text-align: center;
  padding: 9px 16px; border-radius: 18px;
  animation: subtitle-in .18s ease;
}
@keyframes subtitle-in { from { opacity: 0; transform: translate(-50%, 6px) } to { opacity: 1; transform: translate(-50%, 0) } }

/* ---------- 起床オーバーレイ ---------- */
#wake-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #474088 0%, #d97a74 55%, #ffb873 100%);
  padding: calc(var(--safe-top) + 28px) 20px calc(var(--safe-bottom) + 24px);
}
#wake-clock { text-align: center; font-size: 76px; font-weight: 200; color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 2px 12px #0003; }
#wake-title { text-align: center; color: #ffffffd8; font-size: 17px; font-weight: 600; margin-top: 4px; }
#wake-stage { flex: 1; min-height: 0; position: relative; margin: 8px 0; }
#wake-stage canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
#wake-buttons { display: flex; flex-direction: column; gap: 12px; padding: 0 16px; }
#wake-stop {
  background: #fff; color: #e0743f; font-size: 21px; font-weight: 700;
  border-radius: 999px; padding: 16px;
}
#wake-snooze {
  background: #ffffff33; color: #fff; font-size: 16px; font-weight: 600;
  border-radius: 999px; padding: 13px;
}

/* ---------- 共通パーツ(各タブ画面用) ---------- */
.page { padding: calc(var(--safe-top) + 18px) 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.page-title { font-size: 30px; font-weight: 800; letter-spacing: .02em; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; font-size: 21px;
  background: #ffffff12; border: .5px solid #ffffff1c; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.card {
  background: var(--card); border: .5px solid #ffffff14;
  border-radius: 20px; padding: 14px 16px;
}
.empty-note { text-align: center; color: var(--text-dim); font-size: 14px; line-height: 1.9; padding: 48px 0; }
.empty-note .big { font-size: 40px; display: block; margin-bottom: 8px; }
.primary-btn {
  background: var(--grad); color: #fff; font-size: 17px; font-weight: 700;
  border-radius: 999px; padding: 14px; width: 100%;
}
.danger { color: #ff7d90; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }

/* トグルスイッチ */
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; z-index: 2; }
.switch .knob {
  position: absolute; inset: 0; border-radius: 999px; background: #ffffff22; transition: background .2s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
.switch input:checked + .knob { background: #57c07a; }
.switch input:checked + .knob::after { transform: translateX(20px); }

/* モーダル */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: #000a;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
  background: var(--bg2); border-radius: 22px 22px 0 0;
  padding: 16px 18px calc(var(--safe-bottom) + 18px);
  display: flex; flex-direction: column; gap: 14px;
  animation: modal-in .22s ease;
}
@keyframes modal-in { from { transform: translateY(24px); opacity: .6 } to { transform: none; opacity: 1 } }
.modal-title-row { display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal .field { display: flex; flex-direction: column; gap: 6px; }
.modal label { font-size: 12px; color: var(--text-dim); }
.modal input[type="text"], .modal input[type="time"], .modal input[type="datetime-local"], .modal textarea, .modal select {
  background: #ffffff10; border: .5px solid #ffffff1e; border-radius: 12px;
  color: var(--text); padding: 11px 12px; outline: none; width: 100%;
  color-scheme: dark;
}
.text-btn { color: var(--accent2); font-size: 15px; font-weight: 600; padding: 6px 8px; }

/* 曜日丸ボタン */
.day-circles { display: flex; gap: 8px; justify-content: space-between; }
.day-circle {
  width: 38px; height: 38px; border-radius: 50%; font-size: 14px;
  background: #ffffff12; color: var(--text-dim); border: .5px solid #ffffff1c;
}
.day-circle.on { background: var(--grad); color: #fff; border-color: transparent; }

/* スライダー */
input[type="range"] { width: 100%; accent-color: var(--accent); }
