* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Dark theme, but with clearly separated surfaces (base → panel → panel-2 step
     up in lightness) and visible borders so cards don't melt together. */
  --bg: #0c0e13;
  --panel: #1c212d;
  --panel-2: #2b3140;
  --text: #f3f5fa;
  --muted: #b3bccd;
  --border: rgba(255, 255, 255, .28);
  --accent: #ff5a6a;
  --accent-2: #5b95ff;
  /* Checkerboard = "this is transparent" indicator behind cut-out yokai. */
  --checker: repeating-conic-gradient(#333a49 0% 25%, #232936 0% 50%) 50% / 16px 16px;
}
/* Lock horizontal scroll with overflow-x: CLIP (not hidden). `hidden` coerces
   overflow-y to `auto`, turning the element into its own scroll container — which
   made window.scrollY stop updating and broke pull-to-refresh. `clip` blocks the
   horizontal axis while leaving overflow-y visible, so the window stays the
   vertical scroller. */
html {
  height: 100%;
  overflow-x: clip;
  overscroll-behavior-x: none;
}
body {
  min-height: 100%;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  max-width: 100%;
  /* スマホで勝手にズームしない：ダブルタップ拡大を無効化、回転時の文字拡大も無効化 */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* iOS Safari は 16px 未満の入力欄にフォーカスすると画面ごと拡大する。
   入力欄は全部 16px 以上に固定する（見た目が大きすぎるところは padding で調整）。 */
input, textarea, select { font-size: 16px; font-family: inherit; }
.screen { min-height: 100vh; min-height: 100dvh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.error { color: var(--accent); min-height: 1.2em; margin-top: 8px; }
.link { background: none; border: none; color: var(--muted); font-size: 14px; }

/* Login */
#login { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border);
  padding: 28px 24px; border-radius: 18px; text-align: center;
}
.login-card h1 { font-size: 28px; margin-bottom: 6px; }
.login-card p { margin-bottom: 16px; }
.login-card input {
  width: 100%; padding: 14px; margin-bottom: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); font-size: 16px;
}
.login-card button {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
}

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  /* 上はノッチ分だけ空ける。下は詰める。 */
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.hello { font-weight: 700; }
.topbar-actions { display: flex; gap: 6px; align-items: center; }

/* Tabs */
.tab { padding: 16px; padding-bottom: 92px; }

/* Camera */
/* Portrait 3:4 frame — must match the server output aspect (VLOG_WIDTH:HEIGHT)
   so the cover-crop shown here equals what's saved. */
.camera-wrap {
  position: relative; width: 100%; aspect-ratio: 3/4; max-height: 66vh;
  margin: 0 auto; background: #000; border-radius: 16px; overflow: hidden;
}
/* object-fit: cover center-crops the camera frame to the 3:4 box — the same
   center-crop ffmpeg does server-side. Front camera is mirrored for a natural
   selfie view; back camera shows the world as-is. */
#preview {
  display: block; width: 100%; height: 100%; object-fit: cover;
}
#preview.mirrored { transform: scaleX(-1); }
/* カメラ起動前のプレースホルダ */
.cam-idle {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: #bbb; font-size: 14px; background: #111; cursor: pointer;
}
.cam-idle-icon { font-size: 64px; line-height: 1; }

.switch-cam {
  position: absolute; bottom: 12px; right: 12px;
  background: rgba(0,0,0,.55); color: #fff; border: none;
  padding: 8px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.switch-cam:disabled { opacity: .5; }
.cam-name {
  position: absolute; bottom: 12px; left: 12px; max-width: 60%;
  background: rgba(0,0,0,.55); color: #fff; padding: 6px 10px; border-radius: 16px;
  font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.rec-dot {
  position: absolute; top: 12px; left: 12px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent); animation: blink 1s infinite;
}
.rec-timer {
  position: absolute; top: 10px; right: 12px; background: rgba(0,0,0,.5);
  padding: 4px 10px; border-radius: 20px; font-variant-numeric: tabular-nums;
}
@keyframes blink { 50% { opacity: .3; } }

.record-btn {
  display: block; margin: 16px auto; width: 100%; max-width: 320px;
  padding: 16px; border: none; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 18px; font-weight: 700;
}
.record-btn.recording { background: #fff; color: var(--accent); }
.record-btn:disabled { opacity: .5; }

.stock {
  margin: 14px auto; max-width: 320px; text-align: center; border: 1px solid var(--border);
  background: var(--panel); padding: 12px; border-radius: 12px; font-size: 14px;
}
.stock strong { color: var(--accent-2); font-size: 18px; }
.stock-list { list-style: none; max-width: 320px; margin: 0 auto; }
.stock-list li {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; margin-top: 8px;
  font-size: 14px; overflow: hidden;
}
.stock-row { padding: 10px 12px; }
.stock-label { font-weight: 600; margin-bottom: 8px; }
.stock-actions { display: flex; gap: 6px; }
.stock-actions button { flex: 1; white-space: nowrap; }
.stock-list button {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; padding: 8px 6px; border-radius: 8px;
}
.stock-list button.danger { color: var(--accent); background: transparent; border-color: transparent; }
.stock-list button.gen { color: #fff; background: var(--accent-2); font-weight: 700; }
.stock-list button.gen:disabled { opacity: .6; }
.badge {
  background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px; margin-left: 6px;
}
.stock-player { width: 100%; display: block; background: #000; max-height: 60vh; }

/* Character gate on record tab */
.char-gate {
  max-width: 340px; margin: 0 auto 14px; padding: 14px; border-radius: 12px;
  background: rgba(255,77,94,.12); border: 1px solid var(--accent);
  color: var(--text); font-size: 14px; text-align: center;
}
.char-gate button {
  display: block; margin: 10px auto 0; padding: 8px 16px; border: none;
  border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700;
}

/* Mic warning on record tab */
.mic-warn {
  max-width: 340px; margin: 0 auto 14px; padding: 12px; border-radius: 12px;
  background: rgba(255,193,7,.14); border: 1px solid #ffc107;
  color: var(--text); font-size: 13px; text-align: center; line-height: 1.5;
}

/* Character tab */
.char-intro { max-width: 420px; margin: 0 auto 14px; }
.char-intro h2 { margin-bottom: 6px; }
.char-intro p { line-height: 1.6; font-size: 14px; }
.char-form { max-width: 420px; margin: 0 auto; }
.field-label { display: block; font-size: 13px; font-weight: 700; color: #c6cdda; margin: 14px 0 6px; }
.char-input {
  display: block; width: 100%; padding: 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); font-size: 16px; font-family: inherit;
}
.char-input:focus, .comment-input:focus { outline: none; border-color: var(--accent-2); }
.char-upload {
  display: block; padding: 16px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 14px; text-align: center;
  color: var(--accent-2); font-weight: 700; cursor: pointer;
}
.char-preview {
  display: block; max-width: 180px; max-height: 180px; margin: 10px auto 0;
  border-radius: 12px; background:
    repeating-conic-gradient(#2a2f3a 0% 25%, #232733 0% 50%) 50% / 20px 20px;
}
.char-genbtn {
  display: block; width: 100%; margin: 14px 0 0; padding: 14px; border: none;
  border-radius: 12px; background: var(--accent-2); color: #fff;
  font-size: 16px; font-weight: 700;
}
.char-genbtn:disabled { background: var(--panel-2); color: var(--muted); }
.or-divider {
  text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 6px;
}
.char-submit {
  display: block; width: 100%; margin: 16px 0 0; padding: 14px; border: none;
  border-radius: 12px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 700; transition: background .15s, opacity .15s;
}
/* Dim/greyed until all fields are filled, then it "brightens" to accent. */
.char-submit:disabled { background: var(--panel-2); color: var(--muted); cursor: default; }
.char-meta { padding: 8px 10px 4px; text-align: left; }
.char-name { font-weight: 700; font-size: 14px; }
.char-desc { color: var(--muted); font-size: 12px; line-height: 1.5; max-height: 4.5em; overflow: hidden; margin-top: 2px; }

/* Yokai dictionary on a post */
.yokai-dict { padding: 12px 14px; border-top: 1px solid var(--border); }
.dict-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.yokai-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.yokai-row img { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: var(--checker); flex: none; }
.yokai-info { flex: 1; min-width: 0; }
.yokai-name { font-weight: 700; font-size: 14px; }
.yokai-desc { color: var(--muted); font-size: 12px; line-height: 1.4; }
.fav { flex: none; background: var(--panel-2); border: none; color: var(--text); font-size: 12px; padding: 6px 10px; border-radius: 16px; }
.fav.on { background: var(--accent); color: #fff; }
.fav:disabled { opacity: .5; }

.char-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px; max-width: 420px; margin: 8px auto 0;
}
.char-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; text-align: center; }
.char-card img {
  width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--checker); display: block;
}
.char-card button { width: 100%; padding: 8px; border: none; background: transparent; color: var(--accent); font-size: 13px; }

/* Feed — day sections, each a 2-up grid of portrait thumbnails (Shorts-style) */
.feed { max-width: 560px; margin: 0 auto; }
.feed-cell {
  position: relative; padding: 0; border: 1.5px solid rgba(255,255,255,.38); background: #000;
  border-radius: 14px; overflow: hidden; aspect-ratio: 3/4; cursor: pointer;
}
.feed-cell video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell-author {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 10px 8px;
  color: #fff; font-size: 13px; font-weight: 700; text-align: left;
  background: rgba(0,0,0,.66);
}
.cell-badge {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.55);
  color: #fff; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 12px;
}

/* AI yokai chat builder */
.ychat {
  position: fixed; inset: 0; z-index: 65; background: #0b0d12;
  display: flex; flex-direction: column;
}
.ychat-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px; background: var(--panel);
}
.ychat-title { font-weight: 700; }
.ychat-image-wrap {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  position: relative; padding: 12px;
  background: var(--checker);
}
.ychat-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.ychat-candidates { display: flex; gap: 8px; width: 100%; max-width: 600px; }
.cand-card {
  flex: 1; position: relative; padding: 0; border: 2px solid transparent;
  border-radius: 12px; overflow: hidden; background: var(--checker); aspect-ratio: 1;
}
.cand-card img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cand-card:active { border-color: var(--accent-2); }
.cand-num {
  position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff;
  font-weight: 700; font-size: 15px; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.ychat-undo {
  flex: none; background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 600;
}
.ychat-undo:disabled { opacity: .38; }
.cand-label {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.66);
  color: #fff; font-size: 12px; font-weight: 700; text-align: center;
  padding: 5px 4px; line-height: 1.3; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.ychat-placeholder { color: var(--text); font-size: 15px; text-align: center; line-height: 1.8; max-width: 320px; }
.ychat-busy {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); color: #fff; font-weight: 700;
}
.ychat-status-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 6px; background: var(--panel);
}
.ychat-status { flex: 1; font-size: 14px; line-height: 1.6; min-height: 1.6em; }
.notice {
  padding: 10px 14px 4px; margin: 0;
  background: var(--panel); color: var(--muted);
  font-size: 12px; line-height: 1.6;
}
.char-form .notice, .char-edit .notice { background: transparent; padding: 4px 0 8px; }
.char-edit .notice { padding: 0 0 2px; text-align: left; }
.ychat-input-row { display: flex; gap: 8px; padding: 8px 14px 10px; background: var(--panel); }
.hidden-tag { color: var(--accent); font-weight: 700; }
.char-share { display: flex; align-items: flex-start; gap: 8px; padding: 6px 10px 2px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.char-share input { margin: 3px 0 0; flex: 0 0 auto; width: 16px; height: 16px; }
.ychat-input {
  flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 16px;
}
.ychat-send { background: var(--accent-2); color: #fff; border: none; font-weight: 700; padding: 0 18px; border-radius: 10px; }
.ychat-send:disabled { opacity: .6; }
.ychat-register {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--border);
}
.ychat-register .char-input { margin: 0; flex: 1; }
.ychat-register .char-submit { margin: 0; }

/* Sticker editor */
.editor-modal {
  position: fixed; inset: 0; z-index: 60; background: #0b0d12;
  display: flex; flex-direction: column;
  overflow: hidden; overscroll-behavior: contain; max-width: 100vw;
}
.editor-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px; background: var(--panel);
}
.editor-title { font-weight: 700; }
.editor-save {
  background: var(--accent); color: #fff; border: none; font-weight: 700;
  padding: 8px 18px; border-radius: 20px; font-size: 15px;
}
.editor-save:disabled { opacity: .6; }
.editor-stage-wrap { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 8px; }
.editor-stage {
  position: relative; aspect-ratio: 3/4; max-height: 100%; max-width: 100%;
  background: #000; border-radius: 12px; overflow: hidden; touch-action: none;
}
.editor-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.editor-layer { position: absolute; inset: 0; }
.sticker { position: absolute; touch-action: none; cursor: move; }
.sticker img { width: 100%; height: auto; display: block; pointer-events: none; -webkit-user-select: none; user-select: none; }
.sticker.selected { outline: 2px dashed var(--accent-2); outline-offset: 2px; }
.sticker-del {
  position: absolute; top: -12px; right: -12px; width: 26px; height: 26px;
  border-radius: 50%; border: none; background: var(--accent); color: #fff;
  font-size: 13px; display: none;
}
.sticker-resize {
  position: absolute; right: -10px; bottom: -10px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--accent-2); border: 2px solid #fff;
  touch-action: none; display: none;
}
.sticker-rotate {
  position: absolute; left: -12px; bottom: -12px; width: 24px; height: 24px;
  border-radius: 50%; background: #2ec36b; border: 2px solid #fff; color: #fff;
  font-size: 14px; line-height: 20px; text-align: center; touch-action: none; display: none;
}
.sticker.selected .sticker-del,
.sticker.selected .sticker-resize,
.sticker.selected .sticker-rotate { display: block; }
.editor-bottom { background: var(--panel); border-top: 1px solid var(--border); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.editor-hint { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 8px; }
.editor-palette { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pal-item {
  flex: 0 0 auto; width: 68px; padding: 4px; border: none; background: var(--panel-2);
  border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pal-item img { width: 56px; height: 56px; object-fit: contain; background: var(--checker); border-radius: 8px; }
.pal-item span { font-size: 11px; color: var(--text); max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Fullscreen post viewer */
.post-modal {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal-close {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 51;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.15); color: #fff; font-size: 18px;
}
.modal-inner { max-width: 520px; margin: 0 auto; padding: 0 0 40px; }
.modal-inner video {
  width: 100%; display: block; background: #000; max-height: 82vh; margin-top: 12px;
}
.modal-meta { padding: 12px 16px; }
.modal-meta .author { font-weight: 700; font-size: 16px; }
.modal-meta .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: #161b24; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; padding: 13px 2px; background: none; border: none;
  color: #8892a3; font-size: 13px; font-weight: 700; white-space: nowrap; letter-spacing: -.02em;
  border-top: 2px solid transparent; margin-top: -1px;
}
.tabbar button.active { color: #fff; border-top-color: var(--accent-2); }

/* ---- Clip timeline (video-Twitter) + likes/comments ---------------------- */
.clip-feed { display: flex; flex-direction: column; gap: 14px; padding: 8px 0 16px; }
.clip-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.clip-head { padding: 10px 12px 6px; }
/* Reserve the 3:4 space up-front so the card doesn't jump (and scroll targets
   don't drift) when the video poster finally loads. Clips are 810x1080 = 3:4. */
.clip-video { width: 100%; display: block; background: #000; aspect-ratio: 3 / 4; object-fit: cover; }
.post-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
.post-actions button {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-size: 14px;
  font-weight: 600; padding: 7px 11px; border-radius: 20px; white-space: nowrap; flex: none;
}
.post-actions .act-like.on { background: #4a1f27; color: #ff8fa0; }
.post-actions .act-del { margin-left: auto; color: #ff8fa0; border-color: rgba(255,90,106,.4); }
.clip-dict { padding: 0 12px 12px; }
.clip-dict.hidden { display: none; }
.share { color: var(--accent-2) !important; }
.share.shared { color: #2ec36b !important; }
.share:disabled { opacity: .6; }

/* Feed date separators */
.feed-day-header {
  font-size: 20px; font-weight: 800; color: #fff; margin: 18px 4px 10px;
}
.feed-day-header:first-child { margin-top: 4px; }
.feed-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px;
}

/* Comments sheet */
.comments-modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.comments-sheet {
  width: 100%; max-height: 80vh; background: var(--panel); border-radius: 18px 18px 0 0;
  border: 1px solid var(--border); border-bottom: none;
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
.comments-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.comments-title { font-weight: 700; }
.comments-list { flex: 1; overflow-y: auto; padding: 4px 16px; min-height: 30vh; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--border); }
.comment-head { margin-bottom: 2px; }
.comment-body { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.comments-input-row { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.comment-input { flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 16px; }
.comment-send { background: var(--accent); color: #fff; border: none; font-weight: 700; padding: 0 18px; border-radius: 12px; }

/* Post actions inside the vlog modal */
#modalActions { margin: 4px 0 2px; }

/* ---- Yokai edit (in the 妖怪 grid) + notifications ------------------------ */
.char-actions { display: flex; gap: 6px; padding: 8px 10px 10px; }
.char-actions button { flex: 1; padding: 7px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); border-radius: 8px; font-size: 12px; font-weight: 600; }
.char-actions button.danger { color: var(--accent); border-color: transparent; background: transparent; }
.char-edit { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.char-edit .char-input { font-size: 16px; padding: 8px; }
.char-edit-btns { display: flex; gap: 6px; align-items: center; }
.char-edit-btns .gen { flex: 1; background: var(--accent-2); color: #fff; border: none; border-radius: 8px; padding: 8px; font-weight: 700; }

.notif-list { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.notif {
  display: flex; align-items: center; gap: 10px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.notif.unread { border-color: var(--accent-2); background: #1a2330; }
.notif .notif-ico { font-size: 20px; }
.notif .notif-time { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tab-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px;
  margin-left: 4px; background: var(--accent); color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 700; vertical-align: top;
}

/* Comment delete + pull-to-refresh */
.comment-head { display: flex; align-items: center; gap: 8px; }
.comment-del { margin-left: auto; background: none; border: none; color: var(--accent); font-size: 12px; }
/* Pull-to-refresh: the active tab slides down; a spinner rests at the top. */
.tab.ptr-anim { transition: transform .28s cubic-bezier(.22,.61,.36,1); }
.ptr-spinner {
  position: fixed; top: 6px; left: calc(50% - 14px); width: 28px; height: 28px;
  z-index: 45; opacity: 0; pointer-events: none;
  border: 3px solid var(--panel-2); border-top-color: var(--accent-2); border-radius: 50%;
  transition: opacity .2s ease;
}
.ptr-spinner.ready { border-top-color: var(--accent); }
.ptr-spinner.spin { animation: ptr-rot .7s linear infinite; }
@keyframes ptr-rot { to { transform: rotate(360deg); } }

/* Tappable notifications (jump to the target) */
.notif.tappable { cursor: pointer; }
.notif.tappable:active { background: var(--panel-2); }
.notif-chev { margin-left: auto; color: var(--muted); font-size: 22px; line-height: 1; padding-left: 6px; }

/* Highlight a post when jumped-to from a notification */
.post-flash { animation: post-flash 3s ease; }
@keyframes post-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91,149,255,0); }
  8% { box-shadow: 0 0 0 3px var(--accent-2); }
  85% { box-shadow: 0 0 0 3px var(--accent-2); }
}

/* Poster thumbnails (feeds load JPEGs, not video, until you play) */
.feed-cell .cell-poster { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.clip-media { position: relative; width: 100%; aspect-ratio: 3 / 4; background: #000; }
.clip-poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-media .clip-video { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }
.clip-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.55); color: #fff; font-size: 24px; padding-left: 4px;
}
.clip-play:active { background: rgba(0,0,0,.75); }

/* Background-generation chip + toast */
.gen-chip {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 55;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 22px; font-size: 14px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.gen-chip.ready { background: var(--accent-2); color: #fff; border-color: transparent; }
.chip-spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); border-top-color: var(--accent-2);
  animation: ptr-rot .7s linear infinite;
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(120px + env(safe-area-inset-bottom)); z-index: 80;
  background: #000d; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; max-width: 86%; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 妖怪 tab: sectioned like the vlog feed (自分の妖怪 / お気に入り) */
.char-list { max-width: 420px; margin: 0 auto; }
.char-section-header { font-size: 17px; font-weight: 800; color: #fff; margin: 18px 4px 2px; }
.char-section-header:first-child { margin-top: 6px; }

/* ---------------------------------------------------------------------------
   Daily affect diary (research measurement)
   --------------------------------------------------------------------------- */
body.modal-open { overflow: hidden; }

/* Banner shown on any tab while tonight's rating is still missing. */
.affect-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: linear-gradient(180deg, #2a3350, #232a42);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.affect-banner button {
  background: var(--accent-2); color: #fff; border: none;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600;
}

/* Full-screen sheet. Scrolls internally: 8 items + note don't fit on a phone. */
.affect-modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, .72);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 12px calc(24px + env(safe-area-inset-bottom));
}
.affect-sheet {
  max-width: 520px; margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 16px 16px;
}
.affect-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.affect-title { font-size: 17px; font-weight: 700; }
.affect-day { color: var(--muted); font-size: 13px; }
.affect-instruction { color: var(--text); font-size: 14px; line-height: 1.6; }
.affect-legend {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 12px; margin: 12px 2px 6px;
}
.affect-items { display: flex; flex-direction: column; gap: 4px; }
.affect-item {
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.affect-item.answered { background: rgba(91, 149, 255, .07); border-color: rgba(91, 149, 255, .22); }
.affect-item-label { font-size: 15px; margin-bottom: 8px; }
.affect-options { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.affect-opt {
  padding: 11px 0;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; font-variant-numeric: tabular-nums;
}
.affect-opt.sel { background: var(--accent-2); border-color: var(--accent-2); color: #fff; font-weight: 700; }
.affect-note-label { display: block; margin: 18px 0 6px; font-size: 14px; }
.affect-note {
  width: 100%; padding: 10px 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; font-family: inherit; resize: vertical;
}
.affect-actions { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.affect-submit {
  width: 100%; padding: 14px;
  background: var(--accent-2); color: #fff;
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700;
}
.affect-submit:disabled { background: var(--panel-2); color: var(--muted); }

/* Baseline period (before APP_UNLOCK): diary only. */
.baseline-card {
  max-width: 480px; margin: 40px auto; padding: 24px 20px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  text-align: center;
}
.baseline-card h2 { font-size: 18px; margin-bottom: 12px; }
.baseline-card p { line-height: 1.7; font-size: 14px; }
.baseline-card .char-submit { margin-top: 20px; }

/* ---- 通知設定（プッシュ通知） ---- */
.notif-settings {
  max-width: 560px; margin: 8px auto 4px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; font-size: 14px;
}
.notif-settings summary {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 0; cursor: pointer; list-style: none; font-weight: 600;
}
.notif-settings summary::-webkit-details-marker { display: none; }
.notif-settings[open] summary { border-bottom: 1px solid var(--border); }
.notif-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; }
.notif-master { font-weight: 600; }
.notif-types { padding-left: 12px; border-left: 2px solid var(--border); margin: 4px 0 6px; }
.notif-types .notif-row { padding: 9px 0; }
.notif-types.off { opacity: .45; pointer-events: none; }
.notif-settings p { margin: 4px 0 10px; line-height: 1.6; }
.notif-settings #pushTest { display: block; margin: 0 0 12px; }
input.switch {
  appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 13px;
  background: var(--panel-2); border: 1px solid var(--border); position: relative; flex: none; margin: 0;
  transition: background .15s;
}
input.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
input.switch:checked { background: var(--accent); border-color: var(--accent); }
input.switch:checked::after { transform: translateX(20px); }
input.switch:disabled { opacity: .5; }
