/* 字号统一由通配规则一锤定音，层级靠字重与留白，不写零散 font-size */
html { font-size: 16px; }
* { box-sizing: border-box; font-size: 16px; }
body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", "PingFang SC", sans-serif;
  background: #fdf7ef;
  color: #3a3a3a;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #ff8a3d;
}
.brand {
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.controls { display: flex; align-items: center; }
.pill, .lang button {
  padding: 0.35rem 0.8rem;
  margin-left: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: transparent;
  color: #fff;
}
.pill.on, .lang button.current {
  background: #fff;
  color: #ff8a3d;
  border-color: #fff;
}

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.addform { display: flex; gap: 0.5rem; }
.addform input[type="url"] {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border: 2px solid #f0c9a6;
  border-radius: 10px;
  background: #fff;
}
.addform button {
  padding: 0.7rem 1.5rem;
  border: 0;
  border-radius: 10px;
  background: #ff8a3d;
  color: #fff;
  font-weight: 700;
}
.messages { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.messages li {
  background: #e7f5e7;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-top: 0.4rem;
  word-break: break-all;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.2rem;
  margin-top: 1.2rem;
}
.card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #f2e7d8;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-badge {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
}
.play-badge::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-top: 0.9rem solid transparent;
  border-bottom: 0.9rem solid transparent;
  border-left: 1.4rem solid #fff;
  transform: translateX(0.2rem);
}
.dur {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
}
.title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0.7rem 0.9rem 0.9rem;
  margin: 0;
  font-weight: 700;
  line-height: 1.35;
  color: #3a3a3a;
  text-decoration: none;
  min-height: 3.2em;
}
a.title { display: -webkit-box; }

/* 削除は編集モードでだけ出す：子どもが標準状態で誤って消せないように */
.del { display: none; }
body.edit-on .del { display: block; position: absolute; top: 0.4rem; right: 0.4rem; }
.del button {
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  line-height: 1;
}
body.edit-on a.thumb, body.edit-on a.title { pointer-events: none; }

.busybox {
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #fff3e0;
  padding: 0.5rem;
}
.state { margin: 0; font-weight: 600; color: #b06000; }
.state.failed { color: #b00020; }
.error-text {
  margin: 0;
  color: #b00020;
  word-break: break-all;
  max-height: 3.2em;
  overflow: hidden;
}
.retry {
  padding: 0.6rem 1.4rem;
  border: 0;
  border-radius: 10px;
  background: #ff8a3d;
  color: #fff;
  font-weight: 700;
}

.progress { width: 82%; }
.progress .bar {
  width: 100%;
  height: 1rem;
  border: 0;
  border-radius: 999px;
  background: #ffd9b3;
}
.progress .bar::-webkit-progress-bar { background: #ffd9b3; border-radius: 999px; }
.progress .bar::-webkit-progress-value { background: #ff8a3d; border-radius: 999px; }
.progress .bar::-moz-progress-bar { background: #ff8a3d; border-radius: 999px; }
.progress .pct { margin: 0.35rem 0 0; color: #b06000; font-weight: 600; }

.empty { margin-top: 3rem; text-align: center; color: #a09890; }

.loginbox {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.loginform {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: min(100%, 22rem);
}
.loginform input[type="password"] {
  padding: 0.9rem 1rem;
  border: 2px solid #f0c9a6;
  border-radius: 10px;
  background: #fff;
}
.loginform button {
  padding: 0.9rem;
  border: 0;
  border-radius: 10px;
  background: #ff8a3d;
  color: #fff;
  font-weight: 700;
}
.login-error { color: #b00020; text-align: center; }

/* 播放页：沉浸式深色，播完出大按钮 */
body.player-page { background: #141414; color: #eee; }
body.player-page .topbar { background: #1e1e1e; }
.player { max-width: 1080px; margin: 0 auto; padding: 0 1rem 2rem; }
.player video {
  width: 100%;
  max-height: 82vh;
  background: #000;
  border-radius: 12px;
}
.back-btn {
  position: fixed;
  top: 4.6rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  line-height: 1;
  padding-bottom: 0.3rem;
}
#lock-btn {
  position: fixed;
  top: 4.6rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}
#lock-btn[hidden] { display: none; }

/* CSS 画的挂锁：主体矩形 + 上方半圆锁梁，不引图标库 */
.padlock {
  position: relative;
  display: block;
  width: 1.1rem;
  height: 0.85rem;
  border: 0.18rem solid #fff;
  border-radius: 0.2rem;
}
.padlock::before {
  content: "";
  position: absolute;
  top: -0.55rem;
  left: 50%;
  transform: translateX(-50%);
  width: 0.7rem;
  height: 0.6rem;
  border: 0.18rem solid #fff;
  border-bottom: 0;
  border-radius: 0.45rem 0.45rem 0 0;
}

#lock-cover {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: transparent;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.lock-indicator {
  position: fixed;
  top: 4.6rem;
  right: 1rem;
  z-index: 51;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.45);
  touch-action: none;
  -webkit-touch-callout: none;
}
.lock-hint { margin: 0; color: #fff; }
.hold-bar {
  width: 6rem;
  height: 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}
.hold-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: #fff;
}
.lock-indicator.holding .hold-bar span {
  width: 100%;
  transition: width 2.5s linear;
}
.player-title { font-weight: 600; margin: 0.8rem 0 0; color: #ddd; }
#end-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  background: rgba(0, 0, 0, 0.82);
}
#end-overlay[hidden] { display: none; }
#end-overlay .big {
  width: min(80%, 26rem);
  padding: 1.3rem;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  background: transparent;
  color: #fff;
  font-weight: 700;
}
#end-overlay .big.primary {
  border: 0;
  background: #ff8a3d;
}
