:root {
  --cream: #f5f1e8;
  --grey: #4a473f;
  --grey-soft: #8a8578;
  --line: #e2dccb;
  --red: #cc2b2b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  background: var(--cream);
  color: var(--grey);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
}
#app { position: fixed; inset: 0; }

.view { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ---- icon buttons ---- */
.icon-btn {
  appearance: none;
  border: none;
  background: #fffdf8;
  color: var(--grey);
  border-radius: 999px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(60, 50, 30, 0.12), 0 0 0 1px var(--line) inset;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.icon-btn:active { transform: scale(0.93); }
.icon-btn.small { width: 40px; height: 40px; box-shadow: none; background: transparent; }
.icon-btn.small:active { transform: scale(0.88); }
.icon-btn.ghost { opacity: 0.4; }
.icon-btn.active { color: var(--red); box-shadow: 0 2px 10px rgba(60, 50, 30, 0.12), 0 0 0 1.5px var(--red) inset; }
.icon-btn:disabled { opacity: 0.3; pointer-events: none; }

.corner {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  z-index: 5;
}
.corner.left { left: max(16px, env(safe-area-inset-left)); display: flex; gap: 10px; }
.corner.right { right: max(16px, env(safe-area-inset-right)); display: flex; gap: 10px; }
.corner.bottom { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); }

/* ---- home ---- */
.home { align-items: center; justify-content: center; gap: 40px; flex-direction: row; }
.home .icon-btn { width: 84px; height: 84px; }

/* ---- login ---- */
.login { align-items: center; justify-content: center; gap: 22px; }
.login input {
  border: none;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  font-size: 22px;
  text-align: center;
  letter-spacing: 4px;
  padding: 10px 4px;
  width: 180px;
  color: var(--grey);
  outline: none;
}
.login .row { display: flex; align-items: center; gap: 14px; }
.login .icon-btn.lock { color: var(--grey-soft); box-shadow: none; background: transparent; width: 40px; height: 40px; }
.login.shake { animation: shake 0.4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

/* ---- canvas viewport ---- */
.viewport { position: absolute; inset: 0; }
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---- intensity slider ---- */
.slider-wrap {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 5;
}
.slider-num { font-size: 13px; color: var(--grey-soft); font-variant-numeric: tabular-nums; }
.slider-label { font-size: 11px; letter-spacing: 2px; color: var(--grey-soft); text-transform: uppercase; margin-bottom: 2px; }
.slider-track {
  position: relative;
  width: 34px;
  height: 190px;
  border-radius: 17px;
  background: #fffdf8;
  box-shadow: 0 2px 10px rgba(60,50,30,0.1), 0 0 0 1px var(--line) inset;
  touch-action: none;
}
.slider-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  border-radius: 17px;
  background: linear-gradient(180deg, #e9998f, var(--red));
  transition: height 0.05s linear;
}
.slider-thumb {
  position: absolute;
  left: 3px; right: 3px;
  height: 4px;
  border-radius: 2px;
  background: #fffdf8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ---- date popover (record view) ---- */
.date-popover {
  position: absolute;
  top: 88px;
  left: max(16px, env(safe-area-inset-left));
  z-index: 10;
  background: #fffdf8;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 24px rgba(60, 50, 30, 0.18), 0 0 0 1px var(--line) inset;
}
.date-popover .calendar { width: 260px; }

/* ---- calendar ---- */
.cal-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.calendar { width: min(88vw, 380px); }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.cal-label { font-size: 15px; color: var(--grey-soft); letter-spacing: 3px; font-variant-numeric: tabular-nums; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
  appearance: none; border: none; background: transparent;
  aspect-ratio: 1; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--grey); font-size: 14px; cursor: pointer;
  gap: 3px;
}
.cal-day:active { background: var(--line); }
.cal-day.selected { background: #e9d8c8; box-shadow: 0 0 0 1.5px var(--red) inset; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }

/* ---- video ---- */
.video-stage { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.video-stage video { max-width: 90vw; max-height: 70vh; border-radius: 14px; box-shadow: 0 4px 30px rgba(0,0,0,0.15); }
.rec-dot { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.25} }
