/* =============================================================
   style.css - Kids Safe Tube (ぽんぽんTube)
   ============================================================= */

:root {
  --font-kids: 'Zen Maru Gothic', 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --bg-main: #FFFDF9;
  --bg-card: #FFFFFF;
  --bg-soft: #F0F7FF;
  
  --primary: #FF6B8B;       /* コーラルピンク */
  --primary-hover: #FA5274;
  --secondary: #38B2AC;     /* ミントグリーン */
  --accent-gold: #F6AD55;   /* サンシャインオレンジ */
  --accent-blue: #4299E1;   /* スカイブルー */
  --accent-purple: #9F7AEA; /* ラベンダー */
  
  --text-dark: #2D3748;
  --text-muted: #718096;
  --text-light: #A0AEC0;
  
  --border-subtle: #E2E8F0;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);
  --shadow-pop: 0 10px 0 rgba(0, 0, 0, 0.08);
  
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-kids);
  background-color: var(--bg-main);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* -------------------------------------------------------------
   Header
   ------------------------------------------------------------- */
.app-header {
  background: var(--bg-card);
  border-bottom: 2px solid #EDF2F7;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  font-size: 2rem;
  animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo-title {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.logo-sub {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--secondary);
  background: rgba(56, 178, 172, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Timer Badge in Header */
.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFF5F5;
  color: #E53E3E;
  border: 1.5px solid #FEB2B2;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Parent Lock Button */
.btn-parent-lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EDF2F7;
  color: #4A5568;
  border: 1px solid #CBD5E0;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-parent-lock:hover {
  background: #E2E8F0;
  color: var(--text-dark);
}

/* -------------------------------------------------------------
   Category Filter Tabs
   ------------------------------------------------------------- */
.category-nav {
  padding: 18px 20px 10px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.category-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 2px solid #E2E8F0;
  border-radius: var(--radius-full);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-dark);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 6px rgba(0,0,0,0.03);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cat-tab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.06);
}

.cat-tab.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(255, 107, 139, 0.4);
  transform: translateY(-2px) scale(1.04);
}

.cat-tab .cat-count {
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.cat-tab.active .cat-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.cat-tab.cat-tab-channel.active {
  background: #3182CE;
  border-color: #3182CE;
  box-shadow: 0 6px 16px rgba(49, 130, 206, 0.4);
}

.cat-tab-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   Video Grid Container
   ------------------------------------------------------------- */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px 48px;
  flex: 1;
  width: 100%;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.video-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 2px solid #EDF2F7;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
}

.video-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.video-card:active {
  transform: scale(0.98);
}

.thumb-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #E2E8F0;
  overflow: hidden;
}

.thumb-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.video-card:hover .thumb-img {
  transform: scale(1.05);
}

.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  background: rgba(255, 107, 139, 0.92);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

.video-card:hover .play-badge {
  transform: translate(-50%, -50%) scale(1.15);
  background: var(--primary);
}

.play-badge svg {
  margin-left: 4px;
}

.video-info {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.video-title {
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.45;
  color: var(--text-dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.video-author {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 14px;
}

.empty-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------
   Child Safe Video Player View (Full Theater Overlay)
   ------------------------------------------------------------- */
.player-view {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.98);
  z-index: 170;
  display: none;
  flex-direction: column;
  padding: 16px;
}

.player-view.active {
  display: flex;
}

.player-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 16px;
}

.btn-back-kids {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: var(--font-kids);
  font-size: 1.15rem;
  font-weight: 900;
  padding: 12px 26px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255, 107, 139, 0.4);
  transition: transform 0.15s;
}

.btn-back-kids:active {
  transform: scale(0.95);
}

.player-now-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.player-frame-wrap {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-frame-inner {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 120px);
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.player-frame-inner iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* -------------------------------------------------------------
   Bedtime / Sleep Overlay (Timer Expired)
   ------------------------------------------------------------- */
.bedtime-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #0B0F19 0%, #1A202C 100%);
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  color: #FFFFFF;
}

.bedtime-overlay.active {
  display: flex;
}

.bedtime-moon {
  font-size: 5.5rem;
  margin-bottom: 20px;
  animation: floatMoon 3s infinite ease-in-out;
}

@keyframes floatMoon {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
}

.bedtime-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: #F6AD55;
  margin-bottom: 12px;
}

.bedtime-msg {
  font-size: 1.2rem;
  color: #CBD5E0;
  margin-bottom: 36px;
  line-height: 1.8;
}

.btn-bedtime-unlock {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  border: 2px solid rgba(255, 255, 255, 0.4);
  font-family: var(--font-kids);
  font-size: 1.05rem;
  font-weight: 800;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-bedtime-unlock:hover,
.btn-bedtime-unlock:active {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.03);
}

/* -------------------------------------------------------------
   PIN Keypad Modal (テンキー入力)
   ------------------------------------------------------------- */
.pin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pin-modal.active {
  display: flex;
}

.pin-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  animation: popIn 0.2s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.pin-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
}

.pin-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.pin-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.pin-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 28px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: #EDF2F7;
  border: 2px solid #CBD5E0;
  transition: all 0.15s;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.15);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.btn-key {
  height: 60px;
  border-radius: var(--radius-md);
  border: 1px solid #E2E8F0;
  background: #F8FAFC;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  box-shadow: 0 2px 0 rgba(0,0,0,0.05);
}

.btn-key:active {
  transform: translateY(2px);
  box-shadow: none;
  background: #EDF2F7;
}

.btn-key.action {
  font-size: 1rem;
  color: var(--text-muted);
  background: #EDF2F7;
}

/* Shake on error */
.shake {
  animation: shakeAnimation 0.4s ease-in-out;
}

@keyframes shakeAnimation {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

/* -------------------------------------------------------------
   Parent Settings Modal (保護者ダッシュボード)
   ------------------------------------------------------------- */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 160;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.settings-modal.active {
  display: flex;
}

.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.settings-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F8FAFC;
}

.settings-header-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-nav-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px 0;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 16px;
  border: none;
  background: none;
  font-family: var(--font-kids);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.settings-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.settings-footer {
  padding: 14px 24px;
  background: #F8FAFC;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
}

.btn-settings-footer-cancel {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: #fff;
  color: var(--text-muted);
  font-family: var(--font-kids);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-settings-footer-cancel:hover {
  background: #F1F5F9;
  color: var(--text-dark);
}

.btn-settings-footer-save {
  padding: 10px 22px;
  font-size: 0.95rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(255, 107, 139, 0.3);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Forms & UI Controls in Settings */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-kids);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: var(--font-kids);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger-sm {
  background: #FFF5F5;
  color: #E53E3E;
  border: 1px solid #FEB2B2;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.btn-danger-sm:hover {
  background: #E53E3E;
  color: #fff;
}

/* Video Management List in Settings */
.settings-video-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.settings-video-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: #FAFBFD;
}

.settings-video-thumb {
  width: 72px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.settings-video-info {
  flex: 1;
  min-width: 0;
}

.settings-video-title {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dark);
}

/* Negative Keywords Chips */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFF5F5;
  color: #C53030;
  border: 1px solid #FEB2B2;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
}

.tag-chip-del {
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #E53E3E;
}

/* Timer Button Options */
.timer-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.btn-timer-opt {
  background: #FFFFFF;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  cursor: pointer;
  font-family: var(--font-kids);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease-out;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.btn-timer-opt:hover {
  border-color: #CBD5E0;
  background: #F8FAFC;
}

.btn-timer-opt:active {
  transform: scale(0.97);
}

.btn-timer-opt.active {
  background: #FFF5F7;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(255, 107, 139, 0.25);
}

.timer-opt-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.timer-opt-text {
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}



/* -------------------------------------------------------------
   LockTube Keyword Management & Inspector
   ------------------------------------------------------------- */
.spin {
  display: inline-block;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.settings-kw-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kw-manage-card {
  background: #FFFFFF;
  border: 1.5px solid #E2E8F0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}

.kw-manage-card:hover {
  border-color: #CBD5E0;
}

.kw-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kw-card-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.kw-card-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.kw-card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-dark);
}

.kw-card-search-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #4A5568;
  background: #EDF2F7;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kw-card-count {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--secondary);
  background: rgba(56, 178, 172, 0.12);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.kw-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-kw-action {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: #F7FAFC;
  color: var(--text-dark);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-kw-action:hover {
  background: #EDF2F7;
}

.btn-kw-action.danger {
  color: #E53E3E;
  border-color: #FED7D7;
  background: #FFF5F5;
}

.btn-kw-action.danger:hover {
  background: #FED7D7;
}

/* Collapsible Inspector Drawer */
.kw-inspect-drawer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #E2E8F0;
  display: none;
}

.kw-inspect-drawer.open {
  display: block;
}

.kw-inspect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #718096;
  font-weight: 700;
  gap: 8px;
}

.btn-drawer-close {
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #CBD5E0;
  background: #EDF2F7;
  color: #4A5568;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-drawer-close:hover {
  background: #E2E8F0;
  color: #2D3748;
}

.btn-drawer-close-bottom {
  padding: 8px 20px;
  font-size: 0.84rem;
  border-radius: 20px;
  background: #F7FAFC;
  border: 1px solid #CBD5E0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.btn-drawer-close-bottom:hover {
  background: #EDF2F7;
}

.kw-inspect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 440px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.kw-video-chip {
  display: flex;
  flex-direction: column;
  background: #FAFBFD;
  border: 1px solid #E2E8F0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 0.8rem;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
}

.kw-video-chip.is-blocked {
  opacity: 0.55;
  background: #FFF5F5;
  border-color: #FEB2B2;
}

.kw-video-chip-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
  overflow: hidden;
}

.kw-video-chip-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kw-video-chip-play-hint {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: background 0.15s, opacity 0.15s;
}

.kw-video-chip-thumb-wrap:hover .kw-video-chip-play-hint {
  opacity: 1;
  background: rgba(229, 62, 62, 0.95);
}

.kw-video-chip-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  gap: 6px;
}

.kw-video-chip-title {
  font-weight: 700;
  color: var(--text-dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 2px;
  line-height: 1.35;
}

.kw-video-chip-channel {
  font-size: 0.72rem;
  color: #718096;
}

.btn-block-video {
  align-self: flex-start;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #FEB2B2;
  background: #FFF5F5;
  color: #C53030;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  touch-action: manipulation;
}

.btn-block-video:hover {
  background: #FED7D7;
}

.btn-block-video.unblock {
  border-color: #C6F6D5;
  background: #F0FFF4;
  color: #276749;
}

.btn-block-video.unblock:hover {
  background: #C6F6D5;
}

/* -------------------------------------------------------------
   Channel Management & Search Results Styles
   ------------------------------------------------------------- */
.btn-channel-mode {
  font-family: inherit;
  transition: all 0.2s;
}

.btn-channel-mode.active {
  background: #3182CE !important;
  color: #FFFFFF !important;
  border-color: #3182CE !important;
}

.channel-search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #EDF2F7;
  transition: background 0.15s;
}

.channel-search-result-item:last-child {
  border-bottom: none;
}

.channel-search-result-item:hover {
  background: #F7FAFC;
}

.channel-result-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.channel-result-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #E2E8F0;
}

.channel-result-info {
  min-width: 0;
}

.channel-result-title {
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-result-meta {
  font-size: 0.78rem;
  color: #718096;
  margin-top: 2px;
}

.btn-add-found-channel {
  padding: 6px 14px;
  font-size: 0.84rem;
  font-weight: 800;
  background: #3182CE;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-add-found-channel:hover {
  background: #2B6CB0;
  transform: translateY(-1px);
}

.ch-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid #CBD5E0;
}

/* -------------------------------------------------------------
   PIN Recovery Link & Adult Math Quiz Modal
   ------------------------------------------------------------- */
.btn-forgot-pin {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: #718096;
  margin-top: 18px;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.15s;
  display: inline-block;
}

.btn-forgot-pin:hover {
  color: var(--primary);
}

.math-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 260;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.math-modal.active {
  display: flex;
}

.math-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  animation: popIn 0.2s ease-out;
}

.math-question-box {
  background: #FFF5F7;
  border: 2px dashed #FEB2B2;
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 1.6rem;
  font-weight: 900;
  color: #C53030;
  letter-spacing: 0.05em;
  margin: 14px 0;
}

.btn-subtle {
  font-family: inherit;
  transition: opacity 0.15s;
}

.btn-subtle:hover {
  opacity: 0.8;
}

/* -------------------------------------------------------------
   Continuous Playback Controls & Next Video Overlay
   ------------------------------------------------------------- */
.player-nav-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
}

.btn-player-step {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
  font-family: var(--font-kids);
  font-size: 0.95rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-player-step:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
}

.btn-player-step:active {
  transform: scale(0.95);
}

.player-cat-badge {
  font-size: 0.85rem;
  font-weight: 800;
  color: #A0AEC0;
  padding: 0 4px;
  white-space: nowrap;
}

/* Next Video Transition Overlay */
.next-video-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 29, 0.88);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: var(--radius-md);
  animation: fadeIn 0.2s ease-out;
}

.next-video-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.next-video-badge {
  display: inline-block;
  background: rgba(56, 178, 172, 0.15);
  color: #234E52;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.next-video-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-dark);
  margin: 10px 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.next-video-countdown {
  font-size: 0.85rem;
  color: #718096;
  font-weight: 700;
  margin-bottom: 16px;
}

.btn-play-now {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  font-family: var(--font-kids);
  font-size: 1.1rem;
  font-weight: 900;
  padding: 12px 32px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 107, 139, 0.45);
  transition: transform 0.15s, background 0.15s;
  animation: pulseBtn 1.5s infinite ease-in-out;
}

.btn-play-now:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

@keyframes pulseBtn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* =============================================================
   Responsive Design for Smartphones & Tablets
   ============================================================= */
@media (max-width: 640px) {
  /* Header */
  .app-header {
    padding: 10px 12px;
  }

  .logo-title {
    font-size: 1.15rem;
  }

  .logo-icon {
    font-size: 1.4rem;
  }

  .logo-sub {
    display: none !important;
  }

  .header-controls {
    gap: 6px;
  }

  .timer-badge {
    padding: 5px 8px;
    font-size: 0.78rem;
    gap: 4px;
  }

  .btn-parent-lock {
    padding: 6px 10px;
    font-size: 0.8rem;
    gap: 4px;
  }

  /* Kiosk fullscreen lock: hide text on mobile to save precious width */
  #btnFullscreenLock .hdr-btn-text {
    display: none;
  }

  #btnFullscreenLock {
    padding: 6px 8px;
    min-width: 36px;
    justify-content: center;
  }

  /* Category Nav Tabs */
  .category-nav {
    padding: 10px 12px 6px;
  }

  .category-scroll {
    gap: 6px;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cat-pill {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  /* Video Grid */
  .main-content {
    padding: 8px 10px 40px;
  }

  .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .video-card {
    border-radius: var(--radius-md);
  }

  .video-info {
    padding: 10px;
  }

  .video-title {
    font-size: 0.82rem;
    line-height: 1.35;
    max-height: 2.7em;
    margin-bottom: 4px;
  }

  .video-channel {
    font-size: 0.72rem;
  }

  /* Settings Modal - Fully Scrollable & Compact for Mobile */
  .settings-modal {
    padding: 8px;
    align-items: center;
    justify-content: center;
  }

  .settings-card {
    width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
  }

  .settings-header {
    padding: 10px 14px;
    flex-shrink: 0;
  }

  .settings-header-title {
    font-size: 1.1rem;
  }

  .settings-nav-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 10px 0;
    gap: 4px;
    flex-shrink: 0;
    scrollbar-width: none;
  }

  .settings-nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 8px 10px;
    font-size: 0.82rem;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .settings-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
  }

  /* Mobile Optimized Video Inspect Drawer (スマホ用 横型コンパクトリスト & スクロール快適化) */
  .kw-inspect-drawer {
    margin-top: 10px;
    padding-top: 10px;
  }

  .kw-inspect-header {
    font-size: 0.78rem;
    flex-wrap: wrap;
    gap: 6px;
  }

  .kw-inspect-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: none; /* スマホでは内側スクロールの罠を排除し、モーダル全体で自然にスクロール */
    overflow-y: visible;
    padding-right: 0;
  }

  .kw-video-chip {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    min-height: 84px;
  }

  .kw-video-chip-thumb-wrap {
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    height: auto;
    aspect-ratio: auto;
    border-radius: 11px 0 0 11px;
    flex-shrink: 0;
  }

  .kw-video-chip-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .kw-video-chip-play-hint {
    font-size: 0.62rem;
    padding: 2px 4px;
    bottom: 4px;
    right: 4px;
  }

  .kw-video-chip-body {
    padding: 8px 10px;
    min-width: 0;
    gap: 4px;
  }

  .kw-video-chip-title {
    font-size: 0.78rem;
    line-height: 1.3;
    -webkit-line-clamp: 2;
  }

  .kw-video-chip-channel {
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn-block-video {
    font-size: 0.76rem;
    padding: 6px 12px;
    min-height: 32px;
    border-radius: 8px;
  }

  /* Timer Options - 2 Columns on Mobile, never overflow! */
  .timer-options {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
  }

  .btn-timer-opt:nth-child(5):last-child {
    grid-column: span 2;
  }

  .btn-timer-opt {
    padding: 12px 8px;
    min-height: 60px;
    font-size: 0.9rem;
  }

  .timer-opt-icon {
    font-size: 1.3rem;
  }

  .timer-status-box {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  /* Player Fullscreen Overlay */
  .btn-step-label {
    display: none;
  }

  .player-top-bar {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .player-brand {
    font-size: 0.85rem;
  }

  .player-now-title {
    order: 3;
    width: 100%;
    font-size: 0.82rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn-player-action {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  /* PIN Modal on Mobile */
  .pin-card {
    max-width: 320px;
    width: 92%;
    padding: 20px 16px;
    border-radius: 20px;
  }

  .pin-title {
    font-size: 1.15rem;
  }

  .pin-keypad {
    gap: 8px;
    margin-bottom: 12px;
  }

  .key-btn {
    min-height: 48px;
    font-size: 1.25rem;
  }

  /* Keywords & Negative Form on Mobile */
  .add-kw-form-row {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .add-kw-form-row > div {
    min-width: 100% !important;
    width: 100% !important;
  }

  .add-kw-btn-row {
    flex-direction: column;
    gap: 10px;
    align-items: stretch !important;
  }

  .add-kw-btn-row .btn-primary {
    width: 100%;
    text-align: center;
    padding: 12px !important;
  }

  .negative-kw-input-row {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .negative-kw-input-row .btn-primary {
    width: 100%;
    padding: 12px !important;
  }

  .settings-kw-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .settings-kw-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Extra small devices (iPhone SE, Galaxy Fold, etc. <= 380px) */
@media (max-width: 380px) {
  .logo-title {
    font-size: 1rem;
  }

  #btnParentLock .hdr-btn-text {
    display: none;
  }

  #btnParentLock {
    padding: 6px 8px;
    min-width: 36px;
    justify-content: center;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }
}

