:root { color-scheme: dark; }
body { font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }

.brand-mark { width: 22px; height: 22px; border-radius: 9999px; display: inline-block;
  background: radial-gradient(circle at 50% 50%, #0b1020 0 22%, #2dd4bf 23% 40%, #0ea5e9 41% 62%, #1e293b 63% 100%);
  box-shadow: 0 0 0 2px #334155; }

.nav-link { padding: .4rem .75rem; border-radius: .5rem; color: #94a3b8; display: inline-flex; gap: .4rem; align-items: center; }
.nav-link:hover { background: #1e293b; color: #e2e8f0; }
.nav-link.active { background: #134e4a; color: #5eead4; }

.bnav-link { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); color: #94a3b8; }
.bnav-link i { font-size: 18px; }
.bnav-link.active { color: #5eead4; }
.bnav-primary i { background: #14b8a6; color: #042f2e; width: 42px; height: 42px; border-radius: 9999px; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 4px 14px rgba(20,184,166,.4); }

.card { background: #0f172a; border: 1px solid #1e293b; border-radius: 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .6rem 1rem; border-radius: .75rem; font-weight: 600; font-size: .9rem; transition: .15s; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-primary { background: #14b8a6; color: #042f2e; }
.btn-primary:hover { background: #2dd4bf; }
.btn-ghost { background: #1e293b; color: #e2e8f0; }
.btn-ghost:hover { background: #334155; }
.btn-danger { background: #7f1d1d; color: #fecaca; }
.btn-danger:hover { background: #991b1b; }

.field-label { font-size: .75rem; color: #94a3b8; margin-bottom: .25rem; display: block; }
.input { width: 100%; background: #020617; border: 1px solid #334155; border-radius: .6rem; padding: .55rem .7rem; color: #e2e8f0; font-size: .95rem; }
.input:focus { outline: none; border-color: #14b8a6; }

.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .7rem; border-radius: 9999px; border: 1px solid #334155; font-size: .8rem; color: #cbd5e1; cursor: pointer; user-select: none; }
.chip.on { background: #134e4a; border-color: #14b8a6; color: #5eead4; }

.eye-badge { font-size: .7rem; font-weight: 700; padding: .1rem .45rem; border-radius: .35rem; }
.eye-R { background: #1e3a8a; color: #bfdbfe; }
.eye-L { background: #581c87; color: #e9d5ff; }

/* Camera */
.cam-wrap { position: relative; width: 100%; max-width: 520px; aspect-ratio: 1/1; margin: 0 auto; border-radius: 1rem; overflow: hidden; background: #000; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; }
.guide { position: absolute; inset: 0; pointer-events: none; }
.guide::before { content: ""; position: absolute; left: 50%; top: 50%; width: 62%; aspect-ratio: 1/1; transform: translate(-50%,-50%); border-radius: 9999px;
  border: 2px dashed rgba(94,234,212,.9); box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.guide::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14%; aspect-ratio: 1/1; transform: translate(-50%,-50%); border-radius: 9999px; border: 1px solid rgba(255,255,255,.5); }

/* Crop editor */
.crop-wrap { position: relative; width: 100%; max-width: 520px; aspect-ratio: 1/1; margin: 0 auto; border-radius: 1rem; overflow: hidden; background: #000; touch-action: none; cursor: grab; }
.crop-wrap canvas { width: 100%; height: 100%; display: block; }

/* Compare */
.cmp-wrap { position: relative; width: 100%; max-width: 560px; aspect-ratio: 1/1; margin: 0 auto; border-radius: 1rem; overflow: hidden; background: #000; touch-action: none; user-select: none; }
.cmp-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.cmp-handle { position: absolute; top: 0; bottom: 0; width: 2px; background: #5eead4; pointer-events: none; }
.cmp-handle::after { content: "\2194"; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #14b8a6; color: #042f2e; width: 30px; height: 30px; border-radius: 9999px; display: grid; place-items: center; font-weight: 700; }
.grid-overlay { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle, transparent 0 15%, rgba(94,234,212,.35) 15.2% 15.5%, transparent 15.7% 30%, rgba(94,234,212,.35) 30.2% 30.5%, transparent 30.7% 45%, rgba(94,234,212,.35) 45.2% 45.5%, transparent 45.7%); }
.grid-overlay::before, .grid-overlay::after { content: ""; position: absolute; background: rgba(94,234,212,.35); }
.grid-overlay::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.grid-overlay::after { top: 50%; left: 0; right: 0; height: 1px; }

.thumb { aspect-ratio: 1/1; object-fit: cover; width: 100%; border-radius: .75rem; background: #020617; }
.thumb-sel { outline: 3px solid #14b8a6; outline-offset: 2px; }

.heat { width: 14px; height: 14px; border-radius: 3px; background: #1e293b; }
.heat.l1 { background: #115e59; } .heat.l2 { background: #14b8a6; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #134e4a; color: #ccfbf1; padding: .6rem 1rem; border-radius: .75rem; z-index: 50; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.4); }

.zoom-view { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.95); display: grid; place-items: center; touch-action: none; }
.zoom-view img { max-width: 100vw; max-height: 100vh; transform-origin: center; }

/* Bottom sheet */
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.7); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 768px) { .sheet-bg { align-items: center; } }
.sheet { width: 100%; max-width: 32rem; max-height: 92vh; overflow-y: auto; background: #0f172a; border: 1px solid #1e293b; border-radius: 1.25rem 1.25rem 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
@media (min-width: 768px) { .sheet { border-radius: 1.25rem; } }

/* Sleep chart */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 150px; }
.chart-col { flex: 1 1 0; min-width: 2px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; cursor: pointer; }
.chart-bar { width: 100%; border-radius: 3px 3px 0 0; background: #6366f1; min-height: 2px; }
.chart-bar.empty { background: #1e293b; }
.chart-col:hover .chart-bar { filter: brightness(1.3); }
.chart-dots { display: flex; gap: 1px; height: 8px; margin-top: 3px; }
.chart-dot { width: 4px; height: 4px; flex-shrink: 0; border-radius: 9999px; }
.dot-R { background: #60a5fa; } .dot-L { background: #c084fc; } .dot-M { background: #f59e0b; }
.chart-x { display: flex; gap: 2px; font-size: 9px; color: #64748b; overflow: hidden; }
.chart-x span { flex: 1 1 0; min-width: 2px; text-align: left; white-space: nowrap; overflow: visible; }

.q-chip.on { background: #312e81; border-color: #818cf8; color: #c7d2fe; }

/* PWA: 全画面起動時のノッチ・ステータスバー対応 */
#site-header { padding-top: env(safe-area-inset-top); }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
