* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: #fafaf7; color: #222;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 480px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 14px 40px; }
button { font: inherit; color: inherit; cursor: pointer; }

.card { background: #fff; border-radius: 16px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.today { margin-bottom: 20px; text-align: center; }
.today h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.hint { margin: 10px 0 0; font-size: 13px; color: #888; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button {
  aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--c);
  background: #fff; color: var(--c); font-weight: 700; font-size: 18px;
}
.scale button.on, .scale button:active { background: var(--c); color: #fff; }

.month { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.month h1 { margin: 0; font-size: 20px; font-weight: 600; }
.month button { border: 0; background: none; font-size: 30px; width: 44px; height: 44px; border-radius: 50%; }
.month button:hover { background: #eee; }

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.grid.head { margin-bottom: 6px; font-size: 12px; color: #999; text-align: center; }
.day {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 10px; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.day .num { position: absolute; top: 4px; left: 6px; font-size: 11px; color: #999; }
.day .dot { width: 46%; aspect-ratio: 1; border-radius: 50%; }
.day .mark { position: absolute; bottom: 2px; right: 4px; font-size: 9px; color: #aaa; }
.day.is-today { outline: 2px solid #222; }
.day.is-today .num { color: #222; font-weight: 700; }
.day.future { opacity: .35; cursor: default; }

.legend { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 12px; color: #999; }
.legend .bar { flex: 1; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, hsl(0,72%,46%), hsl(42,72%,46%), hsl(83,72%,46%), hsl(125,72%,46%)); }

dialog {
  border: 0; border-radius: 18px; padding: 18px; width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.x { border: 0; background: none; font-size: 28px; line-height: 1; width: 36px; height: 36px; }
.q { margin: 12px 0 10px; color: #666; }
textarea {
  width: 100%; margin-top: 14px; padding: 10px 12px; border: 1px solid #ddd; border-radius: 10px;
  font: inherit; resize: vertical;
}
.photo-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.file { display: inline-block; padding: 9px 14px; border: 1px solid #ddd; border-radius: 10px; cursor: pointer; }
.file input { display: none; }
#photoPreview { display: block; width: 100%; margin-top: 12px; border-radius: 12px; }
#photoPreview[hidden] { display: none; }
.actions { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.primary { margin-left: auto; padding: 11px 26px; border: 0; border-radius: 10px; background: #222; color: #fff; font-weight: 600; }
.primary:disabled { opacity: .6; }
.link { border: 0; background: none; color: #666; text-decoration: underline; padding: 6px 0; }
.danger { color: #c33; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login h1 { margin: 0 0 6px; font-size: 22px; }
.login input { padding: 12px; border: 1px solid #ddd; border-radius: 10px; font: inherit; }
.login button { padding: 12px; border: 0; border-radius: 10px; background: #222; color: #fff; font-weight: 600; }
.wrong { margin: 0; color: #c33; font-size: 14px; }
